SettingsDialog.xaml.cs 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. using System;
  2. using System.ComponentModel;
  3. using System.Diagnostics;
  4. using System.Windows;
  5. using System.Windows.Controls;
  6. using Compdfkit_Tools.Helper;
  7. namespace PDFViewer
  8. {
  9. /// <summary>
  10. /// Interaction logic for SettingsDialog.xaml
  11. /// </summary>
  12. public partial class SettingsDialog : Window
  13. {
  14. public event EventHandler<string> LanguageChanged;
  15. public SettingsDialog()
  16. {
  17. InitializeComponent();
  18. Closing += MainWindow_Closing;
  19. Title = App.MainResourceManager.GetString("Title_Settings");
  20. }
  21. private void MainWindow_Closing(object sender, CancelEventArgs e)
  22. {
  23. Properties.Settings.Default.Save();
  24. Compdfkit_Tools.Data.CPDFAnnotationData.Author = Properties.Settings.Default.DocumentAuthor;
  25. }
  26. private void EventSetter_ClickHandler(object sender, RoutedEventArgs e)
  27. {
  28. var webLocation = (sender as Button)?.Tag.ToString();
  29. if (!string.IsNullOrEmpty(webLocation))
  30. {
  31. Process.Start(webLocation);
  32. }
  33. }
  34. private void SettingsDialog_Loaded(object sender, RoutedEventArgs e)
  35. {
  36. HighlightFormTog.IsChecked = Properties.Settings.Default.IsHighlightFormArea;
  37. HighlightLinkTog.IsChecked = Properties.Settings.Default.IsHighlightLinkArea;
  38. AuthorTxb.Text = Properties.Settings.Default.DocumentAuthor;
  39. foreach (ComboBoxItem item in LanguageCmb.Items)
  40. {
  41. if (item.Content.ToString() == App.CurrentLanguage)
  42. {
  43. item.IsSelected = true;
  44. }
  45. }
  46. }
  47. private void AuthorTxb_TextChanged(object sender, TextChangedEventArgs e)
  48. {
  49. Properties.Settings.Default.DocumentAuthor = AuthorTxb.Text;
  50. }
  51. private void HighlightLinkTog_Click(object sender, RoutedEventArgs e)
  52. {
  53. if (HighlightLinkTog.IsChecked != null)
  54. Properties.Settings.Default.IsHighlightLinkArea = HighlightLinkTog.IsChecked.Value;
  55. }
  56. private void HighlightFormTog_Click(object sender, RoutedEventArgs e)
  57. {
  58. if (HighlightFormTog.IsChecked != null)
  59. Properties.Settings.Default.IsHighlightFormArea = HighlightFormTog.IsChecked.Value;
  60. }
  61. private void LanguageCmb_SelectionChanged(object sender, SelectionChangedEventArgs e)
  62. {
  63. string language = ((ComboBoxItem)LanguageCmb.SelectedItem).Content.ToString();
  64. if (language.Equals(App.CurrentLanguage))
  65. {
  66. return;
  67. }
  68. MessageBoxResult result = MessageBox.Show(App.MainResourceManager.GetString("Tip_Restart"),
  69. App.MainResourceManager.GetString("Tip_RestartTitle"),
  70. MessageBoxButton.YesNo,
  71. MessageBoxImage.Question);
  72. if (result == MessageBoxResult.Yes)
  73. {
  74. Properties.Settings.Default.Language = language;
  75. Properties.Settings.Default.Save();
  76. LanguageChanged?.Invoke(this, language);
  77. }
  78. else
  79. {
  80. LanguageCmb.SelectedIndex = 0;
  81. }
  82. }
  83. }
  84. }