-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathMainWindow.xaml.cs
More file actions
102 lines (91 loc) · 3.27 KB
/
MainWindow.xaml.cs
File metadata and controls
102 lines (91 loc) · 3.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Navigation;
using LinuxGate.Helpers;
using LinuxGate.Pages;
namespace LinuxGate
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
// Detect Windows language and set as default
string windowsLang = Localization.GetWindowsLanguageCode();
int langIndex = 0; // Default to English
switch (windowsLang)
{
case "en": langIndex = 0; break;
case "fr": langIndex = 1; break;
case "es": langIndex = 2; break;
case "ja": langIndex = 3; break;
}
LanguageComboBox.SelectedIndex = langIndex;
Localization.SetLanguage(windowsLang);
/*#if DEBUG
DebugPanel.Visibility = Visibility.Visible;
#endif*/
}
private void Button_Click(object sender, RoutedEventArgs e)
{
StateManager.ClearState("ChooseDistro"); // Clear state when starting fresh
NavigationHelper.NavigateWithAnimationInFrame(
MainFrame,
new ChooseDistro(),
TimeSpan.FromSeconds(0.3));
}
private void LanguageComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (LanguageComboBox.SelectedItem is ComboBoxItem item)
{
string cultureName = item.Tag.ToString();
Localization.SetLanguage(cultureName);
}
}
private void LanguageSelector_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (sender is ComboBox combo && combo.SelectedItem is ComboBoxItem item)
{
string lang = (string)item.Tag;
Localization.SetLanguage(lang);
}
}
private void DebugPageComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (DebugPageComboBox.SelectedItem is ComboBoxItem item)
{
string pageName = item.Tag.ToString();
Page targetPage = null;
switch (pageName)
{
case "ChooseDistro":
targetPage = new ChooseDistro();
break;
case "ResizeDisk":
targetPage = new ResizeDisk();
break;
case "AccountCreation":
targetPage = new AccountCreation();
break;
case "WarningConfirmation":
targetPage = new WarningConfirmation();
break;
case "ApplyChanges":
targetPage = new ApplyChanges();
break;
}
if (targetPage != null)
{
NavigationHelper.NavigateWithAnimationInFrame(
MainFrame,
targetPage,
TimeSpan.FromSeconds(0.3));
}
}
}
}
}