Skip to content

Commit 441c698

Browse files
committed
-connection status update & changed placement
1 parent f119cfd commit 441c698

File tree

5 files changed

+36
-31
lines changed

5 files changed

+36
-31
lines changed

.Source/GTweak/Core/ViewModel/PagesViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,15 @@ public InformationSystemVM()
146146
DisplayIpAddress = SystemData.СomputerСonfiguration.СonfigurationData["IpAddress"];
147147
DisplayCountProcess = new SystemData.MonitoringSystem().CountProcess.ToString();
148148

149-
if (Settings.IsHiddenIpAddress & !SystemData.СomputerСonfiguration.IsConnectionLose & !SystemData.СomputerСonfiguration.IsInternetLimited & !SystemData.СomputerСonfiguration.IsConnectionBlock)
149+
if (Settings.IsHiddenIpAddress & SystemData.СomputerСonfiguration.ConnectionStatus == 0)
150150
{
151151
SetBlurValue = 20;
152152
DisplayImageHidden = (DrawingImage)Application.Current.Resources["DI_Show"];
153153
}
154154
else
155155
{
156156
SetBlurValue = 0;
157-
DisplayImageHidden = !SystemData.СomputerСonfiguration.IsConnectionLose & !SystemData.СomputerСonfiguration.IsInternetLimited & !SystemData.СomputerСonfiguration.IsConnectionBlock ? (DrawingImage)Application.Current.Resources["DI_Hide"] : default;
157+
DisplayImageHidden = SystemData.СomputerСonfiguration.ConnectionStatus == 0 ? (DrawingImage)Application.Current.Resources["DI_Hide"] : default;
158158
}
159159
}
160160
}

.Source/GTweak/Utilities/Tweaks/SystemData.cs

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Newtonsoft.Json;
33
using System;
44
using System.Collections.Generic;
5+
using System.Data;
56
using System.Diagnostics;
67
using System.Globalization;
78
using System.IO;
@@ -125,9 +126,15 @@ internal sealed class ClientInternetProtocol
125126
internal sealed class СomputerСonfiguration
126127
{
127128
internal static string WindowsClientVersion { get; set; } = string.Empty;
128-
internal static bool IsConnectionLose { get; private set; } = false;
129-
internal static bool IsConnectionBlock { get; private set; } = false;
130-
internal static bool IsInternetLimited { get; private set; } = false;
129+
130+
/// <summary>
131+
/// No connection problems - [0];
132+
/// Connection lose - [1];
133+
/// Conection block - [2];
134+
/// Connection limited - [3].
135+
/// </summary>
136+
internal static byte ConnectionStatus = 0;
137+
131138

132139
private static string _type = string.Empty;
133140
private static readonly EnumerationOptions optionsObj = new EnumerationOptions { ReturnImmediately = true };
@@ -277,30 +284,33 @@ internal static void GetUserIP()
277284
catch
278285
{
279286
СonfigurationData["IpAddress"] = (string)Application.Current.Resources["limited_systemInformation"];
280-
IsInternetLimited = true;
287+
ConnectionStatus = 3;
281288
}
282289
finally
283290
{
284-
if (IsInternetLimited)
285-
IsInternetLimited = false;
286-
if (IsConnectionBlock)
287-
IsConnectionBlock = false;
291+
switch (ConnectionStatus)
292+
{
293+
case 2:
294+
case 3:
295+
ConnectionStatus = 0;
296+
break;
297+
}
288298

289299
if (IPAddress.TryParse(clientInternetProtocol.Ip, out _) && !string.IsNullOrEmpty(clientInternetProtocol.Ip) && !string.IsNullOrEmpty(clientInternetProtocol.Country))
290300
{
291-
IsConnectionLose = false;
301+
ConnectionStatus = 0;
292302
СonfigurationData["IpAddress"] = clientInternetProtocol.Ip + " (" + clientInternetProtocol.Country + ")";
293303
}
294304
else
295305
{
296-
IsConnectionBlock = true;
306+
ConnectionStatus = 2;
297307
СonfigurationData["IpAddress"] = (string)Application.Current.Resources["connection_block_systemInformation"];
298308
}
299309
}
300310
}
301311
else
302312
{
303-
IsConnectionLose = true;
313+
ConnectionStatus = 1;
304314
СonfigurationData["IpAddress"] = (string)Application.Current.Resources["connection_lose_systemInformation"];
305315
}
306316
});

