Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lookup performance #54

Merged
merged 3 commits into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions DicomGrep/Views/DicomDictionaryLookupView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" MinHeight="20"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid Name="header" MinHeight="40">
<Grid Name="header" MinHeight="40" Margin="8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
Expand Down Expand Up @@ -47,6 +48,10 @@
<DataGridTextColumn Header="Private Creator" Binding="{Binding Tag.PrivateCreator, Mode=OneWay}"/>
</DataGrid.Columns>
</DataGrid>

<StatusBar Grid.Row="2">
<StatusBarItem>
<Label Content="{Binding ElementName=dataGridUid, Path=Items.Count}" ContentStringFormat="Tags: {0}"/>
</StatusBarItem>
</StatusBar>
</Grid>
</Window>
22 changes: 19 additions & 3 deletions DicomGrep/Views/DicomDictionaryLookupView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Threading;

namespace DicomGrep.Views
{
Expand All @@ -21,14 +22,22 @@ namespace DicomGrep.Views
/// </summary>
public partial class DicomDictionaryLookupView : Window
{
// delayed search for better performance
private DispatcherTimer timer = new DispatcherTimer();

public DicomDictionaryLookupView()
{
InitializeComponent();

timer.Interval = TimeSpan.FromSeconds(1);
timer.Tick += Timer_Tick;
}

private void Filter_TextChanged(object sender, TextChangedEventArgs e)
private void Timer_Tick(object sender, EventArgs e)
{
TextBox filterTextBox = (TextBox)sender;
timer.Stop();

TextBox filterTextBox = filter;
string filterText = filterTextBox.Text;
ICollectionView cv = CollectionViewSource.GetDefaultView(dataGridUid.ItemsSource);

Expand All @@ -39,7 +48,7 @@ private void Filter_TextChanged(object sender, TextChangedEventArgs e)
DicomDictionaryEntry dictionary = obj as DicomDictionaryEntry;
return dictionary.ToString().Contains(filterText.Trim(), StringComparison.OrdinalIgnoreCase) ||
(
dictionary.Tag.PrivateCreator != null &&
dictionary.Tag.PrivateCreator != null &&
dictionary.Tag.PrivateCreator.Creator.Contains(filterText.Trim(), StringComparison.OrdinalIgnoreCase)
) ||
dictionary.Name.Contains(filterText.Trim(), StringComparison.OrdinalIgnoreCase);
Expand All @@ -52,6 +61,13 @@ private void Filter_TextChanged(object sender, TextChangedEventArgs e)
}
}

private void Filter_TextChanged(object sender, TextChangedEventArgs e)
{
// reset the timer
timer.Stop();
timer.Start();
}

private void pick_Click(object sender, RoutedEventArgs e)
{
this.DialogResult = true;
Expand Down
13 changes: 9 additions & 4 deletions DicomGrep/Views/SopClassLookupView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
</Window.DataContext>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" MinHeight="20"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid Name="header" MinHeight="40">
<Grid Name="header" MinHeight="40" Margin="8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
Expand All @@ -34,6 +35,10 @@
<DataGrid Name="dataGridUid" ItemsSource="{Binding SOPClassUIDs, Mode=OneWay}" AutoGenerateColumns="True"
SelectedItem="{Binding SelectedUID, Mode=OneWayToSource}" SelectionMode="Single"
Grid.Row="1" MouseDoubleClick="dataGridUid_MouseDoubleClick"/>

<StatusBar Grid.Row="2">
<StatusBarItem>
<Label Content="{Binding ElementName=dataGridUid, Path=Items.Count}" ContentStringFormat="UIDs: {0}"/>
</StatusBarItem>
</StatusBar>
</Grid>
</Window>
20 changes: 18 additions & 2 deletions DicomGrep/Views/SopClassLookupView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Threading;

namespace DicomGrep.Views
{
Expand All @@ -21,14 +22,22 @@ namespace DicomGrep.Views
/// </summary>
public partial class SopClassLookupView : Window
{
// delayed search for better performance
private DispatcherTimer timer = new DispatcherTimer();

public SopClassLookupView()
{
InitializeComponent();

timer.Interval = TimeSpan.FromSeconds(1);
timer.Tick += Timer_Tick;
}

private void Filter_TextChanged(object sender, TextChangedEventArgs e)
private void Timer_Tick(object sender, EventArgs e)
{
TextBox filterTextBox = (TextBox)sender;
timer.Stop();

TextBox filterTextBox = filter;
string filterText = filterTextBox.Text;
ICollectionView cv = CollectionViewSource.GetDefaultView(dataGridUid.ItemsSource);

Expand All @@ -47,6 +56,13 @@ private void Filter_TextChanged(object sender, TextChangedEventArgs e)
}
}

private void Filter_TextChanged(object sender, TextChangedEventArgs e)
{
// reset the timer
timer.Stop();
timer.Start();
}

private void pick_Click(object sender, RoutedEventArgs e)
{
this.DialogResult = true;
Expand Down
Loading