Skip to content

Commit 7ff9df9

Browse files
committed
[#12] : premier plan ajouté
1 parent 5a221de commit 7ff9df9

File tree

8 files changed

+78
-6
lines changed

8 files changed

+78
-6
lines changed

src/MachineMonitor/App.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
<setting name="Disk" serializeAs="String">
2929
<value>_Total</value>
3030
</setting>
31+
<setting name="Topmost" serializeAs="String">
32+
<value>True</value>
33+
</setting>
3134
</Monbsoft.MachineMonitor.Properties.Settings>
3235
<Monbsoft.MachineMonitor.Settings>
3336
<setting name="Network" serializeAs="String">

src/MachineMonitor/Configuration/ConfigurationStore.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,20 @@ public string Network
3030
}
3131
}
3232

33+
public bool Topmost
34+
{
35+
get
36+
{
37+
return Settings.Default.Topmost;
38+
}
39+
set
40+
{
41+
Settings.Default.Topmost = value;
42+
Save();
43+
}
44+
}
45+
46+
3347
public bool Transparent
3448
{
3549
get

src/MachineMonitor/Messages/UpdatedConfigurationMessage.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ public enum ChangedType
1515
{
1616
Disk = 0,
1717
Network = 1,
18-
Transparent = 2
18+
Transparent = 2,
19+
Topmost = 3
1920
}
2021

2122
public ChangedType Changed { get; set; }

src/MachineMonitor/Properties/Settings.Designer.cs

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

src/MachineMonitor/Properties/Settings.settings

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,8 @@
1111
<Setting Name="Disk" Type="System.String" Scope="User">
1212
<Value Profile="(Default)">_Total</Value>
1313
</Setting>
14+
<Setting Name="Topmost" Type="System.Boolean" Scope="User">
15+
<Value Profile="(Default)">True</Value>
16+
</Setting>
1417
</Settings>
1518
</SettingsFile>

src/MachineMonitor/ViewModels/ConfigurationViewModel.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public class ConfigurationViewModel : ViewModelBase
1616
private string _disk;
1717
private string _network;
1818
private bool _transparent;
19+
private bool _topmost;
1920
#endregion
2021

2122
#region Constructeurs
@@ -88,6 +89,19 @@ public bool Transparent
8889
Transparent_Changed();
8990
}
9091
}
92+
93+
public bool Topmost
94+
{
95+
get
96+
{
97+
return _topmost;
98+
}
99+
set
100+
{
101+
Set(ref _topmost, value);
102+
Topmost_Changed();
103+
}
104+
}
91105
#endregion
92106

93107
#region Méthodes
@@ -111,6 +125,12 @@ private void Transparent_Changed()
111125
_configuration.Transparent = _transparent;
112126
SendMessage(ChangedType.Transparent);
113127
}
128+
129+
private void Topmost_Changed()
130+
{
131+
_configuration.Topmost = _topmost;
132+
SendMessage(ChangedType.Topmost);
133+
}
114134
#endregion
115135
}
116136
}

src/MachineMonitor/ViewModels/MainViewModel.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,11 @@ private void HandleUpdatedConfiguration(UpdatedConfigurationMessage updatedMessa
167167
OnTransparencyChange(_configuration.Transparent);
168168
break;
169169
}
170-
170+
case ChangedType.Topmost:
171+
{
172+
OnTopmostChange();
173+
break;
174+
}
171175
default:
172176
{
173177
break;
@@ -183,13 +187,18 @@ private void OnDiskChange()
183187

184188
private void OnNetworkChange()
185189
{
186-
if(string.IsNullOrEmpty(_configuration.Network))
190+
if (string.IsNullOrEmpty(_configuration.Network))
187191
{
188192
_networkCounter = null;
189193
return;
190194
}
191195
_networkCounter = new PerformanceCounter("Network Interface", "Bytes Received/sec", _configuration.Network);
192196
}
197+
private void OnTopmostChange()
198+
{
199+
_view.Topmost = _configuration.Topmost;
200+
//_view.Activate();
201+
}
193202
private void OnTransparencyChange(bool transparent)
194203
{
195204
if (transparent)

src/MachineMonitor/Views/ConfigurationWindow.xaml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
mc:Ignorable="d"
77
Title="Configuration"
88
Background="{StaticResource SystemControlBackgroundBrush}"
9-
Height="200"
9+
Height="210"
10+
ResizeMode="NoResize"
1011
ShowInTaskbar="False"
1112
Width="400"
1213
WindowStartupLocation="CenterScreen">
@@ -21,7 +22,9 @@
2122
<RowDefinition Height="Auto"/>
2223
<RowDefinition Height="Auto"/>
2324
<RowDefinition Height="Auto"/>
24-
<RowDefinition Height="Auto"/>
25+
<RowDefinition Height="Auto"/>
26+
<RowDefinition Height="Auto"/>
27+
<RowDefinition Height="Auto"/>
2528
<RowDefinition/>
2629
<RowDefinition Height="Auto"/>
2730
</Grid.RowDefinitions>
@@ -49,12 +52,19 @@
4952
<CheckBox Grid.Column="1"
5053
Grid.Row="5"
5154
IsChecked="{Binding Transparent}"/>
55+
<TextBlock Grid.Row="6"
56+
Style="{StaticResource TextBlockStyle}"
57+
Text="Premier plan"/>
58+
<CheckBox Grid.Column="1"
59+
Grid.Row="7"
60+
IsChecked="{Binding Topmost}"/>
61+
<!-- close button -->
5262
<Button x:Name="closeButton"
5363
Click="CloseButton_Click"
5464
Content="Fermer"
5565
HorizontalAlignment="Center"
5666
Grid.ColumnSpan="2"
57-
Grid.Row="7"
67+
Grid.Row="9"
5868
Margin="5"
5969
Padding="5" />
6070
</Grid>

0 commit comments

Comments
 (0)