Skip to content

Commit

Permalink
Preparing System Setting Page
Browse files Browse the repository at this point in the history
  • Loading branch information
Taiizor committed Sep 29, 2023
1 parent 99f97ad commit 42148d2
Show file tree
Hide file tree
Showing 18 changed files with 240 additions and 52 deletions.
1 change: 1 addition & 0 deletions src/Launcher/Sucrose.Launcher/Sucrose.Launcher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@

<ItemGroup>
<PackageReference Include="Skylark.Wing" Version="3.1.1.4" />
<PackageReference Include="Skylark.Standard" Version="3.1.1.8" />
<PackageReference Include="DiscordRichPresence" Version="1.2.1.24" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ private void InitializeViewModel()
DeleteState.Checked += (s, e) => DeleteStateChecked(true);
DeleteState.Unchecked += (s, e) => DeleteStateChecked(false);

Delete.HeaderFrame = DeleteState;

TextBlock DeleteHint = new()
{
Text = "Not: Dikkatli olunması gerekir. Aksi taktirde veri kayıplarına yol açabilir",
Expand All @@ -169,8 +171,6 @@ private void InitializeViewModel()

Delete.FooterCard = DeleteHint;

Delete.HeaderFrame = DeleteState;

Contents.Add(Delete);

TextBlock AppearanceBehaviorArea = new()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
using CommunityToolkit.Mvvm.ComponentModel;
using System.IO;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Threading;
using Wpf.Ui.Controls;
using Button = Wpf.Ui.Controls.Button;
using SMR = Sucrose.Memory.Readonly;
using SPVCEC = Sucrose.Portal.Views.Controls.ExpanderCard;
using SSDECT = Sucrose.Shared.Dependency.Enum.CommandsType;
using SSRER = Sucrose.Shared.Resources.Extension.Resources;
using SSSHP = Sucrose.Shared.Space.Helper.Processor;
using SSSHT = Sucrose.Shared.Space.Helper.Temporary;
using SSSMI = Sucrose.Shared.Space.Manage.Internal;
using TextBlock = System.Windows.Controls.TextBlock;

namespace Sucrose.Portal.ViewModels.Pages
{
public partial class SystemSettingViewModel : ObservableObject, INavigationAware, IDisposable
{
private string CacheTemporaryPath = Path.Combine(SMR.AppDataPath, SMR.AppName, SMR.CacheFolder);

private DispatcherTimer InitializeTimer = new();

private TextBlock CacheTemporaryHint = new();

[ObservableProperty]
private List<UIElement> _Contents = new();

Expand All @@ -21,7 +40,96 @@ public SystemSettingViewModel()

private void InitializeViewModel()
{
//
TextBlock CacheArea = new()
{
Foreground = SSRER.GetResource<Brush>("TextFillColorPrimaryBrush"),
Text = SSRER.GetValue("Portal", "Area", "Cache"),
Margin = new Thickness(0, 0, 0, 0),
FontWeight = FontWeights.Bold
};

Contents.Add(CacheArea);

SPVCEC CacheTemporary = new()
{
Margin = new Thickness(0, 10, 0, 0),
Expandable = true,
IsExpand = true
};

CacheTemporary.Title.Text = "Önbellek Temizleme";
CacheTemporary.LeftIcon.Symbol = SymbolRegular.FolderBriefcase20;
CacheTemporary.Description.Text = "Uygulamanın oluşturmuş olduğu tüm önbellek dosyalarını temizleme.";

Button CacheTemporaryStart = new()
{
Foreground = SSRER.GetResource<Brush>("TextFillColorPrimaryBrush"),
Appearance = ControlAppearance.Secondary,
Margin = new Thickness(0, 0, 0, 0),
Content = "Temizliğe Başla",
Padding = new Thickness(8),
Cursor = Cursors.Hand,
};

CacheTemporaryStart.Click += (s, e) => CacheTemporaryStartClick(CacheTemporaryStart, CacheTemporaryPath);

CacheTemporary.HeaderFrame = CacheTemporaryStart;

CacheTemporaryHint = new()
{
Text = "Not: Önbellek dosyalarının kapladığı toplam alan 0 b. Temizliğe başlandığında tüm uygulamalar kapanacaktır.",
Foreground = SSRER.GetResource<Brush>("TextFillColorSecondaryBrush"),
Margin = new Thickness(0, 0, 0, 0),
FontWeight = FontWeights.SemiBold
};

CacheTemporary.FooterCard = CacheTemporaryHint;

Contents.Add(CacheTemporary);

SPVCEC StoreTemporary = new()
{
Margin = new Thickness(0, 10, 0, 0),
Expandable = true,
IsExpand = true
};

StoreTemporary.Title.Text = "Mağaza Temizleme";
StoreTemporary.LeftIcon.Symbol = SymbolRegular.FolderGlobe20;
StoreTemporary.Description.Text = "Uygulamanın oluşturmuş olduğu tüm mağaza dosyalarını temizleme.";

//boyutunun ne kadar olduğunu yaz hint şeklinde

Contents.Add(StoreTemporary);

TextBlock BackupArea = new()
{
Foreground = SSRER.GetResource<Brush>("TextFillColorPrimaryBrush"),
Text = SSRER.GetValue("Portal", "Area", "Backup"),
Margin = new Thickness(0, 10, 0, 0),
FontWeight = FontWeights.Bold
};

Contents.Add(BackupArea);

SPVCEC SettingBackup = new()
{
Margin = new Thickness(0, 10, 0, 0),
Expandable = true,
IsExpand = true
};

SettingBackup.Title.Text = "Ayar Yedekleme";
SettingBackup.LeftIcon.Symbol = SymbolRegular.PeopleSettings24;
SettingBackup.Description.Text = "Uygulamanın oluşturmuş olduğu tüm ayar dosyalarını yönetme.";

//boyutunun ne kadar olduğunu yaz hint şeklinde

Contents.Add(SettingBackup);

InitializeTimer.Tick += new EventHandler(InitializeTimer_Tick);
InitializeTimer.Interval = new TimeSpan(0, 0, 3);
InitializeTimer.Start();

_isInitialized = true;
}
Expand All @@ -34,6 +142,21 @@ public void OnNavigatedTo()
public void OnNavigatedFrom()
{
//Dispose();
InitializeTimer.Stop();
}

private void CacheTemporaryStartClick(Button CacheTemporaryStart, string CacheTemporaryPath)
{
CacheTemporaryStart.IsEnabled = false;

SSSHP.Run(SSSMI.Commandog, $"{SMR.StartCommand}{SSDECT.Temp}{SMR.ValueSeparator}{CacheTemporaryPath}{SMR.ValueSeparator}{SSSMI.Launcher}");
}

private async void InitializeTimer_Tick(object sender, EventArgs e)
{
string CacheTemporarySize = await SSSHT.Size(CacheTemporaryPath);

CacheTemporaryHint.Text = $"Not: Önbellek dosyalarının kapladığı toplam alan {CacheTemporarySize}. Temizliğe başlandığında tüm uygulamalar kapanacaktır.";
}

public void Dispose()
Expand Down
6 changes: 6 additions & 0 deletions src/Portal/Sucrose.Portal/Views/Windows/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using SPVMWMWVM = Sucrose.Portal.ViewModels.Windows.MainWindowViewModel;
using SPVPLP = Sucrose.Portal.Views.Pages.LibraryPage;
using SPVPSGSP = Sucrose.Portal.Views.Pages.Setting.GeneralSettingPage;
using SPVPSSSP = Sucrose.Portal.Views.Pages.Setting.SystemSettingPage;
using SSDEACT = Sucrose.Shared.Dependency.Enum.ArgumentCommandsType;
using WUAAT = Wpf.Ui.Appearance.ApplicationTheme;
using WUAT = Wpf.Ui.Appearance.ApplicationThemeManager;
Expand Down Expand Up @@ -60,6 +61,11 @@ public MainWindow(SPVMWMWVM ViewModel, INavigationService NavigationService, ISe
ApplySetting(false);
RootView.Loaded += (_, _) => RootView.Navigate(typeof(SPVPSGSP));
}
else if (Args.Count() > 1 && Args[1] == $"{SSDEACT.SystemSetting}")
{
ApplySetting(false);
RootView.Loaded += (_, _) => RootView.Navigate(typeof(SPVPSSSP));
}
else
{
ApplyGeneral(false);
Expand Down
4 changes: 2 additions & 2 deletions src/Project/Sucrose.Commandog/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ namespace Sucrose.Commandog
{
internal class App : IDisposable
{
public static void Main(string[] Args)
public static async Task Main(string[] Args)
{
try
{
Console.OutputEncoding = Encoding.UTF8;
SHC.All = new CultureInfo(SMMM.Culture, true);

SCHA.Parse(Args);
await SCHA.Parse(Args);
}
catch (Exception Exception)
{
Expand Down
10 changes: 6 additions & 4 deletions src/Project/Sucrose.Commandog/Helper/Arguments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Sucrose.Commandog.Helper
{
internal static class Arguments
{
public static void Parse(string[] Arguments)
public static async Task Parse(string[] Arguments)
{
if (Arguments.Any())
{
Expand Down Expand Up @@ -83,7 +83,7 @@ public static void Parse(string[] Arguments)
}
break;
case SSDECT.Temp:
SSSHT.Delete(SCHP.ArgumentValue<string>(Values[0]), SCHP.ArgumentValue<string>(Values[1]));
await SSSHT.Delete(SCHP.ArgumentValue<string>(Values[0]), SCHP.ArgumentValue<string>(Values[1]));
break;
case SSDECT.Wiki:
SSSHP.Run(SCHP.ArgumentValue<string>(Values[0]));
Expand All @@ -95,10 +95,10 @@ public static void Parse(string[] Arguments)
SSSHP.Run(SCHP.ArgumentValue<string>(Values[0]));
break;
case SSDECT.Import:
SSSHI.Start(SCHP.ArgumentValue<string>(Values[0]), SCHP.ArgumentValue<string>(Values[1]));
await SSSHI.Start(SCHP.ArgumentValue<string>(Values[0]), SCHP.ArgumentValue<string>(Values[1]));
break;
case SSDECT.Export:
SSSHE.Start(SCHP.ArgumentValue<string>(Values[0]));
await SSSHE.Start(SCHP.ArgumentValue<string>(Values[0]), SCHP.ArgumentValue<string>(Values[1]));
break;
case SSDECT.Report:
SSSHP.Run(SCHP.ArgumentValue<string>(Values[0]));
Expand Down Expand Up @@ -155,6 +155,8 @@ public static void Parse(string[] Arguments)
}
}
}

await Task.CompletedTask;
}
}
}
1 change: 1 addition & 0 deletions src/Project/Sucrose.Commandog/Sucrose.Commandog.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
<ItemGroup>
<PackageReference Include="TaskScheduler" Version="2.10.1" />
<PackageReference Include="Skylark.Wing" Version="3.1.1.4" />
<PackageReference Include="Skylark.Standard" Version="3.1.1.8" />
</ItemGroup>

<ItemGroup Condition="$(TargetFramework.StartsWith('net48'))">
Expand Down
1 change: 1 addition & 0 deletions src/Project/Sucrose.WPF.CS/Sucrose.WPF.CS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@

<ItemGroup>
<PackageReference Include="Skylark.Wing" Version="3.1.1.4" />
<PackageReference Include="Skylark.Standard" Version="3.1.1.8" />
</ItemGroup>

<ItemGroup Condition="$(TargetFramework.StartsWith('net48'))">
Expand Down
3 changes: 2 additions & 1 deletion src/Shared/Sucrose.Shared.Dependency/Enum/CommandsType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ internal enum CommandsType

internal enum ArgumentCommandsType
{
Setting
Setting,
SystemSetting
}

internal enum SchedulerCommandsType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
<system:String x:Key="Portal.Area.Store">Geschäft</system:String>
<system:String x:Key="Portal.Area.Donate">Spende</system:String>
<system:String x:Key="Portal.Area.System">System</system:String>
<system:String x:Key="Portal.Area.Cache">Zwischenspeicher</system:String>
<system:String x:Key="Portal.Area.Laptop">Laptop</system:String>
<system:String x:Key="Portal.Area.Support">Unterstützung</system:String>
<system:String x:Key="Portal.Area.Backup">Sicherung</system:String>
<system:String x:Key="Portal.Area.Priority">Priorität</system:String>
<system:String x:Key="Portal.Area.Engines">Motoren</system:String>
<system:String x:Key="Portal.Area.Library">Bibliothek</system:String>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
<system:String x:Key="Portal.Area.Store">Store</system:String>
<system:String x:Key="Portal.Area.Donate">Donate</system:String>
<system:String x:Key="Portal.Area.System">System</system:String>
<system:String x:Key="Portal.Area.Cache">Cache</system:String>
<system:String x:Key="Portal.Area.Laptop">Laptop</system:String>
<system:String x:Key="Portal.Area.Support">Support</system:String>
<system:String x:Key="Portal.Area.Backup">Backup</system:String>
<system:String x:Key="Portal.Area.Priority">Priority</system:String>
<system:String x:Key="Portal.Area.Engines">Engines</system:String>
<system:String x:Key="Portal.Area.Library">Library</system:String>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
<system:String x:Key="Portal.Area.Store">Tienda</system:String>
<system:String x:Key="Portal.Area.Donate">Donar</system:String>
<system:String x:Key="Portal.Area.System">Sistema</system:String>
<system:String x:Key="Portal.Area.Cache">Cache</system:String>
<system:String x:Key="Portal.Area.Laptop">Portátil</system:String>
<system:String x:Key="Portal.Area.Support">Soporte</system:String>
<system:String x:Key="Portal.Area.Backup">Respaldo</system:String>
<system:String x:Key="Portal.Area.Priority">Prioridad</system:String>
<system:String x:Key="Portal.Area.Engines">Motores</system:String>
<system:String x:Key="Portal.Area.Library">Biblioteca</system:String>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
<system:String x:Key="Portal.Area.Store">Magasin</system:String>
<system:String x:Key="Portal.Area.Donate">Don</system:String>
<system:String x:Key="Portal.Area.System">Système</system:String>
<system:String x:Key="Portal.Area.Cache">Cache</system:String>
<system:String x:Key="Portal.Area.Laptop">Ordinateur Portable</system:String>
<system:String x:Key="Portal.Area.Support">Support</system:String>
<system:String x:Key="Portal.Area.Backup">Sauvegarde</system:String>
<system:String x:Key="Portal.Area.Priority">Priorité</system:String>
<system:String x:Key="Portal.Area.Engines">Moteurs</system:String>
<system:String x:Key="Portal.Area.Library">Bibliothèque</system:String>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
<system:String x:Key="Portal.Area.Store">Sklep</system:String>
<system:String x:Key="Portal.Area.Donate">Donacja</system:String>
<system:String x:Key="Portal.Area.System">Systemowe</system:String>
<system:String x:Key="Portal.Area.Cache">Pamięć Podręczna</system:String>
<system:String x:Key="Portal.Area.Laptop">Laptop</system:String>
<system:String x:Key="Portal.Area.Support">Wsparcie</system:String>
<system:String x:Key="Portal.Area.Backup">Kopia Zapasowa</system:String>
<system:String x:Key="Portal.Area.Priority">Priorytet</system:String>
<system:String x:Key="Portal.Area.Engines">Silniki</system:String>
<system:String x:Key="Portal.Area.Library">Biblioteka</system:String>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
<system:String x:Key="Portal.Area.Store">Mağaza</system:String>
<system:String x:Key="Portal.Area.Donate">Bağış</system:String>
<system:String x:Key="Portal.Area.System">Sistem</system:String>
<system:String x:Key="Portal.Area.Cache">Önbellek</system:String>
<system:String x:Key="Portal.Area.Laptop">Dizüstü</system:String>
<system:String x:Key="Portal.Area.Support">Destek</system:String>
<system:String x:Key="Portal.Area.Backup">Yedekleme</system:String>
<system:String x:Key="Portal.Area.Priority">Öncelik</system:String>
<system:String x:Key="Portal.Area.Engines">Motorlar</system:String>
<system:String x:Key="Portal.Area.Library">Kütüphane</system:String>
Expand Down
32 changes: 22 additions & 10 deletions src/Shared/Sucrose.Shared.Space/Helper/Export.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,35 @@
using System.IO;
using SMR = Sucrose.Memory.Readonly;
using SSDEACT = Sucrose.Shared.Dependency.Enum.ArgumentCommandsType;
using SSLHK = Sucrose.Shared.Live.Helper.Kill;
using SSSHP = Sucrose.Shared.Space.Helper.Processor;
using SSSMI = Sucrose.Shared.Space.Manage.Internal;

namespace Sucrose.Shared.Space.Helper
{
internal static class Export
{
public static void Start(string Destination)
public static async Task Start(string Destination, string Application)
{
try
{
foreach (string Setting in Settings(Path.Combine(SMR.AppDataPath, SMR.AppName, SMR.SettingFolder)))
{
File.Copy(Setting, Destination, true);
}
}
catch
SSLHK.Stop();
SSSHP.Kill(SMR.Portal);
SSSHP.Kill(SMR.Update);
SSSHP.Kill(SMR.Launcher);
SSSHP.Kill(SMR.Backgroundog);

await Task.Delay(TimeSpan.FromSeconds(1));

foreach (string Setting in Settings(Path.Combine(SMR.AppDataPath, SMR.AppName, SMR.SettingFolder)))
{
//
File.Copy(Setting, Destination, true);
}

await Task.Delay(TimeSpan.FromSeconds(1));

SSSHP.Run(Application);
SSSHP.Run(SSSMI.Portal, $"{SSDEACT.SystemSetting}");

await Task.CompletedTask;
}

public static string[] Settings(string Path)
Expand Down
Loading

0 comments on commit 42148d2

Please sign in to comment.