Skip to content

Commit

Permalink
Preparing Other Setting Page
Browse files Browse the repository at this point in the history
  • Loading branch information
Taiizor committed Oct 6, 2023
1 parent 89acae5 commit 5b9104e
Show file tree
Hide file tree
Showing 9 changed files with 124 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Windows.Input;
using System.Windows.Media;
using Wpf.Ui.Controls;
using SEST = Skylark.Enum.StorageType;
using SMC = Sucrose.Memory.Constant;
using SMMI = Sucrose.Manager.Manage.Internal;
using SMMM = Sucrose.Manager.Manage.Manager;
Expand Down Expand Up @@ -223,7 +224,7 @@ private void InitializeViewModel()
SPVCEC Update = new()
{
Margin = new Thickness(0, 10, 0, 0),
Expandable = false
IsExpand = true
};

Update.LeftIcon.Symbol = SymbolRegular.ArrowSwap24;
Expand All @@ -243,6 +244,57 @@ private void InitializeViewModel()

Update.HeaderFrame = UpdateType;

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

TextBlock UpdateLimitText = new()
{
Text = SSRER.GetValue("Portal", "OtherSettingPage", "Update", "Limit"),
Foreground = SSRER.GetResource<Brush>("TextFillColorPrimaryBrush"),
VerticalAlignment = VerticalAlignment.Center,
Margin = new Thickness(0, 0, 10, 0),
FontWeight = FontWeights.SemiBold
};

NumberBox UpdateLimit = new()
{
Icon = new SymbolIcon(SymbolRegular.ArrowBetweenDown24),
IconPlacement = ElementPlacement.Left,
Margin = new Thickness(0, 0, 10, 0),
Value = SMMM.UpdateLimitValue,
ClearButtonEnabled = false,
MaxDecimalPlaces = 0,
Maximum = 99999999,
MaxLength = 8,
Minimum = 0
};

UpdateLimit.ValueChanged += (s, e) => UpdateLimitChanged(UpdateLimit.Value);

ComboBox UpdateLimitType = new()
{
MaxDropDownHeight = 200
};

ScrollViewer.SetVerticalScrollBarVisibility(UpdateLimitType, ScrollBarVisibility.Auto);

UpdateLimitType.SelectionChanged += (s, e) => UpdateLimitTypeSelected(UpdateLimitType.SelectedIndex);

foreach (SEST Type in Enum.GetValues(typeof(SEST)))
{
UpdateLimitType.Items.Add(Type);
}

UpdateLimitType.SelectedIndex = (int)SMMM.DownloadType;

UpdateContent.Children.Add(UpdateLimitText);
UpdateContent.Children.Add(UpdateLimit);
UpdateContent.Children.Add(UpdateLimitType);

Update.FooterCard = UpdateContent;

Contents.Add(Update);

TextBlock DeveloperArea = new()
Expand Down Expand Up @@ -325,6 +377,26 @@ private void DeveloperStateChecked(bool State)
SMMI.EngineSettingManager.SetSetting(SMC.DeveloperMode, State);
}

private void UpdateLimitChanged(double? Value)
{
int NewValue = Convert.ToInt32(Value);

if (NewValue != SMMM.UpdateLimitValue)
{
SMMI.UpdateSettingManager.SetSetting(SMC.UpdateLimitValue, NewValue);
}
}

private void UpdateLimitTypeSelected(int Index)
{
if (Index != (int)SMMM.UpdateLimitType)
{
SEST Type = (SEST)Index;

SMMI.UpdateSettingManager.SetSetting(SMC.UpdateLimitType, Type);
}
}

