@@ -9,12 +9,16 @@
|
|||||||
Width="800"
|
Width="800"
|
||||||
Height="600"
|
Height="600"
|
||||||
Title="CsvView">
|
Title="CsvView">
|
||||||
<Grid RowDefinitions="Auto,Auto,*">
|
<Grid RowDefinitions="Auto,Auto,Auto,*">
|
||||||
<StackPanel Orientation="Horizontal" Grid.Row="0">
|
<Grid ColumnDefinitions="Auto,*" Grid.Row="0">
|
||||||
<Button Name="BtnLoad" Click="BtnLoad_OnClick">...</Button>
|
<Button Grid.Column="0" Name="BtnLoad" Click="BtnLoad_OnClick">...</Button>
|
||||||
<TextBox Name="TxtFileName" IsReadOnly="true" />
|
<TextBox Grid.Column="1" Name="TxtFileName" IsReadOnly="true" />
|
||||||
</StackPanel>
|
</Grid>
|
||||||
<StackPanel Orientation="Horizontal" Grid.Row="1">
|
<Grid ColumnDefinitions="*,Auto" Grid.Row="1">
|
||||||
|
<TextBox Grid.Column="0" Name="TxtSearch" />
|
||||||
|
<Button Grid.Column="1" Name="BtnSearch" Click="BtnSearch_OnClick">🔍</Button>
|
||||||
|
</Grid>
|
||||||
|
<StackPanel Orientation="Horizontal" Grid.Row="2">
|
||||||
<Button Name="BtnFirst" Click="BtnFirst_OnClick">|◁</Button>
|
<Button Name="BtnFirst" Click="BtnFirst_OnClick">|◁</Button>
|
||||||
<Button Name="BtnPrevious" Click="BtnPrevious_OnClick">◁</Button>
|
<Button Name="BtnPrevious" Click="BtnPrevious_OnClick">◁</Button>
|
||||||
<TextBox Name="TxtIndex" Text="{Binding Index}" TextChanged="TxtIndex_OnTextChanged"></TextBox>
|
<TextBox Name="TxtIndex" Text="{Binding Index}" TextChanged="TxtIndex_OnTextChanged"></TextBox>
|
||||||
@@ -23,7 +27,7 @@
|
|||||||
<Button Name="BtnNext" Click="BtnNext_OnClick">▷</Button>
|
<Button Name="BtnNext" Click="BtnNext_OnClick">▷</Button>
|
||||||
<Button Name="BtnLast" Click="BtnLast_OnClick">▷|</Button>
|
<Button Name="BtnLast" Click="BtnLast_OnClick">▷|</Button>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<ScrollViewer Grid.Row="2">
|
<ScrollViewer Grid.Row="3">
|
||||||
<StackPanel Orientation="Vertical">
|
<StackPanel Orientation="Vertical">
|
||||||
<ItemsControl ItemsSource="{Binding Fields}">
|
<ItemsControl ItemsSource="{Binding Fields}">
|
||||||
<ItemsControl.DataTemplates>
|
<ItemsControl.DataTemplates>
|
||||||
|
|||||||
@@ -38,6 +38,11 @@ public partial class MainWindow : Window
|
|||||||
LoadFile(files[0].Path.LocalPath);
|
LoadFile(files[0].Path.LocalPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void BtnSearch_OnClick(object? sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
Search(TxtSearch.Text);
|
||||||
|
}
|
||||||
|
|
||||||
private void BtnFirst_OnClick(object? sender, RoutedEventArgs e)
|
private void BtnFirst_OnClick(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
RenderReg(0);
|
RenderReg(0);
|
||||||
@@ -68,9 +73,9 @@ public partial class MainWindow : Window
|
|||||||
private int _totalRegs;
|
private int _totalRegs;
|
||||||
private List<long> _index = new();
|
private List<long> _index = new();
|
||||||
|
|
||||||
|
|
||||||
private void LoadFile(string fileName)
|
private void LoadFile(string fileName)
|
||||||
{
|
{
|
||||||
|
// TODO: Loading animation
|
||||||
_loadedFile = fileName;
|
_loadedFile = fileName;
|
||||||
TxtFileName.Text = fileName;
|
TxtFileName.Text = fileName;
|
||||||
|
|
||||||
@@ -82,9 +87,22 @@ public partial class MainWindow : Window
|
|||||||
RenderReg(0);
|
RenderReg(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Search(string? textToSearch)
|
||||||
|
{
|
||||||
|
// TODO: Loading animation
|
||||||
|
CsvFieldIndexer csvIndexer = new();
|
||||||
|
csvIndexer.LoadIndexOfFile(_loadedFile);
|
||||||
|
|
||||||
|
List<long> newIndexes = csvIndexer.Search(_loadedFile, textToSearch);
|
||||||
|
_index = newIndexes;
|
||||||
|
_totalRegs = _index.Count - 1;
|
||||||
|
|
||||||
|
RenderReg(0, forceLoad: true);
|
||||||
|
}
|
||||||
|
|
||||||
private bool _rendering;
|
private bool _rendering;
|
||||||
|
|
||||||
private void RenderReg(long currentReg)
|
private void RenderReg(long currentReg, bool forceLoad = false)
|
||||||
{
|
{
|
||||||
if (_rendering) { return; }
|
if (_rendering) { return; }
|
||||||
_rendering = true;
|
_rendering = true;
|
||||||
@@ -122,7 +140,7 @@ public partial class MainWindow : Window
|
|||||||
BtnNext.IsEnabled = (last == false);
|
BtnNext.IsEnabled = (last == false);
|
||||||
BtnLast.IsEnabled = (last == false);
|
BtnLast.IsEnabled = (last == false);
|
||||||
|
|
||||||
if (_currentReg == currentReg)
|
if (_currentReg == currentReg && forceLoad == false)
|
||||||
{
|
{
|
||||||
_rendering = false;
|
_rendering = false;
|
||||||
return;
|
return;
|
||||||
@@ -143,7 +161,6 @@ public partial class MainWindow : Window
|
|||||||
|
|
||||||
_rendering = false;
|
_rendering = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class FieldViewModel
|
public class FieldViewModel
|
||||||
|
|||||||
Reference in New Issue
Block a user