فهرست منبع

compdfkit(win) - 替换文档时释放,修复选中注释时黑色无法识别

liuaoran 1 سال پیش
والد
کامیت
6f78ef7656

+ 2 - 0
Demo/Examples/Annotations/MainWindow.xaml.cs

@@ -188,6 +188,7 @@ namespace Annotations
                     PasswordUI.ClearPassword();
                     PasswordUI.Visibility = Visibility.Collapsed;
                     PopupBorder.Visibility = Visibility.Collapsed;
+                    pdfViewControl.PDFView.Document.Release();
                     pdfViewControl = passwordViewer;
                     LoadDocument();
                 }
@@ -692,6 +693,7 @@ namespace Annotations
                 }
                 else
                 {
+                    pdfViewControl.PDFView.Document.Release();
                     pdfViewControl = passwordViewer;
                     LoadDocument();
                 }

+ 7 - 1
Demo/Examples/Compdfkit_Tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFFreehandUI.xaml.cs

@@ -99,12 +99,18 @@ namespace Compdfkit_Tools.PDFControlUI
             CPDFThicknessControl.Thickness =Convert.ToInt16(annotAttribEvent.Attribs[AnnotAttrib.Thickness]);
             if(annotAttribEvent.Attribs.ContainsKey(AnnotAttrib.Color))
             {
-                ColorPickerControl.SetCheckedForColor((Color)annotAttribEvent.Attribs[AnnotAttrib.Color]);
+                ColorPickerControl.Loaded += ColorPickerControl_Loaded;
             }
             NoteTextBox.Text = (string)annotAttribEvent.Attribs[AnnotAttrib.NoteText];
             this.annotAttribEvent = annotAttribEvent;
         }
 