.Source/GTweak/View/InformationSystemView.xaml.cs

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,19 @@ public InformationSystemView()
2727

2828
App.LanguageChanged += delegate
2929
{
30-
if (!SystemData.СomputerСonfiguration.IsConnectionLose)
30+
switch (SystemData.СomputerСonfiguration.ConnectionStatus)
3131
{
32-
if (SystemData.СomputerСonfiguration.IsInternetLimited)
33-
{
34-
SystemData.СomputerСonfiguration.СonfigurationData["IpAddress"] = (string)FindResource("limited_systemInformation");
35-
DataContext = new InformationSystemVM();
36-
}
37-
else if (SystemData.СomputerСonfiguration.IsConnectionBlock)
38-
{
32+
case 1:
33+
SystemData.СomputerСonfiguration.СonfigurationData["IpAddress"] = (string)FindResource("connection_lose_systemInformation");
34+
break;
35+
case 2:
3936
SystemData.СomputerСonfiguration.СonfigurationData["IpAddress"] = (string)FindResource("connection_block_systemInformation");
40-
DataContext = new InformationSystemVM();
41-
}
42-
}
43-
else
44-
{
45-
SystemData.СomputerСonfiguration.СonfigurationData["IpAddress"] = (string)FindResource("connection_lose_systemInformation");
46-
DataContext = new InformationSystemVM();
37+
break;
38+
case 3:
39+
SystemData.СomputerСonfiguration.СonfigurationData["IpAddress"] = (string)FindResource("limited_systemInformation");
40+
break;
4741
}
42+
DataContext = new InformationSystemVM();
4843
};
4944

5045
timer = new DispatcherTimer(new TimeSpan(0, 0, 1), DispatcherPriority.Normal, delegate

.Source/GTweak/Windows/MainWindow.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,10 @@
192192

193193
<uс:ToggleButton x:Name="BtnNotification" DynamicText="{DynamicResource btgl_notifications_main}" VerticalAlignment="Top" Height="25" Margin="40,20,0,0" ChangedState="BtnNotification_ChangedState"/>
194194

195-
<uс:ToggleButton x:Name="BtnTopMost" VerticalAlignment="Top" Height="25" DynamicText="{DynamicResource btgl_toast_main}" Margin="40,15,0,0" ChangedState="BtnTopMost_ChangedState"/>
196-
197195
<uс:ToggleButton x:Name="BtnUpdate" DynamicText="{DynamicResource btgl_update_main}" VerticalAlignment="Top" Height="25" Margin="40,15,0,0" ChangedState="BtnUpdate_ChangedState"/>
198196

197+
<uс:ToggleButton x:Name="BtnTopMost" VerticalAlignment="Top" Height="25" DynamicText="{DynamicResource btgl_toast_main}" Margin="40,15,0,0" ChangedState="BtnTopMost_ChangedState"/>
198+
199199
<StackPanel Orientation="Horizontal" Height="45" VerticalAlignment="Top" Margin="40,10,0,0">
200200
<TextBlock Style="{StaticResource Text_In}" Foreground="{StaticResource Color_Highlighted}" Margin="0,4,0,0" Text="{DynamicResource slider_volume_main}"/>
201201
<ToggleButton x:Name="BtnSoundNtn" Width="20" Height="20" Margin="10,1,0,0" Style="{StaticResource ToggleSound}" PreviewMouseDown="BtnSoundNtn_PreviewMouseDown"/>

.Source/GTweak/Windows/MainWindow.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ public MainWindow()
2020
InitializeComponent();
2121

2222
BtnNotification.StateNA = Settings.IsViewNotification;
23-
BtnTopMost.StateNA = Topmost = Settings.IsTopMost;
2423
BtnUpdate.StateNA = Settings.IsСheckingUpdate;
24+
BtnTopMost.StateNA = Topmost = Settings.IsTopMost;
2525
BtnSoundNtn.IsChecked = Settings.IsSoundNotification;
2626
SliderVolume.Value = Settings.VolumeNotification;
2727
LanguageSelectionMenu.SelectedIndex = Settings.Language == "en" ? 0 : 1;

0 commit comments

Comments
 (0)