Skip to content

Commit

Permalink
Merge branch 'testing'
Browse files Browse the repository at this point in the history
  • Loading branch information
rayenghanmi committed Jan 12, 2024
2 parents 3fa9b88 + 37e2ebe commit 7fc4797
Show file tree
Hide file tree
Showing 25 changed files with 979 additions and 730 deletions.
13 changes: 4 additions & 9 deletions App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static T GetService<T>()
public App()
{
InitializeComponent();

LogHelper.Log("___________ New Session ___________");
Host = Microsoft.Extensions.Hosting.Host.
CreateDefaultBuilder().
UseContentRoot(AppContext.BaseDirectory).
Expand Down Expand Up @@ -102,23 +102,17 @@ public App()

App.GetService<IAppNotificationService>().Initialize();

UnhandledException += App_UnhandledException;
}

private void App_UnhandledException(object sender, Microsoft.UI.Xaml.UnhandledExceptionEventArgs e)
{
// TODO: Log and handle exceptions as appropriate.
// https://docs.microsoft.com/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.application.unhandledexception.
}

protected async override void OnLaunched(LaunchActivatedEventArgs args)
{
base.OnLaunched(args);

bool showWelcomeNotification = ShouldShowWelcomeNotification();
var showWelcomeNotification = ShouldShowWelcomeNotification();

if (showWelcomeNotification)
{
await LogHelper.Log("Showing Welcome Notification");
App.GetService<IAppNotificationService>().Show(string.Format("WelcomeNotification".GetLocalized(), AppContext.BaseDirectory));

// Set the flag to indicate that the welcome notification has been shown
Expand All @@ -143,6 +137,7 @@ private bool ShouldShowWelcomeNotification()
private void SetWelcomeNotificationShown()
{
// Set the flag to true to indicate that the welcome notification has been shown
LogHelper.Log("Setting WelcomeNotificationShown");
ApplicationData.Current.LocalSettings.Values["WelcomeNotificationShown"] = true;
}
}
36 changes: 32 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,36 @@
# CHANGELOG.md

All notable changes to this project will be documented in this file.
All notable changes to this branch will be documented in this file.

## 0.6
## 0.7.1 - Released

### Added

- Version number is now displayed the taskbar.

### Fixes

- Crashing when exiting the app while fetching installed apps.

## 0.7.0 - Unreleased

### Added

- Error Logging for better debugging.
- New `View Logs` HyperLink in Settings Page.

### Changes

- Minor UI improvements and fixes.
- Better exception handling.
- Package Name has been changed to `Rayen.RyTuneX`.

### Fixes

- Selecting and unselecting a package, then selecting it again, should now attempt to remove it once.
- Crashing when exiting the app while fetching installed apps.

## 0.6 - Released

> [!TIP]
> **This version addressed the following issue:**
Expand All @@ -22,14 +50,14 @@ All notable changes to this project will be documented in this file.
> [!NOTE]
> If you have any design ideas for the setup, feel free to share them.
## 0.5
## 0.5 - Unreleased

### Added

- Extended System information (Operating System, cpu, gpu, ram, ...).


## 0.4
## 0.4 - Unreleased

### Added

Expand Down
58 changes: 58 additions & 0 deletions Helpers/LogHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Windows.Storage;

internal class LogHelper
{
public static async void ShowErrorMessageAndLog(Exception ex, XamlRoot xamlRoot)
{
var errorMessage = $"Caught Error: {ex.Message}";

await LogError(errorMessage);

InitiliseErrorMessage(errorMessage, xamlRoot);
}

private static async Task LogToFile(string message, string fileName)
{
try
{
var tempFolder = ApplicationData.Current.TemporaryFolder;

var logFile = await tempFolder.CreateFileAsync($"{fileName}_{DateTime.Now:yyyy-MM-dd}.txt", CreationCollisionOption.OpenIfExists);

await FileIO.AppendTextAsync(logFile, $"{DateTime.Now:T}: {message}\n");
}
catch (Exception logException)
{
Console.WriteLine($"Error logging to file: {logException.Message}");
}
}

private static async void InitiliseErrorMessage(string errorMessage, XamlRoot xamlRoot)
{
ContentDialog errorDialog = new ContentDialog
{
Title = "Error",
Content = errorMessage,
CloseButtonText = "Close",
PrimaryButtonText = "Open Logs File"
};
errorDialog.XamlRoot = xamlRoot;

errorDialog.PrimaryButtonClick += async (sender, args) =>
{
StorageFolder tempFolder = ApplicationData.Current.TemporaryFolder;
StorageFile logFile = await tempFolder.GetFileAsync($"ErrorLogs_{DateTime.Now:yyyy-MM-dd}.txt");
if (logFile != null)
{
var options = new Windows.System.LauncherOptions();
options.DisplayApplicationPicker = false;
await Windows.System.Launcher.LaunchFileAsync(logFile, options);
}
};
await errorDialog.ShowAsync();
}
public static Task Log(string message) => LogToFile(message, "Logs");
public static Task LogError(string message) => LogToFile(message, "ErrorLogs");
}
7 changes: 5 additions & 2 deletions Helpers/OptimizationOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static List<KeyValuePair<string, string>> GetUWPApps(bool uninstallableOn

using (var PowerShellInstance = PowerShell.Create())
{

LogHelper.Log("Getting Installed Apps [OptimizationOptions.cs]");
PowerShellInstance.AddScript("Set-ExecutionPolicy RemoteSigned -Scope Process");
PowerShellInstance.AddScript("Import-Module Appx")
.AddArgument("-ExecutionPolicy Bypass");
Expand Down Expand Up @@ -52,7 +52,7 @@ public static List<KeyValuePair<string, string>> GetUWPApps(bool uninstallableOn
}
}
}

LogHelper.Log("Returning Installed Apps [OptimizationOptions.cs]");
return installedApps;
}

