Browse Source

compdfkit demo windows - 基础控件 - NumericUpDown

liuaoran 1 year ago
parent
commit
f36fd96535
20 changed files with 595 additions and 63 deletions
  1. 8 7
      compdfkit_demo_windows/compdfkit/annotation-ctrl-demo/MainWindow.xaml.cs
  2. 18 0
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/ArrowControl/CPDFArrowControlControl.xaml
  3. 28 0
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/ArrowControl/CPDFArrowControlControl.xaml.cs
  4. 174 0
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/ArrowControl/CPDFArrowUI.xaml
  5. 4 13
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationUI/CPDFShapeUI.xaml.cs
  6. 16 11
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationData/CPDFAnnotationData.cs
  7. 0 0
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationControl/CPDFAnnotationControl.xaml
  8. 27 8
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationControl/CPDFAnnotationControl.xaml.cs
  9. 0 0
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFLinkUI.xaml
  10. 0 0
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFLinkUI.xaml.cs
  11. 0 0
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFMarkupUI.xaml
  12. 0 0
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFMarkupUI.xaml.cs
  13. 7 3
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationUI/CPDFShapeUI.xaml
  14. 75 0
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFShapeUI.xaml.cs
  15. 0 0
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFSoundUI.xaml
  16. 0 0
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFSoundUI.xaml.cs
  17. 13 11
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/BarControl/CPDFAnnotationBarControl.xaml.cs
  18. 93 0
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/BaseControl/NumericUpDownControl.xaml
  19. 101 0
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/BaseControl/NumericUpDownControl.xaml.cs
  20. 31 10
      compdfkit_demo_windows/compdfkit/compdfkit-tools/compdfkit-tools.csproj

+ 8 - 7
compdfkit_demo_windows/compdfkit/annotation-ctrl-demo/MainWindow.xaml.cs

@@ -40,9 +40,16 @@ namespace annotation_ctrl_demo
 
         private void AnnotationBarControl_Loaded(object sender, RoutedEventArgs e)
         {
-            AnnotationType[] annotationProperties = { AnnotationType.Highlight, AnnotationType.Underline, AnnotationType.Strikeout, AnnotationType.Squiggly, AnnotationType.Freetext, AnnotationType.Note, AnnotationType.Round, AnnotationType.Rect, AnnotationType.Arrow, AnnotationType.StraightLine, AnnotationType.Line, AnnotationType.Stamp, AnnotationType.Signature, AnnotationType.Link, AnnotationType.Sound };
+            AnnotationType[] annotationProperties = { AnnotationType.Highlight, AnnotationType.Underline, AnnotationType.Strikeout, AnnotationType.Squiggly, AnnotationType.Freetext, AnnotationType.Note, AnnotationType.Circle, AnnotationType.Square, AnnotationType.Arrow, AnnotationType.Line, AnnotationType.Stamp, AnnotationType.Signature, AnnotationType.Link, AnnotationType.Sound };
             AnnotationBarControl.InitAnnotationBar(annotationProperties);
             AnnotationBarControl.AnnotationPropertyChanged += AnnotationBarControl_AnnotationPropertyChanged;
+            AnnotationBarControl.AnnotationCancel += AnnotationBarControl_AnnotationCancel;
+        }
+
+        private void AnnotationBarControl_AnnotationCancel(object sender, EventArgs e)
+        {
+            pdfAnnotationControl.AnnotationCancel();
+            ExpandPropertyPanel((sender as ToggleButton).IsChecked == true);
         }
 
         /// <summary>
@@ -62,11 +69,6 @@ namespace annotation_ctrl_demo
             ExpandPropertyPanel((sender as ToggleButton).IsChecked == true);
         }
 
