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 30, 2023
1 parent 6b96266 commit 79947ef
Show file tree
Hide file tree
Showing 16 changed files with 238 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ Add any other context about the problem here.

**Log File (Important)**
Share the diagnostic files by:
Open Sucrose settings (Gear icon) top-right -> System -> Log File -> Save
Open Sucrose settings (Gear icon) top-right -> System -> Log Files -> Create
or
Navigate to the Appdata folder `C:\Users\<UserName>\AppData\Roaming\Sucrose\Log`
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@
using Button = Wpf.Ui.Controls.Button;
using DialogResult = System.Windows.Forms.DialogResult;
using FolderBrowserDialog = System.Windows.Forms.FolderBrowserDialog;
using SaveFileDialog = Microsoft.Win32.SaveFileDialog;
using SMMI = Sucrose.Manager.Manage.Internal;
using SMMM = Sucrose.Manager.Manage.Manager;
using SMR = Sucrose.Memory.Readonly;
using SMV = Sucrose.Memory.Valuable;
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 SSZEZ = Sucrose.Shared.Zip.Extension.Zip;
using TextBlock = System.Windows.Controls.TextBlock;

namespace Sucrose.Portal.ViewModels.Pages
Expand All @@ -24,14 +29,22 @@ public partial class SystemSettingViewModel : ObservableObject, INavigationAware
{
private string StoreTemporaryPath = Path.Combine(SMR.AppDataPath, SMR.AppName, SMR.CacheFolder, SMR.Store);

private string SettingTemporaryPath = Path.Combine(SMR.AppDataPath, SMR.AppName, SMR.SettingFolder);

private string CacheTemporaryPath = Path.Combine(SMR.AppDataPath, SMR.AppName, SMR.CacheFolder);

private string LogTemporaryPath = Path.Combine(SMR.AppDataPath, SMR.AppName, SMR.LogFolder);

private DispatcherTimer InitializeTimer = new();

private TextBlock LibraryTemporaryHint = new();

private TextBlock StoreTemporaryHint = new();

private TextBlock CacheTemporaryHint = new();

private TextBlock LogTemporaryHint = new();

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

Expand All @@ -47,11 +60,123 @@ public SystemSettingViewModel()

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

Contents.Add(LogArea);

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

LogTemporary.Title.Text = "Günlük Dosyaları";
LogTemporary.LeftIcon.Symbol = SymbolRegular.PersonNote24;
LogTemporary.Description.Text = "Uygulamanın oluşturmuş olduğu tüm günlük dosyalarını yönetme.";

StackPanel LogTemporaryContent = new()
{
Orientation = Orientation.Horizontal
};

Button LogTemporaryCreate = new()
{
Foreground = SSRER.GetResource<Brush>("TextFillColorPrimaryBrush"),
Appearance = ControlAppearance.Secondary,
Margin = new Thickness(0, 0, 0, 0),
Padding = new Thickness(8),
Cursor = Cursors.Hand,
Content = "Oluştur"
};

LogTemporaryCreate.Click += (s, e) => LogTemporaryCreateClick(LogTemporaryCreate);

Button LogTemporaryDelete = new()
{
Foreground = SSRER.GetResource<Brush>("TextFillColorPrimaryBrush"),
Appearance = ControlAppearance.Secondary,
Margin = new Thickness(10, 0, 0, 0),
Padding = new Thickness(8),
Cursor = Cursors.Hand,
Content = "Temizle"
};

LogTemporaryDelete.Click += (s, e) => LogTemporaryDeleteClick(LogTemporaryDelete);

LogTemporaryContent.Children.Add(LogTemporaryCreate);
LogTemporaryContent.Children.Add(LogTemporaryDelete);

LogTemporary.HeaderFrame = LogTemporaryContent;

LogTemporaryHint = new()
{
Text = "Not: Günlük dosyalarının kapladığı toplam alan 0 b. Sadece 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
};

LogTemporary.FooterCard = LogTemporaryHint;

Contents.Add(LogTemporary);

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

Contents.Add(ResetArea);

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

SettingReset.Title.Text = "Ayar Sıfırlama";
SettingReset.LeftIcon.Symbol = SymbolRegular.LauncherSettings24;
SettingReset.Description.Text = "Uygulamanın oluşturmuş olduğu tüm ayar dosyalarını sıfırlama.";

Button SettingResetStart = new()
{
Foreground = SSRER.GetResource<Brush>("TextFillColorPrimaryBrush"),
Appearance = ControlAppearance.Secondary,
Margin = new Thickness(0, 0, 0, 0),
Content = "Sıfırlamaya Başla",
Padding = new Thickness(8),
Cursor = Cursors.Hand,
};

SettingResetStart.Click += (s, e) => SettingResetStartClick(SettingResetStart);

SettingReset.HeaderFrame = SettingResetStart;

TextBlock SettingResetHint = new()
{
Text = "Not: Sıfırlama işlemi başladığında tüm uygulamalar kapanacaktır.",
Foreground = SSRER.GetResource<Brush>("TextFillColorSecondaryBrush"),
Margin = new Thickness(0, 0, 0, 0),
FontWeight = FontWeights.SemiBold
};

SettingReset.FooterCard = SettingResetHint;

Contents.Add(SettingReset);

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

Expand Down Expand Up @@ -129,51 +254,51 @@ private void InitializeViewModel()

Contents.Add(StoreTemporary);

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

Contents.Add(ResetArea);
Contents.Add(LibraryArea);

SPVCEC SettingReset = new()
SPVCEC LibraryTemporary = new()
{
Margin = new Thickness(0, 10, 0, 0),
Expandable = true
};

SettingReset.Title.Text = "Ayar Sıfırlama";
SettingReset.LeftIcon.Symbol = SymbolRegular.LauncherSettings24;
SettingReset.Description.Text = "Uygulamanın oluşturmuş olduğu tüm ayar dosyalarını sıfırlama.";
LibraryTemporary.Title.Text = "Kütüphane Temizleme";
LibraryTemporary.LeftIcon.Symbol = SymbolRegular.FolderLink24;
LibraryTemporary.Description.Text = "Kütüphanenizde bulunan veya oluşturmuş olduğunuz tüm tema dosyalarını temizleme.";

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

SettingResetStart.Click += (s, e) => SettingResetStartClick(SettingResetStart);
LibraryTemporaryStart.Click += (s, e) => LibraryTemporaryStartClick(LibraryTemporaryStart);

SettingReset.HeaderFrame = SettingResetStart;
LibraryTemporary.HeaderFrame = LibraryTemporaryStart;

TextBlock SettingResetHint = new()
LibraryTemporaryHint = new()
{
Text = "Not: Sıfırlama işlemi başladığında tüm uygulamalar kapanacaktır.",
Text = "Not: Kütüphanenizdeki temaları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
};

SettingReset.FooterCard = SettingResetHint;
LibraryTemporary.FooterCard = LibraryTemporaryHint;

Contents.Add(SettingReset);
Contents.Add(LibraryTemporary);

TextBlock BackupArea = new()
{
Expand Down Expand Up @@ -259,13 +384,55 @@ public void OnNavigatedFrom()
InitializeTimer.Stop();
}

private async Task CreateLog()
{
SaveFileDialog SaveDialog = new()
{
FileName = SMV.LogCompress,

Filter = SSRER.GetValue("Portal", "SystemSettingPage", "LogSaveDialogFilter"),
FilterIndex = 1,

Title = SSRER.GetValue("Portal", "SystemSettingPage", "LogSaveDialogTitle"),

InitialDirectory = SMR.DesktopPath
};

if (SaveDialog.ShowDialog() == true)
{
string Destination = SaveDialog.FileName;

string[] Sources = new[]
{
LogTemporaryPath,
SettingTemporaryPath,
};

string[] Excludes = new[]
{
SMMI.PrivateSettingManager.SettingFile()
};

SSZEZ.Compress(Sources, Excludes, Destination);
}

await Task.CompletedTask;
}

private void SettingResetStartClick(Button SettingResetStart)
{
SettingResetStart.IsEnabled = false;

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

private void LogTemporaryDeleteClick(Button LogTemporaryDelete)
{
LogTemporaryDelete.IsEnabled = false;

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

private void CacheTemporaryStartClick(Button CacheTemporaryStart)
{
CacheTemporaryStart.IsEnabled = false;
Expand Down Expand Up @@ -322,17 +489,41 @@ private void SettingBackupImportClick(Button SettingBackupImport)
}
}

private void LibraryTemporaryStartClick(Button LibraryTemporaryStart)
{
LibraryTemporaryStart.IsEnabled = false;

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

private async void LogTemporaryCreateClick(Button LogTemporaryCreate)
{
LogTemporaryCreate.IsEnabled = false;

await Task.Run(CreateLog);

LogTemporaryCreate.IsEnabled = true;
}

private async void InitializeTimer_Tick(object sender, EventArgs e)
{
try
{
string LogTemporarySize = await SSSHT.Size(LogTemporaryPath);

LogTemporaryHint.Text = $"Not: Günlük dosyalarının kapladığı toplam alan {LogTemporarySize}. Sadece temizliğe başlandığında tüm uygulamalar kapanacaktır.";

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.";

string StoreTemporarySize = await SSSHT.Size(StoreTemporaryPath);

StoreTemporaryHint.Text = $"Not: Mağaza dosyalarının kapladığı toplam alan {StoreTemporarySize}. Temizliğe başlandığında tüm uygulamalar kapanacaktır.";

string LibraryTemporarySize = await SSSHT.Size(SMMM.LibraryLocation);

LibraryTemporaryHint.Text = $"Not: Kütüphanenizdeki temaların kapladığı toplam alan {LibraryTemporarySize}. Temizliğe başlandığında tüm uygulamalar kapanacaktır.";
}
catch { }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<system:String x:Key="Launcher.OpenText">Otwórz Sucrose</system:String>
<system:String x:Key="Launcher.ReportText">Zgłoś Błąd</system:String>
<system:String x:Key="Launcher.ReportWindowTitle">Diagnostyka Sucrose</system:String>
<system:String x:Key="Launcher.SaveDialogFilter">Pliki ZIP (*.zip)|*.zip|Wszystkie pliki (*.*)|*.*</system:String>
<system:String x:Key="Launcher.SaveDialogFilter">Pliki ZIP (*.zip)|*.zip|Wszystkie Pliki (*.*)|*.*</system:String>
<system:String x:Key="Launcher.SaveDialogTitle">Zapisz Plik Dziennika</system:String>
<system:String x:Key="Launcher.SettingText">Ustawienia</system:String>
<system:String x:Key="Launcher.TrayText">Sucrose Wallpaper Engine</system:String>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
>
<system:String x:Key="Portal.Area.Sound">Ton</system:String>
<system:String x:Key="Portal.Area.Log">Protokoll</system:String>
<system:String x:Key="Portal.Area.Hook">Haken</system:String>
<system:String x:Key="Portal.Area.Store">Geschäft</system:String>
<system:String x:Key="Portal.Area.Donate">Spende</system:String>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
>
<system:String x:Key="Portal.Area.Sound">Sound</system:String>
<system:String x:Key="Portal.Area.Log">Log</system:String>
<system:String x:Key="Portal.Area.Hook">Hook</system:String>
<system:String x:Key="Portal.Area.Store">Store</system:String>
<system:String x:Key="Portal.Area.Donate">Donate</system:String>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
>
<system:String x:Key="Portal.Area.Sound">Sonido</system:String>
<system:String x:Key="Portal.Area.Log">Registro</system:String>
<system:String x:Key="Portal.Area.Hook">Gancho</system:String>
<system:String x:Key="Portal.Area.Store">Tienda</system:String>
<system:String x:Key="Portal.Area.Donate">Donar</system:String>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
>
<system:String x:Key="Portal.Area.Sound">Son</system:String>
<system:String x:Key="Portal.Area.Log">Journal</system:String>
<system:String x:Key="Portal.Area.Hook">Crochet</system:String>
<system:String x:Key="Portal.Area.Store">Magasin</system:String>
<system:String x:Key="Portal.Area.Donate">Don</system:String>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
>
<system:String x:Key="Portal.Area.Sound">Dźwięk</system:String>
<system:String x:Key="Portal.Area.Log">Dziennik</system:String>
<system:String x:Key="Portal.Area.Hook">Hak</system:String>
<system:String x:Key="Portal.Area.Store">Sklep</system:String>
<system:String x:Key="Portal.Area.Donate">Donacja</system:String>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
>
<system:String x:Key="Portal.Area.Sound">Ses</system:String>
<system:String x:Key="Portal.Area.Log">Günlük</system:String>
<system:String x:Key="Portal.Area.Hook">Kanca</system:String>
<system:String x:Key="Portal.Area.Store">Mağaza</system:String>
<system:String x:Key="Portal.Area.Donate">Bağış</system:String>
Expand Down
Loading

0 comments on commit 79947ef

Please sign in to comment.