123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452 |
- using ComPDFKitViewer;
- using ComPDFKitViewer.AnnotEvent;
- using PDF_Office.Properties;
- using PDFSettings;
- 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.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>
- /// TextAnnotProperty.xaml 的交互逻辑
- /// </summary>
- public partial class TextAnnotProperty : UserControl
- {
- public TextAnnotProperty()
- {
- InitializeComponent();
- }
- private void OpacitySlider_DragStarted(object sender, System.Windows.Controls.Primitives.DragStartedEventArgs e)
- {
- }
- private void OpacitySlider_DragCompleted(object sender, System.Windows.Controls.Primitives.DragCompletedEventArgs e)
- {
- }
- private void OpacitySlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
- {
- }
- }
- //public partial class TextAnnotProperty : UserControl
- //{
- // /// <summary>
- // /// 属性更改事件
- // /// </summary>
- // public event EventHandler<Dictionary<AnnotArgsType, object>> DataChanged;
- // /// <summary>
- // /// 默认值设置事件
- // /// </summary>
- // public event EventHandler<object> DefaultStored;
- // public Color? SelectedColor { get { return ColorDropPicker.SelectedColor; } }
- // public string AnnotTitle { get { return AnnotTypeTitle.Text; } }
- // public string AnnoteNote { get { return AnnotNoteText.Text; } }
- // public double AnnotOpacity { get { return OpacitySlider.Value; } }
- // public AnnotArgsType AnnotType { get; private set; }
- // public AnnotAttribEvent AnnotEvent { get; set; }
- // private bool DisableValueChange = false;
- // public TextAnnotProperty()
- // {
- // InitializeComponent();
- // SetLangText();
- // string font = Settings.Default.AppProperties.Annotate.AnchoredFamaily;
- // if (font.Equals("Courier"))
- // AnnotNoteText.FontFamily = new FontFamily("Courier New");
- // else if (font.Equals("Helvetica"))
- // AnnotNoteText.FontFamily = new FontFamily("Arial");
- // else
- // AnnotNoteText.FontFamily = new FontFamily("Times New Roman");
- // DataContext = this;
- // PathFigure FigureData = GetSquigglyPathFigure(new Point(0, 0), new Point(62, 0), 60, 2);
- // PathGeometry SquigglyGeometry = new PathGeometry();
- // PathFigureCollection FiguresCollection = new PathFigureCollection();
- // SquigglyGeometry.Figures = FiguresCollection;
- // FiguresCollection.Add(FigureData);
- // SquigglyPath.Data = SquigglyGeometry;
- // }
- // private void SetLangText()
- // {
- // //SampleText.Text = App.MainPageLoader.GetString("ProperPanel_Example");
- // //colorText.Text = App.MainPageLoader.GetString("ProperPanel_Color");
- // //opacityText.Text = App.MainPageLoader.GetString("ProperPanel_Opacity");
- // //UseAsDefaultBtn.Content = App.MainPageLoader.GetString("ProperPanel_SetAsDefault");
- // //NoteText.Text = App.MainPageLoader.GetString("ProperPanel_Note");
- // }
- // private void SetTextDecoratePath(Color? selectColor, double? opacity)
- // {
- // UnderlinePath.Visibility = Visibility.Collapsed;
- // StrikeoutPath.Visibility = Visibility.Collapsed;
- // SquigglyPath.Visibility = Visibility.Collapsed;
- // UnderlinePath.Opacity = 1;
- // StrikeoutPath.Opacity = 1;
- // UnderlinePath.Opacity = 1;
- // switch (AnnotType)
- // {
- // case AnnotArgsType.AnnotHighlight:
- // if (selectColor != null)
- // {
- // SampleText.Background = new SolidColorBrush((Color)selectColor);
- // }
- // if (opacity != null)
- // {
- // SampleText.Background.Opacity = (double)opacity;
- // }
- // break;
- // case AnnotArgsType.AnnotUnderline:
- // UnderlinePath.Visibility = Visibility.Visible;
- // SampleText.Background = Brushes.Transparent;
- // if (opacity != null)
- // {
- // UnderlinePath.Opacity = (double)opacity;
- // }
- // if (selectColor != null)
- // {
- // UnderlinePath.Stroke = new SolidColorBrush((Color)selectColor);
- // }
- // break;
- // case AnnotArgsType.AnnotStrikeout:
- // StrikeoutPath.Visibility = Visibility.Visible;
- // SampleText.Background = Brushes.Transparent;
- // if (opacity != null)
- // {
- // StrikeoutPath.Opacity = (double)opacity;
- // }
- // if (selectColor != null)
- // {
- // StrikeoutPath.Stroke = new SolidColorBrush((Color)selectColor);
- // }
- // break;
- // case AnnotArgsType.AnnotSquiggly:
- // SquigglyPath.Visibility = Visibility.Visible;
- // SampleText.Background = Brushes.Transparent;
- // if (opacity != null)
- // {
- // SquigglyPath.Opacity = (double)opacity;
- // }
- // if (selectColor != null)
- // {
- // SquigglyPath.Stroke = new SolidColorBrush((Color)selectColor);
- // }
- // break;
- // case AnnotArgsType.AnnotSticky:
- // {
- // if (opacity != null)
- // {
- // StickyPath.Opacity = (double)opacity;
- // }
- // if (selectColor != null)
- // {
- // StickyPath.Fill = new SolidColorBrush((Color)selectColor);
- // }
- // }
- // break;
- // default:
- // break;
- // }
- // }
- // public void SetSelectedColor(Color selectColor)
- // {
- // bool changed = false;
- // if (ColorDropPicker.SelectedColor != selectColor)
- // {
- // changed = true;
- // }
- // ColorDropPicker.SetSelectedColor(selectColor);
- // SetTextDecoratePath(selectColor, null);
- // if (changed)
- // {
- // Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
- // changeData[AnnotType] = selectColor;
- // DataChanged?.Invoke(this, changeData);
- // }
- // }
- // public void SetSelectOpacity(double opacity)
- // {
- // OpacitySlider.Value = opacity;
- // SetTextDecoratePath(null, opacity);
- // }
- // public void SetNoteContent(string textNote)
- // {
- // AnnotNoteText.Text = textNote;
- // }
- // public void SetAnnotType(AnnotArgsType annotType)
- // {
- // //AnnotType = annotType;
- // //switch (annotType)
- // //{
- // // case AnnotArgsType.AnnotHighlight:
- // // AnnotTypeTitle.Text = App.MainPageLoader.GetString("SubTools_Tools_Highlight");
- // // break;
- // // case AnnotArgsType.AnnotUnderline:
- // // AnnotTypeTitle.Text = App.MainPageLoader.GetString("SubTools_Tools_Underline");
- // // break;
- // // case AnnotArgsType.AnnotStrikeout:
- // // AnnotTypeTitle.Text = App.MainPageLoader.GetString("SubTools_Tools_Strikthrough");
- // // break;
- // // case AnnotArgsType.AnnotSquiggly:
- // // AnnotTypeTitle.Text = App.MainPageLoader.GetString("SubTools_Tools_Squiggly");
- // // break;
- // // case AnnotArgsType.AnnotSticky:
- // // AnnotTypeTitle.Text = App.MainPageLoader.GetString("SubTools_Tools_AnchoredNote");
- // // SampleText.Visibility = Visibility.Collapsed;
- // // StickyPath.Visibility = Visibility.Visible;
- // // break;
- // // default:
- // // break;
- // //}
- // }
- // private void ColorDropPicker_SelectedColorChanged(object sender, Color? e)
- // {
- // if (e != null && AnnotEvent != null)
- // {
- // AnnotEvent.UpdateAttrib(AnnotAttrib.Color, e);
- // AnnotEvent.UpdateAnnot();
- // double? opacity = null;
- // if (OpacitySlider != null)
- // {
- // opacity = OpacitySlider.Value;
- // }
- // SetTextDecoratePath(e, opacity);
- // if (e != null)
- // {
- // Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
- // changeData[AnnotType] = e;
- // DataChanged?.Invoke(this, changeData);
- // }
- // }
- // }
- // private void OpacitySlider_DragCompleted(object sender, System.Windows.Controls.Primitives.DragCompletedEventArgs e)
- // {
- // DisableValueChange = false;
- // if (AnnotEvent != null)
- // {
- // AnnotEvent.UpdateAttrib(AnnotAttrib.Transparency, OpacitySlider.Value);
- // AnnotEvent.UpdateAnnot();
- // SetTextDecoratePath(null, OpacitySlider.Value);
- // if (e != null)
- // {
- // Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
- // changeData[AnnotType] = OpacitySlider.Value;
- // DataChanged?.Invoke(this, changeData);
- // }
- // }
- // }
- // private void OpacitySlider_DragStarted(object sender, System.Windows.Controls.Primitives.DragStartedEventArgs e)
- // {
- // DisableValueChange = true;
- // }
- // private void OpacitySlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
- // {
- // if (AnnotEvent != null && DisableValueChange == false)
- // {
- // AnnotEvent.UpdateAttrib(AnnotAttrib.Transparency, e.NewValue);
- // AnnotEvent.UpdateAnnot();
- // SetTextDecoratePath(null, e.NewValue);
- // if (e != null)
- // {
- // Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
- // changeData[AnnotType] = e.NewValue;
- // DataChanged?.Invoke(this, changeData);
- // }
- // }
- // }
- // private PathFigure GetSquigglyPathFigure(Point StartPoint, Point EndPoint, double PathWidth, double PathHeight)
- // {
- // PathFigure FigureData = new PathFigure();
- // FigureData.StartPoint = StartPoint;
- // int Radius = (int)Math.Max(2, 2);
- // if (PathWidth > PathHeight)
- // {
- // // 橫線
- // var arcCount = PathWidth / (Radius * 2);
- // var x = StartPoint.X;
- // if (EndPoint.X > StartPoint.X)
- // {
- // // left to right
- // for (int i = 0; i < arcCount; i++)
- // {
- // if (i % 2 == 0)
- // {
- // // 上弧
- // FigureData.Segments.Add(new BezierSegment()
- // {
- // Point1 = new Point(x, StartPoint.Y),
- // Point2 = new Point(x + Radius, StartPoint.Y - Radius),
- // Point3 = new Point(x + Radius * 2, StartPoint.Y)
- // });
- // }
- // else
- // {
- // // 下弧
- // FigureData.Segments.Add(new BezierSegment()
- // {
- // Point1 = new Point(x, StartPoint.Y),
- // Point2 = new Point(x + Radius, StartPoint.Y + Radius),
- // Point3 = new Point(x + Radius * 2, StartPoint.Y)
- // });
- // }
- // x += Radius * 2;
- // }
- // }
- // else
- // {
- // // right to left
- // for (int i = 0; i < arcCount; i++)
- // {
- // if (i % 2 == 0)
- // {
- // //下弧
- // FigureData.Segments.Add(new BezierSegment()
- // {
- // Point1 = new Point(x, StartPoint.Y),
- // Point2 = new Point(x - Radius, StartPoint.Y + Radius),
- // Point3 = new Point(x - Radius * 2, StartPoint.Y)
- // });
- // }
- // else
- // {
- // //上弧
- // FigureData.Segments.Add(new BezierSegment()
- // {
- // Point1 = new Point(x, StartPoint.Y),
- // Point2 = new Point(x - Radius, StartPoint.Y - Radius),
- // Point3 = new Point(x - Radius * 2, StartPoint.Y)
- // });
- // }
- // x -= Radius * 2;
- // }
- // }
- // }
- // else
- // {
- // // 直線
- // var arcCount = PathHeight / (Radius * 2);
- // var y = StartPoint.Y;
- // if (EndPoint.Y > StartPoint.Y)
- // {
- // // up to down
- // for (int i = 0; i < arcCount; i++)
- // {
- // if (i % 2 == 0)
- // {
- // //右弧
- // FigureData.Segments.Add(new BezierSegment()
- // {
- // Point1 = new Point(StartPoint.X, y),
- // Point2 = new Point(StartPoint.X + Radius, y + Radius),
- // Point3 = new Point(StartPoint.X, y + Radius * 2)
- // });
- // }
- // else
- // {
- // //左弧
- // FigureData.Segments.Add(new BezierSegment()
- // {
- // Point1 = new Point(StartPoint.X, y),
- // Point2 = new Point(StartPoint.X - Radius, y + Radius),
- // Point3 = new Point(StartPoint.X, y + Radius * 2)
- // });
- // }
- // y += Radius * 2;
- // }
- // }
- // else
- // {
- // // down to up
- // for (int i = 0; i < arcCount; i++)
- // {
- // if (i % 2 == 0)
- // {
- // //左弧
- // FigureData.Segments.Add(new BezierSegment()
- // {
- // Point1 = new Point(StartPoint.X, y),
- // Point2 = new Point(StartPoint.X - Radius, y - Radius),
- // Point3 = new Point(StartPoint.X, y - Radius * 2)
- // });
- // }
- // else
- // {
- // //右弧
- // FigureData.Segments.Add(new BezierSegment()
- // {
- // Point1 = new Point(StartPoint.X, y),
- // Point2 = new Point(StartPoint.X + Radius, y - Radius),
- // Point3 = new Point(StartPoint.X, y - Radius * 2)
- // });
- // }
- // y -= Radius * 2;
- // }
- // }
- // }
- // return FigureData;
- // }
- // private void Button_StoreAsDefaultProperty(object sender, RoutedEventArgs e)
- // {
- // DefaultAnnotProperty defaultProperty = new DefaultAnnotProperty();
- // defaultProperty.AnnotToolType = AnnotType;
- // defaultProperty.ForgoundColor = ColorDropPicker.SelectedColor == null ? Colors.Yellow : (Color)ColorDropPicker.SelectedColor;
- // defaultProperty.Opacity = OpacitySlider.Value;
- // Helper.SettingHelper.SetAnnotDefaultProperty(defaultProperty);
- // DefaultStored?.Invoke(this, null);
- // }
- // private void AnnotNoteText_LostFocus(object sender, RoutedEventArgs e)
- // {
- // AnnotEvent?.UpdateAttrib(AnnotAttrib.NoteText, AnnotNoteText.Text);
- // AnnotEvent?.UpdateAnnot();
- // }
- // public void NoteFocus()
- // {
- // AnnotNoteText.Focus();
- // }
- // private void OpacityItem_PreviewMouseDown(object sender, MouseButtonEventArgs e)
- // {
- // ComboBoxItem selectItem = sender as ComboBoxItem;
- // if (selectItem != null && selectItem.Content != null)
- // {
- // int opacity = -1;
- // if (int.TryParse(selectItem.Content.ToString().TrimEnd('%'), out opacity))
- // {
- // OpacitySlider.Value = opacity / 100D;
- // }
- // }
- // }
- //}
- }
|