TextEditProperty.xaml.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. using PDF_Office.ViewModels.PropertyPanel;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Data;
  10. using System.Windows.Documents;
  11. using System.Windows.Input;
  12. using System.Windows.Media;
  13. using System.Windows.Media.Imaging;
  14. using System.Windows.Navigation;
  15. using System.Windows.Shapes;
  16. namespace PDF_Office.Views.PropertyPanel
  17. {
  18. /// <summary>
  19. /// TextEditProperty.xaml 的交互逻辑
  20. /// </summary>
  21. public partial class TextEditProperty : UserControl
  22. {
  23. public TextEditProperty()
  24. {
  25. InitializeComponent();
  26. }
  27. private void UserControl_Loaded(object sender, RoutedEventArgs e)
  28. {
  29. FontFamilyBox.SelectionChanged -= FontFamilyBox_SelectionChanged;
  30. FontStyleBox.SelectionChanged -= FontStyleBox_SelectionChanged;
  31. FontSizeBox.SelectionChanged -= FontSizeBox_SelectionChanged;
  32. FontColorBox.SelectedColorHandler -= FontColorBox_SelectedColorHandler;
  33. FontFamilyBox.SelectionChanged += FontFamilyBox_SelectionChanged;
  34. FontStyleBox.SelectionChanged += FontStyleBox_SelectionChanged;
  35. FontSizeBox.SelectionChanged += FontSizeBox_SelectionChanged;
  36. FontColorBox.SelectedColorHandler += FontColorBox_SelectedColorHandler;
  37. FontTitleBox.SelectedIndex = 0;
  38. FontFamilyBox.SelectedIndex = 0;
  39. FontStyleBox.SelectedIndex = 0;
  40. FontSizeBox.SelectedIndex = 0;
  41. }
  42. private void FontSizeBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
  43. {
  44. var listItem = FontSizeBox.ItemContainerGenerator.ContainerFromItem(FontSizeBox.SelectedItem) as ComboBoxItem;
  45. if (listItem != null)
  46. FontSizeText.Text = listItem.Content.ToString();
  47. else
  48. FontSizeText.Text = "6";
  49. }
  50. private void FontStyleBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
  51. {
  52. var listItem = FontStyleBox.ItemContainerGenerator.ContainerFromItem(FontStyleBox.SelectedItem) as ComboBoxItem;
  53. if (listItem != null)
  54. FontStyleText.Text = listItem.Content.ToString();
  55. else
  56. FontStyleText.Text = "Regular";
  57. }
  58. private void FontFamilyBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
  59. {
  60. var listItem = FontFamilyBox.ItemContainerGenerator.ContainerFromItem(FontFamilyBox.SelectedItem) as ComboBoxItem;
  61. if (listItem != null)
  62. FontFamilyText.Text = (listItem.Content as TextBlock).Text;
  63. else
  64. FontFamilyText.Text = "Courier New";
  65. }
  66. private void FontColorBox_SelectedColorHandler(object sender, Color e)
  67. {
  68. var data = this.DataContext as TextEditPropertyViewModel;
  69. if (data != null)
  70. {
  71. data.SelectedColorCommand?.Execute(e);
  72. }
  73. }
  74. private void BtnTextAlign_Click(object sender, RoutedEventArgs e)
  75. {
  76. }
  77. }
  78. }