Skip to content

Commit 7fc9d49

Browse files
committed
Feature: Profile description and tooltip
1 parent cbc187d commit 7fc9d49

File tree

10 files changed

+101
-33
lines changed

10 files changed

+101
-33
lines changed

Source/NETworkManager.Localization/Resources/StaticStrings.Designer.cs

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Source/NETworkManager.Localization/Resources/StaticStrings.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@
227227
<data name="ExamplePortScanRange" xml:space="preserve">
228228
<value>22; 80; 443; 500 - 999; 8080</value>
229229
</data>
230-
<data name="ExampleRemoteDesktopProfileName" xml:space="preserve">
230+
<data name="ExampleProfileName" xml:space="preserve">
231231
<value>Webserver</value>
232232
</data>
233233
<data name="ExampleSerialLine" xml:space="preserve">

Source/NETworkManager.Localization/Resources/Strings.Designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Source/NETworkManager.Localization/Resources/Strings.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3851,4 +3851,7 @@ Right-click for more options.</value>
38513851
<data name="SetDefault" xml:space="preserve">
38523852
<value>Set default</value>
38533853
</data>
3854+
<data name="ExampleProfileDescription" xml:space="preserve">
3855+
<value>Ubuntu Server running Docker with Nextcloud and Traefik...</value>
3856+
</data>
38543857
</root>

