SettingsDialog.xaml.cs 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. SelectCurrentLanguage();
  40. }
  41. private void SelectCurrentLanguage()
  42. {
  43. foreach (ComboBoxItem item in LanguageCmb.Items)
  44. {
  45. if (item.Tag.ToString() == App.CurrentCulture)
  46. {
  47. item.IsSelected = true;
  48. }
  49. }
  50. }
  51. private void AuthorTxb_TextChanged(object sender, TextChangedEventArgs e)
  52. {
  53. Properties.Settings.Default.DocumentAuthor = AuthorTxb.Text;
  54. }
  55. private void HighlightLinkTog_Click(object sender, RoutedEventArgs e)
  56. {
  57. if (HighlightLinkTog.IsChecked != null)
  58. Properties.Settings.Default.IsHighlightLinkArea = HighlightLinkTog.IsChecked.Value;
  59. }
  60. private void HighlightFormTog_Click(object sender, RoutedEventArgs e)
  61. {
  62. if (HighlightFormTog.IsChecked != null)
  63. Properties.Settings.Default.IsHighlightFormArea = HighlightFormTog.IsChecked.Value;
  64. }
  65. private void LanguageCmb_SelectionChanged(object sender, SelectionChangedEventArgs e)
  66. {
  67. string language = ((ComboBoxItem)LanguageCmb.SelectedItem).Tag.ToString();
  68. if (language.Equals(App.CurrentCulture))
  69. {
  70. return;
  71. }
  72. MessageBoxResult result = MessageBox.Show(App.MainResourceManager.GetString("Tip_Restart"),
  73. App.MainResourceManager.GetString("Tip_RestartTitle"),
  74. MessageBoxButton.YesNo,
  75. MessageBoxImage.Question);
  76. if (result == MessageBoxResult.Yes)
  77. {
  78. Properties.Settings.Default.Cultrue = language;
  79. Properties.Settings.Default.Save();
  80. LanguageChanged?.Invoke(this, language);
  81. }
  82. else
  83. {
  84. SelectCurrentLanguage();
  85. }
  86. }
  87. }
  88. }