FreetextAnnotProperty.xaml.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using PDF_Office.CustomControl;
  2. using PDF_Office.ViewModels.PropertyPanel.AnnotPanel;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows;
  9. using System.Windows.Controls;
  10. using System.Windows.Controls.Primitives;
  11. using System.Windows.Data;
  12. using System.Windows.Documents;
  13. using System.Windows.Input;
  14. using System.Windows.Media;
  15. using System.Windows.Media.Imaging;
  16. using System.Windows.Navigation;
  17. using System.Windows.Shapes;
  18. namespace PDF_Office.Views.PropertyPanel.AnnotPanel
  19. {
  20. /// <summary>
  21. /// FreetextAnnotProperty.xaml 的交互逻辑
  22. /// </summary>
  23. public partial class FreetextAnnotProperty : UserControl
  24. {
  25. public FreetextAnnotProperty()
  26. {
  27. InitializeComponent();
  28. this.Loaded += usercontrol_Loaded;
  29. this.Unloaded += usercontrol_Unloaded;
  30. }
  31. private void usercontrol_Loaded(object sender, RoutedEventArgs e)
  32. {
  33. FontFamilyBox.SelectedIndex = 0;
  34. FontStyleBox.SelectedIndex = 0;
  35. FontSizeBox.SelectedIndex = 0;
  36. ThicknessBox.SelectedIndex = 0;
  37. BindingEvent();
  38. }
  39. private void usercontrol_Unloaded(object sender, RoutedEventArgs e)
  40. {
  41. UnBindingEvent();
  42. }
  43. private void BindingEvent()
  44. {
  45. UnBindingEvent();
  46. ThicknessBox.SelectionChanged += ThicknessBox_SelectionChanged;
  47. }
  48. private void UnBindingEvent()
  49. {
  50. ThicknessBox.SelectionChanged -= ThicknessBox_SelectionChanged;
  51. }
  52. private void ThicknessBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
  53. {
  54. var listItem = ThicknessBox.ItemContainerGenerator.ContainerFromItem(ThicknessBox.SelectedItem) as ComboBoxItem;
  55. if (listItem != null)
  56. ThicknessText.Text = listItem.Content.ToString();
  57. else
  58. ThicknessText.Text = "1";
  59. }
  60. }
  61. }