116
CsvView.csproj
116
CsvView.csproj
@@ -1,116 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{587169B9-7891-4A2F-8537-9196898B86AF}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>CsvView</RootNamespace>
|
||||
<AssemblyName>CsvView</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="UI\CTextBox.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UI\DoubleBufferPanel.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UI\FrmCsvViewer.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UI\FrmCsvViewer.Designer.cs">
|
||||
<DependentUpon>FrmCsvViewer.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="UI\MessageBoxEx.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.manifest" />
|
||||
<None Include="README.md" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include=".NETFramework,Version=v4.6.1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Microsoft .NET Framework 4.6.1 %28x86 and x64%29</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="LICENSE.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="CsvLib\CsvLib.csproj">
|
||||
<Project>{eb0fdb60-8b9d-401c-85a8-4cf4105d5063}</Project>
|
||||
<Name>CsvLib</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
20
CsvView.sln
20
CsvView.sln
@@ -3,22 +3,26 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.25420.1
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CsvView", "CsvView.csproj", "{587169B9-7891-4A2F-8537-9196898B86AF}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CsvLib", "CsvLib\CsvLib.csproj", "{EB0FDB60-8B9D-401C-85A8-4CF4105D5063}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CsvLib.Tests", "CsvLib.Tests\CsvLib.Tests.csproj", "{EC5C84D8-1CDE-4AED-9C16-6C4086A20893}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CsvView", "CsvView\CsvView.csproj", "{65A0A7DA-5884-4DFE-8223-C8F5DBD881A8}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Misc", "Misc", "{94D4A247-9453-45F4-8552-0D106801C9F0}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
README.md = README.md
|
||||
LICENSE.txt = LICENSE.txt
|
||||
.editorconfig = .editorconfig
|
||||
.gitignore = .gitignore
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{587169B9-7891-4A2F-8537-9196898B86AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{587169B9-7891-4A2F-8537-9196898B86AF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{587169B9-7891-4A2F-8537-9196898B86AF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{587169B9-7891-4A2F-8537-9196898B86AF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{EB0FDB60-8B9D-401C-85A8-4CF4105D5063}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{EB0FDB60-8B9D-401C-85A8-4CF4105D5063}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{EB0FDB60-8B9D-401C-85A8-4CF4105D5063}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
@@ -27,6 +31,10 @@ Global
|
||||
{EC5C84D8-1CDE-4AED-9C16-6C4086A20893}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{EC5C84D8-1CDE-4AED-9C16-6C4086A20893}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{EC5C84D8-1CDE-4AED-9C16-6C4086A20893}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{65A0A7DA-5884-4DFE-8223-C8F5DBD881A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{65A0A7DA-5884-4DFE-8223-C8F5DBD881A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{65A0A7DA-5884-4DFE-8223-C8F5DBD881A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{65A0A7DA-5884-4DFE-8223-C8F5DBD881A8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:String x:Key="/Default/Environment/Hierarchy/Build/BuildTool/CustomBuildToolPath/@EntryValue">/usr/lib/mono/msbuild/15.0/bin/MSBuild.dll</s:String>
|
||||
<s:Int64 x:Key="/Default/Environment/Hierarchy/Build/BuildTool/MsbuildVersion/@EntryValue">983040</s:Int64></wpf:ResourceDictionary>
|
||||
<s:String x:Key="/Default/Environment/Hierarchy/Build/BuildTool/CustomBuildToolPath/@EntryValue">/usr/share/dotnet/sdk/7.0.107/MSBuild.dll</s:String>
|
||||
<s:Int64 x:Key="/Default/Environment/Hierarchy/Build/BuildTool/MsbuildVersion/@EntryValue">4294967293</s:Int64></wpf:ResourceDictionary>
|
||||
10
CsvView/App.axaml
Normal file
10
CsvView/App.axaml
Normal file
@@ -0,0 +1,10 @@
|
||||
<Application xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="CsvView.App"
|
||||
RequestedThemeVariant="Default">
|
||||
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
|
||||
|
||||
<Application.Styles>
|
||||
<FluentTheme />
|
||||
</Application.Styles>
|
||||
</Application>
|
||||
23
CsvView/App.axaml.cs
Normal file
23
CsvView/App.axaml.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace CsvView;
|
||||
|
||||
public partial class App : Application
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
|
||||
public override void OnFrameworkInitializationCompleted()
|
||||
{
|
||||
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
{
|
||||
desktop.MainWindow = new MainWindow();
|
||||
}
|
||||
|
||||
base.OnFrameworkInitializationCompleted();
|
||||
}
|
||||
}
|
||||
25
CsvView/CsvView.csproj
Normal file
25
CsvView/CsvView.csproj
Normal file
@@ -0,0 +1,25 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia" Version="11.0.2"/>
|
||||
<PackageReference Include="Avalonia.Desktop" Version="11.0.2"/>
|
||||
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.2"/>
|
||||
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.2"/>
|
||||
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
||||
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.2"/>
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CsvLib\CsvLib.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
38
CsvView/MainWindow.axaml
Normal file
38
CsvView/MainWindow.axaml
Normal file
@@ -0,0 +1,38 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:csvView="clr-namespace:CsvView"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="600"
|
||||
x:Class="CsvView.MainWindow"
|
||||
x:DataType="csvView:MainWindowViewModel"
|
||||
Width="800"
|
||||
Height="600"
|
||||
Title="CsvView">
|
||||
<Grid RowDefinitions="Auto,Auto,*">
|
||||
<StackPanel Orientation="Horizontal" Grid.Row="0">
|
||||
<Button Name="BtnLoad" Click="BtnLoad_OnClick">...</Button>
|
||||
<TextBlock Name="TxtFileName" />
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" Grid.Row="1">
|
||||
<Button Name="BtnFirst" Click="BtnFirst_OnClick">|◁</Button>
|
||||
<Button Name="BtnPrevious" Click="BtnPrevious_OnClick">◁</Button>
|
||||
<TextBox Name="TxtIndex" Text="{Binding Index}" TextChanged="TxtIndex_OnTextChanged" ></TextBox>
|
||||
<TextBlock>/</TextBlock>
|
||||
<TextBox Name="TxtMaxIndex" Text="{Binding MaxIndex}" IsEnabled="false"></TextBox>
|
||||
<Button Name="BtnNext" Click="BtnNext_OnClick">▷</Button>
|
||||
<Button Name="BtnLast" Click="BtnLast_OnClick">▷|</Button>
|
||||
</StackPanel>
|
||||
<ScrollViewer Grid.Row="2" >
|
||||
<StackPanel Orientation="Vertical" >
|
||||
<ItemsControl ItemsSource="{Binding Fields}">
|
||||
<ItemsControl.DataTemplates>
|
||||
<DataTemplate x:DataType="csvView:FieldViewModel">
|
||||
<TextBox Text="{Binding Text}" IsEnabled="False"/>
|
||||
</DataTemplate>
|
||||
</ItemsControl.DataTemplates>
|
||||
</ItemsControl>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</Window>
|
||||
171
CsvView/MainWindow.axaml.cs
Normal file
171
CsvView/MainWindow.axaml.cs
Normal file
@@ -0,0 +1,171 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Platform.Storage;
|
||||
using CsvLib;
|
||||
|
||||
namespace CsvView;
|
||||
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
RenderReg(0);
|
||||
}
|
||||
|
||||
private async void BtnLoad_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
TopLevel? topLevel = GetTopLevel(this);
|
||||
if (topLevel == null) { return; }
|
||||
|
||||
IReadOnlyList<IStorageFile> files = await topLevel.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
|
||||
{
|
||||
Title = "Open CSV File",
|
||||
AllowMultiple = false,
|
||||
FileTypeFilter = new List<FilePickerFileType>
|
||||
{
|
||||
new("CSV Files") { Patterns = new[] { "*.csv" } },
|
||||
new("Any File") { Patterns = new[] { "*" } },
|
||||
},
|
||||
});
|
||||
|
||||
if (files.Count <= 0) { return; }
|
||||
|
||||
LoadFile(files[0].Path.LocalPath);
|
||||
}
|
||||
|
||||
private void BtnFirst_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
RenderReg(0);
|
||||
}
|
||||
|
||||
private void BtnPrevious_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
RenderReg(_currentReg - 1);
|
||||
}
|
||||
|
||||
private void TxtIndex_OnTextChanged(object? sender, TextChangedEventArgs e)
|
||||
{
|
||||
RenderReg(int.TryParse(TxtIndex.Text, out int newReg) ? newReg : _currentReg);
|
||||
}
|
||||
|
||||
private void BtnNext_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
RenderReg(_currentReg + 1);
|
||||
}
|
||||
|
||||
private void BtnLast_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
RenderReg(_totalRegs - 1);
|
||||
}
|
||||
|
||||
private string _loadedFile = string.Empty;
|
||||
private long _currentReg;
|
||||
private int _totalRegs;
|
||||
private List<long> _index = new();
|
||||
|
||||
|
||||
private void LoadFile(string fileName)
|
||||
{
|
||||
_loadedFile = fileName;
|
||||
TxtFileName.Text = fileName;
|
||||
|
||||
CsvIndexer csvIndexer = new();
|
||||
csvIndexer.LoadIndexOfFile(_loadedFile);
|
||||
_index = csvIndexer.Index;
|
||||
_totalRegs = _index.Count - 1;
|
||||
|
||||
RenderReg(0);
|
||||
}
|
||||
|
||||
private MainWindowViewModel Index_LoadReg(int idx, int maxIndex)
|
||||
{
|
||||
CsvParser csvParser = new();
|
||||
csvParser.ParseFile(_loadedFile, _index[idx], 1);
|
||||
MainWindowViewModel viewModel = new()
|
||||
{
|
||||
Index = idx,
|
||||
MaxIndex = maxIndex,
|
||||
Fields = csvParser.Data[0].Select(f => new FieldViewModel { Text = f, }).ToList(),
|
||||
};
|
||||
return viewModel;
|
||||
}
|
||||
|
||||
bool _rendering;
|
||||
private void RenderReg(long currentReg)
|
||||
{
|
||||
if (_rendering) { return; }
|
||||
_rendering = true;
|
||||
|
||||
if (_index.Count <= 0)
|
||||
{
|
||||
_currentReg = -1;
|
||||
BtnFirst.IsEnabled = false;
|
||||
BtnPrevious.IsEnabled = false;
|
||||
TxtIndex.IsEnabled = false;
|
||||
BtnNext.IsEnabled = false;
|
||||
BtnLast.IsEnabled = false;
|
||||
|
||||
DataContext = new MainWindowViewModel { Index = 0, Fields = new(), };
|
||||
_rendering = false;
|
||||
return;
|
||||
}
|
||||
|
||||
bool first = false;
|
||||
bool last = false;
|
||||
if (currentReg <= 0)
|
||||
{
|
||||
currentReg = 0;
|
||||
first = true;
|
||||
}
|
||||
if (currentReg >= (_totalRegs - 1))
|
||||
{
|
||||
currentReg = _totalRegs - 1;
|
||||
last = true;
|
||||
}
|
||||
|
||||
BtnFirst.IsEnabled = (first == false);
|
||||
BtnPrevious.IsEnabled = (first == false);
|
||||
TxtIndex.IsEnabled = true;
|
||||
BtnNext.IsEnabled = (last == false);
|
||||
BtnLast.IsEnabled = (last == false);
|
||||
|
||||
if (_currentReg == currentReg)
|
||||
{
|
||||
_rendering = false;
|
||||
return;
|
||||
}
|
||||
|
||||
_currentReg = currentReg;
|
||||
|
||||
CsvParser csvParser = new();
|
||||
csvParser.ParseFile(_loadedFile, _index[(int)currentReg], 1);
|
||||
MainWindowViewModel viewModel = new()
|
||||
{
|
||||
Index = (int)currentReg,
|
||||
MaxIndex = _totalRegs,
|
||||
Fields = csvParser.Data[0].Select(f => new FieldViewModel { Text = f, }).ToList(),
|
||||
};
|
||||
|
||||
DataContext = viewModel;
|
||||
|
||||
_rendering = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class FieldViewModel
|
||||
{
|
||||
public string Text { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class MainWindowViewModel
|
||||
{
|
||||
public int? Index { get; set; }
|
||||
|
||||
public int? MaxIndex { get; set; }
|
||||
|
||||
public List<FieldViewModel>? Fields { get; set; }
|
||||
}
|
||||
21
CsvView/Program.cs
Normal file
21
CsvView/Program.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using Avalonia;
|
||||
using System;
|
||||
|
||||
namespace CsvView;
|
||||
|
||||
class Program
|
||||
{
|
||||
// Initialization code. Don't use any Avalonia, third-party APIs or any
|
||||
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
|
||||
// yet and stuff might break.
|
||||
[STAThread]
|
||||
public static void Main(string[] args) => BuildAvaloniaApp()
|
||||
.StartWithClassicDesktopLifetime(args);
|
||||
|
||||
// Avalonia configuration, don't remove; also used by visual designer.
|
||||
public static AppBuilder BuildAvaloniaApp()
|
||||
=> AppBuilder.Configure<App>()
|
||||
.UsePlatformDetect()
|
||||
.WithInterFont()
|
||||
.LogToTrace();
|
||||
}
|
||||
18
CsvView/app.manifest
Normal file
18
CsvView/app.manifest
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<!-- This manifest is used on Windows only.
|
||||
Don't remove it as it might cause problems with window transparency and embeded controls.
|
||||
For more details visit https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests -->
|
||||
<assemblyIdentity version="1.0.0.0" name="CsvView.Desktop"/>
|
||||
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
<application>
|
||||
<!-- A list of the Windows versions that this application has been tested on
|
||||
and is designed to work with. Uncomment the appropriate elements
|
||||
and Windows will automatically select the most compatible environment. -->
|
||||
|
||||
<!-- Windows 10 -->
|
||||
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
|
||||
</application>
|
||||
</compatibility>
|
||||
</assembly>
|
||||
26
Program.cs
26
Program.cs
@@ -1,26 +0,0 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using CsvView.UI;
|
||||
|
||||
namespace CsvView
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
[STAThread]
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
|
||||
var frmCsvViewer = new FrmCsvViewer();
|
||||
if (args.Length > 0)
|
||||
{
|
||||
if (System.IO.File.Exists(args[0]))
|
||||
{
|
||||
frmCsvViewer.LoadFile(args[0]);
|
||||
}
|
||||
}
|
||||
Application.Run(frmCsvViewer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyTitle("CSVView.Net")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("CSVView.Net")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2017")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: Guid("587169b9-7891-4a2f-8537-9196898b86af")]
|
||||
[assembly: AssemblyVersion("1.0.*")]
|
||||
@@ -1,34 +0,0 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Drawing;
|
||||
|
||||
namespace CsvView.UI
|
||||
{
|
||||
public class CTextBox : TextBox
|
||||
{
|
||||
public CTextBox()
|
||||
{
|
||||
WordWrap = false;
|
||||
ScrollBars = ScrollBars.Horizontal;
|
||||
Font = new Font("Courier New", 9, FontStyle.Regular, GraphicsUnit.Point, 0);
|
||||
}
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wp, IntPtr lp);
|
||||
|
||||
private const int WM_MOUSEWHEEL = 0x20a;
|
||||
|
||||
protected override void WndProc(ref Message m)
|
||||
{
|
||||
if (m.Msg == WM_MOUSEWHEEL)
|
||||
{
|
||||
SendMessage(Parent.Handle, m.Msg, m.WParam, m.LParam);
|
||||
}
|
||||
else
|
||||
{
|
||||
base.WndProc(ref m);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace CsvView.UI
|
||||
{
|
||||
public class DoubleBufferPanel : Panel
|
||||
{
|
||||
public DoubleBufferPanel()
|
||||
{
|
||||
DoubleBuffered = true;
|
||||
SetStyle(ControlStyles.UserPaint |
|
||||
ControlStyles.AllPaintingInWmPaint |
|
||||
ControlStyles.ResizeRedraw |
|
||||
ControlStyles.ContainerControl |
|
||||
ControlStyles.OptimizedDoubleBuffer |
|
||||
ControlStyles.SupportsTransparentBackColor
|
||||
, true);
|
||||
}
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto)]
|
||||
public static extern int SendMessage(IntPtr hWnd, Int32 wMsg, bool wParam, Int32 lParam);
|
||||
|
||||
private const int WM_SetRedraw = 0XB;
|
||||
|
||||
public void SuspendDrawing()
|
||||
{
|
||||
SuspendLayout();
|
||||
SendMessage(Handle, WM_SetRedraw, false, 0);
|
||||
}
|
||||
|
||||
public void ResumeDrawing()
|
||||
{
|
||||
ResumeLayout(true);
|
||||
SendMessage(Handle, WM_SetRedraw, true, 0);
|
||||
Refresh();
|
||||
}
|
||||
|
||||
[DefaultValue(false)]
|
||||
[Localizable(false)]
|
||||
[Category("CatLayout")]
|
||||
[Description("DisableAutoScrollDescr")]
|
||||
public bool DisableAutoScroll { get; set; }
|
||||
|
||||
protected override Point ScrollToControl(Control activeControl)
|
||||
{
|
||||
if (DisableAutoScroll)
|
||||
{
|
||||
return DisplayRectangle.Location;
|
||||
}
|
||||
return base.ScrollToControl(activeControl);
|
||||
}
|
||||
}
|
||||
}
|
||||
247
UI/FrmCsvViewer.Designer.cs
generated
247
UI/FrmCsvViewer.Designer.cs
generated
@@ -1,247 +0,0 @@
|
||||
namespace CsvView.UI
|
||||
{
|
||||
partial class FrmCsvViewer
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.txtPath = new System.Windows.Forms.TextBox();
|
||||
this.btnLoad = new System.Windows.Forms.Button();
|
||||
this.grpFile = new System.Windows.Forms.GroupBox();
|
||||
this.pnlScrollData = new CsvView.UI.DoubleBufferPanel();
|
||||
this.pnlData = new CsvView.UI.DoubleBufferPanel();
|
||||
this.pnlReg = new CsvView.UI.DoubleBufferPanel();
|
||||
this.btnPrevReg = new System.Windows.Forms.Button();
|
||||
this.tblRegNumbers = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.txtCurrentReg = new System.Windows.Forms.TextBox();
|
||||
this.txtTotalRegs = new System.Windows.Forms.TextBox();
|
||||
this.btnFirstReg = new System.Windows.Forms.Button();
|
||||
this.btnLastReg = new System.Windows.Forms.Button();
|
||||
this.btnNextReg = new System.Windows.Forms.Button();
|
||||
this.grpFile.SuspendLayout();
|
||||
this.pnlScrollData.SuspendLayout();
|
||||
this.pnlReg.SuspendLayout();
|
||||
this.tblRegNumbers.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// txtPath
|
||||
//
|
||||
this.txtPath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.txtPath.Location = new System.Drawing.Point(5, 18);
|
||||
this.txtPath.Name = "txtPath";
|
||||
this.txtPath.Size = new System.Drawing.Size(452, 20);
|
||||
this.txtPath.TabIndex = 0;
|
||||
this.txtPath.DoubleClick += new System.EventHandler(this.txtPath_DoubleClick);
|
||||
//
|
||||
// btnLoad
|
||||
//
|
||||
this.btnLoad.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnLoad.Location = new System.Drawing.Point(461, 18);
|
||||
this.btnLoad.Name = "btnLoad";
|
||||
this.btnLoad.Size = new System.Drawing.Size(45, 20);
|
||||
this.btnLoad.TabIndex = 3;
|
||||
this.btnLoad.Text = "Load";
|
||||
this.btnLoad.UseVisualStyleBackColor = true;
|
||||
this.btnLoad.Click += new System.EventHandler(this.btnLoad_Click);
|
||||
//
|
||||
// grpFile
|
||||
//
|
||||
this.grpFile.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.grpFile.Controls.Add(this.btnLoad);
|
||||
this.grpFile.Controls.Add(this.txtPath);
|
||||
this.grpFile.Location = new System.Drawing.Point(13, 8);
|
||||
this.grpFile.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.grpFile.Name = "grpFile";
|
||||
this.grpFile.Padding = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.grpFile.Size = new System.Drawing.Size(511, 44);
|
||||
this.grpFile.TabIndex = 12;
|
||||
this.grpFile.TabStop = false;
|
||||
this.grpFile.Text = "File";
|
||||
//
|
||||
// pnlScrollData
|
||||
//
|
||||
this.pnlScrollData.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.pnlScrollData.AutoScroll = true;
|
||||
this.pnlScrollData.Controls.Add(this.pnlData);
|
||||
this.pnlScrollData.DisableAutoScroll = true;
|
||||
this.pnlScrollData.Location = new System.Drawing.Point(13, 85);
|
||||
this.pnlScrollData.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.pnlScrollData.Name = "pnlScrollData";
|
||||
this.pnlScrollData.Size = new System.Drawing.Size(511, 429);
|
||||
this.pnlScrollData.TabIndex = 12;
|
||||
//
|
||||
// pnlData
|
||||
//
|
||||
this.pnlData.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.pnlData.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.pnlData.DisableAutoScroll = true;
|
||||
this.pnlData.Location = new System.Drawing.Point(0, 1);
|
||||
this.pnlData.Name = "pnlData";
|
||||
this.pnlData.Size = new System.Drawing.Size(511, 51);
|
||||
this.pnlData.TabIndex = 11;
|
||||
//
|
||||
// pnlReg
|
||||
//
|
||||
this.pnlReg.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.pnlReg.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.pnlReg.Controls.Add(this.btnPrevReg);
|
||||
this.pnlReg.Controls.Add(this.tblRegNumbers);
|
||||
this.pnlReg.Controls.Add(this.btnFirstReg);
|
||||
this.pnlReg.Controls.Add(this.btnLastReg);
|
||||
this.pnlReg.Controls.Add(this.btnNextReg);
|
||||
this.pnlReg.Enabled = false;
|
||||
this.pnlReg.Location = new System.Drawing.Point(14, 57);
|
||||
this.pnlReg.Name = "pnlReg";
|
||||
this.pnlReg.Size = new System.Drawing.Size(510, 456);
|
||||
this.pnlReg.TabIndex = 11;
|
||||
//
|
||||
// btnPrevReg
|
||||
//
|
||||
this.btnPrevReg.Font = new System.Drawing.Font("Courier New", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.btnPrevReg.Location = new System.Drawing.Point(41, 0);
|
||||
this.btnPrevReg.Name = "btnPrevReg";
|
||||
this.btnPrevReg.Size = new System.Drawing.Size(36, 23);
|
||||
this.btnPrevReg.TabIndex = 5;
|
||||
this.btnPrevReg.Text = "<";
|
||||
this.btnPrevReg.UseVisualStyleBackColor = true;
|
||||
this.btnPrevReg.Click += new System.EventHandler(this.btnPrevReg_Click);
|
||||
//
|
||||
// tblRegNumbers
|
||||
//
|
||||
this.tblRegNumbers.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.tblRegNumbers.ColumnCount = 2;
|
||||
this.tblRegNumbers.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||
this.tblRegNumbers.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||
this.tblRegNumbers.Controls.Add(this.txtCurrentReg, 0, 0);
|
||||
this.tblRegNumbers.Controls.Add(this.txtTotalRegs, 1, 0);
|
||||
this.tblRegNumbers.Location = new System.Drawing.Point(83, 0);
|
||||
this.tblRegNumbers.Name = "tblRegNumbers";
|
||||
this.tblRegNumbers.RowCount = 1;
|
||||
this.tblRegNumbers.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||
this.tblRegNumbers.Size = new System.Drawing.Size(345, 28);
|
||||
this.tblRegNumbers.TabIndex = 10;
|
||||
//
|
||||
// txtCurrentReg
|
||||
//
|
||||
this.txtCurrentReg.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.txtCurrentReg.Location = new System.Drawing.Point(3, 3);
|
||||
this.txtCurrentReg.Name = "txtCurrentReg";
|
||||
this.txtCurrentReg.Size = new System.Drawing.Size(166, 20);
|
||||
this.txtCurrentReg.TabIndex = 8;
|
||||
this.txtCurrentReg.TextChanged += new System.EventHandler(this.txtCurrentReg_TextChanged);
|
||||
//
|
||||
// txtTotalRegs
|
||||
//
|
||||
this.txtTotalRegs.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.txtTotalRegs.Location = new System.Drawing.Point(175, 3);
|
||||
this.txtTotalRegs.Name = "txtTotalRegs";
|
||||
this.txtTotalRegs.ReadOnly = true;
|
||||
this.txtTotalRegs.Size = new System.Drawing.Size(167, 20);
|
||||
this.txtTotalRegs.TabIndex = 9;
|
||||
//
|
||||
// btnFirstReg
|
||||
//
|
||||
this.btnFirstReg.Font = new System.Drawing.Font("Courier New", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.btnFirstReg.Location = new System.Drawing.Point(0, 0);
|
||||
this.btnFirstReg.Name = "btnFirstReg";
|
||||
this.btnFirstReg.Size = new System.Drawing.Size(36, 23);
|
||||
this.btnFirstReg.TabIndex = 4;
|
||||
this.btnFirstReg.Text = "|<";
|
||||
this.btnFirstReg.UseVisualStyleBackColor = true;
|
||||
this.btnFirstReg.Click += new System.EventHandler(this.btnFirstReg_Click);
|
||||
//
|
||||
// btnLastReg
|
||||
//
|
||||
this.btnLastReg.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnLastReg.Font = new System.Drawing.Font("Courier New", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.btnLastReg.Location = new System.Drawing.Point(474, 0);
|
||||
this.btnLastReg.Name = "btnLastReg";
|
||||
this.btnLastReg.Size = new System.Drawing.Size(36, 23);
|
||||
this.btnLastReg.TabIndex = 7;
|
||||
this.btnLastReg.Text = ">|";
|
||||
this.btnLastReg.UseVisualStyleBackColor = true;
|
||||
this.btnLastReg.Click += new System.EventHandler(this.btnLastReg_Click);
|
||||
//
|
||||
// btnNextReg
|
||||
//
|
||||
this.btnNextReg.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnNextReg.Font = new System.Drawing.Font("Courier New", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.btnNextReg.Location = new System.Drawing.Point(433, 0);
|
||||
this.btnNextReg.Name = "btnNextReg";
|
||||
this.btnNextReg.Size = new System.Drawing.Size(36, 23);
|
||||
this.btnNextReg.TabIndex = 6;
|
||||
this.btnNextReg.Text = ">";
|
||||
this.btnNextReg.UseVisualStyleBackColor = true;
|
||||
this.btnNextReg.Click += new System.EventHandler(this.btnNextReg_Click);
|
||||
//
|
||||
// FrmCsvViewer
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(532, 521);
|
||||
this.Controls.Add(this.pnlScrollData);
|
||||
this.Controls.Add(this.grpFile);
|
||||
this.Controls.Add(this.pnlReg);
|
||||
this.Name = "FrmCsvViewer";
|
||||
this.Text = "CsvViewer";
|
||||
this.grpFile.ResumeLayout(false);
|
||||
this.grpFile.PerformLayout();
|
||||
this.pnlScrollData.ResumeLayout(false);
|
||||
this.pnlReg.ResumeLayout(false);
|
||||
this.tblRegNumbers.ResumeLayout(false);
|
||||
this.tblRegNumbers.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TextBox txtPath;
|
||||
private System.Windows.Forms.Button btnLoad;
|
||||
private System.Windows.Forms.Button btnFirstReg;
|
||||
private System.Windows.Forms.Button btnPrevReg;
|
||||
private System.Windows.Forms.Button btnNextReg;
|
||||
private System.Windows.Forms.Button btnLastReg;
|
||||
private System.Windows.Forms.TextBox txtCurrentReg;
|
||||
private System.Windows.Forms.TextBox txtTotalRegs;
|
||||
private System.Windows.Forms.TableLayoutPanel tblRegNumbers;
|
||||
private CsvView.UI.DoubleBufferPanel pnlReg;
|
||||
private CsvView.UI.DoubleBufferPanel pnlData;
|
||||
private System.Windows.Forms.GroupBox grpFile;
|
||||
private CsvView.UI.DoubleBufferPanel pnlScrollData;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,203 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using CsvLib;
|
||||
|
||||
namespace CsvView.UI
|
||||
{
|
||||
public partial class FrmCsvViewer : Form
|
||||
{
|
||||
public FrmCsvViewer()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void txtPath_DoubleClick(object sender, EventArgs e)
|
||||
{
|
||||
OpenFileDialog loadDialog = new OpenFileDialog();
|
||||
loadDialog.InitialDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
|
||||
loadDialog.DefaultExt = "csv";
|
||||
loadDialog.Filter = "CSV Files|*.csv|Any File|*";
|
||||
DialogResult result = loadDialog.ShowDialog();
|
||||
if (result == DialogResult.OK)
|
||||
{
|
||||
txtPath.Text = loadDialog.FileName;
|
||||
}
|
||||
}
|
||||
|
||||
private string _loadedFile = string.Empty;
|
||||
private long _currentReg;
|
||||
private long _totalRegs;
|
||||
private List<long> _index;
|
||||
|
||||
private void btnLoad_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (File.Exists(txtPath.Text) == false)
|
||||
{
|
||||
RenderRegClean();
|
||||
_loadedFile = null;
|
||||
_totalRegs = 0;
|
||||
_index = null;
|
||||
MessageBoxEx.Show(this, "FileNotFound");
|
||||
return;
|
||||
}
|
||||
|
||||
LoadFile(txtPath.Text);
|
||||
}
|
||||
|
||||
public void LoadFile(string fileName)
|
||||
{
|
||||
_loadedFile = fileName;
|
||||
txtPath.Text = fileName;
|
||||
|
||||
CsvIndexer csvIndexer = new CsvIndexer();
|
||||
csvIndexer.LoadIndexOfFile(_loadedFile);
|
||||
_index = csvIndexer.Index;
|
||||
_totalRegs = _index.Count - 1;
|
||||
|
||||
RenderReg(0);
|
||||
}
|
||||
|
||||
private List<string> Index_LoadReg(int idx)
|
||||
{
|
||||
var csvParser = new CsvParser();
|
||||
csvParser.ParseFile(_loadedFile, _index[idx], 1);
|
||||
return csvParser.Data[0];
|
||||
}
|
||||
|
||||
bool _rendering;
|
||||
private void RenderReg(long currentReg)
|
||||
{
|
||||
if (_index == null || _index.Count <= 0)
|
||||
{
|
||||
RenderRegClean();
|
||||
}
|
||||
|
||||
if (_rendering) { return; }
|
||||
_rendering = true;
|
||||
|
||||
pnlReg.Enabled = true;
|
||||
bool first = false;
|
||||
bool last = false;
|
||||
if (currentReg <= 0)
|
||||
{
|
||||
currentReg = 0;
|
||||
first = true;
|
||||
}
|
||||
if (currentReg >= (_totalRegs - 1))
|
||||
{
|
||||
currentReg = _totalRegs - 1;
|
||||
last = true;
|
||||
}
|
||||
|
||||
pnlScrollData.SuspendDrawing();
|
||||
pnlScrollData.VerticalScroll.Value = 0;
|
||||
pnlData.Height = 10;
|
||||
|
||||
pnlData.Controls.Clear();
|
||||
_currentReg = currentReg;
|
||||
txtCurrentReg.Text = Convert.ToString(currentReg);
|
||||
txtTotalRegs.Text = Convert.ToString(_totalRegs);
|
||||
|
||||
btnFirstReg.Enabled = (first == false);
|
||||
btnPrevReg.Enabled = (first == false);
|
||||
btnLastReg.Enabled = (last == false);
|
||||
btnNextReg.Enabled = (last == false);
|
||||
|
||||
List<string> currentData = Index_LoadReg((int)currentReg);
|
||||
|
||||
int y = 0;
|
||||
const int textBoxPadding = 5;
|
||||
const int paddingLeft = 0;
|
||||
const int paddingRight = 0;
|
||||
const int paddingBetween = 10;
|
||||
const int lineHeight = 15;
|
||||
for (int i = 0; i < currentData.Count; i++)
|
||||
{
|
||||
TextBox txtValue = RenderValue(currentData[i], y, textBoxPadding, paddingLeft, paddingRight, lineHeight);
|
||||
pnlData.Controls.Add(txtValue);
|
||||
y += txtValue.Height + paddingBetween;
|
||||
}
|
||||
pnlData.Height = y;
|
||||
|
||||
pnlScrollData.ResumeDrawing();
|
||||
_rendering = false;
|
||||
}
|
||||
|
||||
private TextBox RenderValue(string value, int y, int textBoxPadding, int paddingLeft, int paddingRight, int lineHeight)
|
||||
{
|
||||
string[] valueLines = value.Split('\n');
|
||||
CTextBox txtValue = new CTextBox()
|
||||
{
|
||||
Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right),
|
||||
Width = pnlData.Width - (paddingLeft + paddingRight),
|
||||
Height = (valueLines.Length * lineHeight) + textBoxPadding,
|
||||
Multiline = (valueLines.Length > 1),
|
||||
Top = y,
|
||||
Left = paddingLeft,
|
||||
ReadOnly = true,
|
||||
};
|
||||
for (int j = 0; j < valueLines.Length; j++)
|
||||
{
|
||||
if (j > 0)
|
||||
{
|
||||
txtValue.AppendText("\n");
|
||||
}
|
||||
txtValue.AppendText(valueLines[j]);
|
||||
}
|
||||
return txtValue;
|
||||
}
|
||||
|
||||
private void RenderRegClean()
|
||||
{
|
||||
if (_rendering) { return; }
|
||||
_rendering = true;
|
||||
|
||||
pnlScrollData.SuspendDrawing();
|
||||
pnlScrollData.VerticalScroll.Value = 0;
|
||||
pnlData.Height = 10;
|
||||
|
||||
pnlData.Controls.Clear();
|
||||
pnlReg.Enabled = false;
|
||||
txtCurrentReg.Text = string.Empty;
|
||||
txtTotalRegs.Text = string.Empty;
|
||||
|
||||
pnlScrollData.ResumeDrawing();
|
||||
_rendering = false;
|
||||
}
|
||||
|
||||
private void btnFirstReg_Click(object sender, EventArgs e)
|
||||
{
|
||||
RenderReg(0);
|
||||
}
|
||||
|
||||
private void btnPrevReg_Click(object sender, EventArgs e)
|
||||
{
|
||||
RenderReg(_currentReg - 1);
|
||||
}
|
||||
|
||||
private void btnNextReg_Click(object sender, EventArgs e)
|
||||
{
|
||||
RenderReg(_currentReg + 1);
|
||||
}
|
||||
|
||||
private void btnLastReg_Click(object sender, EventArgs e)
|
||||
{
|
||||
RenderReg(_totalRegs - 1);
|
||||
}
|
||||
|
||||
private void txtCurrentReg_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
int newReg = 0;
|
||||
if (int.TryParse(txtCurrentReg.Text, out newReg))
|
||||
{
|
||||
RenderReg(newReg);
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderReg(_currentReg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace CsvView.UI
|
||||
{
|
||||
public static class MessageBoxEx
|
||||
{
|
||||
public static DialogResult Show(string text)
|
||||
{
|
||||
Initialize();
|
||||
return MessageBox.Show(text);
|
||||
}
|
||||
|
||||
public static DialogResult Show(string text, string caption)
|
||||
{
|
||||
Initialize();
|
||||
return MessageBox.Show(text, caption);
|
||||
}
|
||||
|
||||
public static DialogResult Show(string text, string caption, MessageBoxButtons buttons)
|
||||
{
|
||||
Initialize();
|
||||
return MessageBox.Show(text, caption, buttons);
|
||||
}
|
||||
|
||||
public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon)
|
||||
{
|
||||
Initialize();
|
||||
return MessageBox.Show(text, caption, buttons, icon);
|
||||
}
|
||||
|
||||
public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defButton)
|
||||
{
|
||||
Initialize();
|
||||
return MessageBox.Show(text, caption, buttons, icon, defButton);
|
||||
}
|
||||
|
||||
public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defButton, MessageBoxOptions options)
|
||||
{
|
||||
Initialize();
|
||||
return MessageBox.Show(text, caption, buttons, icon, defButton, options);
|
||||
}
|
||||
|
||||
public static DialogResult Show(IWin32Window owner, string text)
|
||||
{
|
||||
Initialize();
|
||||
return MessageBox.Show(owner, text);
|
||||
}
|
||||
|
||||
public static DialogResult Show(IWin32Window owner, string text, string caption)
|
||||
{
|
||||
Initialize();
|
||||
return MessageBox.Show(owner, text, caption);
|
||||
}
|
||||
|
||||
public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons)
|
||||
{
|
||||
Initialize();
|
||||
return MessageBox.Show(owner, text, caption, buttons);
|
||||
}
|
||||
|
||||
public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon)
|
||||
{
|
||||
Initialize();
|
||||
return MessageBox.Show(owner, text, caption, buttons, icon);
|
||||
}
|
||||
|
||||
public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defButton)
|
||||
{
|
||||
Initialize();
|
||||
return MessageBox.Show(owner, text, caption, buttons, icon, defButton);
|
||||
}
|
||||
|
||||
public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defButton, MessageBoxOptions options)
|
||||
{
|
||||
Initialize();
|
||||
return MessageBox.Show(owner, text, caption, buttons, icon,
|
||||
defButton, options);
|
||||
}
|
||||
|
||||
private static void Initialize()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
75
app.manifest
75
app.manifest
@@ -1,75 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
|
||||
<security>
|
||||
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<!-- UAC Manifest Options
|
||||
If you want to change the Windows User Account Control level replace the
|
||||
requestedExecutionLevel node with one of the following.
|
||||
|
||||
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
|
||||
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
|
||||
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
|
||||
|
||||
Specifying requestedExecutionLevel element will disable file and registry virtualization.
|
||||
Remove this element if your application requires this virtualization for backwards
|
||||
compatibility.
|
||||
-->
|
||||
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
|
||||
</requestedPrivileges>
|
||||
</security>
|
||||
</trustInfo>
|
||||
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
<application>
|
||||
<!-- A list of the Windows versions that this application has been tested on and is
|
||||
is designed to work with. Uncomment the appropriate elements and Windows will
|
||||
automatically selected the most compatible environment. -->
|
||||
|
||||
<!-- Windows Vista -->
|
||||
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
|
||||
|
||||
<!-- Windows 7 -->
|
||||
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
|
||||
|
||||
<!-- Windows 8 -->
|
||||
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
|
||||
|
||||
<!-- Windows 8.1 -->
|
||||
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
|
||||
|
||||
<!-- Windows 10 -->
|
||||
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->
|
||||
|
||||
</application>
|
||||
</compatibility>
|
||||
|
||||
<!-- Indicates that the application is DPI-aware and will not be automatically scaled by Windows at higher
|
||||
DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need
|
||||
to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should
|
||||
also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config. -->
|
||||
|
||||
<application xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<windowsSettings>
|
||||
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
|
||||
</windowsSettings>
|
||||
</application>
|
||||
|
||||
<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
|
||||
<!--
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity
|
||||
type="win32"
|
||||
name="Microsoft.Windows.Common-Controls"
|
||||
version="6.0.0.0"
|
||||
processorArchitecture="*"
|
||||
publicKeyToken="6595b64144ccf1df"
|
||||
language="*"
|
||||
/>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
-->
|
||||
|
||||
</assembly>
|
||||
Reference in New Issue
Block a user