Explorar el Código

注释 - 修复bug,选中文字工具创建文字,形状注释

chenrongqian@kdanmobile.com hace 1 año
padre
commit
e1cf04a336

+ 32 - 0
PDF Office/ViewModels/PropertyPanel/AnnotPanel/SharpsAnnotPropertyViewModel.cs

@@ -55,6 +55,34 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
     public class SharpsAnnotPropertyViewModel : BindableBase, INavigationAware
     {
         #region 属性
+        private bool isRect = false;
+        public bool IsRect
+        {
+            get { return isRect; }
+            set => SetProperty(ref isRect, value);
+        }
+
+        private bool isCircle = false;
+        public bool IsCircle
+        {
+            get { return isCircle; }
+            set => SetProperty(ref isCircle, value);
+        }
+
+        private bool isArrow = false;
+        public bool IsArrow
+        {
+            get { return isArrow; }
+            set => SetProperty(ref isArrow, value);
+        }
+
+        private bool isLine = false;
+        public bool IsLine
+        {
+            get { return isLine; }
+            set => SetProperty(ref isLine, value);
+        }
+
         private string _strShapeChecked = "";
 
         public string StrShapeChecked
@@ -566,6 +594,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                             SharpsType("Rect", true);
                             BasicVm.AnnotTypeTitle = "矩形";
                             IsLineAnnot = false;
+                            IsRect = true;
                         }
                         break;
 
@@ -582,6 +611,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                             SharpsType("Circle", true);
                             BasicVm.AnnotTypeTitle = "圆";
                             IsLineAnnot = false;
+                            IsCircle = true;
                         }
                         break;
 
@@ -600,11 +630,13 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                             {
                                 SharpsType("Arrow", true);
                                 BasicVm.AnnotTypeTitle = "箭头";
+                                IsArrow = true;
                             }
                             else
                             {
                                 SharpsType("Line", true);
                                 BasicVm.AnnotTypeTitle = "线条";
+                                IsLine = true;
                             }
 
                             IsLineAnnot = true;

+ 14 - 0
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Command.cs

@@ -125,6 +125,11 @@ namespace PDF_Office.ViewModels.Tools
                         }
 
                     }
+
+                    if(type == AnnotArgsType.AnnotSticky)
+                    {
+                        (CurrentSelectedAnnot as StickyAnnotArgs).PopupEditWnd();
+                    }
                        
                 }
                    