private void DiscordDelayChanged(double? Value)
{
int NewValue = Convert.ToInt32(Value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

<system:String x:Key="Portal.OtherSettingPage.Update">Aktualisierungsmethode</system:String>
<system:String x:Key="Portal.OtherSettingPage.Update.Description">Die Methode, die für den Aktualisierungsvorgang verwendet wird.</system:String>

<system:String x:Key="Portal.OtherSettingPage.Update.Limit">Download-Bandbreitenbegrenzung:</system:String>

<system:String x:Key="Portal.OtherSettingPage.Developer">Entwicklertools</system:String>
<system:String x:Key="Portal.OtherSettingPage.Developer.Description">Ob Entwicklertools für WebView und den CefSharp-Motor angezeigt werden sollen oder nicht.</system:String>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
<system:String x:Key="Portal.OtherSettingPage.Update">Update Method</system:String>
<system:String x:Key="Portal.OtherSettingPage.Update.Description">The method used for the update process.</system:String>

<system:String x:Key="Portal.OtherSettingPage.Update.Limit">Download Bandwidth Limit:</system:String>

<system:String x:Key="Portal.OtherSettingPage.Developer">Developer Tools</system:String>
<system:String x:Key="Portal.OtherSettingPage.Developer.Description">Whether developer tools for WebView and CefSharp engine should be displayed or not.</system:String>
</ResourceDictionary>
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
<system:String x:Key="Portal.OtherSettingPage.Update">Método de Actualización</system:String>
<system:String x:Key="Portal.OtherSettingPage.Update.Description">El método utilizado para el proceso de actualización.</system:String>

<system:String x:Key="Portal.OtherSettingPage.Update.Limit">Límite de Ancho de Banda de Descarga:</system:String>

<system:String x:Key="Portal.OtherSettingPage.Developer">Herramientas de Desarrollo</system:String>
<system:String x:Key="Portal.OtherSettingPage.Developer.Description">Si se deben mostrar o no las herramientas de desarrollo para WebView y el motor CefSharp.</system:String>
</ResourceDictionary>
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
<system:String x:Key="Portal.OtherSettingPage.Update">Méthode de Mise à Jour</system:String>
<system:String x:Key="Portal.OtherSettingPage.Update.Description">La méthode utilisée pour le processus de mise à jour.</system:String>

<system:String x:Key="Portal.OtherSettingPage.Update.Limit">Limite de Bande Passante de Téléchargement:</system:String>

<system:String x:Key="Portal.OtherSettingPage.Developer">Outils de Développeur</system:String>
<system:String x:Key="Portal.OtherSettingPage.Developer.Description">Affichage ou non des outils de développement pour WebView et le moteur CefSharp.</system:String>
</ResourceDictionary>
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
<system:String x:Key="Portal.OtherSettingPage.Update">Metoda Aktualizacji</system:String>
<system:String x:Key="Portal.OtherSettingPage.Update.Description">Metoda używana w procesie aktualizacji.</system:String>

<system:String x:Key="Portal.OtherSettingPage.Update.Limit">Limit Przepustowości Pobierania:</system:String>

<system:String x:Key="Portal.OtherSettingPage.Developer">Narzędzia Deweloperskie</system:String>
<system:String x:Key="Portal.OtherSettingPage.Developer.Description">Czy wyświetlać narzędzia deweloperskie dla WebView i silnika CefSharp, czy nie.</system:String>
</ResourceDictionary>
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
<system:String x:Key="Portal.OtherSettingPage.Update">Güncelleme Yöntemi</system:String>
<system:String x:Key="Portal.OtherSettingPage.Update.Description">Güncelleme işleminin hangi yöntemle yapılıp yapılmayacağı.</system:String>

<system:String x:Key="Portal.OtherSettingPage.Update.Limit">İndirme Bant Genişliği Sınırı:</system:String>

<system:String x:Key="Portal.OtherSettingPage.Developer">Geliştirici Araçları</system:String>
<system:String x:Key="Portal.OtherSettingPage.Developer.Description">WebView ve CefSharp motoru için geliştirici araçlarının gösterilip gösterilmeyeceği.</system:String>
</ResourceDictionary>
55 changes: 38 additions & 17 deletions src/Update/Sucrose.Update/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public partial class App : Application

private static bool HasError { get; set; } = true;

private static bool HasInfo { get; set; } = false;

private static bool HasFile { get; set; } = false;

private static int MinDelay => 1000;
Expand Down Expand Up @@ -120,16 +122,40 @@ protected void Close()

internal void Info(SSDEUT Type)
{
switch (SUMM.ThemeType)
if (!HasInfo)
{
if (Type != SSDEUT.Updating)
{
HasInfo = true;
}

switch (SUMM.ThemeType)
{
case SEWTT.Dark:
SUVDIB DarkInfoBox = new(Type);
DarkInfoBox.ShowDialog();
break;
default:
SUVLIB LightInfoBox = new(Type);
LightInfoBox.ShowDialog();
break;
}
}
}

protected static void UpdateLimit()
{
if (SMMM.UpdateLimitValue > 0)
{
case SEWTT.Dark:
SUVDIB DarkInfoBox = new(Type);
DarkInfoBox.ShowDialog();
break;
default:
SUVLIB LightInfoBox = new(Type);
LightInfoBox.ShowDialog();
break;
double UpdateLimit = SSESSE.Convert(SMMM.UpdateLimitValue, SMMM.UpdateLimitType, SEST.Byte, SEMST.Palila);

long Limit = Convert.ToInt64(SHN.Numeral(UpdateLimit, false, false, 0, '0', SECNT.None));

SUMI.DownloadConfiguration.MaximumBytesPerSecond = Limit;
}
else
{
SUMI.DownloadConfiguration.MaximumBytesPerSecond = 0;
}
}

Expand Down Expand Up @@ -229,14 +255,7 @@ protected async void Configure()
File.Delete(Bundle);
}

if (SMMM.UpdateLimitValue > 0)
{
double UpdateLimit = SSESSE.Convert(SMMM.UpdateLimitValue, SMMM.UpdateLimitType, SEST.Byte, SEMST.Palila);

long Limit = Convert.ToInt64(SHN.Numeral(UpdateLimit, false, false, 0, '0', SECNT.None));

SUMI.DownloadConfiguration.MaximumBytesPerSecond = Limit;
}
UpdateLimit();

SUMI.DownloadService = new(SUMI.DownloadConfiguration);

Expand Down Expand Up @@ -394,6 +413,8 @@ private static void OnDownloadProgressChanged(object sender, DownloadProgressCha
{
SMMI.UpdateSettingManager.SetSetting(SMC.UpdatePercentage, Percentage);
}

UpdateLimit();
}
}
}
2 changes: 1 addition & 1 deletion src/Update/Sucrose.Update/Sucrose.Update.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<InformationalVersion>$(Version)</InformationalVersion>
<AssemblyVersion>$(Version)</AssemblyVersion>
<FileVersion>$(Version)</FileVersion>
<Version>$([System.DateTime]::Today.ToString(yy)).$([System.DateTime]::Today.ToString(MM)).1</Version>
<Version>$([System.DateTime]::Today.ToString(yy)).$([System.DateTime]::Today.ToString(MM)).$([System.DateTime]::Today.ToString(dd))</Version>
<AssemblyName>Sucrose.Update</AssemblyName>
<RootNamespace>$(AssemblyName)</RootNamespace>
<UseWindowsForms>false</UseWindowsForms>
Expand Down

0 comments on commit 5b9104e

Please sign in to comment.