+        private void ColorPickerControl_Loaded(object sender, RoutedEventArgs e)
+        {
+            ColorPickerControl.SetCheckedForColor((Color)annotAttribEvent.Attribs[AnnotAttrib.Color]);
+            ColorPickerControl.Loaded -= ColorPickerControl_Loaded;
+        }
+
         public CPDFFreehandData GetFreehandData()
         {
             CPDFFreehandData pdfFreehandData = new CPDFFreehandData();

+ 9 - 2
Demo/Examples/Compdfkit_Tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFMarkupUI.xaml.cs

@@ -75,14 +75,21 @@ namespace Compdfkit_Tools.PDFControlUI
         public void SetPresentAnnotAttrib(AnnotAttribEvent annotAttribEvent)
         {
             this.annotAttribEvent = null;
-            ColorPickerControl.Brush = new SolidColorBrush((Color)annotAttribEvent.Attribs[AnnotAttrib.Color]);
-            ColorPickerControl.SetCheckedForColor((Color)annotAttribEvent.Attribs[AnnotAttrib.Color]);
+            //ColorPickerControl.Brush = new SolidColorBrush((Color)annotAttribEvent.Attribs[AnnotAttrib.Color]);
+
+            ColorPickerControl.Loaded += ColorPickerControl_Loaded;
             CPDFOpacityControl.OpacityValue = (int)((double)annotAttribEvent.Attribs[AnnotAttrib.Transparency] * 100);
             NoteTextBox.Text = (string)annotAttribEvent.Attribs[AnnotAttrib.NoteText];
             this.annotAttribEvent = annotAttribEvent;
             CPDFAnnotationPreviewerControl.DrawMarkUpPreview(GetMarkupData());
         }
 
+        private void ColorPickerControl_Loaded(object sender, System.Windows.RoutedEventArgs e)
+        {
+            ColorPickerControl.SetCheckedForColor((Color)annotAttribEvent.Attribs[AnnotAttrib.Color]);
+            ColorPickerControl.Loaded -= ColorPickerControl_Loaded;
+        }
+
         public void InitWithAnnotationType(CPDFAnnotationType annotationType)
         {
             currentAnnotationType = annotationType;

+ 8 - 2
Demo/Examples/Compdfkit_Tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFNoteUI.xaml.cs

@@ -50,16 +50,22 @@ namespace Compdfkit_Tools.PDFControlUI
         public void SetPresentAnnotAttrib(AnnotAttribEvent annotAttribEvent)
         {
             this.annotAttribEvent = null;
-            ColorPickerControl.Brush = new SolidColorBrush((Color)annotAttribEvent.Attribs[AnnotAttrib.Color]);
             NoteTextBox.Text = (string)annotAttribEvent.Attribs[AnnotAttrib.NoteText];
             this.annotAttribEvent = annotAttribEvent;
 
             if (annotAttribEvent.Attribs != null && annotAttribEvent.Attribs.ContainsKey(AnnotAttrib.Color))
             {
-                ColorPickerControl.SetCheckedForColor((Color)annotAttribEvent.Attribs[AnnotAttrib.Color]);
+                ColorPickerControl.Loaded += ColorPickerControl_Loaded;
             }
         }
 
+        private void ColorPickerControl_Loaded(object sender, System.Windows.RoutedEventArgs e)
+        {
+            ColorPickerControl.SetCheckedForColor((Color)annotAttribEvent.Attribs[AnnotAttrib.Color]);
+            ColorPickerControl.Loaded -= ColorPickerControl_Loaded;
+
+        }
+
         public CPDFNoteData GetNoteData()
         {
             CPDFNoteData pdfNoteData = new CPDFNoteData();

+ 16 - 4
Demo/Examples/Compdfkit_Tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFShapeUI.xaml.cs

@@ -165,14 +165,14 @@ namespace Compdfkit_Tools.PDFControlUI
             CPDFOpacityControl.OpacityValue = (int)((double)annotAttribEvent.Attribs[AnnotAttrib.Transparency] * 100);
             CPDFThicknessControl.Thickness = Convert.ToInt16(annotAttribEvent.Attribs[AnnotAttrib.Thickness]);
             NoteTextBox.Text = (string)annotAttribEvent.Attribs[AnnotAttrib.NoteText];
-            if(annotAttribEvent.Attribs!=null && annotAttribEvent.Attribs.ContainsKey(AnnotAttrib.Color))
+            if (annotAttribEvent.Attribs != null && annotAttribEvent.Attribs.ContainsKey(AnnotAttrib.Color))
             {
-                BorderColorPickerControl.SetCheckedForColor((Color)annotAttribEvent.Attribs[AnnotAttrib.Color]);
+                BorderColorPickerControl.Loaded += BorderColorPickerControl_Loaded;
             }
 
             if (annotAttribEvent.Attribs != null && annotAttribEvent.Attribs.ContainsKey(AnnotAttrib.FillColor))
             {
-                FillColorPickerControl.SetCheckedForColor((Color)annotAttribEvent.Attribs[AnnotAttrib.FillColor]);
+                FillColorPickerControl.Loaded += FillColorPickerControl_Loaded;
             }
 
             CPDFLineStyleControl.DashStyle = (DashStyle)(annotAttribEvent.Attribs[AnnotAttrib.LineStyle]);
@@ -189,12 +189,24 @@ namespace Compdfkit_Tools.PDFControlUI
                     HeadLineType = (C_LINE_TYPE)annotAttribEvent.Attribs[AnnotAttrib.LineStart],
                     TailLineType = (C_LINE_TYPE)annotAttribEvent.Attribs[AnnotAttrib.LineEnd]
                 };
-                CPDFArrowControl.LineType = lineType; 
+                CPDFArrowControl.LineType = lineType;
             }
             this.annotAttribEvent = annotAttribEvent;
             CPDFAnnotationPreviewerControl.DrawShapePreview(GetShapeData());
         }
 
