Skip to content

Commit

Permalink
v1.4 Minor Fixex
Browse files Browse the repository at this point in the history
Some Windows Services were protected and the programme was failing, these have been removed.

Chinese and Ukrainian language added

Note : When you move the mouse cursor over each feature, a bubble message describing that feature will appear.
  • Loading branch information
shadesofdeath committed Aug 27, 2023
1 parent ca65bfb commit cf0887f
Show file tree
Hide file tree
Showing 28 changed files with 2,529 additions and 1,727 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified .vs/ShadesTweaker/v17/.suo
Binary file not shown.
281 changes: 138 additions & 143 deletions ShadesTweaker/MainWindow.xaml

Large diffs are not rendered by default.

160 changes: 102 additions & 58 deletions ShadesTweaker/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,15 @@ namespace ShadesTweaker
{
public partial class MainWindow : UiWindow
{
private const string ConfigFileName = "config.xml";
private string configFilePath;
public MainWindow()
{
InitializeComponent();
configFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ConfigFileName);


LoadLanguagePreference();
Loaded += (sender, args) =>
{
if (IsWindows11OrHigher())
Expand All @@ -33,7 +39,50 @@ public MainWindow()
}
};
}
private void LoadLanguagePreference()
{
if (File.Exists(configFilePath))
{
XDocument doc = XDocument.Load(configFilePath);
XElement languageIndexElement = doc.Element("Config")?.Element("LanguageIndex");
if (int.TryParse(languageIndexElement?.Value, out int languageIndex))
{
comboBoxLanguage.SelectedIndex = languageIndex;
ApplyLanguage(languageIndex);
}
}
}

private void SaveLanguagePreference(int languageIndex)
{
if (!string.IsNullOrEmpty(configFilePath))
{
XDocument doc = new XDocument(new XElement("Config", new XElement("LanguageIndex", languageIndex)));
doc.Save(configFilePath);
}
}


private void ApplyLanguage(int languageIndex)
{
ResourceDictionary resourceDictionary = new ResourceDictionary();

string basePath = AppDomain.CurrentDomain.BaseDirectory;
string[] languageFiles = { "StringResources.en.xaml", "StringResources.tr.xaml", "StringResources.de.xaml", "StringResources.es.xaml", "StringResources.zh-cy.xaml","StringResources.ua.xaml" };

if (languageIndex >= 0 && languageIndex < languageFiles.Length)
{
resourceDictionary.Source = new Uri(Path.Combine(basePath, languageFiles[languageIndex]));
this.Resources.MergedDictionaries.Add(resourceDictionary);
}
}

private void comboBoxLanguage_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
int selectedLanguageIndex = comboBoxLanguage.SelectedIndex;
SaveLanguagePreference(selectedLanguageIndex);
ApplyLanguage(selectedLanguageIndex);
}
private bool IsWindows11OrHigher()
{
// Windows 11 version number: 10.0.22000
Expand Down Expand Up @@ -1063,16 +1112,6 @@ private void xboxGameBar_Unchecked(object sender, RoutedEventArgs e)
RegHelper.SetValue(RegistryHive.LocalMachine, @"SOFTWARE\Policies\Microsoft\Windows\GameDVR", "AllowGameDVR", 1, RegistryValueKind.DWord);
}

// Password Reveal Button
private void passwordReveal_Checked(object sender, RoutedEventArgs e)
{
RegHelper.SetValue(RegistryHive.CurrentUser, @"SOFTWARE\Policies\Microsoft\Windows\CredUI", "DisablePasswordReveal", 1, RegistryValueKind.DWord);
}

private void passwordReveal_Unchecked(object sender, RoutedEventArgs e)
{
RegHelper.SetValue(RegistryHive.CurrentUser, @"SOFTWARE\Policies\Microsoft\Windows\CredUI", "DisablePasswordReveal", 0, RegistryValueKind.DWord);
}