Source/NETworkManager.Profiles/ProfileInfo.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public ProfileInfo(ProfileInfo profile)
3131
{
3232
Name = profile.Name;
3333
Host = profile.Host;
34+
Description = profile.Description;
3435
Group = profile.Group;
3536
Tags = profile.Tags;
3637

@@ -248,11 +249,16 @@ public ProfileInfo(ProfileInfo profile)
248249
/// </summary>
249250
public string Host { get; set; }
250251

252+
/// <summary>
253+
/// Description of the profile.
254+
/// </summary>
255+
public string Description { get; set; }
256+
251257
/// <summary>
252258
/// Name of the group. Profiles are grouped based on the name.
253259
/// </summary>
254260
public string Group { get; set; }
255-
261+
256262
/// <summary>
257263
/// Tags to classify the profiles and to filter by it.
258264
/// </summary>

Source/NETworkManager/ProfileDialogManager.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Security;
4-
using System.Threading.Tasks;
5-
using System.Windows;
6-
using MahApps.Metro.Controls.Dialogs;
1+
using MahApps.Metro.Controls.Dialogs;
72
using NETworkManager.Localization.Resources;
83
using NETworkManager.Models;
94
using NETworkManager.Models.Network;
@@ -12,6 +7,11 @@
127
using NETworkManager.Profiles;
138
using NETworkManager.ViewModels;
149
using NETworkManager.Views;
10+
using System;
11+
using System.Collections.Generic;
12+
using System.Security;
13+
using System.Threading.Tasks;
14+
using System.Windows;
1515

1616
namespace NETworkManager;
1717

@@ -31,6 +31,7 @@ private static ProfileInfo ParseProfileInfo(ProfileViewModel instance)
3131
{
3232
Name = instance.Name.Trim(),
3333
Host = instance.Host.Trim(),
34+
Description = instance.Description?.Trim(),
3435
Group = instance.Group.Trim(),
3536
Tags = instance.Tags?.Trim(),
3637

Source/NETworkManager/ViewModels/ProfileViewModel.cs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,18 @@ public ProfileViewModel(Action<ProfileViewModel> saveCommand, Action<ProfileView
4343

4444
Host = profileInfo.Host;
4545

46+
Description = profileInfo.Description;
47+
4648
// Try to get group (name) as parameter, then from profile, then the first in the list of groups, then the default group
4749
Group = group ?? (string.IsNullOrEmpty(profileInfo.Group)
4850
? groups.Count > 0 ? groups.OrderBy(x => x).First() : Strings.Default
4951
: profileInfo.Group);
50-
51-
Tags = profileInfo.Tags;
52-
52+
5353
Groups = CollectionViewSource.GetDefaultView(groups);
5454
Groups.SortDescriptions.Add(new SortDescription());
5555

56+
Tags = profileInfo.Tags;
57+
5658
// Network Interface
5759
NetworkInterface_Enabled = editMode == ProfileEditMode.Add
5860
? applicationName == ApplicationName.NetworkInterface
@@ -449,6 +451,21 @@ public bool ShowCouldNotResolveHostnameWarning
449451
OnPropertyChanged();
450452
}
451453
}
454+
455+
private string _description;
456+
457+
public string Description
458+
{
459+
get => _description;
460+
set
461+
{
462+
if (value == _description)
463+
return;
464+
465+
_description = value;
466+
OnPropertyChanged();
467+
}
468+
}
452469

453470
private string _group;
454471

Source/NETworkManager/Views/PingMonitorHostView.xaml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@
370370
</Grid>
371371
<ListBox Grid.Column="0" Grid.Row="2" ItemsSource="{Binding Path=Profiles}"
372372
Visibility="{Binding Path=IsSearching, Converter={StaticResource ResourceKey=BooleanReverseToVisibilityCollapsedConverter}}"
373-
DisplayMemberPath="Name" SelectedItem="{Binding Path=SelectedProfile}"
373+
SelectedItem="{Binding Path=SelectedProfile}"
374374
Style="{StaticResource ResourceKey=ProfileListBox}"
375375
ScrollViewer.CanContentScroll="True"
376376
VirtualizingPanel.IsVirtualizing="True"
@@ -502,8 +502,26 @@
502502
BasedOn="{StaticResource ResourceKey=MahApps.Styles.ListBoxItem}">
503503
<Setter Property="ContextMenu" Value="{StaticResource ResourceKey=ProfileContextMenu}" />
504504
<EventSetter Event="MouseDoubleClick" Handler="ListBoxItem_MouseDoubleClick" />
505+
<Setter Property="VerticalContentAlignment" Value="Stretch"/>
506+
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
505507
</Style>
506508
</ListBox.ItemContainerStyle>
509+
<ListBox.ItemTemplate>
510+
<DataTemplate>
511+
<Grid Background="Transparent">
512+
<Grid.ToolTip>
513+
<ToolTip MinWidth="250">
514+
<StackPanel Margin="10">
515+
<TextBlock Text="{Binding PingMonitor_Host}" Style="{StaticResource DefaultTextBlock}" />
516+
<Separator Background="{DynamicResource MahApps.Brushes.Gray8}" Margin="0,10" />
517+
<TextBlock Text="{Binding Description}" Style="{StaticResource InfoTextBlock}" TextWrapping="Wrap" />
518+
</StackPanel>
519+
</ToolTip>
520+
</Grid.ToolTip>
521+
<TextBlock Text="{Binding Name}" Style="{StaticResource CenterTextBlock}" />
522+
</Grid>
523+
</DataTemplate>
524+
</ListBox.ItemTemplate>
507525
</ListBox>
508526
<mah:ProgressRing Grid.Row="2" Height="50" Width="50" IsActive="{Binding Path=IsSearching}" />
509527
<Grid Grid.Row="2" VerticalAlignment="Center">

Source/NETworkManager/Views/ProfileDialog.xaml

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,6 +1286,8 @@
12861286
<RowDefinition Height="Auto" />
12871287
<RowDefinition Height="10" />
12881288
<RowDefinition Height="Auto" />
1289+
<RowDefinition Height="10" />
1290+
<RowDefinition Height="Auto" />
12891291
</Grid.RowDefinitions>
12901292
<Grid.ColumnDefinitions>
12911293
<ColumnDefinition Width="1*" />
@@ -1296,7 +1298,7 @@
12961298
<TextBlock Grid.Column="0" Grid.Row="0" Text="{x:Static localization:Strings.Name}" />
12971299
<TextBox x:Name="TextBoxName" GotFocus="TextBoxName_OnGotFocus"
12981300
TextChanged="TextBoxName_OnTextChanged" Grid.Column="2" Grid.Row="0"
1299-
mah:TextBoxHelper.Watermark="{x:Static localization:StaticStrings.ExampleRemoteDesktopProfileName}">
1301+
mah:TextBoxHelper.Watermark="{x:Static localization:StaticStrings.ExampleProfileName}">
13001302
<TextBox.Text>
13011303
<Binding Path="Name" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
13021304
<Binding.ValidationRules>
@@ -1364,8 +1366,20 @@
13641366
<Style TargetType="{x:Type ToolTip}" BasedOn="{StaticResource WarnToolTip}" />
13651367
</Rectangle.Resources>
13661368
</Rectangle>
1367-
<TextBlock Grid.Column="0" Grid.Row="4" Text="{x:Static localization:Strings.Group}" />
1368-
<ComboBox x:Name="ComboBoxGroup" Grid.Column="2" Grid.Row="4"
1369+
<TextBlock Grid.Column="0" Grid.Row="4"
1370+
Text="{x:Static Member=localization:Strings.Description}"
1371+
Margin="0,5,0,0"
1372+
VerticalAlignment="Top" />
1373+
<TextBox Grid.Column="2" Grid.Row="4"
1374+
AcceptsReturn="True"
1375+
TextWrapping="Wrap"
1376+
VerticalScrollBarVisibility="Auto"
1377+
VerticalContentAlignment="Top"
1378+
Height="150"
1379+
Text="{Binding Path=Description, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
1380+
mah:TextBoxHelper.Watermark="{x:Static Member=localization:Strings.ExampleDescription}" />
1381+
<TextBlock Grid.Column="0" Grid.Row="6" Text="{x:Static localization:Strings.Group}" />
1382+
<ComboBox x:Name="ComboBoxGroup" Grid.Column="2" Grid.Row="6"
13691383
Style="{StaticResource EditableComboBox}" ItemsSource="{Binding Groups}"
13701384
mah:TextBoxHelper.Watermark="{x:Static localization:StaticStrings.ExampleGroupServers}">
13711385
<ComboBox.Text>
@@ -1377,22 +1391,22 @@
13771391
</Binding>
13781392
</ComboBox.Text>
13791393
</ComboBox>
1380-
<TextBlock Grid.Column="0" Grid.Row="6" Text="{x:Static localization:Strings.Tags}" />
1381-
<TextBox Grid.Column="2" Grid.Row="6"
1382-
Text="{Binding Tags, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
1383-
mah:TextBoxHelper.Watermark="{x:Static localization:StaticStrings.ExampleTags}" />
1394+
<TextBlock Grid.Column="0" Grid.Row="8" Text="{x:Static Member=localization:Strings.Tags}" />
1395+
<TextBox Grid.Column="2" Grid.Row="8"
1396+
Text="{Binding Path=Tags, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
1397+
mah:TextBoxHelper.Watermark="{x:Static Member=localization:StaticStrings.ExampleTags}" />
13841398
<Rectangle Width="24" Height="24" Grid.Column="3" Grid.Row="6"
1385-
ToolTip="{x:Static localization:Strings.HelpMessage_Tags}"
1386-
Style="{StaticResource HelpImageRectangle}" Margin="10,0,0,0">
1399+
ToolTip="{x:Static Member=localization:Strings.HelpMessage_Tags}"
1400+
Style="{StaticResource ResourceKey=HelpImageRectangle}" Margin="10,0,0,0">
13871401
<Rectangle.Resources>
1388-
<Style TargetType="{x:Type ToolTip}" BasedOn="{StaticResource HelpToolTip}" />
1402+
<Style TargetType="{x:Type TypeName=ToolTip}" BasedOn="{StaticResource ResourceKey=HelpToolTip}" />
13891403
</Rectangle.Resources>
13901404
</Rectangle>
13911405
</Grid>
13921406
</StackPanel>
13931407
</ScrollViewer>
13941408
</TabItem>
1395-
<TabItem Header="{x:Static localization:Strings.NetworkInterface}">
1409+
<TabItem Header="{x:Static Member=localization:Strings.NetworkInterface}">
13961410
<ScrollViewer HorizontalScrollBarVisibility="Disabled">
13971411
<StackPanel IsEnabled="{Binding NetworkInterface_Enabled}">
13981412
<RadioButton x:Name="RadioButtonEnableDynamicIPAddress"

Source/NETworkManager/Views/RemoteDesktopConnectDialog.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
Visibility="{Binding ConnectAs, Converter={StaticResource BooleanToVisibilityCollapsedConverter}}"
4444
Margin="0,0,0,10" />
4545
<TextBox x:Name="TextBoxName" Grid.Column="2" Grid.Row="0"
46-
mah:TextBoxHelper.Watermark="{x:Static localization:StaticStrings.ExampleRemoteDesktopProfileName}"
46+
mah:TextBoxHelper.Watermark="{x:Static localization:StaticStrings.ExampleProfileName}"
4747
Visibility="{Binding ConnectAs, Converter={StaticResource BooleanToVisibilityCollapsedConverter}}"
4848
IsEnabled="{Binding ConnectAs, Converter={StaticResource BooleanReverseConverter}}"
4949
Margin="0,0,0,10">

0 commit comments

Comments
 (0)