Skip to content

Portable Tool for an Ideal Windows Setup

-datacontext for interface page (small changes) -refactoring (recording of applied tweaks)

Greedeks87be70e76122
diff --git a/.Source/GTweak/Core/Model/MainModel.cs b/.Source/GTweak/Core/Model/MainModel.cs
index ae162530..c77c884c 100644
--- a/.Source/GTweak/Core/Model/MainModel.cs
+++ b/.Source/GTweak/Core/Model/MainModel.cs
@@ -4,6 +4,12 @@ namespace GTweak.Core.Model
{
internal sealed class MainModel
{
+ internal sealed class InterfaceModel
+ {
+ internal bool BlockForWin10 { get; set; } = true;
+ internal bool BlockWithoutLicense { get; set; } = true;
+ }
+
internal sealed class InformationSystemModel
{
internal string WindowsName { get; set; }
diff --git a/.Source/GTweak/Core/ViewModel/PagesViewModel.cs b/.Source/GTweak/Core/ViewModel/PagesViewModel.cs
index 31b7fae7..316fd09a 100644
--- a/.Source/GTweak/Core/ViewModel/PagesViewModel.cs
+++ b/.Source/GTweak/Core/ViewModel/PagesViewModel.cs
@@ -1,11 +1,42 @@
using GTweak.Utilities;
using GTweak.Core.Model;
using System.Windows;
+using GTweak.Utilities.Tweaks;
namespace GTweak.Core.ViewModel
{
internal class ConfidentialityVM : ViewModelBase { }
- internal class InterfaceVM : ViewModelBase { }
+ internal class InterfaceVM : ViewModelBase
+ {
+ private readonly MainModel.InterfaceModel _model;
+ public bool SetBlockForWin10
+ {
+ get => _model.BlockForWin10;
+ set { _model.BlockForWin10 = value; OnPropertyChanged(); }
+ }
+
+ public bool SetBlockWithoutLicense
+ {
+ get => _model.BlockWithoutLicense;
+ set { _model.BlockWithoutLicense = value; OnPropertyChanged(); }
+ }
+
+ public InterfaceVM()
+ {
+ _model = new MainModel.InterfaceModel();
+
+ SetBlockForWin10 = SystemData.СomputerСonfiguration.clientWinVersion.Contains("11");
+
+ SetBlockWithoutLicense = WindowsLicense.statusLicense == 1;
+
+ if (WindowsLicense.statusLicense != 1)
+ {
+ App.ViewLang();
+ new ViewNotification().Show("", (string)Application.Current.Resources["title1_notification"], (string)Application.Current.Resources["viewlicense_notification"]);
+ }
+ }
+ }
+
internal class ApplicationsVM : ViewModelBase { }
internal class ServicesVM : ViewModelBase { }
internal class SystemVM : ViewModelBase { }
diff --git a/.Source/GTweak/Utilities/Tweaks/ConfidentialityTweaks.cs b/.Source/GTweak/Utilities/Tweaks/ConfidentialityTweaks.cs
index 5567afc6..b34b81d4 100644
--- a/.Source/GTweak/Utilities/Tweaks/ConfidentialityTweaks.cs
+++ b/.Source/GTweak/Utilities/Tweaks/ConfidentialityTweaks.cs
@@ -255,6 +255,9 @@ namespace GTweak.Utilities.Tweaks
internal static void UseСonfidentiality(string tweak, bool isChoose)
{
+ СonfigSettings.configConfidentiality.Remove(tweak);
+ СonfigSettings.configConfidentiality.Add(tweak, Convert.ToString(isChoose));
+
switch (tweak)
{
case "TglButton1":
diff --git a/.Source/GTweak/Utilities/Tweaks/InterfaceTweaks.cs b/.Source/GTweak/Utilities/Tweaks/InterfaceTweaks.cs
index 9aea04b5..afa9ccfc 100644
--- a/.Source/GTweak/Utilities/Tweaks/InterfaceTweaks.cs
+++ b/.Source/GTweak/Utilities/Tweaks/InterfaceTweaks.cs
@@ -342,6 +342,9 @@ namespace GTweak.Utilities.Tweaks
internal static void UseInterface(string tweak, bool isChoose)
{
+ СonfigSettings.configInterface.Remove(tweak);
+ СonfigSettings.configInterface.Add(tweak, Convert.ToString(isChoose));
+
switch (tweak)
{
case "TglButton1":
diff --git a/.Source/GTweak/Utilities/Tweaks/ServicesTweaks.cs b/.Source/GTweak/Utilities/Tweaks/ServicesTweaks.cs
index 0431fc74..83da4055 100644
--- a/.Source/GTweak/Utilities/Tweaks/ServicesTweaks.cs
+++ b/.Source/GTweak/Utilities/Tweaks/ServicesTweaks.cs
@@ -364,6 +364,9 @@ namespace GTweak.Utilities.Tweaks
internal static void UseServices(string tweak, bool isChoose)
{
+ СonfigSettings.configServices.Remove(tweak);
+ СonfigSettings.configServices.Add(tweak, Convert.ToString(isChoose));
+
switch (tweak)
{
case "TglButton1":
diff --git a/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs b/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs
index 82a09749..f1ccbeff 100644
--- a/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs
+++ b/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs
@@ -320,6 +320,9 @@ namespace GTweak.Utilities.Tweaks
private static extern bool SystemParametersInfo(uint _uiAction, uint _uiParam, uint _pvParam, uint _fWinIni);
internal static void UseSystemSliders(string tweak, uint value)
{
+ СonfigSettings.configSystem.Remove(tweak);
+ СonfigSettings.configSystem.Add(tweak, Convert.ToString(value));
+
switch (tweak)
{
case "Slider1":
@@ -342,6 +345,9 @@ namespace GTweak.Utilities.Tweaks
private static extern bool SystemParametersInfo(uint _uiAction, uint _uiParam, uint[] _pvParam, uint _fWinIni);
internal static void UseSystem(string tweak, bool isChoose)
{
+ СonfigSettings.configSystem.Remove(tweak);
+ СonfigSettings.configSystem.Add(tweak, Convert.ToString(isChoose));
+
switch (tweak)
{
case "TglButton1":
diff --git a/.Source/GTweak/View/ConfidentialityView.xaml.cs b/.Source/GTweak/View/ConfidentialityView.xaml.cs
index 7a4893db..67402b55 100644
--- a/.Source/GTweak/View/ConfidentialityView.xaml.cs
+++ b/.Source/GTweak/View/ConfidentialityView.xaml.cs
@@ -41,9 +41,8 @@ namespace GTweak.View
{
ToggleButton toggleButton = (ToggleButton)sender;
Parallel.Invoke(() => ConfidentialityTweaks.UseСonfidentiality(toggleButton.Name, toggleButton.State));
- СonfigSettings.configConfidentiality.Remove(toggleButton.Name);
- СonfigSettings.configConfidentiality.Add(toggleButton.Name, Convert.ToString(toggleButton.State));
+ await Task.Delay(200);
switch (toggleButton.Name)
{
case "TglButton8":
@@ -51,6 +50,7 @@ namespace GTweak.View
new ViewNotification().Show("restart");
break;
}
+
await Task.Delay(350);
Parallel.Invoke(() => new ConfidentialityTweaks().ViewСonfidentiality(this));
}
diff --git a/.Source/GTweak/View/InterfaceView.xaml b/.Source/GTweak/View/InterfaceView.xaml
index 391b304a..a57e8b79 100644
--- a/.Source/GTweak/View/InterfaceView.xaml
+++ b/.Source/GTweak/View/InterfaceView.xaml
@@ -6,8 +6,13 @@
xmlns:local="clr-namespace:GTweak.View"
xmlns:uc="clr-namespace:GTweak.Assets.UserControl"
mc:Ignorable="d"
+ xmlns:vm="clr-namespace:GTweak.Core.ViewModel"
d:DesignHeight="550" d:DesignWidth="1100"
Style="{StaticResource LaunchPage}" Loaded="Page_Loaded" KeyDown="Page_KeyDown">
+ <UserControl.DataContext>
+ <vm:InterfaceVM />
+ </UserControl.DataContext>
+
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="139*"/>
@@ -29,9 +34,9 @@
<uc:ToggleButton x:Name="TglButton3" Height="25" Width="Auto" Margin="20,20,0,0" DynamicText="{DynamicResource tgl3_interface}" MouseEnter="Tweak_MouseEnter" MouseLeave="Tweak_MouseLeave" ChangedState="TglButton_ChangedState"/>
<uc:ToggleButton x:Name="TglButton4" Height="25" Width="Auto" Margin="20,20,0,0" DynamicText="{DynamicResource tgl4_interface}" MouseEnter="Tweak_MouseEnter" MouseLeave="Tweak_MouseLeave" ChangedState="TglButton_ChangedState"/>
<uc:ToggleButton x:Name="TglButton5" Height="25" Width="Auto" Margin="20,20,0,0" DynamicText="{DynamicResource tgl5_interface}" MouseEnter="Tweak_MouseEnter" MouseLeave="Tweak_MouseLeave" ChangedState="TglButton_ChangedState"/>
- <uc:ToggleButton x:Name="TglButton6" Height="25" Width="Auto" Margin="20,20,0,0" DynamicText="{DynamicResource tgl6_interface}" MouseEnter="Tweak_MouseEnter" MouseLeave="Tweak_MouseLeave" ChangedState="TglButton_ChangedState"/>
- <uc:ToggleButton x:Name="TglButton7" Height="25" Width="Auto" Margin="20,20,0,0" DynamicText="{DynamicResource tgl7_interface}" MouseEnter="Tweak_MouseEnter" MouseLeave="Tweak_MouseLeave" ChangedState="TglButton_ChangedState"/>
- <uc:ToggleButton x:Name="TglButton8" Height="25" Width="Auto" Margin="20,20,0,0" DynamicText="{DynamicResource tgl8_interface}" MouseEnter="Tweak_MouseEnter" MouseLeave="Tweak_MouseLeave" ChangedState="TglButton_ChangedState"/>
+ <uc:ToggleButton x:Name="TglButton6" Height="25" Width="Auto" Margin="20,20,0,0" DynamicText="{DynamicResource tgl6_interface}" IsEnabled="{Binding SetBlockWithoutLicense}" MouseEnter="Tweak_MouseEnter" MouseLeave="Tweak_MouseLeave" ChangedState="TglButton_ChangedState"/>
+ <uc:ToggleButton x:Name="TglButton7" Height="25" Width="Auto" Margin="20,20,0,0" DynamicText="{DynamicResource tgl7_interface}" IsEnabled="{Binding SetBlockWithoutLicense}" MouseEnter="Tweak_MouseEnter" MouseLeave="Tweak_MouseLeave" ChangedState="TglButton_ChangedState"/>
+ <uc:ToggleButton x:Name="TglButton8" Height="25" Width="Auto" Margin="20,20,0,0" DynamicText="{DynamicResource tgl8_interface}" IsEnabled="{Binding SetBlockWithoutLicense}" MouseEnter="Tweak_MouseEnter" MouseLeave="Tweak_MouseLeave" ChangedState="TglButton_ChangedState"/>
<uc:ToggleButton x:Name="TglButton9" Height="25" Width="Auto" Margin="20,20,0,0" DynamicText="{DynamicResource tgl9_interface}" MouseEnter="Tweak_MouseEnter" MouseLeave="Tweak_MouseLeave" ChangedState="TglButton_ChangedState"/>
<uc:ToggleButton x:Name="TglButton10" Height="25" Width="Auto" Margin="20,20,0,0" DynamicText="{DynamicResource tgl10_interface}" MouseEnter="Tweak_MouseEnter" MouseLeave="Tweak_MouseLeave" ChangedState="TglButton_ChangedState"/>
<uc:ToggleButton x:Name="TglButton11" Height="25" Width="Auto" Margin="20,20,0,0" DynamicText="{DynamicResource tgl11_interface}" MouseEnter="Tweak_MouseEnter" MouseLeave="Tweak_MouseLeave" ChangedState="TglButton_ChangedState"/>
@@ -45,11 +50,11 @@
<Grid Grid.Column="1">
<StackPanel Orientation="Vertical" VerticalAlignment="Top" Width="Auto" Height="Auto">
- <uc:ToggleButton x:Name="TglButton15" Height="25" Width="Auto" Margin="20,15,0,0" DynamicText="{DynamicResource tgl15_interface}" MouseEnter="Tweak_MouseEnter" MouseLeave="Tweak_MouseLeave" ChangedState="TglButton_ChangedState"/>
- <uc:ToggleButton x:Name="TglButton16" Height="25" Width="Auto" Margin="20,20,0,0" DynamicText="{DynamicResource tgl16_interface}" MouseEnter="Tweak_MouseEnter" MouseLeave="Tweak_MouseLeave" ChangedState="TglButton_ChangedState"/>
- <uc:ToggleButton x:Name="TglButton17" Height="25" Width="Auto" Margin="20,20,0,0" DynamicText="{DynamicResource tgl17_interface}" MouseEnter="Tweak_MouseEnter" MouseLeave="Tweak_MouseLeave" ChangedState="TglButton_ChangedState"/>
- <uc:ToggleButton x:Name="TglButton18" Height="25" Width="Auto" Margin="20,20,0,0" DynamicText="{DynamicResource tgl18_interface}" MouseEnter="Tweak_MouseEnter" MouseLeave="Tweak_MouseLeave" ChangedState="TglButton_ChangedState"/>
- <uc:ToggleButton x:Name="TglButton19" Height="25" Width="Auto" Margin="20,20,0,0" DynamicText="{DynamicResource tgl19_interface}" MouseEnter="Tweak_MouseEnter" MouseLeave="Tweak_MouseLeave" ChangedState="TglButton_ChangedState"/>
+ <uc:ToggleButton x:Name="TglButton15" Height="25" Width="Auto" Margin="20,15,0,0" DynamicText="{DynamicResource tgl15_interface}" IsEnabled="{Binding SetBlockForWin10}" MouseEnter="Tweak_MouseEnter" MouseLeave="Tweak_MouseLeave" ChangedState="TglButton_ChangedState"/>
+ <uc:ToggleButton x:Name="TglButton16" Height="25" Width="Auto" Margin="20,20,0,0" DynamicText="{DynamicResource tgl16_interface}" IsEnabled="{Binding SetBlockForWin10}" MouseEnter="Tweak_MouseEnter" MouseLeave="Tweak_MouseLeave" ChangedState="TglButton_ChangedState"/>
+ <uc:ToggleButton x:Name="TglButton17" Height="25" Width="Auto" Margin="20,20,0,0" DynamicText="{DynamicResource tgl17_interface}" IsEnabled="{Binding SetBlockForWin10}" MouseEnter="Tweak_MouseEnter" MouseLeave="Tweak_MouseLeave" ChangedState="TglButton_ChangedState"/>
+ <uc:ToggleButton x:Name="TglButton18" Height="25" Width="Auto" Margin="20,20,0,0" DynamicText="{DynamicResource tgl18_interface}" IsEnabled="{Binding SetBlockForWin10}" MouseEnter="Tweak_MouseEnter" MouseLeave="Tweak_MouseLeave" ChangedState="TglButton_ChangedState"/>
+ <uc:ToggleButton x:Name="TglButton19" Height="25" Width="Auto" Margin="20,20,0,0" DynamicText="{DynamicResource tgl19_interface}" IsEnabled="{Binding SetBlockForWin10}" MouseEnter="Tweak_MouseEnter" MouseLeave="Tweak_MouseLeave" ChangedState="TglButton_ChangedState"/>
<uc:ToggleButton x:Name="TglButton20" Height="25" Width="Auto" Margin="20,20,0,0" DynamicText="{DynamicResource tgl20_interface}" MouseEnter="Tweak_MouseEnter" MouseLeave="Tweak_MouseLeave" ChangedState="TglButton_ChangedState"/>
<uc:ToggleButton x:Name="TglButton21" Height="25" Width="Auto" Margin="20,20,0,0" DynamicText="{DynamicResource tgl21_interface}" MouseEnter="Tweak_MouseEnter" MouseLeave="Tweak_MouseLeave" ChangedState="TglButton_ChangedState"/>
<uc:ToggleButton x:Name="TglButton22" Height="25" Width="Auto" Margin="20,20,0,0" DynamicText="{DynamicResource tgl22_interface}" MouseEnter="Tweak_MouseEnter" MouseLeave="Tweak_MouseLeave" ChangedState="TglButton_ChangedState"/>
diff --git a/.Source/GTweak/View/InterfaceView.xaml.cs b/.Source/GTweak/View/InterfaceView.xaml.cs
index 2db3cc50..d174d2ce 100644
--- a/.Source/GTweak/View/InterfaceView.xaml.cs
+++ b/.Source/GTweak/View/InterfaceView.xaml.cs
@@ -21,15 +21,15 @@ namespace GTweak.View
if (!SystemData.СomputerСonfiguration.clientWinVersion.Contains("11"))
{
- TglButton15.IsEnabled = false; TglButton16.IsEnabled = false;
- TglButton17.IsEnabled = false; TglButton18.IsEnabled = false; TglButton19.IsEnabled = false;
+ TglButton15.IsEnabled = TglButton16.IsEnabled = TglButton17.IsEnabled =
+ TglButton18.IsEnabled = TglButton19.IsEnabled = false;
}
if (WindowsLicense.statusLicense != 1)
{
new ViewNotification().Show("", (string)FindResource("title1_notification"), (string)FindResource("viewlicense_notification"));
- TglButton3.IsEnabled = false; TglButton4.IsEnabled = false; TglButton5.IsEnabled = false;
- TglButton6.IsEnabled = false; TglButton7.IsEnabled = false; TglButton8.IsEnabled = false;
+ TglButton3.IsEnabled = TglButton4.IsEnabled = TglButton5.IsEnabled =
+ TglButton6.IsEnabled = TglButton7.IsEnabled = TglButton8.IsEnabled = false;
}
}
@@ -71,9 +71,8 @@ namespace GTweak.View
{
ToggleButton toggleButton = (ToggleButton)sender;
Parallel.Invoke(() => InterfaceTweaks.UseInterface(toggleButton.Name, toggleButton.State));
- СonfigSettings.configInterface.Remove(toggleButton.Name);
- СonfigSettings.configInterface.Add(toggleButton.Name, Convert.ToString(toggleButton.State));
+ await Task.Delay(200);
switch (toggleButton.Name)
{
case "TglButton1":
diff --git a/.Source/GTweak/View/ServicesView.xaml.cs b/.Source/GTweak/View/ServicesView.xaml.cs
index 270c7cf7..e1ec5723 100644
--- a/.Source/GTweak/View/ServicesView.xaml.cs
+++ b/.Source/GTweak/View/ServicesView.xaml.cs
@@ -40,10 +40,10 @@ namespace GTweak.View
{
ToggleButton toggleButton = (ToggleButton)sender;
Parallel.Invoke(() => ServicesTweaks.UseServices(toggleButton.Name, toggleButton.State));
- СonfigSettings.configServices.Remove(toggleButton.Name);
- СonfigSettings.configServices.Add(toggleButton.Name, Convert.ToString(toggleButton.State));
- await Task.Delay(100);
+
+ await Task.Delay(200);
new ViewNotification().Show("restart");
+
await Task.Delay(350);
Parallel.Invoke(() => new ServicesTweaks().ViewServices(this));
}
diff --git a/.Source/GTweak/View/SystemView.xaml.cs b/.Source/GTweak/View/SystemView.xaml.cs
index fe02edcc..988192dc 100644
--- a/.Source/GTweak/View/SystemView.xaml.cs
+++ b/.Source/GTweak/View/SystemView.xaml.cs
@@ -53,8 +53,6 @@ namespace GTweak.View
{
Slider slider = (Slider)sender;
SystemTweaks.UseSystemSliders(slider.Name, (uint)slider.Value);
- СonfigSettings.configSystem.Remove(slider.Name);
- СonfigSettings.configSystem.Add(slider.Name, Convert.ToString((uint)slider.Value));
}
private async void TglButton_ChangedState(object sender, EventArgs e)
@@ -63,9 +61,8 @@ namespace GTweak.View
if (toggleButton.Name != "TglButton8")
{
Parallel.Invoke(() => SystemTweaks.UseSystem(toggleButton.Name, toggleButton.State));
- СonfigSettings.configSystem.Remove(toggleButton.Name);
- СonfigSettings.configSystem.Add(toggleButton.Name, Convert.ToString(toggleButton.State));
+ await Task.Delay(200);
switch (toggleButton.Name)
{
case "TglButton7":
@@ -82,6 +79,7 @@ namespace GTweak.View
new ViewNotification().Show("logout");
break;
}
+
await Task.Delay(350);
Parallel.Invoke(() => new SystemTweaks().ViewSystem(this));
}