-        private void PDFAnnotationControl_PropertyChanged(object sender, CPDFAnnotationData e)
-        {
-            //CPDFViewerControl.ChangeAnnotationMode(e);
-        }
-
         private void ModeSelectorBarControl_ShowBOTAEvent(object sender, EventArgs e)
         {
             UIElement botaTool = GetBotaTool();
@@ -137,7 +139,6 @@ namespace annotation_ctrl_demo
             if (isExpand)
             {
                 BodyGrid.ColumnDefinitions[4].Width = new GridLength(300);
-
             }
             else
             {

+ 18 - 0
compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/ArrowControl/CPDFArrowControlControl.xaml

@@ -0,0 +1,18 @@
+<UserControl x:Class="compdfkit_tools.PDFControl.CPDFArrowControlControl"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             xmlns:cpdftoolsui="clr-namespace:compdfkit_tools.PDFControlUI"
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+             xmlns:local="clr-namespace:compdfkit_tools.PDFControl"
+             mc:Ignorable="d" 
+             d:DesignHeight="75" d:DesignWidth="300">
+    <Grid>
+        <Grid.ColumnDefinitions>
+            <ColumnDefinition></ColumnDefinition>
+            <ColumnDefinition></ColumnDefinition>
+        </Grid.ColumnDefinitions>
+        <cpdftoolsui:CPDFArrowUI></cpdftoolsui:CPDFArrowUI>
+        <cpdftoolsui:CPDFArrowUI Grid.Column="1"></cpdftoolsui:CPDFArrowUI>
+    </Grid>
+</UserControl>

+ 28 - 0
compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/ArrowControl/CPDFArrowControlControl.xaml.cs

@@ -0,0 +1,28 @@
+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 compdfkit_tools.PDFControl
+{
+    /// <summary>
+    /// CPDFArrowControlControl.xaml 的交互逻辑
+    /// </summary>
+    public partial class CPDFArrowControlControl : UserControl
+    {
+        public CPDFArrowControlControl()
+        {
+            InitializeComponent();
+        }
+    }
+}

+ 174 - 0
compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/ArrowControl/CPDFArrowUI.xaml

@@ -0,0 +1,174 @@
+<UserControl x:Class="compdfkit_tools.PDFControlUI.CPDFArrowUI"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+             xmlns:local="clr-namespace:compdfkit_tools.PDFControlUI"
+             mc:Ignorable="d" 
+             d:DesignHeight="30" d:DesignWidth="115">
+    <UserControl.Resources>
+        <ControlTemplate x:Key="ComboxItemTemplate" TargetType="{x:Type ComboBoxItem}">
+            <Border
+                    Name="Bd"
+                    Padding="{TemplateBinding Control.Padding}"
+                    Background="{TemplateBinding Panel.Background}"
+                    BorderBrush="{TemplateBinding Border.BorderBrush}"
+                    BorderThickness="{TemplateBinding Border.BorderThickness}"
+                    SnapsToDevicePixels="True">
+                <ContentPresenter
+                        HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}"
+                        VerticalAlignment="{TemplateBinding Control.VerticalContentAlignment}"
+                        Content="{TemplateBinding ContentControl.Content}"
+                        ContentStringFormat="{TemplateBinding ContentControl.ContentStringFormat}"
+                        ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}"
+                        SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
+            </Border>
+            <ControlTemplate.Triggers>
+                <Trigger Property="UIElement.IsEnabled" Value="False">
+                    <Setter TargetName="Bd" Property="TextElement.Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
+                </Trigger>
+                <MultiTrigger>
+                    <MultiTrigger.Conditions>
+                        <Condition Property="Selector.IsSelected" Value="False" />
+                        <Condition Property="UIElement.IsMouseOver" Value="True" />
+                        <Condition Property="UIElement.IsKeyboardFocused" Value="False" />
+                    </MultiTrigger.Conditions>
+                    <Setter TargetName="Bd" Property="Panel.Background" Value="#1F26A0DA" />
+                    <Setter TargetName="Bd" Property="Border.BorderBrush" Value="#A826A0DA" />
+                </MultiTrigger>
+                <MultiTrigger>
+                    <MultiTrigger.Conditions>
+                        <Condition Property="Selector.IsSelected" Value="True" />
+                        <Condition Property="UIElement.IsMouseOver" Value="False" />
+                        <Condition Property="UIElement.IsKeyboardFocused" Value="True" />
+                    </MultiTrigger.Conditions>
+                    <Setter TargetName="Bd" Property="Panel.Background" Value="#3D26A0DA" />
+                    <Setter TargetName="Bd" Property="Border.BorderBrush" Value="#26A0DA" />
+                </MultiTrigger>
+                <MultiTrigger>
+                    <MultiTrigger.Conditions>
+                        <Condition Property="Selector.IsSelected" Value="True" />
+                        <Condition Property="UIElement.IsMouseOver" Value="True" />
+                    </MultiTrigger.Conditions>
+                    <Setter TargetName="Bd" Property="Panel.Background" Value="#1A477EDE" />
+                    <Setter TargetName="Bd" Property="Border.BorderBrush" Value="#1A477EDE" />
+                </MultiTrigger>
+                <MultiTrigger>
+                    <MultiTrigger.Conditions>
+                        <Condition Property="Selector.IsSelected" Value="True" />
+                        <Condition Property="UIElement.IsMouseOver" Value="False" />
+                        <Condition Property="UIElement.IsKeyboardFocused" Value="False" />
+                    </MultiTrigger.Conditions>
+                    <Setter TargetName="Bd" Property="Panel.Background" Value="#3DDADADA" />
+                    <Setter TargetName="Bd" Property="Border.BorderBrush" Value="#DADADA" />
+                </MultiTrigger>
+                <MultiTrigger>
+                    <MultiTrigger.Conditions>
+                        <Condition Property="Selector.IsSelected" Value="False" />
+                        <Condition Property="UIElement.IsMouseOver" Value="False" />
+                        <Condition Property="UIElement.IsKeyboardFocused" Value="True" />
+                    </MultiTrigger.Conditions>
+                    <Setter TargetName="Bd" Property="Border.BorderBrush" Value="#26A0DA" />
+                </MultiTrigger>
+                <MultiTrigger>
+                    <MultiTrigger.Conditions>
+                        <Condition Property="Selector.IsSelected" Value="False" />
+                        <Condition Property="UIElement.IsMouseOver" Value="True" />
+                        <Condition Property="UIElement.IsKeyboardFocused" Value="True" />
+                    </MultiTrigger.Conditions>
+                    <Setter TargetName="Bd" Property="Panel.Background" Value="#1A000000" />
+                    <Setter TargetName="Bd" Property="Border.BorderBrush" Value="#1A000000" />
+                </MultiTrigger>
+            </ControlTemplate.Triggers>
+        </ControlTemplate>
+    </UserControl.Resources>
+    <Grid>
+        <Border BorderBrush="#E2E3E6" BorderThickness="0"  Width="115" Height="32">
+            <ComboBox x:Name="StartArrowBox" Background="Transparent" BorderThickness="1" BorderBrush="#FFE2E3E6" IsReadOnly="True" MaxDropDownHeight="200">
+                <ComboBox.ItemContainerStyle>
+                    <Style TargetType="{x:Type ComboBoxItem}">
+                        <Setter Property="Padding" Value="25 0 0 0"></Setter>
+                    </Style>
+                </ComboBox.ItemContainerStyle>
+                <ComboBoxItem VerticalAlignment="Center" Height="32" Template="{StaticResource ComboxItemTemplate}">
+                    <Path Fill="#000000" Tag="Line" Height="20">
+                        <Path.Data>
+                            F1 M40,16z M0,0z M34,7.5L34,7.5 34,8.5 6,8.5 6,7.5z
+                        </Path.Data>
+                    </Path>
+                </ComboBoxItem>
+
+                <ComboBoxItem  VerticalAlignment="Center" Height="32" VerticalContentAlignment="Center" Template="{StaticResource ComboxItemTemplate}">
+                    <Path Fill="#000000" Tag="Arrow" Height="20">
+                        <Path.Data>
+                            F1 M40,16z M0,0z M10.7427521,4.57125354L11.2572479,5.42874646 7.80417468,7.49925354 34,7.5 34,8.5 7.80417468,8.49925354 11.2572479,10.5712535 10.7427521,11.4287465 5.02817468,8 10.7427521,4.57125354z
+                        </Path.Data>
+                    </Path>
+                </ComboBoxItem>
+
+                <ComboBoxItem VerticalAlignment="Center" Height="32" VerticalContentAlignment="Center" Template="{StaticResource ComboxItemTemplate}">
+                    <Path Fill="#000000" Tag="CloseArrow" Height="20">
+                        <Path.Data>
+                            F1 M40,16z M0,0z M11.5,4.11690481L11.4991747,7.49990481 34,7.5 34,8.5 11.4991747,8.49990481 11.5,11.8830952 5.02817468,8 11.5,4.11690481z
+                        </Path.Data>
+                    </Path>
+                </ComboBoxItem>
+
+                <ComboBoxItem VerticalAlignment="Center" Height="32" VerticalContentAlignment="Center" Template="{StaticResource ComboxItemTemplate}">
+                    <Path Fill="#000000" Tag="Square"  Height="20">
+                        <Path.Data>
+                            M11.5,5 L11.5,7.5 L34,7.5 L34,8.5 L11.5,8.5 L11.5,11 L5.5,11 L5.5,5 L11.5,5 Z
+                        </Path.Data>
+                    </Path>
+                </ComboBoxItem>
+
+                <ComboBoxItem VerticalAlignment="Center" Height="32" VerticalContentAlignment="Center" Template="{StaticResource ComboxItemTemplate}">
+                    <Path Fill="#000000" Tag="Circle"  Height="20">
+                        <Path.Data>
+                            M8.5,5 C9.98660106,5 11.2206526,6.08129303 11.4585702,7.50029469 L34,7.5 L34,8.5 L11.4584039,8.50069618 C11.2200781,9.9192103 9.98625501,11 8.5,11 C6.84314575,11 5.5,9.65685425 5.5,8 C5.5,6.34314575 6.84314575,5 8.5,5 Z
+                        </Path.Data>
+                    </Path>
+                </ComboBoxItem>
+
+                <ComboBoxItem VerticalAlignment="Center" Height="32" VerticalContentAlignment="Center" Template="{StaticResource ComboxItemTemplate}">
+                    <Path Fill="#000000" Tag="Diamond"  Height="20">
+                        <Path.Data>
+                            M9,4.29289322 L12.2068932,7.49989322 L34,7.5 L34,8.5 L12.2068932,8.49989322 L9,11.7071068 L5.29289322,8 L9,4.29289322 Z
+                        </Path.Data>
+                    </Path>
+                </ComboBoxItem>
+
+                <ComboBoxItem VerticalAlignment="Center" Height="32" VerticalContentAlignment="Center" Template="{StaticResource ComboxItemTemplate}">
+                    <Path Fill="#000000" Tag="Butt"  Height="20">
+                        <Path.Data>
+                            M7.5,5.5 L7.5,7.5 L34,7.5 L34,8.5 L7.5,8.5 L7.5,10.5 L6.5,10.5 L6.5,5.5 L7.5,5.5 Z
+                        </Path.Data>
+                    </Path>
+                </ComboBoxItem>
+
+                <ComboBoxItem  VerticalAlignment="Center" Height="32" VerticalContentAlignment="Center" Template="{StaticResource ComboxItemTemplate}">
+                    <Path Fill="#000000" Tag="RArrow" Height="20">
+                        <Path.Data>
+                            M5.58660083,5.07600085 L9.46460189,7.49900085 L34,7.5 L34,8.5 L9.46460189,8.49900085 L5.58660083,10.9239992 L5.05660189,10.0760008 L8.37960136,8 L5.05660189,5.92399915 L5.58660083,5.07600085 Z
+                        </Path.Data>
+                    </Path>
+                </ComboBoxItem>
+
+                <ComboBoxItem VerticalAlignment="Center" Height="32" VerticalContentAlignment="Center" Template="{StaticResource ComboxItemTemplate}">
+                    <Path Fill="#000000" Tag="RCloseArrow" Height="20">
+                        <Path.Data>
+                            M5.5,4.59787618 L10.143,7.49987618 L34,7.5 L34,8.5 L10.143,8.49987618 L5.5,11.4021238 L5.5,4.59787618 Z
+                        </Path.Data>
+                    </Path>
+                </ComboBoxItem>
+                <ComboBoxItem VerticalAlignment="Center" Height="32" VerticalContentAlignment="Center" Template="{StaticResource ComboxItemTemplate}">
+                    <Path Fill="#000000" Tag="Slash" Height="20">
+                        <Path.Data>
+                            M9.531981,5.84644661 L10.239087,6.55355339 L9.292447,7.49944661 L34,7.5 L34,8.5 L8.292447,8.49944661 L6.703553,10.0890873 L5.996447,9.38198052 L9.531981,5.84644661 Z
+                        </Path.Data>
+                    </Path>
+                </ComboBoxItem>
+            </ComboBox>
+        </Border>
+    </Grid>
+</UserControl>

