Skip to content

Commit df0dadf

Browse files
committed
Search added
1 parent f409ca8 commit df0dadf

8 files changed

Lines changed: 88 additions & 8 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System;
2+
using System.Globalization;
3+
using System.Windows.Data;
4+
5+
namespace NETworkManager.Converters
6+
{
7+
public sealed class NullOrEmptyToBoolConverter : IValueConverter
8+
{
9+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
10+
{
11+
return string.IsNullOrEmpty(value as string);
12+
}
13+
14+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
15+
{
16+
throw new NotImplementedException();
17+
}
18+
}
19+
}

Source/NETworkManager/NETworkManager.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@
180180
<Compile Include="3rdParty\Heijden.DNS\Structs.cs" />
181181
<Compile Include="Controls\DragablzMainInterTabClient.cs" />
182182
<Compile Include="Controls\DragablzTabContent.cs" />
183+
<Compile Include="Converters\NullOrEmptyToBoolConverter.cs" />
183184
<Compile Include="Converters\TimestampToStringConverter.cs" />
184185
<Compile Include="Converters\NullableDateTimeToStringConverter.cs" />
185186
<Compile Include="Converters\ValidateSubnetCalculatorIPv4SplitterConverter.cs" />

Source/NETworkManager/Resources/Localization/Resources.de-DE.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@
266266
<system:String x:Key="String_CopyAs">Kopieren als</system:String>
267267
<system:String x:Key="String_IPScannerProfiles">IP-Scanner Profile</system:String>
268268
<system:String x:Key="String_IPRange">IP-Bereich</system:String>
269+
<system:String x:Key="String_NothingFound">Nichts gefunden!</system:String>
269270

270271
<!-- ToolTip -->
271272
<system:String x:Key="String_ToolTip_Settings">Einstellungen</system:String>

Source/NETworkManager/Resources/Localization/Resources.en-US.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@
266266
<system:String x:Key="String_CopyAs">Copy as</system:String>
267267
<system:String x:Key="String_IPScannerProfiles">IP-Scanner profiles</system:String>
268268
<system:String x:Key="String_IPRange">IP range</system:String>
269+
<system:String x:Key="String_NothingFound">Nothing found!</system:String>
269270

270271
<!-- ToolTip -->
271272
<system:String x:Key="String_ToolTip_Settings">Settings</system:String>

Source/NETworkManager/ViewModels/Applications/IPScannerViewModel.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,23 @@ public bool ExpandProfileView
294294
OnPropertyChanged();
295295
}
296296
}
297+
298+
private string _search;
299+
public string Search
300+
{
301+
get { return _search; }
302+
set
303+
{
304+
if (value == _search)
305+
return;
306+
307+
_search = value;
308+
309+
IPScannerProfiles.Refresh();
310+
311+
OnPropertyChanged();
312+
}
313+
}
297314
#endregion
298315
#endregion
299316

@@ -309,6 +326,19 @@ public IPScannerViewModel(IDialogCoordinator instance)
309326
_ipScannerProfiles = CollectionViewSource.GetDefaultView(IPScannerProfileManager.Profiles);
310327
_ipScannerProfiles.GroupDescriptions.Add(new PropertyGroupDescription("Group"));
311328
_ipScannerProfiles.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));
329+
_ipScannerProfiles.Filter = o =>
330+
{
331+
if (string.IsNullOrEmpty(Search))
332+
return true;
333+
334+
IPScannerProfileInfo info = o as IPScannerProfileInfo;
335+
336+
string search = Search.Trim();
337+
338+
// Search by: Name
339+
return info.Name.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0;
340+
};
341+
312342

313343
LoadSettings();
314344

Source/NETworkManager/ViewModels/Applications/RemoteDesktopViewModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ public RemoteDesktopViewModel(IDialogCoordinator instance)
119119

120120
string search = Search.Trim();
121121

122+
// Search by: Name
122123
return info.Name.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0;
123124
};
124125

