Skip to content

Commit 80e26f3

Browse files
committed
🎨 rewrote i18n init, onload cfg, lang select fix
1 parent 47fee06 commit 80e26f3

18 files changed

+315
-66
lines changed

Biyori/App.xaml.cs

+8-5
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,20 @@ public partial class App : Application
2121
public static readonly ServiceProviderCollector ServiceProvider = new ServiceProviderCollector();
2222
public App() : base()
2323
{
24-
App.ServiceProvider.ScanCurrent();
2524
}
2625
protected override void OnStartup(StartupEventArgs e)
2726
{
2827
base.OnStartup(e);
29-
30-
28+
var wnd = new LoadingWindow();
29+
wnd.Show();
3130
var languageInstance = Lib.Languages.Languages.Instance();
3231
languageInstance.Initialize();
33-
Debug.WriteLine("Currently active Language: " + App.ServiceProvider.GetProvider<SettingsProviderService>()?.GetConfig<ApplicationSettings>()?.SelectedLanguage.DisplayName);
34-
new LoadingWIndow().Show();
32+
App.ServiceProvider.ScanCurrent();
33+
var settingsProvider = App.ServiceProvider.GetProvider<SettingsProviderService>();
34+
Debug.WriteLine("Currently active Language: " + settingsProvider?.GetConfig<ApplicationSettings>()?.SelectedLanguage.DisplayName);
35+
wnd.Hide();
36+
new MainWindow().Show();
37+
wnd.Close();
3538
}
3639

3740
}

Biyori/Biyori.csproj

+21
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@
6363
<Reference Include="JetBrains.Annotations, Version=2019.1.1.0, Culture=neutral, PublicKeyToken=1010a0d8d6380325, processorArchitecture=MSIL">
6464
<HintPath>..\packages\JetBrains.Annotations.2019.1.1\lib\net20\JetBrains.Annotations.dll</HintPath>
6565
</Reference>
66+
<Reference Include="MaterialDesignColors, Version=1.2.0.1418, Culture=neutral, processorArchitecture=MSIL">
67+
<HintPath>..\packages\MaterialDesignColors.1.2.0-ci1418\lib\net45\MaterialDesignColors.dll</HintPath>
68+
</Reference>
69+
<Reference Include="MaterialDesignThemes.Wpf, Version=1.0.1.0, Culture=neutral, processorArchitecture=MSIL">
70+
<HintPath>..\packages\MaterialDesignThemes.3.0.0-ci470\lib\net45\MaterialDesignThemes.Wpf.dll</HintPath>
71+
</Reference>
6672
<Reference Include="Microsoft.Extensions.Caching.Abstractions, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
6773
<HintPath>..\packages\Microsoft.Extensions.Caching.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Caching.Abstractions.dll</HintPath>
6874
</Reference>
@@ -102,6 +108,9 @@
102108
<Reference Include="RestSharp, Version=106.6.10.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL">
103109
<HintPath>..\packages\RestSharp.106.6.10\lib\net452\RestSharp.dll</HintPath>
104110
</Reference>
111+
<Reference Include="ShowMeTheXAML, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
112+
<HintPath>..\packages\ShowMeTheXAML.1.0.12\lib\net45\ShowMeTheXAML.dll</HintPath>
113+
</Reference>
105114
<Reference Include="System" />
106115
<Reference Include="System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
107116
<HintPath>..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll</HintPath>
@@ -207,13 +216,17 @@
207216
<Compile Include="Components\LeftNavigation\LeftNavigationControl.xaml.cs">
208217
<DependentUpon>LeftNavigationControl.xaml</DependentUpon>
209218
</Compile>
219+
<Compile Include="Components\LoadingIndicators\CircleLoading\ActivityLoader.xaml.cs">
220+
<DependentUpon>ActivityLoader.xaml</DependentUpon>
221+
</Compile>
210222
<Compile Include="Components\Loading\LoadingWIndow.xaml.cs">
211223
<DependentUpon>LoadingWIndow.xaml</DependentUpon>
212224
</Compile>
213225
<Compile Include="Lib\Controls\CardControl.cs" />
214226
<Compile Include="Lib\Languages\Languages.xaml.cs">
215227
<DependentUpon>Languages.xaml</DependentUpon>
216228
</Compile>
229+
<Compile Include="Lib\Styles\Styles.cs" />
217230
<Compile Include="Lib\Util\Object.Extensions.cs" />
218231
<Compile Include="Lib\WPF\MarginSetter.cs" />
219232
<Compile Include="Lib\WPF\Spacing.cs" />
@@ -396,6 +409,10 @@
396409
<SubType>Designer</SubType>
397410
<Generator>MSBuild:Compile</Generator>
398411
</Page>
412+
<Page Include="Components\LoadingIndicators\CircleLoading\ActivityLoader.xaml">
413+
<SubType>Designer</SubType>
414+
<Generator>MSBuild:Compile</Generator>
415+
</Page>
399416
<Page Include="Components\Loading\LoadingWIndow.xaml">
400417
<SubType>Designer</SubType>
401418
<Generator>MSBuild:Compile</Generator>
@@ -428,6 +445,10 @@
428445
<SubType>Designer</SubType>
429446
<Generator>MSBuild:Compile</Generator>
430447
</Page>
448+
<Page Include="Lib\Styles\Progress.styles.xaml">
449+
<SubType>Designer</SubType>
450+
<Generator>MSBuild:Compile</Generator>
451+
</Page>
431452
<Page Include="Lib\Styles\TabControl.styles.xaml">
432453
<SubType>Designer</SubType>
433454
<Generator>MSBuild:Compile</Generator>

