Просмотр исходного кода

注释列表-添加附注(有bug)

OYXH\oyxh 2 лет назад
Родитель
Сommit
dbd48dd390

+ 3 - 0
PDF Office/ViewModels/BOTA/AnnotationContentViewModel.cs

@@ -735,6 +735,9 @@ namespace PDF_Office.ViewModels.BOTA
 
 
                                     AnnotAttribEvent annotEvent = e.Parameters.GetValue<AnnotAttribEvent>(ParameterNames.AnnotEvent);
                                     AnnotAttribEvent annotEvent = e.Parameters.GetValue<AnnotAttribEvent>(ParameterNames.AnnotEvent);
 
 
+                                    listBoxItem.DataContext = annotation;
+                                    var annot = AnnotationListItems.FirstOrDefault(q => q.PageIndex == annotation.PageIndex && q.AnnotIndex == annotation.AnnotIndex);
+
                                     //annotEvent?.UpdateAttrib(AnnotAttrib.NoteText, annotation.MarkupContent);
                                     //annotEvent?.UpdateAttrib(AnnotAttrib.NoteText, annotation.MarkupContent);
                                     //annotEvent?.UpdateAnnot();
                                     //annotEvent?.UpdateAnnot();
                                 }
                                 }

+ 2 - 74
PDF Office/ViewModels/Dialog/BOTA/AddAnnotationDialogViewModel.cs

@@ -78,8 +78,7 @@ namespace PDF_Office.ViewModels.Dialog.BOTA
             {
             {
                 if (composite.Parameter is TextBox textBox)
                 if (composite.Parameter is TextBox textBox)
                 {
                 {
-                    Annotation.MarkupContent = textBox.Text;
-                    Annotation.AnnotHandlerEventArgs.MarkupContent = textBox.Text;
+                    Annotation.Content = textBox.Text;
                     AnnotEvent?.UpdateAttrib(AnnotAttrib.NoteText, Annotation.AnnotHandlerEventArgs.MarkupContent);
                     AnnotEvent?.UpdateAttrib(AnnotAttrib.NoteText, Annotation.AnnotHandlerEventArgs.MarkupContent);
                     AnnotEvent?.UpdateAnnot();
                     AnnotEvent?.UpdateAnnot();
                 }
                 }
@@ -118,79 +117,8 @@ namespace PDF_Office.ViewModels.Dialog.BOTA
                 Annotation = annotation;
                 Annotation = annotation;
                 Dictionary<AnnotAttrib, object> annotAttribsList = annotation.AnnotHandlerEventArgs.GetAnnotAttrib();
                 Dictionary<AnnotAttrib, object> annotAttribsList = annotation.AnnotHandlerEventArgs.GetAnnotAttrib();
                 AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annotation.AnnotHandlerEventArgs, annotAttribsList);
                 AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annotation.AnnotHandlerEventArgs, annotAttribsList);
