TextEditProperty.xaml.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. using PDF_Office.ViewModels.PropertyPanel;
  2. using PDF_Office.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_Office.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. InitVariable();
  33. }
  34. private void InitEventHandler()
  35. {
  36. //FontFamilyBox.SelectionChanged -= FontFamilyBox_SelectionChanged;
  37. //FontStyleBox.SelectionChanged -= FontStyleBox_SelectionChanged;
  38. //FontSizeBox.SelectionChanged -= FontSizeBox_SelectionChanged;
  39. //FontColorBox.SelectedColorHandler -= FontColorBox_SelectedColorHandler;
  40. //FontFamilyBox.SelectionChanged += FontFamilyBox_SelectionChanged;
  41. //FontStyleBox.SelectionChanged += FontStyleBox_SelectionChanged;
  42. //FontSizeBox.SelectionChanged += FontSizeBox_SelectionChanged;
  43. //FontColorBox.SelectedColorHandler += FontColorBox_SelectedColorHandler;
  44. if (ViewModel != null)
  45. {
  46. ViewModel.ClearCheckedAglin -= ViewModel_ClearCheckedAglin;
  47. ViewModel.ClearCheckedAglin += ViewModel_ClearCheckedAglin;
  48. }
  49. }
  50. private void InitVariable()
  51. {
  52. FontTitleBox.SelectedIndex = 0;
  53. FontFamilyBox.SelectedIndex = 0;
  54. FontStyleBox.SelectedIndex = 0;
  55. FontSizeBox.SelectedIndex = 0;
  56. }
  57. private void ViewModel_ClearCheckedAglin(object sender, EventArgs e)
  58. {
  59. laoutAglin.ClearCheckedBtn();
  60. }
  61. private void FontSizeBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
  62. {
  63. //var listItem = FontSizeBox.ItemContainerGenerator.ContainerFromItem(FontSizeBox.SelectedItem) as ComboBoxItem;
  64. //if (listItem != null)
  65. // FontSizeText.Text = listItem.Content.ToString();
  66. //else
  67. // FontSizeText.Text = "6";
  68. }
  69. private void FontStyleBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
  70. {
  71. //var listItem = FontStyleBox.ItemContainerGenerator.ContainerFromItem(FontStyleBox.SelectedItem) as ComboBoxItem;
  72. //if (listItem != null)
  73. // FontStyleText.Text = listItem.Content.ToString();
  74. //else
  75. // FontStyleText.Text = "Regular";
  76. }
  77. private void FontFamilyBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
  78. {
  79. //var listItem = FontFamilyBox.ItemContainerGenerator.ContainerFromItem(FontFamilyBox.SelectedItem) as ComboBoxItem;
  80. //if (listItem != null)
  81. // FontFamilyText.Text = (listItem.Content as TextBlock).Text;
  82. //else
  83. // FontFamilyText.Text = "Courier New";
  84. }
  85. private void FontColorBox_SelectedColorHandler(object sender, Color e)
  86. {
  87. var data = this.DataContext as TextEditPropertyViewModel;
  88. if (data != null)
  89. {
  90. data.SelectedColorCommand?.Execute(e);
  91. }
  92. }
  93. private void BtnTextAlign_Click(object sender, RoutedEventArgs e)
  94. {
  95. }
  96. }
  97. }