Biyori/Components/Loading/LoadingWIndow.xaml

+14-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Window x:Class="Biyori.Components.Loading.LoadingWIndow"
1+
<Window x:Class="Biyori.Components.Loading.LoadingWindow"
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
@@ -9,9 +9,13 @@
99
AllowsTransparency="True"
1010
Background="Transparent"
1111
WindowStartupLocation="CenterScreen"
12+
ResizeMode="NoResize"
1213
Title="Loading Biyori..." Height="420" Width="680">
1314
<Grid Margin="18" PreviewMouseDown="Grid_PreviewMouseDown">
14-
<Border BorderThickness="1" BorderBrush="#ddd" Background="#fff" CornerRadius="8">
15+
<Button Name="closeButton" Click="CloseButton_Click" Style="{StaticResource NavButtons}" Panel.ZIndex="9" HorizontalAlignment="Right" Padding="5,4" VerticalAlignment="Top" Margin="8">
16+
<ContentControl VerticalAlignment="Center" Content="{StaticResource closeIcon}" />
17+
</Button>
18+
<Border BorderThickness="1" BorderBrush="#ddd" Background="#fff" CornerRadius="6">
1519
<Border.Effect>
1620
<DropShadowEffect BlurRadius="12" ShadowDepth="0" Direction="0" Color="#000" Opacity=".55" />
1721
</Border.Effect>
@@ -25,11 +29,15 @@
2529
<StackPanel Grid.Row="0" Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center">
2630
<Image
2731
RenderOptions.BitmapScalingMode="HighQuality"
28-
VerticalAlignment="Center" Height="260" HorizontalAlignment="Center" Margin="0,0,16,0" Source="pack://application:,,,/Assets/Logo/appIcon.png"/>
32+
VerticalAlignment="Center" Height="260" HorizontalAlignment="Center" Margin="0,0,16,0" Source="pack://application:,,,/Assets/Logo/appIcon.png">
33+
<Image.Effect>
34+
<DropShadowEffect ShadowDepth="0" BlurRadius="32" Opacity=".25"></DropShadowEffect>
35+
</Image.Effect>
36+
</Image>
2937
<StackPanel Orientation="Vertical" VerticalAlignment="Center" Width="200">
3038
<TextBlock Text="Biyori" HorizontalAlignment="Center" FontSize="32" Opacity=".8" />
31-
<Separator Width="86" Margin="0, 12" Opacity=".5" />
32-
<TextBlock Text="Loading" HorizontalAlignment="Center" Opacity=".8" />
39+
<Separator Width="82" Margin="16, 6" Opacity=".5"/>
40+
<TextBlock FontSize="12" Opacity=".8" Text="Loading..." HorizontalAlignment="Center"/>
3341
</StackPanel>
3442
</StackPanel>
3543
<Separator Grid.Row="1" VerticalAlignment="Top" Margin="20,0" Opacity=".5" />
@@ -40,7 +48,7 @@
4048
<ColumnDefinition Width="Auto"/>
4149
</Grid.ColumnDefinitions>
4250
<StackPanel Grid.Column="0" Orientation="Horizontal">
43-
<TextBlock Text="Loading Status" VerticalAlignment="Center"/>
51+
<ProgressBar Height="8" Width="80" Margin="0, 10" IsIndeterminate="False" Value="100" />
4452
</StackPanel>
4553
<StackPanel Grid.Column="2" Orientation="Horizontal">
4654
<TextBlock Text="{DynamicResource Name}" VerticalAlignment="Center"/>