@@ -333,6 +338,11 @@ namespace PDF_Office.ViewModels.Tools
                         {
                             switch (annot.EventType)
                             {
+                                case AnnotArgsType.AnnotSticky:
+                                    customStickyPopup.GetCurrentAnnot = e.AnnotItemsList[0] as StickyAnnotArgs;
+                                    customStickyPopup.GetPDFViewer = PDFViewer;
+                                    break;
+
                                 case AnnotArgsType.AnnotLink:
                                     //viewContentViewModel.IsCreateLink = false;
                                     GetLink(e.AnnotItemsList, e);
@@ -809,6 +819,10 @@ namespace PDF_Office.ViewModels.Tools
                                 AddAnnotSignature(editEvent.EditAnnotArgs);
                             }
                             
+                            if(editEvent.EditAnnotArgs.EventType == AnnotArgsType.AnnotFreeText)
+                            {
+                                (editEvent.EditAnnotArgs as FreeTextAnnotArgs).LineWidth = 0;
+                            }
 
                             break;
 

+ 45 - 1
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Function.cs

@@ -570,6 +570,7 @@ namespace PDF_Office.ViewModels.Tools
         {
             FreeTextAnnotArgs freetextArgs = null;
             TextAlignment textAlignment;
+            
 
             if (selectedArgs == null || selectedArgs.Count == 0)
             {
@@ -638,13 +639,14 @@ namespace PDF_Office.ViewModels.Tools
                 {
                     selectedArgs = new List<AnnotHandlerEventArgs>();
                     selectedArgs.Add(freetextArgs);
+                    SelectTextCreateAnnot(freetextArgs);
                 }
             }
             else
             {
                 freetextArgs = selectedArgs[0] as FreeTextAnnotArgs;
                 textAlignment = freetextArgs.Align;
-
+                
                 if (NavigatedToFillAndSignVM(selectedArgs, "Freetext"))
                 {
                     return freetextArgs;
@@ -655,6 +657,48 @@ namespace PDF_Office.ViewModels.Tools
             return freetextArgs;
         }
 
+        private void SelectTextCreateAnnot(FreeTextAnnotArgs freeText)
+        {
+            List<TextSelectNode> selectList = PDFViewer.GetSelectTextInfo();
+
+            if (selectList != null && selectList.Count > 0)
+            {
+                foreach (TextSelectNode selectNode in selectList)
+                {
+                    FreeTextAnnotArgs textArgs = new FreeTextAnnotArgs();
+                    Rect clientRect = Rect.Empty;
+
+                    foreach (Rect rawRect in selectNode.RawRect)
+                    {
+                        clientRect.Union(rawRect);
+                    }
+                    if (clientRect.IsEmpty == false)
+                    {
+                        clientRect = new Rect(
+                            clientRect.Left / 72D * 96D,
+                            clientRect.Top / 72D * 96D,
+                            clientRect.Width / 72D * 96D,
+                            clientRect.Height / 72D * 96D);
+
+                        textArgs.ClientRect = DpiHelpers.GetDpiRelatedRect(clientRect);
+                        //textArgs.Transparency = 1;
+                        //textArgs.BgColor = Colors.Transparent;
+                        //textArgs.LineColor = Colors.Red;
+                        //textArgs.LineWidth = 2;
+                        textArgs.Transparency = freeText.Transparency;
+                        textArgs.BgColor = freeText.BgColor;
+                        textArgs.LineColor = freeText.LineColor;
+                        textArgs.LineWidth = freeText.LineWidth;
+                        textArgs.TextContent = selectNode.SelectText;
+                        PDFViewer.CreatePageAnnot(selectNode.PageIndex, textArgs);
+                    }
+
+                    break;
+                }
+            }
+
+        }
+
         //Event导航到填写与签名的属性面板
         private bool NavigatedToFillAndSignVM(List<AnnotHandlerEventArgs> annots, string tag)
         {

+ 1 - 1
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.cs

@@ -203,7 +203,7 @@ namespace PDF_Office.ViewModels.Tools
             if (dictVar["isTemplateAnnot"] == false && annotArgs == null)
             {
                 //当不是注释模板,且无创建注释时,属性面板显示为空内容
-                PDFViewer.SetMouseMode(MouseModes.PanTool);
+                HandToolIsCheckedEvent(false);
                 viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
             }
             else

+ 25 - 18
PDF Office/Views/PropertyPanel/AnnotPanel/SharpsAnnotProperty.xaml

@@ -117,9 +117,7 @@
                     <RadioButton x:Name="SharpRectBtn" Tag="Rect" GroupName="Shape"
                                  Width="32" Height="32" Margin="0,0" ToolTip="矩形" Padding="7,0,0,0"
                                  VerticalContentAlignment="Center" Background="Transparent"
-                                 Command="{Binding SharpsTypeCommand}"
-                                 CommandParameter="{Binding ElementName=SharpRectBtn, Path=Tag}"
-                                 IsChecked="{Binding StrShapeChecked,Converter={StaticResource AnnotToolIsCheckedConvert},ConverterParameter=Rect}"
+                                 IsChecked="{Binding IsRect}"
                                  Style="{DynamicResource GreyBgRadioBtnStyle}">
                         <RadioButton.Content>
                             <Rectangle
@@ -129,15 +127,17 @@
                                 VerticalAlignment="Center"
                                 Stroke="#273C62" />
                         </RadioButton.Content>
-                       
+                        <i:Interaction.Triggers>
+                            <i:EventTrigger EventName="Checked">
+                                <i:InvokeCommandAction Command="{Binding SharpsTypeCommand}"  CommandParameter="{Binding ElementName=SharpRectBtn, Path=Tag}"/>
+                            </i:EventTrigger>
+                        </i:Interaction.Triggers>
                     </RadioButton>
 
                     <RadioButton x:Name="SharpCircleBtn" Tag="Circle" GroupName="Shape"  Grid.Column="1"
                                  Width="32" Height="32" Margin="0,0" ToolTip="圆" Padding="7,0,0,0"
                                  VerticalContentAlignment="Center" Background="Transparent"
-                                 Command="{Binding SharpsTypeCommand}"
-                                 CommandParameter="{Binding ElementName=SharpCircleBtn, Path=Tag}"
-                                 IsChecked="{Binding StrShapeChecked,Converter={StaticResource AnnotToolIsCheckedConvert},ConverterParameter=Circle}"
+                                 IsChecked="{Binding IsCircle}"
                                  Style="{DynamicResource GreyBgRadioBtnStyle}">
                         <RadioButton.Content>
                             <Ellipse
@@ -147,15 +147,17 @@
                                 VerticalAlignment="Center"
                                 Stroke="#273C62" />
                         </RadioButton.Content>
-                       
+                        <i:Interaction.Triggers>
+                            <i:EventTrigger EventName="Checked">
+                                <i:InvokeCommandAction Command="{Binding SharpsTypeCommand}"  CommandParameter="{Binding ElementName=SharpCircleBtn, Path=Tag}"/>
+                            </i:EventTrigger>
+                        </i:Interaction.Triggers>
                     </RadioButton>
 
                     <RadioButton x:Name="SharpArrowBtn" Tag="Arrow" GroupName="Shape"  Grid.Column="2"
                                  Width="32" Height="32" Margin="0,0" ToolTip="箭头" Padding="7,0,0,0"
                                  VerticalContentAlignment="Center" Background="Transparent"
-                                 Command="{Binding SharpsTypeCommand}" 
-                                 CommandParameter="{Binding ElementName=SharpArrowBtn, Path=Tag}"
-                                 IsChecked="{Binding StrShapeChecked,Converter={StaticResource AnnotToolIsCheckedConvert},ConverterParameter=Arrow}"
+                                 IsChecked="{Binding IsArrow}"
                                  Style="{DynamicResource GreyBgRadioBtnStyle}">
                         <RadioButton.Content>
                             <Path
@@ -169,15 +171,16 @@
                                 </Path.Data>
                             </Path>
                         </RadioButton.Content>
-                        
+                        <i:Interaction.Triggers>
+                            <i:EventTrigger EventName="Checked">
+                                <i:InvokeCommandAction Command="{Binding SharpsTypeCommand}"  CommandParameter="{Binding ElementName=SharpArrowBtn, Path=Tag}"/>
+                            </i:EventTrigger>
+                        </i:Interaction.Triggers>
                     </RadioButton>
 
                     <RadioButton x:Name="SharpLineBtn" Tag="Line" GroupName="Shape"  Grid.Column="3"
-                                 Width="32" Height="32" Margin="0,0" ToolTip="线条" Padding="7,0,0,0"
-                                 VerticalContentAlignment="Center" Background="Transparent"
-                                 Command="{Binding SharpsTypeCommand}" 
-                                 CommandParameter="{Binding ElementName=SharpLineBtn, Path=Tag}"
-                                 IsChecked="{Binding StrShapeChecked,Converter={StaticResource AnnotToolIsCheckedConvert},ConverterParameter=Line}"
+                                 Width="32" Height="32" Margin="0,0" ToolTip="线条" Padding="7,8,0,0"
+                                 IsChecked="{Binding IsLine}" Background="Transparent"
                                  Style="{DynamicResource GreyBgRadioBtnStyle}">
                         <RadioButton.Content>
                             <Polygon
@@ -191,7 +194,11 @@
                                 </Polygon.Points>
                             </Polygon>
                         </RadioButton.Content>
-                       
+                        <i:Interaction.Triggers>
+                            <i:EventTrigger EventName="Checked">
+                                <i:InvokeCommandAction Command="{Binding SharpsTypeCommand}"  CommandParameter="{Binding ElementName=SharpLineBtn, Path=Tag}"/>
+                            </i:EventTrigger>
+                        </i:Interaction.Triggers>
                     </RadioButton>
                 </Grid>
             </Border>

+ 1 - 0
PDF Office/Views/PropertyPanel/AnnotPanel/StickyNotePopup.xaml.cs

@@ -361,6 +361,7 @@ namespace PDF_Office.Views.PropertyPanel.AnnotPanel
                     AnnotEvent?.UpdateAttrib(AnnotAttrib.Color, color);
                     AnnotEvent?.UpdateAnnot();
                 }
+
                 border.BorderBrush = new SolidColorBrush(color);
                 this.Background = new SolidColorBrush(Colors.Transparent);
                 this.BorderBrush = new SolidColorBrush(Colors.Transparent);