+ 4 - 13
compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationUI/CPDFShapeUI.xaml.cs

@@ -1,6 +1,4 @@
-using compdfkit_tools.Common;
-using compdfkit_tools.Data;
-using System;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
@@ -18,20 +16,13 @@ using System.Windows.Shapes;
 namespace compdfkit_tools.PDFControlUI
 {
     /// <summary>
-    /// CPDFRectUI.xaml 的交互逻辑
+    /// CPDFArrowControl.xaml 的交互逻辑
     /// </summary>
-    public partial class CPDFShapeUI : UserControl
+    public partial class CPDFArrowUI : UserControl
     {
-        public CPDFShapeUI()
+        public CPDFArrowUI()
         {
             InitializeComponent();
         }
-
-        public CPDFShapeData GetShapeData()
-        {
-            CPDFShapeData pdfShapeData = new CPDFShapeData();
-            
-            return pdfShapeData;
-        }
     }
 }

+ 16 - 11
compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationData/CPDFAnnotationData.cs

@@ -1,4 +1,5 @@
-using compdfkit_tools.PDFControl;
+using ComPDFKit.PDFAnnotation;
+using compdfkit_tools.PDFControl;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -17,10 +18,9 @@ namespace compdfkit_tools.Data
         Squiggly,
         Freetext,
         Note,