Expand All @@ -64,6 +64,7 @@ internal static void StopService(string serviceName)
{
if (ServiceExists(serviceName))
{
LogHelper.Log($"Stopping svc: {serviceName}");
var sc = new ServiceController(serviceName);
if (sc.CanStop)
{
Expand All @@ -77,6 +78,7 @@ internal static void StartInCmd(string command)
{
return;
}
LogHelper.Log("Starting CMD Command");
using var p = new Process();
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.StartInfo.FileName = "cmd.exe";
Expand All @@ -90,6 +92,7 @@ internal static void StartService(string serviceName)
{
if (ServiceExists(serviceName))
{
LogHelper.Log($"Starting svc: {serviceName}");
var sc = new ServiceController(serviceName);
sc.Start();
}
Expand Down
4 changes: 0 additions & 4 deletions Helpers/OptimizeSystemHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -351,16 +351,12 @@ internal static void DisableLegacyVolumeSlider()

internal static void EnableTaskbarColor()
{
OptimizationOptions.StartInCmd("reg add \"HKCU\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize\" /v EnableTransparency /t REG_DWORD /d 0 /f");

OptimizationOptions.StartInCmd("reg add \"HKCU\\SOFTWARE\\Microsoft\\Windows\\DWM\" /v ColorPrevalence /t REG_DWORD /d 00000001 /f");
OptimizationOptions.StartInCmd("reg add \"HKCU\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize\" /v ColorPrevalence /t REG_DWORD /d 00000000 /f");
}

internal static void DisableTaskbarColor()
{
OptimizationOptions.StartInCmd("reg add \"HKCU\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize\" /v EnableTransparency /t REG_DWORD /d 1 /f");

OptimizationOptions.StartInCmd("reg add \"HKCU\\SOFTWARE\\Microsoft\\Windows\\DWM\" /v ColorPrevalence /t REG_DWORD /d 00000000 /f");
OptimizationOptions.StartInCmd("reg add \"HKCU\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize\" /v ColorPrevalence /t REG_DWORD /d 00000001 /f");
}
Expand Down
1 change: 1 addition & 0 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public sealed partial class MainWindow : WindowEx
public MainWindow()
{
InitializeComponent();
LogHelper.Log("Initializing MainWindow");
AppWindow.SetIcon(Path.Combine(AppContext.BaseDirectory, "Assets/WindowIcon.ico"));
Content = null;
Title = "AppDisplayName".GetLocalized();
Expand Down
4 changes: 2 additions & 2 deletions Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
IgnorableNamespaces="uap rescap genTemplate">

<Identity
Name="593c7ba8-f1c9-47cf-a952-7c22b10aac3a"
Name="Rayen.RyTuneX"
Publisher="CN=Ghanmi"
Version="0.6.0.0" />
Version="0.7.1.0" />

<mp:PhoneIdentity PhoneProductId="593c7ba8-f1c9-47cf-a952-7c22b10aac3a" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>

Expand Down
11 changes: 9 additions & 2 deletions RyTuneX.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
<GenerateTestArtifacts>True</GenerateTestArtifacts>
<AppxBundle>Never</AppxBundle>
<WindowsPackageType>MSIX</WindowsPackageType>
<AssemblyVersion>0.6.0.0</AssemblyVersion>
<FileVersion>0.6.0.0</FileVersion>
<PackageCertificateThumbprint>1D92A91C88A122BB200B96F35A8311064D7AD1CE</PackageCertificateThumbprint>
<StartupObject>RyTuneX.Program</StartupObject>
<PackageReadmeFile>README.md</PackageReadmeFile>
Expand All @@ -31,6 +29,7 @@
</PropertyGroup>
<ItemGroup>
<None Remove="Assets\WindowIcon.ico" />
<None Remove="Views\BenchmarkPage.xaml" />
<None Remove="Views\DebloatSystemPage.xaml" />
</ItemGroup>

Expand All @@ -40,6 +39,7 @@

<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="CommunityToolkit.WinUI.Behaviors" Version="8.0.230907" />
<PackageReference Include="CommunityToolkit.WinUI.UI.Controls" Version="7.1.2" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.4.231115000" />
Expand Down Expand Up @@ -79,6 +79,9 @@
<Page Update="Views\DebloatSystemPage.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Update="Views\BenchmarkPage.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
</ItemGroup>

<ItemGroup Condition="'$(DisableMsixProjectCapabilityAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
Expand Down Expand Up @@ -108,4 +111,8 @@
<ItemGroup>
<Compile Remove="C:\Users\Ghanmi\.nuget\packages\microsoft.windowsappsdk\1.4.231115000\buildTransitive\..\include\WindowsAppSDK-VersionInfo.cs" />
</ItemGroup>

<ItemGroup>
<Compile Remove="C:\Users\Ghanmi\.nuget\packages\microsoft.windowsappsdk\1.4.231115000\buildTransitive\..\include\DeploymentManagerAutoInitializer.cs" />
</ItemGroup>
</Project>
1 change: 1 addition & 0 deletions Services/PageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class PageService : IPageService
public PageService()
{
Configure<HomePage>();
Configure<BenchmarkPage>();
Configure<DebloatSystemPage>();
Configure<SystemInfoPage>();
Configure<OptimizeSystemPage>();
Expand Down
3 changes: 3 additions & 0 deletions Strings/ar-tn/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,7 @@
<data name="UninstallTip" xml:space="preserve">
<value>حدد التطبيقات التي ترغب في إزالتها واضغط على إلغاء التثبيت</value>
</data>
<data name="Shell_Benchmark.Content" xml:space="preserve">
<value>قياس الأداء</value>
</data>
</root>
3 changes: 3 additions & 0 deletions Strings/en-us/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,7 @@
<data name="UninstallTip" xml:space="preserve">
<value>Select apps that you want to remove and hit uninstall</value>
</data>
<data name="Shell_Benchmark.Content" xml:space="preserve">
<value>Benchmark</value>
</data>
</root>
3 changes: 3 additions & 0 deletions Strings/fr-fr/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,7 @@
<data name="UninstallTip" xml:space="preserve">
<value>Sélectionnez les applications que vous souhaitez supprimer et appuyez sur Désinstaller</value>
</data>
<data name="Shell_Benchmark.Content" xml:space="preserve">
<value>Performance</value>
</data>
</root>
14 changes: 14 additions & 0 deletions Views/BenchmarkPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Page
x:Class="RyTuneX.Views.BenchmarkPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<ScrollView x:Name="ContentArea" HorizontalScrollMode="Disabled" Margin="-20,0,-20,10" Padding="0,5,0,5">
<StackPanel>
<TextBlock x:Name="CpuUsage"/>
</StackPanel>

</ScrollView>
</Page>
14 changes: 14 additions & 0 deletions Views/BenchmarkPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Microsoft.UI.Xaml.Controls;


namespace RyTuneX.Views;

public sealed partial class BenchmarkPage : Page
{

public BenchmarkPage()
{
InitializeComponent();
LogHelper.Log("Initializing BenchmarkPage");
}
}
13 changes: 12 additions & 1 deletion Views/DebloatSystemPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
xmlns:local="using:RyTuneX.Views"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewmodels="using:RyTuneX.ViewModels"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
xmlns:behaviors="using:CommunityToolkit.WinUI.Behaviors"
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
mc:Ignorable="d">
<Grid Margin="0,0,0,26">
<Grid.RowDefinitions>
Expand Down Expand Up @@ -37,5 +39,14 @@
<TextBlock Margin="3" Grid.Row="3" x:Name="uninstallingStatusText"/>
<ProgressBar Margin="2" Grid.Row="4" x:Name="uninstallingStatusBar" Width="Auto" IsIndeterminate="True" Visibility="Collapsed"/>
<Button x:Uid="DebloatSystemPage_UninstallButton" Margin="3" Grid.Row="5" x:Name="uninstallButton" Visibility="Collapsed" Click="UninstallSelectedApp_Click" HorizontalAlignment="Left" VerticalAlignment="Bottom"/>
<muxc:InfoBar
MaxWidth="480"
Margin="16"
HorizontalAlignment="Right"
VerticalAlignment="Bottom">
<interactivity:Interaction.Behaviors>
<behaviors:StackedNotificationsBehavior x:Name="NotificationQueue" />
</interactivity:Interaction.Behaviors>
</muxc:InfoBar>
</Grid>
</Page>
Loading

0 comments on commit 7fc4797

Please sign in to comment.