-                //Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
 
 
-                switch (annotation.EventType)
-                {
-                    case AnnotArgsType.AnnotFreeText://文本
-                        title = "文本";
-                        //FreeTextAnnotArgs freetextArgs = annotation.AnnotHandlerEventArgs as FreeTextAnnotArgs; ;
-                        //annotAttribsList[AnnotAttrib.Color] = freetextArgs.LineColor;
-                        //annotAttribsList[AnnotAttrib.FillColor] = freetextArgs.BgColor;
-                        //annotAttribsList[AnnotAttrib.Thickness] = freetextArgs.LineWidth;
-                        //annotAttribsList[AnnotAttrib.Transparency] = freetextArgs.Transparency;
-                        //annotAttribsList[AnnotAttrib.FontColor] = freetextArgs.FontColor;
-                        //annotAttribsList[AnnotAttrib.FontSize] = freetextArgs.FontSize;
-                        //annotAttribsList[AnnotAttrib.FontFamily] = freetextArgs.FontFamily;
-                        //annotAttribsList[AnnotAttrib.FontStyle] = freetextArgs.FontStyle;
-                        //annotAttribsList[AnnotAttrib.FontWeight] = freetextArgs.FontWeight;
-                        //annotAttribsList[AnnotAttrib.TextAlign] = TextAlignment.Left;
-                        //annotAttribsList[AnnotAttrib.NoteText] = freetextArgs.TextContent;
-                        //AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(freetextArgs, annotAttribsList);
-                        break;
-
-                    case AnnotArgsType.AnnotHighlight:
-                        title = "高亮";
-                        break;
-
-                    case AnnotArgsType.AnnotFreehand:
-                        title = "手绘";
-                        break;
-
-                    case AnnotArgsType.AnnotSquiggly://波浪线
-                        title = "波浪线";
-                        break;
-
-                    case AnnotArgsType.AnnotStamp:
-                        title = "图章";
-                        break;
-
-                    case AnnotArgsType.AnnotStrikeout://删除线
-                        title = "删除线";
-                        break;
-
-                    case AnnotArgsType.AnnotSticky://便签
-                        break;
-
-                    case AnnotArgsType.AnnotUnderline:
-                        title = "下划线";
-                        break;
-
-                    case AnnotArgsType.AnnotLine:
-                        if ((annotation.AnnotHandlerEventArgs as LineAnnotArgs).HeadLineType >= (C_LINE_TYPE)1 || (annotation.AnnotHandlerEventArgs as LineAnnotArgs).TailLineType >= (C_LINE_TYPE)1)
-                        {
-                            title = "箭头";
-                        }
-                        else
-                        {
-                            title = "线";
-                        }
-                        break;
-
-                    case AnnotArgsType.AnnotSquare:
-                        title = "矩形";
-                        break;
-
-                    case AnnotArgsType.AnnotCircle:
-                        title = "圆";
-                        break;
-                }
-                if (!string.IsNullOrEmpty(annotation.MarkupContent))
-                {
-                    title = title + "-" + annotation.MarkupContent;
-                }
-                Title = title;
-                MarkupContent = annotation.MarkupContent;
+                MarkupContent = annotation.Content;
                 AnnotationName = "页面" + (annotation.PageIndex + 1).ToString();
                 AnnotationName = "页面" + (annotation.PageIndex + 1).ToString();
                 return;
                 return;
             }
             }

+ 6 - 6
PDF Office/Views/BOTA/AnnotationListItem.xaml

@@ -344,14 +344,14 @@
                 </WrapPanel>
                 </WrapPanel>
             </Grid>
             </Grid>
             <TextBlock
             <TextBlock
-                Name="TxbContext"
+                Name="TxbMarkupContent"
                 Grid.Row="1"
                 Grid.Row="1"
                 Margin="5"
                 Margin="5"
                 FontFamily="Segoe UI"
                 FontFamily="Segoe UI"
                 FontSize="14"
                 FontSize="14"
-                Visibility="{Binding ElementName=TxbContext, Path=Text, Converter={StaticResource StringToVisibleConvert}}"
+                Visibility="{Binding ElementName=TxbMarkupContent, Path=Text, Converter={StaticResource StringToVisibleConvert}}"
                 Foreground="#252629"
                 Foreground="#252629"
-                Text="{Binding Content}"
+                Text="{Binding MarkupContent}"
                 TextAlignment="Left"
                 TextAlignment="Left"
                 TextTrimming="CharacterEllipsis"
                 TextTrimming="CharacterEllipsis"
                 TextWrapping="Wrap" />
                 TextWrapping="Wrap" />
@@ -361,17 +361,17 @@
                 Grid.Row="1"
                 Grid.Row="1"
                 Source="{Binding WriteableBitmap}" />
                 Source="{Binding WriteableBitmap}" />
             <TextBlock
             <TextBlock
-                Name="TxbMarkUpContent"
+                Name="TxbContent"
                 Grid.Row="2"
                 Grid.Row="2"
                 Margin="5"
                 Margin="5"
                 FontFamily="Segoe UI"
                 FontFamily="Segoe UI"
                 FontSize="14"
                 FontSize="14"
-                Text="{Binding MarkupContent}"
+                Text="{Binding Content}"
                 TextAlignment="Left"
                 TextAlignment="Left"
                 TextTrimming="CharacterEllipsis"
                 TextTrimming="CharacterEllipsis"
                 TextWrapping="Wrap"
                 TextWrapping="Wrap"
                 Foreground="#616469"
                 Foreground="#616469"