-        Round,
-        Rect,
+        Circle,
+        Square,
         Arrow,
-        StraightLine,
         Line,
         Stamp,
         Signature,
@@ -35,9 +35,9 @@ namespace compdfkit_tools.Data
             { "Underline", AnnotationType.Underline },
             { "Strikeout", AnnotationType.Strikeout },
             { "Squiggly", AnnotationType.Squiggly },
-            { "Rect", AnnotationType.Rect },
-            {"Round", AnnotationType.Round },
-            { "StraightLine", AnnotationType.StraightLine },
+            { "Square", AnnotationType.Square },
+            { "Circle", AnnotationType.Circle },
+            { "Line", AnnotationType.Line },
             { "Arrow", AnnotationType.Arrow }
         };
     }
@@ -61,12 +61,17 @@ namespace compdfkit_tools.Data
         public Color BorderColor = Color.FromRgb(255, 0, 0);
         public Color FillColor = Color.FromRgb(255, 255, 255);
         public double Opacity = 1;
-        public double BorderWidth = 1;
-        public int DottedLineSpacing = 1;
+        public double Thickness = 1;
+        public int DashSpacing = 1;
     }
 
-    public class CPDFArrowData : CPDFShapeData
+    public class CPDFLineShapeData : CPDFAnnotationData
     {
-
+        public Color BorderColor = Color.FromRgb(255, 0, 0);
+        public C_LINE_TYPE HeadLineType = C_LINE_TYPE.LINETYPE_NONE;
+        public C_LINE_TYPE TailLineType = C_LINE_TYPE.LINETYPE_NONE;
+        public double Opacity = 1;
+        public double Thickness = 1;
+        public int DashSpacing = 1;
     }
 }

compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationControl/CPDFAnnotationControl.xaml → compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationControl/CPDFAnnotationControl.xaml


+ 27 - 8
compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationControl/CPDFAnnotationControl.xaml.cs