Source/NETworkManager/Views/Applications/IPScannerView.xaml

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<Converter:IntToStringConverter x:Key="IntToStringConverter" />
1919
<Converter:IPStatusToStringConverter x:Key="IPStatusToStringConverter" />
2020
<Converter:NullableDateTimeToStringConverter x:Key="NullableDateTimeToStringConverter" />
21+
<Converter:NullOrEmptyToBoolConverter x:Key="NullOrEmptyToBoolConverter" />
2122
<Converter:PingTimeToStringConverter x:Key="PingTimeToStringConverter" />
2223
<Converter:PhysicalAddressToStringConverter x:Key="PhysicalAddressToStringConverter" />
2324
</UserControl.Resources>
@@ -236,11 +237,24 @@
236237
<Expander x:Name="expanderProfiles" Header="{DynamicResource String_Header_Profiles}" Style="{StaticResource RightExpander}" IsExpanded="{Binding ExpandProfileView}">
237238
<Grid Width="250">
238239
<Grid.RowDefinitions>
240+
<RowDefinition Height="Auto" />
241+
<RowDefinition Height="10" />
239242
<RowDefinition Height="*" />
240243
<RowDefinition Height="10" />
241244
<RowDefinition Height="Auto" />
242245
</Grid.RowDefinitions>
243-
<ListBox Grid.Column="0" Grid.Row="0" x:Name="listBoxProfiles" FontSize="14" ItemsSource="{Binding IPScannerProfiles}" DisplayMemberPath="Name" SelectedItem="{Binding SelectedProfile}">
246+
<TextBox x:Name="txtSearch" Grid.Column="0" BorderBrush="{DynamicResource GrayBrush8}" BorderThickness="1" FontSize="14" VerticalAlignment="Center" Text="{Binding Search, UpdateSourceTrigger=PropertyChanged}" mah:TextBoxHelper.Watermark="{DynamicResource String_Watermark_Search}" Controls:TextBoxHelper.ClearTextButton="True">
247+
<TextBox.Style>
248+
<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource SearchMetroTextBox}">
249+
<Style.Triggers>
250+
<Trigger Property="Controls:TextBoxHelper.HasText" Value="True">
251+
<Setter Property="Controls:TextBoxHelper.ButtonContentTemplate" Value="{x:Null}" />
252+
</Trigger>
253+
</Style.Triggers>
254+
</Style>
255+
</TextBox.Style>
256+
</TextBox>
257+
<ListBox Grid.Column="0" Grid.Row="2" x:Name="listBoxProfiles" FontSize="14" ItemsSource="{Binding IPScannerProfiles}" DisplayMemberPath="Name" SelectedItem="{Binding SelectedProfile}">
244258
<ListBox.Resources>
245259
<Style TargetType="{x:Type ScrollViewer}" BasedOn="{StaticResource DefaulScrollViewer}" />
246260
<ContextMenu x:Key="ListBoxItemContextMenu" Opened="ContextMenu_Opened" MinWidth="150">
@@ -301,19 +315,25 @@
301315
</GroupStyle>
302316
</ListBox.GroupStyle>
303317
</ListBox>
304-
<TextBlock Grid.Column="0" Grid.Row="0" FontSize="18" Foreground="{DynamicResource GrayBrush3}" Text="{DynamicResource String_NoProfilesFoundCreateOne}" VerticalAlignment="Center" HorizontalAlignment="Center" TextWrapping="Wrap" TextAlignment="Center" Margin="10,0" >
318+
<TextBlock Grid.Row="2" FontSize="18" Foreground="{DynamicResource GrayBrush3}" VerticalAlignment="Center" HorizontalAlignment="Center" TextWrapping="Wrap" TextAlignment="Center" Margin="10,0" >
305319
<TextBlock.Style>
306320
<Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource HeaderTextBlock}">
307321
<Setter Property="Visibility" Value="Collapsed" />
308322
<Style.Triggers>
309-
<DataTrigger Binding="{Binding PortScannerProfiles.Count}" Value="0">
310-
<Setter Property="Visibility" Value="Visible" />
323+
<DataTrigger Binding="{Binding IPScannerProfiles.Count}" Value="0" >
324+
<DataTrigger.Setters>
325+
<Setter Property="Visibility" Value="Visible" />
326+
<Setter Property="Text" Value="{DynamicResource String_NoProfilesFoundCreateOne}" />
327+
</DataTrigger.Setters>
328+
</DataTrigger>
329+
<DataTrigger Binding="{Binding Search, Converter={StaticResource NullOrEmptyToBoolConverter}}" Value="False">
330+
<Setter Property="Text" Value="{DynamicResource String_NothingFound}" />
311331
</DataTrigger>
312332
</Style.Triggers>
313333
</Style>
314334
</TextBlock.Style>
315335
</TextBlock>
316-
<Button x:Name="btnAddProfile" Grid.Column="0" Grid.Row="2" Command="{Binding AddProfileCommand}" Style="{StaticResource ImageWithTextButton}">
336+
<Button x:Name="btnAddProfile" Grid.Column="0" Grid.Row="4" Command="{Binding AddProfileCommand}" Style="{StaticResource ImageWithTextButton}">
317337
<Button.Content>
318338
<Grid>
319339
<Grid.ColumnDefinitions>

Source/NETworkManager/Views/Applications/RemoteDesktopView.xaml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
mc:Ignorable="d">
1515
<UserControl.Resources>
1616
<Converter:BooleanReverseToVisibilityConverter x:Key="BooleanReverseToVisibilityConverter" />
17+
<Converter:NullOrEmptyToBoolConverter x:Key="NullOrEmptyToBoolConverter" />
1718
</UserControl.Resources>
1819
<Grid>
1920
<Grid.ColumnDefinitions>
@@ -151,13 +152,19 @@
151152
</Style>
152153
</ListBox.ItemContainerStyle>
153154
</ListBox>
154-
<TextBlock Grid.Row="2" FontSize="18" Foreground="{DynamicResource GrayBrush3}" Text="{DynamicResource String_NoSessionsFoundCreateOne}" VerticalAlignment="Center" HorizontalAlignment="Center" TextWrapping="Wrap" TextAlignment="Center" Margin="10,0" >
155+
<TextBlock Grid.Row="2" FontSize="18" Foreground="{DynamicResource GrayBrush3}" VerticalAlignment="Center" HorizontalAlignment="Center" TextWrapping="Wrap" TextAlignment="Center" Margin="10,0" >
155156
<TextBlock.Style>
156157
<Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource HeaderTextBlock}">
157158
<Setter Property="Visibility" Value="Collapsed" />
158159
<Style.Triggers>
159-
<DataTrigger Binding="{Binding RemoteDesktopSessions.Count}" Value="0">
160-
<Setter Property="Visibility" Value="Visible" />
160+
<DataTrigger Binding="{Binding RemoteDesktopSessions.Count}" Value="0" >
161+
<DataTrigger.Setters>
162+
<Setter Property="Visibility" Value="Visible" />
163+
<Setter Property="Text" Value="{DynamicResource String_NoSessionsFoundCreateOne}" />
164+
</DataTrigger.Setters>
165+
</DataTrigger>
166+
<DataTrigger Binding="{Binding Search, Converter={StaticResource NullOrEmptyToBoolConverter}}" Value="False">
167+
<Setter Property="Text" Value="{DynamicResource String_NothingFound}" />
161168
</DataTrigger>
162169
</Style.Triggers>
163170
</Style>

0 commit comments

Comments
 (0)