Skip to content

Commit

Permalink
-connection status update & changed placement
Browse files Browse the repository at this point in the history
  • Loading branch information
Greedeks committed Nov 14, 2024
1 parent f119cfd commit 441c698
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 31 deletions.
4 changes: 2 additions & 2 deletions .Source/GTweak/Core/ViewModel/PagesViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,15 @@ public InformationSystemVM()
DisplayIpAddress = SystemData.СomputerСonfiguration.СonfigurationData["IpAddress"];
DisplayCountProcess = new SystemData.MonitoringSystem().CountProcess.ToString();

if (Settings.IsHiddenIpAddress & !SystemData.СomputerСonfiguration.IsConnectionLose & !SystemData.СomputerСonfiguration.IsInternetLimited & !SystemData.СomputerСonfiguration.IsConnectionBlock)
if (Settings.IsHiddenIpAddress & SystemData.СomputerСonfiguration.ConnectionStatus == 0)
{
SetBlurValue = 20;
DisplayImageHidden = (DrawingImage)Application.Current.Resources["DI_Show"];
}
else
{
SetBlurValue = 0;
DisplayImageHidden = !SystemData.СomputerСonfiguration.IsConnectionLose & !SystemData.СomputerСonfiguration.IsInternetLimited & !SystemData.СomputerСonfiguration.IsConnectionBlock ? (DrawingImage)Application.Current.Resources["DI_Hide"] : default;
DisplayImageHidden = SystemData.СomputerСonfiguration.ConnectionStatus == 0 ? (DrawingImage)Application.Current.Resources["DI_Hide"] : default;
}
}
}
Expand Down
32 changes: 21 additions & 11 deletions .Source/GTweak/Utilities/Tweaks/SystemData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Globalization;
using System.IO;
Expand Down Expand Up @@ -125,9 +126,15 @@ internal sealed class ClientInternetProtocol
internal sealed class СomputerСonfiguration
{
internal static string WindowsClientVersion { get; set; } = string.Empty;
internal static bool IsConnectionLose { get; private set; } = false;
internal static bool IsConnectionBlock { get; private set; } = false;
internal static bool IsInternetLimited { get; private set; } = false;

/// <summary>
/// No connection problems - [0];
/// Connection lose - [1];
/// Conection block - [2];
/// Connection limited - [3].
/// </summary>
internal static byte ConnectionStatus = 0;


private static string _type = string.Empty;
private static readonly EnumerationOptions optionsObj = new EnumerationOptions { ReturnImmediately = true };
Expand Down Expand Up @@ -277,30 +284,33 @@ internal static void GetUserIP()
catch
{
СonfigurationData["IpAddress"] = (string)Application.Current.Resources["limited_systemInformation"];
IsInternetLimited = true;
ConnectionStatus = 3;
}
finally
{
if (IsInternetLimited)
IsInternetLimited = false;
if (IsConnectionBlock)
IsConnectionBlock = false;
switch (ConnectionStatus)
{
case 2:
case 3:
ConnectionStatus = 0;
break;
}

if (IPAddress.TryParse(clientInternetProtocol.Ip, out _) && !string.IsNullOrEmpty(clientInternetProtocol.Ip) && !string.IsNullOrEmpty(clientInternetProtocol.Country))
{
IsConnectionLose = false;
ConnectionStatus = 0;
СonfigurationData["IpAddress"] = clientInternetProtocol.Ip + " (" + clientInternetProtocol.Country + ")";
}
else
{
IsConnectionBlock = true;
ConnectionStatus = 2;
СonfigurationData["IpAddress"] = (string)Application.Current.Resources["connection_block_systemInformation"];
}
}
}
else
{
IsConnectionLose = true;
ConnectionStatus = 1;
СonfigurationData["IpAddress"] = (string)Application.Current.Resources["connection_lose_systemInformation"];
}
});
Expand Down
25 changes: 10 additions & 15 deletions .Source/GTweak/View/InformationSystemView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,19 @@ public InformationSystemView()

App.LanguageChanged += delegate
{
if (!SystemData.СomputerСonfiguration.IsConnectionLose)
switch (SystemData.СomputerСonfiguration.ConnectionStatus)
{
if (SystemData.СomputerСonfiguration.IsInternetLimited)
{
SystemData.СomputerСonfiguration.СonfigurationData["IpAddress"] = (string)FindResource("limited_systemInformation");
DataContext = new InformationSystemVM();
}
else if (SystemData.СomputerСonfiguration.IsConnectionBlock)
{
case 1:
SystemData.СomputerСonfiguration.СonfigurationData["IpAddress"] = (string)FindResource("connection_lose_systemInformation");
break;
case 2:
SystemData.СomputerСonfiguration.СonfigurationData["IpAddress"] = (string)FindResource("connection_block_systemInformation");
DataContext = new InformationSystemVM();
}
}
else
{
SystemData.СomputerСonfiguration.СonfigurationData["IpAddress"] = (string)FindResource("connection_lose_systemInformation");
DataContext = new InformationSystemVM();
break;
case 3:
SystemData.СomputerСonfiguration.СonfigurationData["IpAddress"] = (string)FindResource("limited_systemInformation");
break;
}
DataContext = new InformationSystemVM();
};

timer = new DispatcherTimer(new TimeSpan(0, 0, 1), DispatcherPriority.Normal, delegate
Expand Down
4 changes: 2 additions & 2 deletions .Source/GTweak/Windows/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,10 @@

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

<uс:ToggleButton x:Name="BtnTopMost" VerticalAlignment="Top" Height="25" DynamicText="{DynamicResource btgl_toast_main}" Margin="40,15,0,0" ChangedState="BtnTopMost_ChangedState"/>

<uс:ToggleButton x:Name="BtnUpdate" DynamicText="{DynamicResource btgl_update_main}" VerticalAlignment="Top" Height="25" Margin="40,15,0,0" ChangedState="BtnUpdate_ChangedState"/>

<uс:ToggleButton x:Name="BtnTopMost" VerticalAlignment="Top" Height="25" DynamicText="{DynamicResource btgl_toast_main}" Margin="40,15,0,0" ChangedState="BtnTopMost_ChangedState"/>

<StackPanel Orientation="Horizontal" Height="45" VerticalAlignment="Top" Margin="40,10,0,0">
<TextBlock Style="{StaticResource Text_In}" Foreground="{StaticResource Color_Highlighted}" Margin="0,4,0,0" Text="{DynamicResource slider_volume_main}"/>
<ToggleButton x:Name="BtnSoundNtn" Width="20" Height="20" Margin="10,1,0,0" Style="{StaticResource ToggleSound}" PreviewMouseDown="BtnSoundNtn_PreviewMouseDown"/>
Expand Down
2 changes: 1 addition & 1 deletion .Source/GTweak/Windows/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public MainWindow()
InitializeComponent();

BtnNotification.StateNA = Settings.IsViewNotification;
BtnTopMost.StateNA = Topmost = Settings.IsTopMost;
BtnUpdate.StateNA = Settings.IsСheckingUpdate;
BtnTopMost.StateNA = Topmost = Settings.IsTopMost;
BtnSoundNtn.IsChecked = Settings.IsSoundNotification;
SliderVolume.Value = Settings.VolumeNotification;
LanguageSelectionMenu.SelectedIndex = Settings.Language == "en" ? 0 : 1;
Expand Down

0 comments on commit 441c698

Please sign in to comment.