Biyori/Components/Loading/LoadingWIndow.xaml.cs

+7-13
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,26 @@ namespace Biyori.Components.Loading
1818
/// <summary>
1919
/// Interaction logic for LoadingWIndow.xaml
2020
/// </summary>
21-
public partial class LoadingWIndow : Window
21+
public partial class LoadingWindow : Window
2222
{
23-
public LoadingWIndow()
23+
public LoadingWindow()
2424
{
2525
InitializeComponent();
2626
}
2727
protected override void OnInitialized(EventArgs e)
2828
{
2929
base.OnInitialized(e);
3030

31-
//var languageInstance = Lib.Languages.Languages.Instance();
32-
//languageInstance.Initialize();
33-
34-
Dispatcher.BeginInvoke((Action)(() =>
35-
{
36-
// For now just waiting
37-
Task.Delay(1000).Wait();
38-
this.Hide();
39-
new MainWindow().Show();
40-
this.Close();
41-
}));
4231
}
4332
private void Grid_PreviewMouseDown(object sender, MouseButtonEventArgs e)
4433
{
4534
if (e.ChangedButton == MouseButton.Left)
4635
this.DragMove();
4736
}
37+
38+
private void CloseButton_Click(object sender, RoutedEventArgs e)
39+
{
40+
Application.Current.Shutdown();
41+
}
4842
}
4943
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<UserControl x:Class="Biyori.Components.LoadingIndicators.CircleLoading.ActivityLoader"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:local="clr-namespace:Biyori.Components.LoadingIndicators.CircleLoading"
7+
mc:Ignorable="d"
8+
d:DesignHeight="450" d:DesignWidth="800">
9+
10+
</UserControl>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Windows;
7+
using System.Windows.Controls;
8+
using System.Windows.Data;
9+
using System.Windows.Documents;
10+
using System.Windows.Input;
11+
using System.Windows.Media;
12+
using System.Windows.Media.Imaging;
13+
using System.Windows.Navigation;
14+
using System.Windows.Shapes;
15+
16+
namespace Biyori.Components.LoadingIndicators.CircleLoading
17+
{
18+
/// <summary>
19+
/// Interaction logic for ActivityLoader.xaml
20+
/// </summary>
21+
public partial class ActivityLoader : UserControl
22+
{
23+
public ActivityLoader()
24+
{
25+
InitializeComponent();
26+
}
27+
}
28+
}

Biyori/Lib/Languages/Languages.xaml.cs

