Skip to content

Commit

Permalink
1.0.11.0 RELEASE CANDIDATE 3 CC-17
Browse files Browse the repository at this point in the history
App taskbar improvements. UI refresh. Normal installer
  • Loading branch information
Erruar committed May 21, 2024
1 parent a80037d commit 894dc94
Show file tree
Hide file tree
Showing 60 changed files with 7,673 additions and 4,393 deletions.
3 changes: 2 additions & 1 deletion Saku Overclock.Core/Helpers/Json.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Newtonsoft.Json;
using static System.Runtime.InteropServices.JavaScript.JSType;

namespace Saku_Overclock.Core.Helpers;

Expand All @@ -18,5 +19,5 @@ public static async Task<string> StringifyAsync(object value)
{
return JsonConvert.SerializeObject(value);
});
}
}
}
5 changes: 5 additions & 0 deletions Saku Overclock.Core/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*Recommended Markdown Viewer: [Markdown Editor](https://marketplace.visualstudio.com/items?itemName=MadsKristensen.MarkdownEditor2)*

## Getting Started

The Core project contains code that can be [reused across multiple application projects](https://docs.microsoft.com/dotnet/standard/net-standard#net-5-and-net-standard).
Binary file modified Saku Overclock.Core/bin/Debug/net7.0/Saku Overclock.Core.dll
Binary file not shown.
Binary file modified Saku Overclock.Core/bin/Debug/net7.0/Saku Overclock.Core.pdb
Binary file not shown.
Binary file modified Saku Overclock.Core/bin/x64/Debug/net7.0/Saku Overclock.Core.dll
Binary file not shown.
Binary file modified Saku Overclock.Core/bin/x64/Debug/net7.0/Saku Overclock.Core.pdb
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v7.0", FrameworkDisplayName = ".NET 7.0")]
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Этот код создан программой.
// Исполняемая версия:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
// повторной генерации кода.
// </auto-generated>
//------------------------------------------------------------------------------

Expand All @@ -13,7 +14,7 @@
[assembly: System.Reflection.AssemblyCompanyAttribute("Saku Overclock.Core")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.1.5")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+bfd05017962a936d03e0db04a7190a8a7188239e")]
[assembly: System.Reflection.AssemblyProductAttribute("Saku Overclock.Core")]
[assembly: System.Reflection.AssemblyTitleAttribute("Saku Overclock.Core")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.1.5")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
f24ee87fbd25ebdc2558340e8204db4ed22e89403a70b559850813fa9a16af93
9499fa4c14a16e9c6e2106979effa862f8c2047b343cc3664d16841e75371f83
Empty file.
Binary file modified Saku Overclock.Core/obj/Debug/net7.0/Saku Overclock.Core.dll
Binary file not shown.
Binary file modified Saku Overclock.Core/obj/Debug/net7.0/Saku Overclock.Core.pdb
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9499fa4c14a16e9c6e2106979effa862f8c2047b343cc3664d16841e75371f83
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// <auto-generated/>
global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Threading;
global using global::System.Threading.Tasks;
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
C:\Users\Sakura\source\repos\Saku Overclock\Saku Overclock.Core\bin\arm64\Debug\net7.0\Saku Overclock.Core.deps.json
C:\Users\Sakura\source\repos\Saku Overclock\Saku Overclock.Core\bin\arm64\Debug\net7.0\Saku Overclock.Core.dll
C:\Users\Sakura\source\repos\Saku Overclock\Saku Overclock.Core\bin\arm64\Debug\net7.0\Saku Overclock.Core.pdb
C:\Users\Sakura\source\repos\Saku Overclock\Saku Overclock.Core\obj\arm64\Debug\net7.0\Saku Overclock.Core.csproj.AssemblyReference.cache
C:\Users\Sakura\source\repos\Saku Overclock\Saku Overclock.Core\obj\arm64\Debug\net7.0\Saku Overclock.Core.GeneratedMSBuildEditorConfig.editorconfig
C:\Users\Sakura\source\repos\Saku Overclock\Saku Overclock.Core\obj\arm64\Debug\net7.0\Saku Overclock.Core.AssemblyInfoInputs.cache
C:\Users\Sakura\source\repos\Saku Overclock\Saku Overclock.Core\obj\arm64\Debug\net7.0\Saku Overclock.Core.AssemblyInfo.cs
C:\Users\Sakura\source\repos\Saku Overclock\Saku Overclock.Core\obj\arm64\Debug\net7.0\Saku Overclock.Core.csproj.CoreCompileInputs.cache
C:\Users\Sakura\source\repos\Saku Overclock\Saku Overclock.Core\obj\arm64\Debug\net7.0\Saku Overclock.Core.sourcelink.json
C:\Users\Sakura\source\repos\Saku Overclock\Saku Overclock.Core\obj\arm64\Debug\net7.0\Saku Overclock.Core.dll
C:\Users\Sakura\source\repos\Saku Overclock\Saku Overclock.Core\obj\arm64\Debug\net7.0\refint\Saku Overclock.Core.dll
C:\Users\Sakura\source\repos\Saku Overclock\Saku Overclock.Core\obj\arm64\Debug\net7.0\Saku Overclock.Core.pdb
C:\Users\Sakura\source\repos\Saku Overclock\Saku Overclock.Core\obj\arm64\Debug\net7.0\ref\Saku Overclock.Core.dll
Binary file modified Saku Overclock.Core/obj/x64/Debug/net7.0/Saku Overclock.Core.dll
Binary file not shown.
Binary file modified Saku Overclock.Core/obj/x64/Debug/net7.0/Saku Overclock.Core.pdb
Binary file not shown.
596 changes: 595 additions & 1 deletion Saku Overclock/App.xaml

Large diffs are not rendered by default.

75 changes: 21 additions & 54 deletions Saku Overclock/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
using Saku_Overclock.Models;
using Saku_Overclock.Notifications;
using Saku_Overclock.Services;
using Saku_Overclock.SMUEngine;
using Saku_Overclock.ViewModels;
using Saku_Overclock.Views;
using Application = Microsoft.UI.Xaml.Application;
using UIElement = Microsoft.UI.Xaml.UIElement;
namespace Saku_Overclock;
#pragma warning disable CS8601 // Возможно, назначение-ссылка, допускающее значение NULL.
// To learn more about WinUI 3, see https://docs.microsoft.com/windows/apps/winui/winui3/.
public partial class App : Application
{
Expand All @@ -30,54 +30,42 @@ public partial class App : Application
public IHost Host
{
get;
}

}
public static T GetService<T>()
where T : class
{
if ((App.Current as App)!.Host.Services.GetService(typeof(T)) is not T service)
if ((Current as App)!.Host.Services.GetService(typeof(T)) is not T service)
{
throw new ArgumentException($"{typeof(T)} needs to be registered in ConfigureServices within App.xaml.cs.");
}

return service;
}

[Obsolete]
public static WindowEx MainWindow { get; } = new MainWindow();

}
public static WindowEx MainWindow { get; } = new MainWindow();
public static UIElement? AppTitlebar { get; set; }

private Config config = new();

public App()
{
InitializeComponent();

Host = Microsoft.Extensions.Hosting.Host.
CreateDefaultBuilder().
UseContentRoot(AppContext.BaseDirectory).
ConfigureServices((context, services) =>
{
// Default Activation Handler
services.AddTransient<ActivationHandler<LaunchActivatedEventArgs>, DefaultActivationHandler>();

// Other Activation Handlers
services.AddTransient<IActivationHandler, AppNotificationActivationHandler>();

// Services
services.AddSingleton<IAppNotificationService, AppNotificationService>();
services.AddSingleton<ILocalSettingsService, LocalSettingsService>();
services.AddSingleton<IThemeSelectorService, ThemeSelectorService>();
services.AddTransient<INavigationViewService, NavigationViewService>();

services.AddSingleton<IActivationService, ActivationService>();
services.AddSingleton<IPageService, PageService>();
services.AddSingleton<INavigationService, NavigationService>();

// Core Services
services.AddSingleton<IFileService, FileService>();

// Views and ViewModels
services.AddTransient<SettingsViewModel>();
services.AddTransient<SettingsPage>();
Expand All @@ -95,60 +83,39 @@ public App()
services.AddTransient<ГлавнаяPage>();
services.AddTransient<ShellPage>();
services.AddTransient<ShellViewModel>();

services.AddTransient<MainWindow.Applyer>();
services.AddTransient<SendSMUCommand>();
// Configuration
services.Configure<LocalSettingsOptions>(context.Configuration.GetSection(nameof(LocalSettingsOptions)));
}).
Build();

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

GetService<IAppNotificationService>().Initialize();
UnhandledException += App_UnhandledException;

}
#region JSON and Initialization
public void ConfigLoad()
{
config = JsonConvert.DeserializeObject<Config>(File.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "\\SakuOverclock\\config.json"));
config = JsonConvert.DeserializeObject<Config>(File.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "\\SakuOverclock\\config.json"))!;
}
private void App_UnhandledException(object sender, Microsoft.UI.Xaml.UnhandledExceptionEventArgs e)
{
MessageBox.Show(e.Message + "\nRerun application and contact developer", "Critical Error!", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
}
protected async override void OnLaunched(LaunchActivatedEventArgs args)
{
// Проверяем, запущен ли уже экземпляр программы
bool isFirstInstance;
var mutex = new Mutex(true, "MyProgramMutex", out isFirstInstance);

base.OnLaunched(args);
GetService<IAppNotificationService>().Show(string.Format("AppNotificationSamplePayload".GetLocalized(), AppContext.BaseDirectory));
await GetService<IActivationService>().ActivateAsync(args);
bool isFirstInstance; // Проверяем, запущен ли уже экземпляр программы
var mutex = new Mutex(true, "MyProgramMutex", out isFirstInstance);
if (!isFirstInstance)
{
// Если программа уже запущена, завершаем текущий экземпляр
{
MessageBox.Show("Текущий экземпляр будет завершен через 3 секунды...", "Другой экземпляр программы уже запущен.");
Thread.Sleep(3000);
return;
}
mutex.ReleaseMutex();
/*string processName = "Saku Overclock"; // Замените "YourProcessName" на имя процесса, который вы хотите завершить
// Получаем все процессы с указанным именем
Process[] processes = Process.GetProcessesByName(processName);
// Завершаем каждый процесс
foreach (Process process in processes)
{
try
{
process.Kill(); // Завершаем процесс
Console.WriteLine($"Процесс {process.ProcessName} завершен.");
}
catch (Exception ex)
{
Console.WriteLine($"Ошибка при завершении процесса {process.ProcessName}: {ex.Message}");
}
}*/
base.OnLaunched(args);
App.GetService<IAppNotificationService>().Show(string.Format("AppNotificationSamplePayload".GetLocalized(), AppContext.BaseDirectory));
await App.GetService<IActivationService>().ActivateAsync(args);
mutex.ReleaseMutex();
return;
}

}
#pragma warning restore CS8601 // Возможно, назначение-ссылка, допускающее значение NULL.
#endregion
}
4 changes: 2 additions & 2 deletions Saku Overclock/Helpers/SettingsStorageExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static bool IsRoamingStorageAvailable(this ApplicationData appData)
public static async Task SaveAsync<T>(this StorageFolder folder, string name, T content)
{
var file = await folder.CreateFileAsync(GetFileName(name), CreationCollisionOption.ReplaceExisting);
var fileContent = await Json.StringifyAsync(content);
var fileContent = await Json.StringifyAsync(content!);

await FileIO.WriteTextAsync(file, fileContent);
}
Expand All @@ -39,7 +39,7 @@ public static async Task SaveAsync<T>(this StorageFolder folder, string name, T

public static async Task SaveAsync<T>(this ApplicationDataContainer settings, string key, T value)
{
settings.SaveString(key, await Json.StringifyAsync(value));
settings.SaveString(key, await Json.StringifyAsync(value!));
}

public static void SaveString(this ApplicationDataContainer settings, string key, string value)
Expand Down
10 changes: 10 additions & 0 deletions Saku Overclock/JsonContainers/Notifications.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Saku_Overclock.SMUEngine;

namespace Saku_Overclock.JsonContainers;
internal class Notifications
{
public List<Notify>? Notifies
{
get; set;
}
}
2 changes: 2 additions & 0 deletions Saku Overclock/JsonContainers/config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ namespace Saku_Overclock;
#pragma warning disable CS0649 // Поле, не допускающее значения NULL, должно содержать значение, отличное от NULL, при выходе из конструктора. Возможно, стоит объявить поле как допускающее значения NULL.
internal class Config
{
public bool OldTitleBar = false;
public bool FixedTitleBar = false;
public string ApplyInfo;
public int Preset = 0;
public bool RangeApplied = true;
Expand Down
Loading

0 comments on commit 894dc94

Please sign in to comment.