// Location Sensors
private void locationSensors_Checked(object sender, RoutedEventArgs e)
Expand Down Expand Up @@ -1444,7 +1483,6 @@ private void DownloadedMapsManager_Unchecked(object sender, RoutedEventArgs e)
private void FileHistoryService_Checked(object sender, RoutedEventArgs e)
{
RegHelper.SetValue(RegistryHive.LocalMachine, @"SYSTEM\CurrentControlSet\Services\fhsvc", "Start", 4, RegistryValueKind.DWord);

}
private void FileHistoryService_Unchecked(object sender, RoutedEventArgs e)
{
Expand Down Expand Up @@ -1565,12 +1603,46 @@ private void PrintSpoolerService_Unchecked(object sender, RoutedEventArgs e)
// Security Center Service
private void SecurityCenterService_Checked(object sender, RoutedEventArgs e)
{
RegHelper.SetValue(RegistryHive.LocalMachine, @"SYSTEM\CurrentControlSet\Services\wscsvc", "Start", 4, RegistryValueKind.DWord);
try
{
using (RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Services\wscsvc", true))
{
if (key != null)
{
key.SetValue("Start", 4, RegistryValueKind.DWord);
}
else
{
// Anahtar bulunamadı
}
}
}
catch (Exception ex)
{
// Hata işleme
}
}

private void SecurityCenterService_Unchecked(object sender, RoutedEventArgs e)
{
RegHelper.SetValue(RegistryHive.LocalMachine, @"SYSTEM\CurrentControlSet\Services\wscsvc", "Start", 2, RegistryValueKind.DWord);
try
{
using (RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Services\wscsvc", true))
{
if (key != null)
{
key.SetValue("Start", 2, RegistryValueKind.DWord);
}
else
{
// Anahtar bulunamadı
}
}
}
catch (Exception ex)
{
// Hata işleme
}
}

// Windows Error Reporting Service
Expand Down Expand Up @@ -1933,7 +2005,7 @@ await Task.Run(() =>
{
if (!MessageBoxShown)
{
System.Windows.MessageBox.Show("Bazı dosyalar ve klasörler arkaplanda açık uygulamalar tarafından kullanılıyor, bu dosya ve klasörler silinemeyecek!.");
System.Windows.MessageBox.Show("Some files and folders are used in the background by open applications, these files and folders will not be deleted!.");
MessageBoxShown = true; // MessageBox gösterildiğini işaretle
}
}
Expand All @@ -1954,7 +2026,7 @@ private async void AnalyzeButton_Click(object sender, RoutedEventArgs e)
isProcessing = true;
await Task.Delay(3000);

if (LogsCheckbox.IsChecked == true)
if (logsCheckbox.IsChecked == true)
{
string updateLogsPath = @"C:\Windows\Logs\";
if (Directory.Exists(updateLogsPath))
Expand Down Expand Up @@ -1987,7 +2059,7 @@ private async void AnalyzeButton_Click(object sender, RoutedEventArgs e)
}
}

if (WindowsOldCheckbox.IsChecked == true)
if (windowsOldCheckbox.IsChecked == true)
{
string windowsOldPath = @"C:\Windows.old\";
if (Directory.Exists(windowsOldPath))
Expand All @@ -2003,7 +2075,7 @@ private async void AnalyzeButton_Click(object sender, RoutedEventArgs e)
}
}

if (erroreportingCheckbox.IsChecked == true)
if (errorReportingCheckbox.IsChecked == true)
{
string werPath = @"C:\ProgramData\Microsoft\Windows\WER\";
if (Directory.Exists(werPath))
Expand All @@ -2019,7 +2091,7 @@ private async void AnalyzeButton_Click(object sender, RoutedEventArgs e)
}
}

if (programdatacachesCheckbox.IsChecked == true)
if (programDataCachesCheckbox.IsChecked == true)
{
string cachesPath = @"C:\ProgramData\Microsoft\Windows\Caches\";
if (Directory.Exists(cachesPath))
Expand Down Expand Up @@ -2052,7 +2124,7 @@ private async void AnalyzeButton_Click(object sender, RoutedEventArgs e)
}
}

if (recyclebinCheckbox.IsChecked == true)
if (recycleBinCheckbox.IsChecked == true)
{
string cachesPath = @"C:\$Recycle.Bin";
if (Directory.Exists(cachesPath))
Expand All @@ -2068,7 +2140,7 @@ private async void AnalyzeButton_Click(object sender, RoutedEventArgs e)
}
}

if (searchindexCheckbox.IsChecked == true)
if (searchIndexCheckbox.IsChecked == true)
{
string cachesPath = @"C:\ProgramData\Microsoft\Search\Data\";
if (Directory.Exists(cachesPath))
Expand Down Expand Up @@ -2100,7 +2172,7 @@ private async void AnalyzeButton_Click(object sender, RoutedEventArgs e)
}
}

if (fontcacheCheckbox.IsChecked == true)
if (fontCacheCheckbox.IsChecked == true)
{
string cachesPath = @"C:\Windows\ServiceProfiles\LocalService\AppData\Local\FontCache";
if (Directory.Exists(cachesPath))
Expand All @@ -2116,7 +2188,7 @@ private async void AnalyzeButton_Click(object sender, RoutedEventArgs e)
}
}

