private void SettingsButton_Click(object sender, RoutedEventArgs e) { KeyLayout.SaveKeyLayout(CurrentKeyLayout); var settingsWindow = new SettingsWindow(); settingsWindow.ShowDialog(); if (settingsWindow.KeyLayoutUpdated || settingsWindow.KeyLayoutDataDirUpdated) { CurrentKeyLayout = settingsWindow.SelectedKeyLayout; KeyPracticeMenu.KeyLayoutBox.LoadKeyLayout(); var currentKeyLayoutNameBinding = new Binding { Path = new PropertyPath("Name"), Source = CurrentKeyLayout, }; HomeMenu.CurrentKeyLayoutName.SetBinding(TextBlock.TextProperty, currentKeyLayoutNameBinding); var currentKeyLayoutCharBinding = new Binding { Path = new PropertyPath("Character"), Source = CurrentKeyLayout, }; HomeMenu.CurrentKeyLayoutChar.SetBinding(TextBlock.TextProperty, currentKeyLayoutCharBinding); var mostIncorrectBinding = new Binding { Path = new PropertyPath("Stats.MostIncorrect.Key"), Source = CurrentKeyLayout, Converter = new KeyPosToKeyConverter() }; HomeMenu.MostIncorrectKey.SetBinding(KeyBox.KeyProperty, mostIncorrectBinding); var averageSpeedBinding = new Binding { Path = new PropertyPath("Stats.AverageTypingSpeed"), Source = CurrentKeyLayout, }; HomeMenu.AverageTypingSpeed.SetBinding(TextBlock.TextProperty, averageSpeedBinding); var averageAccuracyBinding = new Binding { Path = new PropertyPath("Stats.AverageAccuracy"), Source = CurrentKeyLayout, StringFormat = "{0}%" }; HomeMenu.AverageAccuracy.SetBinding(TextBlock.TextProperty, averageAccuracyBinding); var sentencePracticeCountBinding = new Binding { Path = new PropertyPath("Stats.SentencePracticeCount"), Source = CurrentKeyLayout, }; HomeMenu.SentencePracticeCount.SetBinding(TextBlock.TextProperty, sentencePracticeCountBinding); CheckSyllablePractice(); } SentencePracticeMenu.LoadData(); ArticlePracticeMenu.LoadData(); }
private static void MainWindow_Closed(object sender, EventArgs e) { KeyLayout.SaveKeyLayout(CurrentKeyLayout); Settings.Default.Save(); }