-                Visibility="{Binding ElementName=TxbMarkUpContent, Path=Text, Converter={StaticResource StringToVisibleConvert}}" />
+                Visibility="{Binding ElementName=TxbContent, Path=Text, Converter={StaticResource StringToVisibleConvert}}" />
         </Grid>
         </Grid>
 
 
         <Separator
         <Separator

+ 16 - 16
PDF Office/Views/BOTA/AnnotationListItem.xaml.cs

@@ -44,8 +44,8 @@ namespace PDF_Office.Views.BOTA
             Grid grid = e.Source as Grid;
             Grid grid = e.Source as Grid;
             var args = grid.DataContext as AnnotationHandlerEventArgs;
             var args = grid.DataContext as AnnotationHandlerEventArgs;
             AnnotHandlerEventArgs data = args.AnnotHandlerEventArgs;
             AnnotHandlerEventArgs data = args.AnnotHandlerEventArgs;
-            TxbMarkUpContent.Text = data.MarkupContent;
-            TxbContext.Text = data.Content;
+            TxbMarkupContent.Text = data.MarkupContent;
+            TxbContent.Text = data.Content;
             if (data == null)
             if (data == null)
             {
             {
                 return;
                 return;
@@ -55,16 +55,16 @@ namespace PDF_Office.Views.BOTA
             {
             {
                 case AnnotArgsType.AnnotFreeText:
                 case AnnotArgsType.AnnotFreeText:
                     BtnAnnotFreeText.Visibility = Visibility.Visible;
                     BtnAnnotFreeText.Visibility = Visibility.Visible;
-                    TxbMarkUpContent.Foreground = new SolidColorBrush((data as FreeTextAnnotArgs).FontColor);
+                    TxbMarkupContent.Foreground = new SolidColorBrush((data as FreeTextAnnotArgs).FontColor);
                     break;
                     break;
 
 
                 case AnnotArgsType.AnnotHighlight:
                 case AnnotArgsType.AnnotHighlight:
                     BtnHighlight.Visibility = Visibility.Visible;
                     BtnHighlight.Visibility = Visibility.Visible;
                     PathHighlight.Background = new SolidColorBrush((data as TextHighlightAnnotArgs).Color);
                     PathHighlight.Background = new SolidColorBrush((data as TextHighlightAnnotArgs).Color);
                     //TxbContext.Text = data.Content;
                     //TxbContext.Text = data.Content;
-                    if (!string.IsNullOrEmpty(TxbContext.Text))
+                    if (!string.IsNullOrEmpty(TxbMarkupContent.Text))
                     {
                     {
-                        TxbContext.Background = new SolidColorBrush((data as TextHighlightAnnotArgs).Color);
+                        TxbMarkupContent.Background = new SolidColorBrush((data as TextHighlightAnnotArgs).Color);
                     }
                     }
 
 
                     break;
                     break;
@@ -74,7 +74,7 @@ namespace PDF_Office.Views.BOTA
                     PathFreehand.Fill = new SolidColorBrush((data as FreehandAnnotArgs).InkColor);
                     PathFreehand.Fill = new SolidColorBrush((data as FreehandAnnotArgs).InkColor);
                     ImageContext.Visibility = Visibility.Visible;
                     ImageContext.Visibility = Visibility.Visible;
 
 
-                    TxbContext.Visibility = Visibility.Collapsed;
+                    TxbMarkupContent.Visibility = Visibility.Collapsed;
 
 
                     //var encoder = new PngBitmapEncoder();
                     //var encoder = new PngBitmapEncoder();
                     //encoder.Frames.Add(BitmapFrame.Create((BitmapSource)ImageContext.Source));
                     //encoder.Frames.Add(BitmapFrame.Create((BitmapSource)ImageContext.Source));
@@ -129,7 +129,7 @@ namespace PDF_Office.Views.BOTA
                     TextDecorationCollection myCollection2 = new TextDecorationCollection();
                     TextDecorationCollection myCollection2 = new TextDecorationCollection();
                     myCollection2.Add(myStrikeout);
                     myCollection2.Add(myStrikeout);
                     //因为波浪线无法实现 暂时只显示文字 不显示下划线,删除线等
                     //因为波浪线无法实现 暂时只显示文字 不显示下划线,删除线等
-                    TxbContext.TextDecorations = myCollection2;
+                    TxbMarkupContent.TextDecorations = myCollection2;
 
 
                     #endregion to do
                     #endregion to do
 
 
@@ -155,7 +155,7 @@ namespace PDF_Office.Views.BOTA
                     myUnderline.PenThicknessUnit = TextDecorationUnit.FontRecommended;
                     myUnderline.PenThicknessUnit = TextDecorationUnit.FontRecommended;
                     TextDecorationCollection myCollection1 = new TextDecorationCollection();
                     TextDecorationCollection myCollection1 = new TextDecorationCollection();
                     myCollection1.Add(myUnderline);
                     myCollection1.Add(myUnderline);
-                    TxbContext.TextDecorations = myCollection1;
+                    TxbMarkupContent.TextDecorations = myCollection1;
 
 
                     #endregion TO DO
                     #endregion TO DO
 
 
@@ -175,8 +175,8 @@ namespace PDF_Office.Views.BOTA
                     ///对于形状注释等只有Note 的处理
                     ///对于形状注释等只有Note 的处理
                     if (!string.IsNullOrEmpty(data.Content) && string.IsNullOrEmpty(data.MarkupContent))
                     if (!string.IsNullOrEmpty(data.Content) && string.IsNullOrEmpty(data.MarkupContent))
                     {
                     {
-                        TxbMarkUpContent.Text = Regex.Replace(data.Content, "[\r\n]", " ");
-                        TxbContext.Text = "";
+                        TxbMarkupContent.Text = Regex.Replace(data.Content, "[\r\n]", " ");
+                        TxbMarkupContent.Text = "";
                     }
                     }
                     break;
                     break;
 
 
@@ -187,8 +187,8 @@ namespace PDF_Office.Views.BOTA
                     ///对于形状注释等只有Note 的处理
                     ///对于形状注释等只有Note 的处理
                     if (!string.IsNullOrEmpty(data.Content) && string.IsNullOrEmpty(data.MarkupContent))
                     if (!string.IsNullOrEmpty(data.Content) && string.IsNullOrEmpty(data.MarkupContent))
                     {
                     {
-                        TxbMarkUpContent.Text = Regex.Replace(data.Content, "[\r\n]", " ");
-                        TxbContext.Text = "";
+                        TxbMarkupContent.Text = Regex.Replace(data.Content, "[\r\n]", " ");
+                        TxbMarkupContent.Text = "";
                     }
                     }
                     break;
                     break;
 
 
@@ -199,8 +199,8 @@ namespace PDF_Office.Views.BOTA
                     ///对于形状注释等只有Note 的处理
                     ///对于形状注释等只有Note 的处理
                     if (!string.IsNullOrEmpty(data.Content) && string.IsNullOrEmpty(data.MarkupContent))
                     if (!string.IsNullOrEmpty(data.Content) && string.IsNullOrEmpty(data.MarkupContent))
                     {
                     {
-                        TxbMarkUpContent.Text = Regex.Replace(data.Content, "[\r\n]", " ");
-                        TxbContext.Text = "";
+                        TxbMarkupContent.Text = Regex.Replace(data.Content, "[\r\n]", " ");
+                        TxbMarkupContent.Text = "";
                     }
                     }
                     break;
                     break;
 
 
@@ -212,11 +212,11 @@ namespace PDF_Office.Views.BOTA
                         {
                         {
                             if (linkAnnotArgs.DestIndex != -1)
                             if (linkAnnotArgs.DestIndex != -1)
                             {
                             {
-                                TxbContext.Text = string.Format($"To Page {linkAnnotArgs.DestIndex + 1}");
+                                TxbMarkupContent.Text = string.Format($"To Page {linkAnnotArgs.DestIndex + 1}");
                             }
                             }
                             else
                             else
                             {
                             {
-                                TxbContext.Text = string.Format($"{linkAnnotArgs.URI}");
+                                TxbMarkupContent.Text = string.Format($"{linkAnnotArgs.URI}");
                             }
                             }
                         }
                         }
                     }
                     }