+        private void FillColorPickerControl_Loaded(object sender, RoutedEventArgs e)
+        {
+            FillColorPickerControl.SetCheckedForColor((Color)annotAttribEvent.Attribs[AnnotAttrib.FillColor]);
+            FillColorPickerControl.Loaded -= FillColorPickerControl_Loaded;
+        }
+
+        private void BorderColorPickerControl_Loaded(object sender, RoutedEventArgs e)
+        {
+            BorderColorPickerControl.SetCheckedForColor((Color)annotAttribEvent.Attribs[AnnotAttrib.Color]);
+            BorderColorPickerControl.Loaded -= BorderColorPickerControl_Loaded;
+        }
+
         public void InitWhenRectAndRound()
         {
             FillColorStackPanel.Visibility = Visibility.Visible;

+ 1 - 1
Demo/Examples/Compdfkit_Tools/Common/PropertyControl/ColorPickerControl.xaml.cs

@@ -110,7 +110,7 @@ namespace Compdfkit_Tools.Common
 
         public void SetCheckedForColor(Color color)
         {
-            bool Transparent =GetTransparentBtnVisibility();
+            bool Transparent = GetTransparentBtnVisibility();
             List<string> brushes = GetButtonColor();
             int index = brushes.IndexOf(color.ToString());
             if (index < 0)

+ 2 - 0
Demo/Examples/ContentEditor/MainWindow.xaml.cs

@@ -182,6 +182,7 @@ namespace ContentEditor
                     PasswordUI.ClearPassword();
                     PasswordUI.Visibility = Visibility.Collapsed;
                     PopupBorder.Visibility = Visibility.Collapsed;
+                    pdfViewControl.PDFView.Document.Release();
                     pdfViewControl = passwordViewer;
                     LoadDocument();
                 }
@@ -820,6 +821,7 @@ namespace ContentEditor
                 }
                 else
                 {
+                    pdfViewControl.PDFView.Document.Release();
                     pdfViewControl = passwordViewer;
                     LoadDocument();
                 }

+ 2 - 0
Demo/Examples/DocsEditor/MainWindow.xaml.cs

@@ -372,6 +372,7 @@ namespace DocsEditor
                     PasswordUI.ClearPassword();
                     PasswordUI.Visibility = Visibility.Collapsed;
                     PopupBorder.Visibility = Visibility.Collapsed;
+                    pdfViewControl.PDFView.Document.Release();
                     pdfViewControl = passwordViewer;
                     LoadDocument();
                 }
@@ -455,6 +456,7 @@ namespace DocsEditor
                 }
                 else
                 {
+                    pdfViewControl.PDFView.Document.Release();
                     pdfViewControl = passwordViewer;
                     LoadDocument();
                 }

+ 2 - 0
Demo/Examples/Forms/MainWindow.xaml.cs

@@ -392,6 +392,7 @@ namespace Forms
                     PasswordUI.ClearPassword();
                     PasswordUI.Visibility = Visibility.Collapsed;
                     PopupBorder.Visibility = Visibility.Collapsed;
+                    pdfViewControl.PDFView.Document.Release();
                     pdfViewControl = passwordViewer;
                     LoadDocument();
                 }
@@ -616,6 +617,7 @@ namespace Forms
                 }
                 else
                 {
+                    pdfViewControl.PDFView.Document.Release();
                     pdfViewControl = passwordViewer;
                     LoadDocument();
                 }

+ 2 - 0
Demo/Examples/PDFViewer/MainPage.xaml.cs

@@ -244,6 +244,7 @@ namespace PDFViewer
                     PasswordUI.ClearPassword();
                     PasswordUI.Visibility = Visibility.Collapsed;
                     PopupBorder.Visibility = Visibility.Collapsed;
+                    pdfViewControl.PDFView.Document.Release();
                     pdfViewControl = passwordViewer;
                     LoadDocument();
                     FileChangeEvent?.Invoke(null, EventArgs.Empty);
@@ -1036,6 +1037,7 @@ namespace PDFViewer
                 }
                 else
                 {
+                    pdfViewControl.PDFView.Document.Release();
                     pdfViewControl = passwordViewer;
                     LoadDocument();
                     FileChangeEvent?.Invoke(null, EventArgs.Empty);

+ 3 - 0
Demo/Examples/Viewer/MainWindow.xaml.cs

@@ -118,6 +118,7 @@ namespace Viewer
                     PasswordUI.ClearPassword();
                     PasswordUI.Visibility = Visibility.Collapsed;
                     PopupBorder.Visibility = Visibility.Collapsed;
+                    pdfViewControl.PDFView.Document.Release();
                     pdfViewControl = passwordViewer;
                     LoadDocument();
                 }
@@ -362,6 +363,7 @@ namespace Viewer
                 }
                 else
                 {
+                    pdfViewControl.PDFView.Document.Release();
                     pdfViewControl = passwordViewer;
                     LoadDocument();
                 }
@@ -647,6 +649,7 @@ namespace Viewer
 
         private void CommandBinding_Executed_Open(object sender, ExecutedRoutedEventArgs e)
         {
+            
             OpenFile();
         }