TextEditProperty.xaml.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. using PDF_Master.ViewModels.PropertyPanel;
  2. using PDF_Master.ViewModels.PropertyPanel.PDFEdit;
  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.Data;
  11. using System.Windows.Documents;
  12. using System.Windows.Input;
  13. using System.Windows.Media;
  14. using System.Windows.Media.Imaging;
  15. using System.Windows.Navigation;
  16. using System.Windows.Shapes;
  17. namespace PDF_Master.Views.PropertyPanel.PDFEdit
  18. {
  19. /// <summary>
  20. /// TextEditProperty.xaml 的交互逻辑
  21. /// </summary>
  22. public partial class TextEditProperty : UserControl
  23. {
  24. public TextEditPropertyViewModel ViewModel => DataContext as TextEditPropertyViewModel;
  25. public TextEditProperty()
  26. {
  27. InitializeComponent();
  28. }
  29. private void UserControl_Loaded(object sender, RoutedEventArgs e)
  30. {
  31. InitEventHandler();
  32. //不需要在cs中初始化
  33. //InitVariable();
  34. }
  35. private void InitEventHandler()
  36. {
  37. //FontFamilyBox.SelectionChanged -= FontFamilyBox_SelectionChanged;
  38. //FontStyleBox.SelectionChanged -= FontStyleBox_SelectionChanged;
  39. //FontSizeBox.SelectionChanged -= FontSizeBox_SelectionChanged;
  40. //FontColorBox.SelectedColorHandler -= FontColorBox_SelectedColorHandler;
  41. //FontFamilyBox.SelectionChanged += FontFamilyBox_SelectionChanged;
  42. //FontStyleBox.SelectionChanged += FontStyleBox_SelectionChanged;
  43. //FontSizeBox.SelectionChanged += FontSizeBox_SelectionChanged;
  44. //FontColorBox.SelectedColorHandler += FontColorBox_SelectedColorHandler;
  45. if (ViewModel != null)
  46. {
  47. ViewModel.ClearCheckedAglin -= ViewModel_ClearCheckedAglin;
  48. ViewModel.ClearCheckedAglin += ViewModel_ClearCheckedAglin;
  49. }
  50. }
  51. private void InitVariable()
  52. {
  53. FontTitleBox.SelectedIndex = 0;
  54. FontFamilyBox.SelectedIndex = 0;
  55. FontStyleBox.SelectedIndex = 0;
  56. FontSizeBox.SelectedIndex = 0;
  57. }
  58. private void ViewModel_ClearCheckedAglin(object sender, EventArgs e)
  59. {
  60. laoutAglin.ClearCheckedBtn();
  61. }
  62. private void FontSizeBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
  63. {
  64. //var listItem = FontSizeBox.ItemContainerGenerator.ContainerFromItem(FontSizeBox.SelectedItem) as ComboBoxItem;
  65. //if (listItem != null)
  66. // FontSizeText.Text = listItem.Content.ToString();
  67. //else
  68. // FontSizeText.Text = "6";
  69. }
  70. private void FontStyleBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
  71. {
  72. //var listItem = FontStyleBox.ItemContainerGenerator.ContainerFromItem(FontStyleBox.SelectedItem) as ComboBoxItem;
  73. //if (listItem != null)
  74. // FontStyleText.Text = listItem.Content.ToString();
  75. //else
  76. // FontStyleText.Text = "Regular";
  77. }
  78. private void FontFamilyBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
  79. {
  80. //var listItem = FontFamilyBox.ItemContainerGenerator.ContainerFromItem(FontFamilyBox.SelectedItem) as ComboBoxItem;
  81. //if (listItem != null)
  82. // FontFamilyText.Text = (listItem.Content as TextBlock).Text;
  83. //else
  84. // FontFamilyText.Text = "Courier New";
  85. }
  86. private void FontColorBox_SelectedColorHandler(object sender, Color e)
  87. {
  88. var data = this.DataContext as TextEditPropertyViewModel;
  89. if (data != null)
  90. {
  91. data.SelectedColorCommand?.Execute(e);
  92. }
  93. }
  94. private void BtnTextAlign_Click(object sender, RoutedEventArgs e)
  95. {
  96. }
  97. }
  98. }