FreetextAnnotProperty.xaml.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. private FreetextAnnotPropertyViewModel ViewModel => DataContext as FreetextAnnotPropertyViewModel;
  26. public FreetextAnnotProperty()
  27. {
  28. InitializeComponent();
  29. this.Loaded += usercontrol_Loaded;
  30. this.Unloaded += usercontrol_Unloaded;
  31. }
  32. private void usercontrol_Loaded(object sender, RoutedEventArgs e)
  33. {
  34. //FontFamilyBox.SelectedIndex = 0;
  35. //FontStyleBox.SelectedIndex = 0;
  36. //FontSizeBox.SelectedIndex = 0;
  37. //ThicknessBox.SelectedIndex = 0;
  38. BindingEvent();
  39. if(ViewModel != null && string.IsNullOrEmpty(ViewModel.BasicVm.strDashStyle) == false)
  40. {
  41. var str = ViewModel.BasicVm.strDashStyle;
  42. if (str == "AlignLeft")
  43. {
  44. TextAlignLeftBtn.IsChecked = true;
  45. }
  46. else if(str == "AlignCenter")
  47. {
  48. TextAlignCenterBtn.IsChecked = true;
  49. }
  50. else if (str == "AlignRight")
  51. {
  52. TextAlignRightBtn.IsChecked = true;
  53. }
  54. else if (str == "AlignJustify")
  55. {
  56. TextAlignBtn.IsChecked = true;
  57. }
  58. else
  59. {
  60. TextAlignLeftBtn.IsChecked = false;
  61. TextAlignCenterBtn.IsChecked = false;
  62. TextAlignRightBtn.IsChecked = false;
  63. TextAlignBtn.IsChecked = false;
  64. }
  65. }
  66. }
  67. private void usercontrol_Unloaded(object sender, RoutedEventArgs e)
  68. {
  69. UnBindingEvent();
  70. }
  71. private void BindingEvent()
  72. {
  73. UnBindingEvent();
  74. //ThicknessBox.SelectionChanged += ThicknessBox_SelectionChanged;
  75. }
  76. private void UnBindingEvent()
  77. {
  78. // ThicknessBox.SelectionChanged -= ThicknessBox_SelectionChanged;
  79. }
  80. private void ThicknessBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
  81. {
  82. var listItem = ThicknessBox.ItemContainerGenerator.ContainerFromItem(ThicknessBox.SelectedItem) as ComboBoxItem;
  83. if (listItem != null)
  84. ThicknessText.Text = listItem.Content.ToString();
  85. else
  86. ThicknessText.Text = "1";
  87. }
  88. }
  89. }