123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- using ComPDFKitViewer.AnnotEvent;
- using PDF_Office.Helper;
- using Prism.Commands;
- using Prism.Mvvm;
- using Prism.Regions;
- 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.Media;
- namespace PDF_Office.ViewModels.BOTA
- {
- internal class AnnotationListItemViewModel : BindableBase
- {
- private Visibility pathTxtIcoVisibility = Visibility.Collapsed;
- public Visibility PathTxtIcoVisibility
- {
- get { return pathTxtIcoVisibility; }
- set
- {
- SetProperty(ref pathTxtIcoVisibility, value);
- }
- }
- public DelegateCommand<object> GridIcoLoadedCommand { get; set; }
- public AnnotationListItemViewModel()
- {
- GridIcoLoadedCommand = new DelegateCommand<object>(GridIcoLoaded);
- }
- private void GridIcoLoaded(object obj)
- {
- if (obj is CompositeCommandParameter commandParameter)
- {
- if (commandParameter.EventArgs is RoutedEventArgs eventArgs && commandParameter.Parameter is object[] parameters)
- {
- if ((eventArgs.Source as Grid).DataContext is AnnotHandlerEventArgs data)
- {
- TextBlock txbContext = parameters[0] as TextBlock;
- TextBlock txbMarkUpContent = parameters[1] as TextBlock;
- Grid grid = parameters[2] as Grid;
- switch (data.EventType)
- {
- case AnnotArgsType.AnnotFreeText:
- PathTxtIcoVisibility = Visibility.Visible;
- txbMarkUpContent.Foreground = new SolidColorBrush((data as FreeTextAnnotArgs).FontColor);
- //txtContext.FontSize = (data as FreeTextAnnotArgs).FontSize;
- //txtContext.FontFamily = (data as FreeTextAnnotArgs).Family;
- if ((data as FreeTextAnnotArgs).HasBgColor)
- {
- txbContext.Background = new SolidColorBrush((data as FreeTextAnnotArgs).BgColor);
- }
- break;
- //case AnnotArgsType.AnnotHighlight:
- // highlight.Visibility = Visibility.Visible;
- // highlightcolor.Fill = new SolidColorBrush((data as TextHighlightAnnotArgs).Color);
- // txtContext.Text = data.Content;
- // // txtContext.Background = new SolidColorBrush((data as TextHighlightAnnotArgs).HighlightColor);
- // break;
- //case AnnotArgsType.AnnotFreehand:
- // freehand.Visibility = Visibility.Visible;
- // freehandcolor.Fill = new SolidColorBrush((data as FreehandAnnotArgs).InkColor);
- // break;
- //case AnnotArgsType.AnnotLine:
- // if ((data as LineAnnotArgs).HeadLineType >= (C_LINE_TYPE)1 || (data as LineAnnotArgs).TailLineType >= (C_LINE_TYPE)1)
- // {
- // arrow.Visibility = Visibility.Visible;
- // arrow.Fill = new SolidColorBrush((data as LineAnnotArgs).LineColor);
- // }
- // else
- // {
- // line.Stroke = new SolidColorBrush((data as LineAnnotArgs).LineColor);
- // line.Visibility = Visibility.Visible;
- // }
- // break;
- //case AnnotArgsType.AnnotSquiggly://波浪线
- // AnnotSquiggly.Visibility = Visibility.Visible;
- // AnnotSquigglycolor.Stroke = new SolidColorBrush((data as TextSquigglyAnnotArgs).Color);
- // txtContext.Text = data.Content;
- // TextDecoration mySquiggly = new TextDecoration();
- // Pen myPen = new Pen();
- // myPen.Brush = new SolidColorBrush((data as TextSquigglyAnnotArgs).Color);
- // myPen.Brush.Opacity = 0.8;
- // myPen.Thickness = 2;
- // myPen.DashStyle = DashStyles.Dash;
- // mySquiggly.Pen = myPen;
- // mySquiggly.PenThicknessUnit = TextDecorationUnit.FontRecommended;
- // TextDecorationCollection myCollection = new TextDecorationCollection();
- // myCollection.Add(mySquiggly);
- // //txtContext.TextDecorations = myCollection;
- // break;
- //case AnnotArgsType.AnnotStamp:
- // stamp.Visibility = Visibility.Visible;
- // break;
- //case AnnotArgsType.AnnotStrikeout://删除线
- // AnnotStrikeout.Visibility = Visibility.Visible;
- // AnnotStrikeoutycolor.Stroke = new SolidColorBrush((data as TextStrikeoutAnnotArgs).Color);
- // AnnotStrikeoutycolor.VerticalAlignment = VerticalAlignment.Center;
- // txtContext.Text = data.Content;
- // TextDecoration myStrikeout = new TextDecoration();
- // Pen myPen2 = new Pen();
- // myPen2.Brush = new SolidColorBrush((data as TextStrikeoutAnnotArgs).Color);
- // myPen2.Brush.Opacity = 0.8;
- // myPen2.Thickness = 1;
- // myStrikeout.Pen = myPen2;
- // myStrikeout.PenOffset = -3;
- // myStrikeout.PenThicknessUnit = TextDecorationUnit.FontRecommended;
- // TextDecorationCollection myCollection2 = new TextDecorationCollection();
- // myCollection2.Add(myStrikeout);
- // //因为波浪线无法实现 暂时只显示文字 不显示下划线,删除线等
- // //txtContext.TextDecorations = myCollection2;
- // break;
- //case AnnotArgsType.AnnotSticky://便签
- // sticky.Visibility = Visibility;
- // sticky.Fill = new SolidColorBrush((data as StickyAnnotArgs).Color);
- // break;
- //case AnnotArgsType.AnnotUnderline:
- // AnnotStrikeout.Visibility = Visibility.Visible;
- // AnnotStrikeoutycolor.VerticalAlignment = VerticalAlignment.Bottom;
- // txtContext.Text = data.Content;
- // AnnotStrikeoutycolor.Stroke = new SolidColorBrush((data as TextUnderlineAnnotArgs).Color);
- // TextDecoration myUnderline = new TextDecoration();
- // Pen myPen1 = new Pen();
- // myPen1.Brush = new SolidColorBrush((data as TextUnderlineAnnotArgs).Color);
- // myPen1.Brush.Opacity = 0.8;
- // myPen1.Thickness = 2;
- // myUnderline.Pen = myPen1;
- // myUnderline.PenThicknessUnit = TextDecorationUnit.FontRecommended;
- // TextDecorationCollection myCollection1 = new TextDecorationCollection();
- // myCollection1.Add(myUnderline);
- // //txtContext.TextDecorations = myCollection1;
- // break;
- //case AnnotArgsType.AnnotSquare:
- // rect.Visibility = Visibility.Visible;
- // rect.Stroke = new SolidColorBrush((data as SquareAnnotArgs).LineColor);
- // rect.Fill = new SolidColorBrush((data as SquareAnnotArgs).BgColor);
- // break;
- //case AnnotArgsType.AnnotCircle:
- // circle.Visibility = Visibility.Visible;
- // circle.Stroke = new SolidColorBrush((data as CircleAnnotArgs).LineColor);
- // circle.Fill = new SolidColorBrush((data as CircleAnnotArgs).BgColor);
- // break;
- default:
- break;
- }
- }
- }
- }
- }
- }
- }
|