public MainWindow() { //System.Console.WriteLine("AAA"); if (Configuration.Languages["en"] != null) App.Instance.Resources.MergedDictionaries.Add(Configuration.Languages["en"].Resource); InitializeComponent(); Instance = this; ModAPI.Utils.WebService.OnDoLogin = ShowLoginLoader; ModAPI.Utils.WebService.OnLogin = ShowLoginUser; ModAPI.Utils.WebService.OnLoginError = ShowLoginError; ModAPI.Utils.WebService.OnLogout = ShowLogin; ModAPI.Utils.WebService.Initialize(); foreach (string LangCode in Languages) { ComboBoxItem newItem = new ComboBoxItem(); newItem.Style = Application.Current.FindResource("ComboBoxItem") as Style; newItem.DataContext = LangCode; LanguageItems.Add(LangCode, newItem); StackPanel panel = new StackPanel(); panel.Orientation = Orientation.Horizontal; Image image = new Image(); image.Height = 20; BitmapImage source = new BitmapImage(); source.BeginInit(); source.UriSource = new Uri("pack://application:,,,/ModAPI;component/resources/textures/Icons/Lang_"+LangCode+".png"); source.EndInit(); image.Source = source; image.Margin = new Thickness(0,0,5,0); panel.Children.Add(image); TextBlock label = new TextBlock(); label.SetResourceReference(TextBlock.TextProperty, "Lang.Languages." + LangCode); panel.Children.Add(label); newItem.Content = panel; DevelopmentLanguageSelector.Items.Add(newItem); } FirstSetup = Configuration.GetString("SetupDone").ToLower() != "true"; if (FirstSetup) { ModAPI.Windows.SubWindows.FirstSetup win = new ModAPI.Windows.SubWindows.FirstSetup("Lang.Windows.FirstSetup"); win.ShowSubWindow(); win.Show(); } else { FirstSetupDone(); } Configuration.OnLanguageChanged += LanguageChanged; foreach (Configuration.Language language in Configuration.Languages.Values) { AddLanguage(language); } SettingsVM = new SettingsViewModel(); Settings.DataContext = SettingsVM; //LanguageSelector.SelectedIndex = Configuration.Languages.Values.ToList().IndexOf(Configuration.CurrentLanguage); foreach (GUIConfiguration.Tab tab in GUIConfiguration.Tabs) { IconTabItem newTab = new IconTabItem(); Style style = App.Instance.Resources["TopTab"] as Style; newTab.Style = style; try { BitmapImage image = new BitmapImage(); image.BeginInit(); image.UriSource = new Uri("pack://application:,,,/ModAPI;component/resources/textures/Icons/" + tab.IconName); image.EndInit(); newTab.IconSource = image; } catch (Exception e) { Debug.Log("MainWindow", "Couldn't find the icon \""+tab.IconName+"\".", Debug.Type.WARNING); } try { BitmapImage imageSelected = new BitmapImage(); imageSelected.BeginInit(); imageSelected.UriSource = new Uri("pack://application:,,,/ModAPI;component/resources/textures/Icons/" + tab.IconSelectedName); imageSelected.EndInit(); newTab.SelectedIconSource = imageSelected; } catch (Exception e) { Debug.Log("MainWindow", "Couldn't find the icon \"" + tab.IconSelectedName + "\".", Debug.Type.WARNING); } newTab.SetResourceReference(IconTabItem.LabelProperty, tab.LangPath + ".Tab"); IPanel newPanel = (IPanel)Activator.CreateInstance(tab.ComponentType); newTab.Content = newPanel; Debug.Log("MainWindow", "Added tab of type \"" + tab.TypeName + "\"."); newPanel.SetTab(tab); Panels.Add(newPanel); Tabs.Items.Add(newTab); } Timer = new DispatcherTimer(); Timer.Tick += new EventHandler(GUITick); Timer.Interval = new TimeSpan((long) (GUIDeltaTime * 10000000)); Timer.Start(); LanguageChanged(); SettingsVM.Changed(); }
public MainWindow() { //System.Console.WriteLine("AAA"); if (Configuration.Languages["en"] != null) { App.Instance.Resources.MergedDictionaries.Add(Configuration.Languages["en"].Resource); } InitializeComponent(); Instance = this; ModAPI.Utils.WebService.OnDoLogin = ShowLoginLoader; ModAPI.Utils.WebService.OnLogin = ShowLoginUser; ModAPI.Utils.WebService.OnLoginError = ShowLoginError; ModAPI.Utils.WebService.OnLogout = ShowLogin; ModAPI.Utils.WebService.Initialize(); foreach (string LangCode in Languages) { ComboBoxItem newItem = new ComboBoxItem(); newItem.Style = Application.Current.FindResource("ComboBoxItem") as Style; newItem.DataContext = LangCode; LanguageItems.Add(LangCode, newItem); StackPanel panel = new StackPanel(); panel.Orientation = Orientation.Horizontal; Image image = new Image(); image.Height = 20; BitmapImage source = new BitmapImage(); source.BeginInit(); source.UriSource = new Uri("pack://application:,,,/ModAPI;component/resources/textures/Icons/Lang_" + LangCode + ".png"); source.EndInit(); image.Source = source; image.Margin = new Thickness(0, 0, 5, 0); panel.Children.Add(image); TextBlock label = new TextBlock(); label.FontSize = 16; label.SetResourceReference(TextBlock.TextProperty, "Lang.Languages." + LangCode); panel.Children.Add(label); newItem.Content = panel; DevelopmentLanguageSelector.Items.Add(newItem); } FirstSetup = Configuration.GetString("SetupDone").ToLower() != "true"; if (FirstSetup) { ModAPI.Windows.SubWindows.FirstSetup win = new ModAPI.Windows.SubWindows.FirstSetup("Lang.Windows.FirstSetup"); win.ShowSubWindow(); win.Show(); } else { FirstSetupDone(); } Configuration.OnLanguageChanged += LanguageChanged; foreach (Configuration.Language language in Configuration.Languages.Values) { AddLanguage(language); } SettingsVM = new SettingsViewModel(); Settings.DataContext = SettingsVM; //LanguageSelector.SelectedIndex = Configuration.Languages.Values.ToList().IndexOf(Configuration.CurrentLanguage); foreach (GUIConfiguration.Tab tab in GUIConfiguration.Tabs) { IconTabItem newTab = new IconTabItem(); Style style = App.Instance.Resources["TopTab"] as Style; newTab.Style = style; try { BitmapImage image = new BitmapImage(); image.BeginInit(); image.UriSource = new Uri("pack://application:,,,/ModAPI;component/resources/textures/Icons/" + tab.IconName); image.EndInit(); newTab.IconSource = image; } catch (Exception e) { Debug.Log("MainWindow", "Couldn't find the icon \"" + tab.IconName + "\".", Debug.Type.WARNING); } try { BitmapImage imageSelected = new BitmapImage(); imageSelected.BeginInit(); imageSelected.UriSource = new Uri("pack://application:,,,/ModAPI;component/resources/textures/Icons/" + tab.IconSelectedName); imageSelected.EndInit(); newTab.SelectedIconSource = imageSelected; } catch (Exception e) { Debug.Log("MainWindow", "Couldn't find the icon \"" + tab.IconSelectedName + "\".", Debug.Type.WARNING); } newTab.SetResourceReference(IconTabItem.LabelProperty, tab.LangPath + ".Tab"); IPanel newPanel = (IPanel)Activator.CreateInstance(tab.ComponentType); newTab.Content = newPanel; Debug.Log("MainWindow", "Added tab of type \"" + tab.TypeName + "\"."); newPanel.SetTab(tab); Panels.Add(newPanel); Tabs.Items.Add(newTab); } Timer = new DispatcherTimer(); Timer.Tick += new EventHandler(GUITick); Timer.Interval = new TimeSpan((long)(GUIDeltaTime * 10000000)); Timer.Start(); LanguageChanged(); SettingsVM.Changed(); }