Skip to content

Commit eb5f63a

Browse files
committed
Add selection tracking and clear results to worklist
Introduces selection count tracking in the worklist results and updates status text to reflect selected items. Adds a Clear button and command to clear results and selection. Handles DataGrid selection changes in MainWindow and updates status accordingly. Assembly version updated to 1.1.2.
1 parent 2a517f2 commit eb5f63a

File tree

5 files changed

+104
-11
lines changed

5 files changed

+104
-11
lines changed

DMWL4/MWL4.sln

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 17
4-
VisualStudioVersion = 17.14.36623.8 d17.14
4+
VisualStudioVersion = 17.14.36623.8
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MWL4", "MWL4.csproj", "{A3DE8EB7-C80F-4F34-BCDC-253F646C7FE1}"
77
EndProject
8+
Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "DMWL4", "..\..\..\MSI\DMWL4\DMWL4.vdproj", "{FBE87749-4DFE-E910-3ACA-BD3C8AA86AAD}"
9+
EndProject
810
Global
911
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1012
Debug|Any CPU = Debug|Any CPU
@@ -15,6 +17,8 @@ Global
1517
{A3DE8EB7-C80F-4F34-BCDC-253F646C7FE1}.Debug|Any CPU.Build.0 = Debug|Any CPU
1618
{A3DE8EB7-C80F-4F34-BCDC-253F646C7FE1}.Release|Any CPU.ActiveCfg = Release|Any CPU
1719
{A3DE8EB7-C80F-4F34-BCDC-253F646C7FE1}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{FBE87749-4DFE-E910-3ACA-BD3C8AA86AAD}.Debug|Any CPU.ActiveCfg = Debug
21+
{FBE87749-4DFE-E910-3ACA-BD3C8AA86AAD}.Release|Any CPU.ActiveCfg = Release
1822
EndGlobalSection
1923
GlobalSection(SolutionProperties) = preSolution
2024
HideSolutionNode = FALSE

DMWL4/MainWindow.xaml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@
5252
<Grid Margin="8,8,8,0">
5353
<Grid.ColumnDefinitions>
5454
<ColumnDefinition Width="Auto"/>
55-
<ColumnDefinition Width="221*"/>
56-
<ColumnDefinition Width="34*"/>
57-
<ColumnDefinition Width="69*"/>
55+
<ColumnDefinition Width="Auto"/>
56+
<ColumnDefinition Width="39*"/>
57+
<ColumnDefinition Width="80*"/>
5858
<ColumnDefinition Width="Auto"/>
5959
</Grid.ColumnDefinitions>
6060
<Grid.RowDefinitions>
@@ -74,7 +74,7 @@
7474
<Label Content="Port:" Grid.Row="1" Grid.RowSpan="4" RenderTransformOrigin="0.512,0.301" Margin="0,20,0,28"/>
7575
<TextBox Grid.Row="2" Text="{Binding ServerPort, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="81,5,0,0" Grid.ColumnSpan="5" Height="17.96"/>
7676

77-
<CheckBox Grid.Row="3" Content="Use TLS" IsChecked="{Binding UseTLS, Mode=TwoWay}" Margin="25,62,0,0" HorizontalAlignment="Left" Grid.ColumnSpan="2" Grid.RowSpan="2"/>
77+
<CheckBox Grid.Row="3" Content="Use TLS" IsChecked="{Binding UseTLS, Mode=TwoWay}" Margin="10,62,0,0" HorizontalAlignment="Left" Grid.ColumnSpan="2" Grid.RowSpan="2"/>
7878

7979
<Button Grid.Row="3" Grid.Column="4" Content="Dicom Echo" Width="100" Command="{Binding DicomEchoCommand}" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,62,0,0"/>
8080
<Button Grid.Row="3" Grid.Column="2" Content="Ping" Width="100" Command="{Binding PingCommand}" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,10,0" Grid.ColumnSpan="2" Grid.RowSpan="2"/>
@@ -121,8 +121,17 @@
121121
<DatePicker Grid.Row="6" Grid.Column="1" SelectedDate="{Binding EndDate, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="0,0,0,4"/>
122122

