123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- using ComPDFKit.PDFAnnotation;
- using ComPDFKitViewer.AnnotEvent;
- using PDF_Office.CustomControl;
- using PDF_Office.ViewModels.PropertyPanel.AnnotPanel;
- 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 PDF_Office.Views.PropertyPanel.AnnotPanel
- {
- /// <summary>
- /// SharpsAnnotProperty.xaml 的交互逻辑
- /// </summary>
- public partial class SharpsAnnotProperty : UserControl
- {
- private SharpsAnnotPropertyViewModel ViewModel => DataContext as SharpsAnnotPropertyViewModel;
- public SharpsAnnotProperty()
- {
- InitializeComponent();
- cusColor.SelectedColorHandler += cusColor_SelectedColor;
- layerThick.SelectedValueChanged += layerThick_SelectedValue;
- cusFillColor.SelectedColorHandler += cusFillColor_SelectedColor;
- layerFill.SelectedValueChanged += layerFill_SelectedValue;
- ViewModel.LoadPropertyHandler += ViewModel_LoadPropertyHandler;
- }
- private void ViewModel_LoadPropertyHandler(object sender, object e)
- {
- var item = e as AnnotHandlerEventArgs;
- switch (item.EventType)
- {
- case AnnotArgsType.AnnotSquare:
- {
- var annot = item as SquareAnnotArgs;
- if (annot != null)
- {
- cusColor.SetSelectedColor(annot.LineColor);
- cusFillColor.SetSelectedColor(annot.BgColor);
- layerFill.SetSliOpacity(annot.Transparency);
- SharpsBtn_Click(SharpRectBtn, null);
- SolidLineIschecked(annot.LineDash.Dashes == null || annot.LineDash.Dashes.Count == 0 || annot.LineDash.Dashes[0] == 0);
- }
- break;
- }
- case AnnotArgsType.AnnotCircle:
- {
- var annot = item as CircleAnnotArgs;
- if (annot != null)
- {
- cusColor.SetSelectedColor(annot.LineColor);
- cusFillColor.SetSelectedColor(annot.BgColor);
- layerFill.SetSliOpacity(annot.Transparency);
- SharpsBtn_Click(SharpCircleBtn, null);
- SolidLineIschecked(annot.LineDash.Dashes == null || annot.LineDash.Dashes.Count == 0 || annot.LineDash.Dashes[0] == 0);
- }
- break;
- }
- case AnnotArgsType.AnnotLine:
- {
- var annot = item as LineAnnotArgs;
- if (annot != null)
- {
- cusColor.SetSelectedColor(annot.LineColor);
- cusFillColor.SetSelectedColor(annot.LineColor);
- layerFill.SetSliOpacity(annot.Transparency);
- if (annot.TailLineType == C_LINE_TYPE.LINETYPE_ARROW && annot.HeadLineType == C_LINE_TYPE.LINETYPE_NONE)
- SharpsBtn_Click(SharpArrowBtn, null);
- else
- SharpsBtn_Click(SharpLineBtn, null);
- SolidLineIschecked(annot.LineDash.Dashes == null || annot.LineDash.Dashes.Count == 0 || annot.LineDash.Dashes[0] == 0);
- }
- break;
- }
- }
- }
- private void SolidLineIschecked(bool isSolid)
- {
- if (isSolid)
- {
- BtnSolidLine.IsChecked = true;
- BtnDottedLine.IsChecked = false;
- }
- else
- {
- BtnDottedLine.IsChecked = true;
- BtnSolidLine.IsChecked = false;
- }
- }
- private void layerFill_SelectedValue(object sender, double e)
- {
- if (ViewModel != null)
- {
- ViewModel.SelectedFillOpacityCommand?.Execute(e);
- }
- }
- private void cusFillColor_SelectedColor(object sender, Color e)
- {
- if (ViewModel != null)
- {
- ViewModel.SelectedFillColorCommand?.Execute(e);
- }
- }
- private void layerThick_SelectedValue(object sender, double e)
- {
- if (ViewModel != null)
- {
- ViewModel.SelectedThickCommand?.Execute(e);
- }
- }
- private void cusColor_SelectedColor(object sender, Color e)
- {
- if (ViewModel != null)
- {
- ViewModel.SelectedColorCommand?.Execute(e);
- }
- }
- private void SharpsBtn_Click(object sender, RoutedEventArgs e)
- {
- var btn = sender as ToggleButton;
- foreach(var item in ToolGrid.Children)
- {
- var btnItem = item as ToggleButton;
- if(btnItem != null)
- {
- if(btnItem != btn)
- {
- btnItem.IsChecked = false;
- }
- else
- {
- btnItem.IsChecked = true;
- if(btnItem.Tag.ToString() == "Arrow" || btnItem.Tag.ToString() == "Line")
- {
- GridFill.Visibility = Visibility.Collapsed;
- }
- else
- {
- GridFill.Visibility = Visibility.Visible;
- }
- }
- }
- }
- }
- private void BtnLineStyle_Click(object sender, RoutedEventArgs e)
- {
- var btn = sender as CustomIconToggleBtn;
- foreach (var item in PnlLineStyle.Children)
- {
- var btnItem = item as CustomIconToggleBtn;
- if (btnItem != null)
- {
- if (btnItem != btn)
- {
- btnItem.IsChecked = false;
- }
- else
- {
- btnItem.IsChecked = true;
-
- }
- }
- }
- }
- }
- }
|