Skip to content

Commit

Permalink
change welcome page procedure #8
Browse files Browse the repository at this point in the history
  • Loading branch information
Scighost committed Jul 17, 2023
1 parent 3c7b118 commit 192ec2b
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 23 deletions.
16 changes: 9 additions & 7 deletions Starward/Pages/Welcome/SelectLanguagePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,9 @@
Padding="24,12,24,12"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Background="{ThemeResource CustomAcrylicBrush}"
CornerRadius="8"
Shadow="{ThemeResource ThemeShadow}"
Translation="0,0,16">
<StackPanel Spacing="12">
Background="{ThemeResource CustomOverlayAcrylicBrush}"
CornerRadius="8">
<StackPanel Spacing="8">
<TextBlock FontSize="20"
FontWeight="SemiBold"
Foreground="{ThemeResource AccentTextFillColorPrimaryBrush}"
Expand All @@ -57,7 +55,9 @@
FontWeight="SemiBold"
Foreground="{ThemeResource AccentTextFillColorPrimaryBrush}"
Text="Windows Size" />
<StackPanel Orientation="Horizontal" Spacing="16">
<StackPanel Margin="0,-4,0,0"
Orientation="Horizontal"
Spacing="16">
<RadioButton Name="RadioButton_WindowSize_Normal"
Click="RadioButton_WindowSize_Click"
GroupName="WindowSize"
Expand Down Expand Up @@ -87,7 +87,7 @@
Text="{x:Bind lang:Lang.SettingPage_CloudFlareConnectProperly}"
TextWrapping="Wrap" />

<RadioButtons Margin="0,-8,0,0">
<RadioButtons Margin="0,-4,0,0">
<RadioButton Name="RadioButton_CF"
Click="RadioButton_CDN_Click"
Tag="cf">
Expand All @@ -105,6 +105,7 @@
</StackPanel>
</RadioButton>
<RadioButton Name="RadioButton_GH"
Margin="0,-4,0,0"
Click="RadioButton_CDN_Click"
Tag="gh">
<StackPanel Orientation="Horizontal">
Expand All @@ -121,6 +122,7 @@
</StackPanel>
</RadioButton>
<RadioButton Name="RadioButton_JD"
Margin="0,-8,0,0"
Click="RadioButton_CDN_Click"
Tag="jd">
<StackPanel Orientation="Horizontal">
Expand Down
34 changes: 20 additions & 14 deletions Starward/Pages/Welcome/SelectLanguagePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ public SelectLanguagePage()
this.InitializeComponent();
WelcomePage.Current.TextLanguage = null!;
CultureInfo.CurrentUICulture = CultureInfo.InstalledUICulture;
}





private async void Page_Loaded(object sender, RoutedEventArgs e)
{
await Task.Delay(16);
InitializeLanguageComboBox();
switch (AppConfig.ApiCDNIndex)
{
Expand All @@ -51,19 +60,12 @@ public SelectLanguagePage()
case 1: RadioButton_WindowSize_Small.IsChecked = true; break;
default: RadioButton_WindowSize_Normal.IsChecked = true; break;
}
}





private async void Page_Loaded(object sender, RoutedEventArgs e)
{
await Task.Delay(100);
TestCDNCommand.Execute(null);
}


private bool enableSelectionChanged = false;


private void InitializeLanguageComboBox()
{
Expand All @@ -75,7 +77,6 @@ private void InitializeLanguageComboBox()
Content = Lang.SettingPage_FollowSystem,
Tag = "",
});
ComboBox_Language.SelectedIndex = 0;
foreach (var (Title, LangCode) in Localization.LanguageList)
{
ComboBox_Language.Items.Add(new ComboBoxItem
Expand All @@ -84,8 +85,13 @@ private void InitializeLanguageComboBox()
Tag = LangCode,
});
}
ComboBox_Language.SelectedIndex = 0;
}
catch { }
finally
{
enableSelectionChanged = true;
}
}


Expand Down Expand Up @@ -150,7 +156,7 @@ private async Task TestCDNAsync()
}
catch (HttpRequestException)
{
TextBlock_TestCND_CF.Text = "Network Error";
TextBlock_TestCND_CF.Text = Lang.Common_NetworkError;
}
finally
{
Expand All @@ -167,7 +173,7 @@ private async Task TestCDNAsync()
}
catch (HttpRequestException)
{
TextBlock_TestCDN_GH.Text = "Network Error";
TextBlock_TestCDN_GH.Text = Lang.Common_NetworkError;
}
finally
{
Expand All @@ -184,7 +190,7 @@ private async Task TestCDNAsync()
}
catch (HttpRequestException)
{
TextBlock_TestCDN_JD.Text = "Network Error";
TextBlock_TestCDN_JD.Text = Lang.Common_NetworkError;
}
finally
{
Expand Down Expand Up @@ -225,7 +231,7 @@ private void ComboBox_Language_SelectionChanged(object sender, SelectionChangedE
{
if (ComboBox_Language.SelectedItem is ComboBoxItem item)
{
if (this.IsLoaded)
if (enableSelectionChanged)
{
var lang = item.Tag as string;
_logger.LogInformation("Language change to {lang}", lang);
Expand Down
1 change: 1 addition & 0 deletions Starward/Pages/Welcome/WelcomePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:Starward.Pages"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Loaded="Page_Loaded"
mc:Ignorable="d">

<Grid>
Expand Down
13 changes: 11 additions & 2 deletions Starward/Pages/Welcome/WelcomePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public WelcomePage()
Current = this;
this.InitializeComponent();
MainWindow.Current.ChangeAccentColor(null);
frame.Navigate(typeof(SelectDirectoryPage));
}


Expand All @@ -42,6 +41,16 @@ public WelcomePage(bool first)
Current = this;
this.InitializeComponent();
MainWindow.Current.ChangeAccentColor(null);
this.first = first;

}


bool first;


private void Page_Loaded(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
if (first)
{
frame.Navigate(typeof(SelectLanguagePage));
Expand All @@ -67,5 +76,5 @@ public void ApplySetting()
AppConfig.ApiCDNIndex = ApiCDNIndex;
}


}

0 comments on commit 192ec2b

Please sign in to comment.