123123
<StackPanel Grid.Row="7" Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,8,0,0">
124-
<Button Content="Query" Width="100" Command="{Binding QueryCommand}"/>
124+
<Button Content="Clear" Command="{Binding ClearResultsCommand}" Width="100" VerticalAlignment="Bottom" HorizontalAlignment="Right" />
125125
</StackPanel>
126+
<Button Content="Query"
127+
Command="{Binding QueryCommand}"
128+
Grid.Column="1"
129+
Grid.Row="7"
130+
Width="100"
131+
VerticalAlignment="Top"
132+
HorizontalAlignment="Right"
133+
Margin="0,8,116,0"
134+
IsDefault="True"/>
126135
</Grid>
127136
</GroupBox>
128137
<GroupBox Header="Results" Grid.Row="2" Grid.ColumnSpan="2">
@@ -133,7 +142,8 @@
133142
Margin="8"
134143
ColumnWidth="Auto"
135144
ScrollViewer.HorizontalScrollBarVisibility="Auto"
136-
ScrollViewer.VerticalScrollBarVisibility="Auto">
145+
ScrollViewer.VerticalScrollBarVisibility="Auto"
146+
SelectionChanged="DataGrid_SelectionChanged">
137147
<DataGrid.Columns>
138148
<DataGridTextColumn Binding="{Binding PatientName}">
139149
<DataGridTextColumn.Header>

DMWL4/MainWindow.xaml.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.IO;
66
using System.Reflection;
77
using System.Windows;
8+
using System.Windows.Controls;
89

910
namespace MWL4
1011
{
@@ -57,5 +58,15 @@ private void AppendVersionToTitle()
5758
?? "1.0";
5859
Title = $"{Title} v{ver}";
5960
}
61+
62+
// Handles DataGrid SelectionChanged from MainWindow.xaml
63+
private void DataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
64+
{
65+
var dg = (DataGrid)sender;
66+
if (DataContext is MainViewModel vm)
67+
{
68+
vm.SelectionChangedCommand.Execute(dg.SelectedItems?.Count ?? 0);
69+
}
70+
}
6071
}
6172
}

DMWL4/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,5 @@
4747
// Revision
4848
//
4949
[assembly: AssemblyVersion("1.1")]
50-
[assembly: AssemblyFileVersion("1.1")]
51-
[assembly: AssemblyInformationalVersion("1.1")]
50+
[assembly: AssemblyFileVersion("1.1.2")]
51+
[assembly: AssemblyInformationalVersion("1.1.2")]

DMWL4/ViewModels/MainViewModel.cs

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,31 @@ public bool UseTLS
8888
private string _statusText = "Ready";
8989
public string StatusText { get => _statusText; set { _statusText = value; OnPropertyChanged(); } }
9090

91+
// Selected rows count
92+
private int _selectedCount;
93+
public int SelectedCount
94+
{
95+
get => _selectedCount;
96+
set
97+
{
98+
if (_selectedCount == value) return;
99+
_selectedCount = value;
100+
OnPropertyChanged();
101+
UpdateStatusWithCounts();
102+
}
103+
}
104+
91105
public ObservableCollection<WorklistItem> WorklistResults { get; } = new ObservableCollection<WorklistItem>();
92106

93107
public ICommand DicomEchoCommand { get; }
94108
public ICommand QueryCommand { get; }
95109
public ICommand ExitCommand { get; }
96110
public ICommand AboutCommand { get; }
97111
public ICommand PingCommand { get; }
112+
public ICommand ClearResultsCommand { get; } // NEW
113+
114+
// Command to update selection count (bound from view)
115+
public ICommand SelectionChangedCommand { get; }
98116