@@ -59,9 +59,9 @@ namespace compdfkit_tools.Annotation.PDFAnnotationControl
         /// 展开Annotation面板
         /// </summary>
         /// <param name="isExpand"></param>
-        private void ExpandPanel(bool isExpand)
+        private void ExpandPanel()
         {
-            AnnotationPanelContainer.Visibility = isExpand ? Visibility.Visible : Visibility.Collapsed;
+            AnnotationPanelContainer.Visibility = Visibility.Visible;
         }
 
         private void GetAnnotationData()
@@ -76,7 +76,7 @@ namespace compdfkit_tools.Annotation.PDFAnnotationControl
                     SetAnnotationProperty((annotationPanel as CPDFMarkupUI).GetMarkupData());
                     break;
 
-                case AnnotationType.Rect:
+                case AnnotationType.Square:
                     break;
                 default:
                     break;
@@ -98,7 +98,6 @@ namespace compdfkit_tools.Annotation.PDFAnnotationControl
                     (annotHandlerEventArgs as TextHighlightAnnotArgs).Content = highlightData.Note;
                     (annotHandlerEventArgs as TextHighlightAnnotArgs).Author = highlightData.Author;
                     (annotHandlerEventArgs as TextHighlightAnnotArgs).Locked = highlightData.IsLocked;
-
                     break;
 
                 case AnnotationType.Underline:
@@ -120,6 +119,7 @@ namespace compdfkit_tools.Annotation.PDFAnnotationControl
                     (annotHandlerEventArgs as TextStrikeoutAnnotArgs).Author = strikeoutData.Author;
                     (annotHandlerEventArgs as TextStrikeoutAnnotArgs).Content = strikeoutData.Note;
                     break;
+
                 case AnnotationType.Squiggly:
                     CPDFMarkupData squigglyData = pdfAnnotationData as CPDFMarkupData;
                     annotHandlerEventArgs = new TextSquigglyAnnotArgs();
@@ -129,6 +129,19 @@ namespace compdfkit_tools.Annotation.PDFAnnotationControl
                     (annotHandlerEventArgs as TextSquigglyAnnotArgs).Author = squigglyData.Author;
                     (annotHandlerEventArgs as TextSquigglyAnnotArgs).Content = squigglyData.Note;
                     break;
+
+                case AnnotationType.Square:
+                    annotHandlerEventArgs = new SquareAnnotArgs();
+                    break;
+                case AnnotationType.Circle:
+                    annotHandlerEventArgs = new CircleAnnotArgs();
+                    break;
+                case AnnotationType.Arrow:
+                    annotHandlerEventArgs = new LineAnnotArgs();
+                    break;
+                case AnnotationType.Line:
+                    annotHandlerEventArgs = new LineAnnotArgs();
+                    break;
                 case AnnotationType.None:
                 default:
                     break;
@@ -140,6 +153,11 @@ namespace compdfkit_tools.Annotation.PDFAnnotationControl
             }
         }
 
+        public void AnnotationCancel()
+        {
+            this.pdfViewer.SetMouseMode(MouseModes.PanTool);
+        }
+
         private void CPDFAnnotationControl_PropertyChanged(object sender, CPDFAnnotationData e)
         {
             SetAnnotationProperty(e);
@@ -158,17 +176,18 @@ namespace compdfkit_tools.Annotation.PDFAnnotationControl
                     annotationPanel = new CPDFMarkupUI();
                     (annotationPanel as CPDFMarkupUI).InitWithAnnotationType(annotationType);
                     break;
-                case AnnotationType.Rect:
-                case AnnotationType.Round:
+                case AnnotationType.Square:
+                case AnnotationType.Circle:
                 case AnnotationType.Arrow:
-                case AnnotationType.StraightLine:
+                case AnnotationType.Line:
                     annotationPanel = new CPDFShapeUI();
+                    (annotationPanel as CPDFShapeUI).InitWithAnnotationType(annotationType);
                     break;
                 default:
                     break;
             }
             SetAnnotationPanel(annotationPanel);
-            ExpandPanel(true);
+            ExpandPanel();
             GetAnnotationData();
         }
     }

compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationUI/CPDFLinkUI.xaml → compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFLinkUI.xaml


compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationUI/CPDFLinkUI.xaml.cs → compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFLinkUI.xaml.cs


compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationUI/CPDFMarkupUI.xaml → compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFMarkupUI.xaml


compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationUI/CPDFMarkupUI.xaml.cs → compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFMarkupUI.xaml.cs


+ 7 - 3
compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationUI/CPDFShapeUI.xaml

@@ -3,6 +3,7 @@
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+             xmlns:cpdftools="clr-namespace:compdfkit_tools.PDFControl"
              xmlns:local="clr-namespace:compdfkit_tools.PDFControlUI"
             xmlns:cpdfcommon="clr-namespace:compdfkit_tools.Common"
              mc:Ignorable="d" 
@@ -11,14 +12,14 @@
         <StackPanel Orientation="Vertical">
 
             <StackPanel Orientation="Vertical" Height="150">