if (ınstallerCheckbox.IsChecked == true)
if (installerCheckbox.IsChecked == true)
{
string cachesPath = @"C:\Windows\Installer";
if (Directory.Exists(cachesPath))
Expand Down Expand Up @@ -2157,7 +2229,7 @@ private async void CleanButton_Click(object sender, RoutedEventArgs e)

/// CLEAR BAŞLANGICI ///

if (LogsCheckbox.IsChecked == true)
if (logsCheckbox.IsChecked == true)
{
selectedPath[0] = @"C:\Windows\Logs\";
}
Expand All @@ -2168,17 +2240,17 @@ private async void CleanButton_Click(object sender, RoutedEventArgs e)
selectedPath[1] = Path.Combine(@"C:\Users", username, "AppData", "Local", "Temp");
}

if (WindowsOldCheckbox.IsChecked == true)
if (windowsOldCheckbox.IsChecked == true)
{
selectedPath[2] = Path.Combine(@"C:\Windows.old");
}

if (erroreportingCheckbox.IsChecked == true)
if (errorReportingCheckbox.IsChecked == true)
{
selectedPath[3] = Path.Combine(@"C:\ProgramData\Microsoft\Windows\WER");
}

if (programdatacachesCheckbox.IsChecked == true)
if (programDataCachesCheckbox.IsChecked == true)
{
selectedPath[4] = Path.Combine(@"C:\ProgramData\Microsoft\Windows\Caches");
}
Expand All @@ -2189,12 +2261,12 @@ private async void CleanButton_Click(object sender, RoutedEventArgs e)
selectedPath[5] = Path.Combine(@"C:\Users", username, "Downloads");
}

if (recyclebinCheckbox.IsChecked == true)
if (recycleBinCheckbox.IsChecked == true)
{
selectedPath[6] = Path.Combine(@"C:\$Recycle.Bin");
}

if (searchindexCheckbox.IsChecked == true)
if (searchIndexCheckbox.IsChecked == true)
{
selectedPath[7] = Path.Combine(@"C:\ProgramData\Microsoft\Search\Data");
}
Expand All @@ -2204,12 +2276,12 @@ private async void CleanButton_Click(object sender, RoutedEventArgs e)
selectedPath[8] = Path.Combine(@"C:\Windows\Prefetch");
}

if (fontcacheCheckbox.IsChecked == true)
if (fontCacheCheckbox.IsChecked == true)
{
selectedPath[9] = Path.Combine(@"C:\Windows\ServiceProfiles\LocalService\AppData\Local\FontCache");
}

if (ınstallerCheckbox.IsChecked == true)
if (installerCheckbox.IsChecked == true)
{
selectedPath[10] = Path.Combine(@"C:\Windows\Installer");
}
Expand All @@ -2234,33 +2306,5 @@ private void TakeOwnership(string filePath)
}
}

private void comboBoxLanguage_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
ResourceDictionary resourceDictionary = new ResourceDictionary();
string basePath = AppDomain.CurrentDomain.BaseDirectory; // Programın çalıştığı dizin

if (comboBoxLanguage.SelectedIndex == 0)
{
resourceDictionary.Source = new Uri(Path.Combine(basePath, "StringResources.en.xaml"));
}
else if (comboBoxLanguage.SelectedIndex == 1)
{
resourceDictionary.Source = new Uri(Path.Combine(basePath, "StringResources.tr.xaml"));
}
else if (comboBoxLanguage.SelectedIndex == 2)
{
resourceDictionary.Source = new Uri(Path.Combine(basePath, "StringResources.de.xaml"));
}
else if (comboBoxLanguage.SelectedIndex == 3)
{
resourceDictionary.Source = new Uri(Path.Combine(basePath, "StringResources.es.xaml"));
}
this.Resources.MergedDictionaries.Add(resourceDictionary);
}





}
}
3 changes: 3 additions & 0 deletions ShadesTweaker/ShadesTweaker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,8 @@
<LastGenOutput>Resource.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Resource Include="flag.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
Binary file modified ShadesTweaker/bin/Debug/ShadesTweaker.exe
Binary file not shown.
Binary file modified ShadesTweaker/bin/Debug/ShadesTweaker.pdb
Binary file not shown.
Loading

0 comments on commit cf0887f

Please sign in to comment.