99117
public MainViewModel()
100118
{
@@ -112,6 +130,29 @@ public MainViewModel()
112130
SaveSettings();
113131
Application.Current?.Shutdown();
114132
});
133+
134+
ClearResultsCommand = new RelayCommand(_ => ClearResults()); // NEW
135+
136+
SelectionChangedCommand = new RelayCommand(p =>
137+
{
138+
// Expect parameter to be the selected count (int)
139+
var count = 0;
140+
if (p is int i)
141+
{
142+
count = i;
143+
}
144+
else if (p != null)
145+
{
146+
// Fallback: try to read Count property via reflection to support SelectedItems
147+
var prop = p.GetType().GetProperty("Count");
148+
if (prop != null)
149+
{
150+
var val = prop.GetValue(p, null);
151+
if (val is int ci) count = ci;
152+
}
153+
}
154+
SelectedCount = count;
155+
});
115156
}
116157

117158
private void LoadSettings()
@@ -166,6 +207,7 @@ private async Task DoEchoAsync()
166207
_logger.Information("C-ECHO success");
167208
ShowMessage($"Connection to {ServerHost} successful.", MessageBoxImage.Information);
168209
StatusText = "Echo successful";
210+
UpdateStatusWithCounts();
169211
}
170212
catch (Exception ex)
171213
{
@@ -191,11 +233,13 @@ private async Task DoPingAsync()
191233
{
192234
ShowMessage($"Ping Success.\nTime: {reply.RoundtripTime}ms", MessageBoxImage.Information, "Ping Result");
193235
StatusText = "Ping successful";
236+
UpdateStatusWithCounts();
194237
}
195238
else
196239
{
197240
ShowMessage($"Ping Failed: {reply.Status}", MessageBoxImage.Warning, "Ping Result");
198241
StatusText = "Ping failed";
242+
UpdateStatusWithCounts();
199243
}
200244
}
201245
}
@@ -208,6 +252,7 @@ private async Task DoPingAsync()
208252
private async Task DoQueryAsync()
209253
{
210254
WorklistResults.Clear();
255+
SelectedCount = 0; // reset selection when querying
211256
StatusText = "Querying Worklist...";
212257

213258
try
@@ -227,7 +272,7 @@ private async Task DoQueryAsync()
227272
await client.AddRequestAsync(request);
228273
await client.SendAsync();
229274

230-
StatusText = $"Found {WorklistResults.Count} items.";
275+
UpdateStatusWithCounts();
231276
_logger.Information("Query completed. Results: {count}", WorklistResults.Count);
232277
}
233278
catch (Exception ex)
@@ -236,6 +281,28 @@ private async Task DoQueryAsync()
236281
}
237282
}
238283

284+
private void ClearResults() // NEW
285+
{
286+
WorklistResults.Clear();
287+
SelectedCount = 0;
288+
StatusText = "Cleared results.";
289+
UpdateStatusWithCounts();
290+
}
291+
292+
private void UpdateStatusWithCounts()
293+
{
294+
// Compose status text to include result count and selection
295+
var baseText = $"Found {WorklistResults.Count} items.";
296+
if (SelectedCount > 0)
297+
{
298+
StatusText = $"{baseText} {SelectedCount} selected.";
299+
}
300+
else
301+
{
302+
StatusText = baseText;
303+
}
304+
}
305+
239306
private WorklistItem MapDatasetToWorklistItem(DicomDataset ds)
240307
{
241308
var spsSeq = DicomTag.ScheduledProcedureStepSequence;
@@ -264,7 +331,8 @@ private WorklistItem MapDatasetToWorklistItem(DicomDataset ds)
264331
ScheduledPerformingPhysicianName = ds.GetStringSafe(DicomTag.ScheduledPerformingPhysicianName, spsSeq),
265332
ScheduledProtocolCodeValue = ds.GetNestedStringSafe(spsSeq, protoSeq, DicomTag.CodeValue),
266333
ScheduledProtocolCodeMeaning = ds.GetNestedStringSafe(spsSeq, protoSeq, DicomTag.CodeMeaning),
267-
ScheduledProtocolCodeScheme = ds.GetNestedStringSafe(spsSeq, protoSeq, DicomTag.CodingSchemeDesignator)
334+
ScheduledProtocolCodeScheme = ds.GetNestedStringSafe(spsSeq, protoSeq, DicomTag.CodingSchemeDesignator
335+
)
268336
};
269337
}
270338

0 commit comments

Comments
 (0)