-                <TextBlock Text="矩形" HorizontalAlignment="Center"></TextBlock>
+                <TextBlock x:Name="TitleTextBlock" HorizontalAlignment="Center"></TextBlock>
                 <Border Height="100" Background="#DEDEDE" Margin="10" CornerRadius="5"></Border>
             </StackPanel>
             <StackPanel Height="75" Margin="5">
                 <TextBlock Text="Border Color"></TextBlock>
                 <cpdfcommon:ColorPickerControl x:Name="BorderColorPickerControl"></cpdfcommon:ColorPickerControl>
             </StackPanel>
-            <StackPanel Height="75" Margin="5" Visibility="Visible">
+            <StackPanel x:Name="FillColorStackPanel" Height="75" Margin="5">
                 <TextBlock Text="Fill Color"></TextBlock>
                 <cpdfcommon:ColorPickerControl x:Name="FillColorPickerControl"></cpdfcommon:ColorPickerControl>
             </StackPanel>
@@ -28,12 +29,15 @@
             </StackPanel>
             <StackPanel Height="75" Margin="5">
                 <TextBlock Text="Border Width"></TextBlock>
-                <cpdfcommon:CPDFOpacityControl x:Name="CPDFBorderWidthControl"></cpdfcommon:CPDFOpacityControl>
+                <cpdfcommon:CPDFBorderWidthUI x:Name="CPDFBorderWidthControl"></cpdfcommon:CPDFBorderWidthUI>
             </StackPanel>
             <StackPanel Height="75" Margin="5">
                 <TextBlock Text="Dotted Line"></TextBlock>
                 <cpdfcommon:CPDFOpacityControl x:Name="DottedLineControl"></cpdfcommon:CPDFOpacityControl>
             </StackPanel>
+            <StackPanel x:Name="ArrowStackPanel" Visibility="Visible" Height="75">
+                <cpdftools:CPDFArrowControlControl></cpdftools:CPDFArrowControlControl>
+            </StackPanel>
             <StackPanel Height="200" Margin="5">
                 <TextBlock Text="Note"></TextBlock>
                 <TextBox Height="150"  x:Name="NoteTextBox"></TextBox>

+ 75 - 0
compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFShapeUI.xaml.cs

@@ -0,0 +1,75 @@
+using compdfkit_tools.Common;
+using compdfkit_tools.Data;
+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 compdfkit_tools.PDFControlUI
+{
+    /// <summary>
+    /// CPDFRectUI.xaml 的交互逻辑
+    /// </summary>
+    public partial class CPDFShapeUI : UserControl
+    {
+        private AnnotationType currentAnnotationType;
+
+        public CPDFShapeUI()
+        {
+            InitializeComponent();
+        }
+
+        public CPDFShapeData GetShapeData()
+        {
+            CPDFShapeData pdfShapeData = new CPDFShapeData();
+
+            return pdfShapeData;
+        }
+
+        public void SetUIWhenRectAndRound()
+        {
+
+        }
+
+        public void SetUIWhenArrowAndLine()
+        {
+
+        }
+
+        public void InitWithAnnotationType(AnnotationType annotationType)
+        {
+            switch (annotationType)
+            {
+                case AnnotationType.Square:
+                    TitleTextBlock.Text = "Square";
+                    SetUIWhenRectAndRound();
+                    break;
+                case AnnotationType.Circle:
+                    TitleTextBlock.Text = "Circle";
+                    SetUIWhenRectAndRound();
+                    break;
+                case AnnotationType.Arrow:
+                    TitleTextBlock.Text = "Arrow";
+                    SetUIWhenArrowAndLine();
+                    break;
+                case AnnotationType.Line:
+                    TitleTextBlock.Text = "Line";
+                    SetUIWhenArrowAndLine();
+                    break;
+                default:
+                    throw new ArgumentException("Not Excepted Argument");
+            }
+            currentAnnotationType = annotationType;
+        }
+    }
+}

compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationUI/CPDFSoundUI.xaml → compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFSoundUI.xaml


compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationUI/CPDFSoundUI.xaml.cs → compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFSoundUI.xaml.cs


+ 13 - 11
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/BarControl/CPDFAnnotationBarControl.xaml.cs