+12-16
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ namespace Biyori.Lib.Languages
1414
public partial class Languages : ResourceDictionary
1515
{
1616
public static ApplicationLanguage DefaultAppLanguage { get; set; }
17+
public static List<ApplicationLanguage> AvailableLanguages { get; private set; }
1718
public Languages()
1819
{
1920
}
@@ -23,22 +24,17 @@ public static Languages Instance()
2324
}
2425
public void Initialize()
2526
{
26-
var provider = App.ServiceProvider.GetProvider<SettingsProviderService>();
27-
var appConfig = provider.GetConfig<ApplicationSettings>();
28-
var selectedLanguageResource = appConfig?.SelectedLanguage?.Name != null &&
29-
this.MergedDictionaries.Where(x => x.Contains("LangKey") && x["LangKey"].ToString() == appConfig.SelectedLanguage.Name).Count() > 0 ?
30-
this.getLanguageResource(appConfig.SelectedLanguage.Name) :
31-
this.getLanguageResource("en-us");
32-
var selectedLanguage = new ApplicationLanguage()
33-
{
34-
ImageUrl = selectedLanguageResource["ImageUrl"]?.ToString(),
35-
DisplayName = selectedLanguageResource["DisplayName"]?.ToString(),
36-
Name = selectedLanguageResource["LangKey"]?.ToString(),
37-
};
38-
appConfig.Languages.AddRange(this.getLanguages());
39-
provider.UpdateConfig(appConfig, true);
27+
Languages.AvailableLanguages = this.getLanguages().ToList();
28+
Languages.DefaultAppLanguage = Languages.AvailableLanguages.FirstOrDefault(x => x.Name == "en-us");
29+
this.setLanguage(Languages.DefaultAppLanguage);
30+
31+
}
32+
public void setLanguage(ApplicationLanguage selectedLanguage)
33+
{
34+
var items = this.MergedDictionaries.ToList();
4035
this.MergedDictionaries.Clear();
41-
this.MergedDictionaries.Add(selectedLanguageResource);
36+
items.Where(x => x["LangKey"]?.ToString() != selectedLanguage.Name).ToList().ForEach(x => this.MergedDictionaries.Add(x));
37+
this.MergedDictionaries.Add(items.FirstOrDefault(x => x["LangKey"]?.ToString() == selectedLanguage.Name));
4238
}
4339

4440
private ApplicationLanguage getDefaultLanguage()
@@ -54,7 +50,7 @@ private ApplicationLanguage getLanguageByLangKey(string langKey)
5450
var lang = new ApplicationLanguage()
5551
{
5652
ImageUrl = resource["ImageUrl"]?.ToString(),
57-
DisplayName = resource["DisplayName"]?.ToString(),
53+
DisplayName = resource["Name"]?.ToString(),
5854
Name = resource["LangKey"]?.ToString(),
5955
};
6056
return lang;

Biyori/Lib/Styles/App.styles.xaml

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<Setter Property="TextOptions.TextHintingMode" Value="Auto" />
2222
</Style>
2323
<ResourceDictionary.MergedDictionaries>
24+
<ResourceDictionary Source="pack://application:,,,/Lib/Styles/Progress.styles.xaml" />
2425
<ResourceDictionary Source="pack://application:,,,/Lib/Styles/Icons.xaml" />
2526
<ResourceDictionary Source="pack://application:,,,/Lib/Styles/Buttons.styles.xaml" />
2627
<ResourceDictionary Source="pack://application:,,,/Lib/Styles/TabControl.styles.xaml" />

Biyori/Lib/Styles/Icons.xaml

+17
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,21 @@
5656
</Rectangle.Fill>
5757
</Rectangle>
5858
</Viewbox>
59+
<Viewbox Width="16" Height="16" x:Key="closeIcon">
60+
<Rectangle Width="16" Height="16">
61+
<Rectangle.Fill>
62+
<DrawingBrush>
63+
<DrawingBrush.Drawing>
64+
<DrawingGroup>
65+
<DrawingGroup.Children>
66+
<GeometryDrawing Brush="#00FFFFFF" Geometry="F1M16,16L0,16 0,0 16,0z" />
67+
<GeometryDrawing Brush="#FFF6F6F6" Geometry="F1M8.0001,5.1721L3.4571,0.6291 0.629099999999999,3.4571 5.1721,8.0001 0.629099999999999,12.5431 3.4571,15.3711 8.0001,10.8281 12.5431,15.3711 15.3711,12.5431 10.8281,8.0001 15.3711,3.4571 12.5431,0.6291z" />
68+
<GeometryDrawing Brush="#FF424242" Geometry="F1M9.4141,8L13.9571,12.543 12.5431,13.957 8.0001,9.414 3.4571,13.957 2.0431,12.543 6.5861,8 2.0431,3.457 3.4571,2.043 8.0001,6.586 12.5431,2.043 13.9571,3.457z" />
69+
</DrawingGroup.Children>
70+
</DrawingGroup>
71+
</DrawingBrush.Drawing>
72+
</DrawingBrush>
73+
</Rectangle.Fill>
74+
</Rectangle>
75+
</Viewbox>
5976
</ResourceDictionary>

0 commit comments

Comments
 (0)