123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- using ComPDFKit.PDFPage.Edit;
- using ComPDFKitViewer.PdfViewer;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Controls.Primitives;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- namespace compdfkit_tools.Edit
- {
- /// <summary>
- /// CPDFTextAlignUI.xaml 的交互逻辑
- /// </summary>
- public partial class CPDFTextAlignUI : UserControl
- {
- public event EventHandler<TextAlignType> TextAlignChanged;
- public CPDFTextAlignUI()
- {
- InitializeComponent();
- }
- public Orientation Orientation
- {
- get
- {
- return TextAlignUI.Orientation;
- }
- set
- {
- TextAlignUI.Orientation = value;
- }
- }
- public TextAlignType Alignment { get;private set; }
- public void SetFontAlign(TextAlignType newAlign)
- {
- ClearAlign();
- Alignment = newAlign;
- switch (newAlign)
- {
- case TextAlignType.AlignLeft:
- AlignLeftBtn.IsChecked = true;
- AlignLeftPath.Fill = Brushes.Blue;
- break;
- case TextAlignType.AlignMiddle:
- AlignCenterBtn.IsChecked = true;
- AlignCenterPath.Fill = Brushes.Blue;
- break;
- case TextAlignType.AlignRight:
- AlignRightBtn.IsChecked = true;
- AlignRightPath.Fill = Brushes.Blue;
- break;
- default:
- break;
- }
- }
- public void ClearAlign()
- {
- Alignment = TextAlignType.AlignNone;
- AlignLeftPath.Fill = Brushes.Gray;
- AlignCenterPath.Fill= Brushes.Gray;
- AlignRightPath.Fill= Brushes.Gray;
- AlignLeftBtn.IsChecked = false;
- AlignCenterBtn.IsChecked = false;
- AlignRightBtn.IsChecked= false;
- }
- private void TextAlignBtn_Click(object sender, RoutedEventArgs e)
- {
- ClearAlign();
- ToggleButton clickBtn = sender as ToggleButton;
- if (clickBtn != null && clickBtn.Tag!=null)
- {
- clickBtn.IsChecked = true;
- TextAlignType newAlign = Alignment;
- switch(clickBtn.Tag.ToString())
- {
- case "AlignLeft":
- newAlign = TextAlignType.AlignLeft;
- break;
- case "AlignCenter":
- newAlign = TextAlignType.AlignMiddle;
- break;
- case "AlignRight":
- newAlign= TextAlignType.AlignRight;
- break;
- default:
- break;
- }
- if(newAlign!=Alignment)
- {
- SetFontAlign(newAlign);
- TextAlignChanged?.Invoke(this, newAlign);
- }
- }
- }
- }
- }
|