SettingsDialog.xaml.cs 3.1 KB

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