@@ -13,13 +13,9 @@ 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 compdfkit_tools.PDFControl
 {
-
-
     /// <summary>
     /// PDFAnnotationBarControl.xaml 的交互逻辑
     /// </summary>
@@ -29,7 +25,7 @@ namespace compdfkit_tools.PDFControl
         private Brush brush = null;
 
         public event EventHandler<AnnotationType> AnnotationPropertyChanged;
-        public event EventHandler AnnotationPropertyCancel;
+        public event EventHandler AnnotationCancel;
 
         public CPDFAnnotationBarControl()
         {
@@ -38,7 +34,6 @@ namespace compdfkit_tools.PDFControl
 
         private void CreateAnnotationButton(ToggleButton toggleButton)
         {
-
             toggleButton.Width = 50;
             toggleButton.Background = brush;
             Geometry annotationGeometry = Geometry.Parse(""); ;
@@ -69,11 +64,11 @@ namespace compdfkit_tools.PDFControl
             {
                 path = "pack://application:,,,/com.compdfkit.tools;component/Asset/Resource/Annotation/Note.png";
             }
-            else if (toggleButton.Tag.ToString() == AnnotationType.Rect.ToString())
+            else if (toggleButton.Tag.ToString() == AnnotationType.Square.ToString())
             {
                 path = "pack://application:,,,/com.compdfkit.tools;component/Asset/Resource/Annotation/Rect.png";
             }
-            else if (toggleButton.Tag.ToString() == AnnotationType.Round.ToString())
+            else if (toggleButton.Tag.ToString() == AnnotationType.Circle.ToString())
             {
                 path = "pack://application:,,,/com.compdfkit.tools;component/Asset/Resource/Annotation/Round.png";
             }
@@ -81,7 +76,7 @@ namespace compdfkit_tools.PDFControl
             {
                 path = "pack://application:,,,/com.compdfkit.tools;component/Asset/Resource/Annotation/Arrow.png";
             }
-            else if (toggleButton.Tag.ToString() == AnnotationType.StraightLine.ToString())
+            else if (toggleButton.Tag.ToString() == AnnotationType.Line.ToString())
             {
                 path = "pack://application:,,,/com.compdfkit.tools;component/Asset/Resource/Annotation/StraightLine.png";
             }
@@ -104,7 +99,6 @@ namespace compdfkit_tools.PDFControl
             else if (toggleButton.Tag.ToString() == AnnotationType.Sound.ToString())
             {
                 path = "pack://application:,,,/com.compdfkit.tools;component/Asset/Resource/Annotation/Sound.png";
-
             }
             if (path != string.Empty)
             {
@@ -138,8 +132,16 @@ namespace compdfkit_tools.PDFControl
 
         private void ToggleButton_Click(object sender, RoutedEventArgs e)
         {
+
             ClearToolState(sender as ToggleButton);
-            AnnotationPropertyChanged?.Invoke(sender, CPDFAnnotationDictionary.GetAnnotationFromTag[(sender as ToggleButton).Tag.ToString()]);
+            if((bool)(sender as ToggleButton).IsChecked)
+            {
+                AnnotationPropertyChanged?.Invoke(sender, CPDFAnnotationDictionary.GetAnnotationFromTag[(sender as ToggleButton).Tag.ToString()]);
+            }
+            else
+            {
+                AnnotationCancel?.Invoke(sender, EventArgs.Empty);
+            }
         }
 
         public void InitAnnotationBar(AnnotationType[] annotationProperties)

File diff suppressed because it is too large
+ 93 - 0
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/BaseControl/NumericUpDownControl.xaml


+ 101 - 0
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/BaseControl/NumericUpDownControl.xaml.cs

@@ -0,0 +1,101 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Text.RegularExpressions;
+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 compdfkit_tools.Common
+{
+    /// <summary>
+    /// NumericUpDownControl.xaml 的交互逻辑
+    /// </summary>
+    public partial class NumericUpDownControl : UserControl
+    {
+        private string regixString = "[^0-9]+";
+
+        // The dependency property which will be accessible on the UserControl
+        public static readonly DependencyProperty UnitProperty =
+            DependencyProperty.Register("Unit", typeof(string), typeof(NumericUpDownControl), new UIPropertyMetadata());
+
+        public string Unit
+        {
+            get { return (string)GetValue(UnitProperty); }
+            set { SetValue(UnitProperty, value); }
+        }
+
+        public static readonly DependencyProperty MaxiumProperty =
+           DependencyProperty.Register("Maxium", typeof(int), typeof(NumericUpDownControl), new UIPropertyMetadata());
+        public int Maxium
+        {
+            get { return (int)GetValue(MaxiumProperty); }
+            set { SetValue(MaxiumProperty, value); }
+        }
+
+        public static readonly DependencyProperty MinimumProperty =
+    DependencyProperty.Register("Minimum", typeof(int), typeof(NumericUpDownControl), new UIPropertyMetadata());
+        public int Minimum
+        {
+            get { return (int)GetValue(MinimumProperty); }
+            set { SetValue(MinimumProperty, value); }
+        }
+        public NumericUpDownControl()
+        {
+            InitializeComponent();
+        }
+        private void TextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
+        {
+            e.Handled = new Regex(regixString).IsMatch(e.Text);
+        }
+
+        private void TextBox_PreviewKeyDown(object sender, KeyEventArgs e)
+        {
+            if ((e.KeyStates == Keyboard.GetKeyStates(Key.LeftCtrl) || e.KeyStates == Keyboard.GetKeyStates(Key.RightCtrl)) && e.KeyStates == Keyboard.GetKeyStates(Key.V))
+                e.Handled = true;
+            else
+                e.Handled = false;
+        }
+
+        private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
+        {
+            if (!string.IsNullOrEmpty(TextBox.Text))
+            {
+                if (int.Parse(TextBox.Text) > Maxium)
+                {
+                    TextBox.Text = Maxium.ToString();
+                }
+
+                if (int.Parse(TextBox.Text) < Minimum)
+                {
+                    TextBox.Text = Minimum.ToString();
+                }
+            }
+        }
+
+        private void UpButton_Click(object sender, RoutedEventArgs e)
+        {
+            if (int.TryParse(TextBox.Text, out int num))
+            {
+                TextBox.Text = (++num).ToString();
+            }
+        }
+
+        private void DownButton_Click(object sender, RoutedEventArgs e)
+        {
+            if (int.TryParse(TextBox.Text, out int num))
+            {
+                TextBox.Text = (--num).ToString();
+            }
+        }
+    }
+}
+

+ 31 - 10
compdfkit_demo_windows/compdfkit/compdfkit-tools/compdfkit-tools.csproj

@@ -65,20 +65,26 @@
     <Reference Include="PresentationFramework" />
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="Annotation\PDFAnnotationControl\CPDFAnnotationControl.xaml.cs">
+    <Compile Include="Annotation\ArrowControl\CPDFArrowControlControl.xaml.cs">
+      <DependentUpon>CPDFArrowControlControl.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Annotation\ArrowControl\CPDFArrowUI.xaml.cs">
+      <DependentUpon>CPDFArrowUI.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Annotation\PDFAnnotationPanel\PDFAnnotationControl\CPDFAnnotationControl.xaml.cs">
       <DependentUpon>CPDFAnnotationControl.xaml</DependentUpon>
     </Compile>
     <Compile Include="Annotation\PDFAnnotationData\CPDFAnnotationData.cs" />
-    <Compile Include="Annotation\PDFAnnotationUI\CPDFLinkUI.xaml.cs">
+    <Compile Include="Annotation\PDFAnnotationPanel\PDFAnnotationUI\CPDFLinkUI.xaml.cs">
       <DependentUpon>CPDFLinkUI.xaml</DependentUpon>
     </Compile>
-    <Compile Include="Annotation\PDFAnnotationUI\CPDFMarkupUI.xaml.cs">
+    <Compile Include="Annotation\PDFAnnotationPanel\PDFAnnotationUI\CPDFMarkupUI.xaml.cs">
       <DependentUpon>CPDFMarkupUI.xaml</DependentUpon>
     </Compile>
-    <Compile Include="Annotation\PDFAnnotationUI\CPDFSoundUI.xaml.cs">
+    <Compile Include="Annotation\PDFAnnotationPanel\PDFAnnotationUI\CPDFSoundUI.xaml.cs">
       <DependentUpon>CPDFSoundUI.xaml</DependentUpon>
     </Compile>
-    <Compile Include="Annotation\PDFAnnotationUI\CPDFShapeUI.xaml.cs">
+    <Compile Include="Annotation\PDFAnnotationPanel\PDFAnnotationUI\CPDFShapeUI.xaml.cs">
       <DependentUpon>CPDFShapeUI.xaml</DependentUpon>
     </Compile>
     <Compile Include="Common\BarControl\CPDFBOTABarControl.xaml.cs">
@@ -93,6 +99,9 @@
     <Compile Include="Common\BarControl\TitleBarControl.xaml.cs">
       <DependentUpon>TitleBarControl.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Common\BaseControl\NumericUpDownControl.xaml.cs">
+      <DependentUpon>NumericUpDownControl.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Common\Convert\BoolToVisibilityConvert.cs" />
     <Compile Include="Common\Convert\ListViewWidthConvert.cs" />
     <Compile Include="Common\PropertyControl\ColorPickerControl.xaml.cs">
@@ -230,23 +239,31 @@
     <Resource Include="Asset\Resource\Annotation\Rect.png" />
   </ItemGroup>
   <ItemGroup>
-    <Page Include="Annotation\PDFAnnotationControl\CPDFAnnotationControl.xaml">
+    <Page Include="Annotation\ArrowControl\CPDFArrowControlControl.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Annotation\ArrowControl\CPDFArrowUI.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
-    <Page Include="Annotation\PDFAnnotationUI\CPDFLinkUI.xaml">
+    <Page Include="Annotation\PDFAnnotationPanel\PDFAnnotationControl\CPDFAnnotationControl.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
-    <Page Include="Annotation\PDFAnnotationUI\CPDFMarkupUI.xaml">
+    <Page Include="Annotation\PDFAnnotationPanel\PDFAnnotationUI\CPDFLinkUI.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
-    <Page Include="Annotation\PDFAnnotationUI\CPDFSoundUI.xaml">
+    <Page Include="Annotation\PDFAnnotationPanel\PDFAnnotationUI\CPDFMarkupUI.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
-    <Page Include="Annotation\PDFAnnotationUI\CPDFShapeUI.xaml">
+    <Page Include="Annotation\PDFAnnotationPanel\PDFAnnotationUI\CPDFSoundUI.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Annotation\PDFAnnotationPanel\PDFAnnotationUI\CPDFShapeUI.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
@@ -274,6 +291,10 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="Common\BaseControl\NumericUpDownControl.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="Common\PropertyControl\ColorPickerControl.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>