Browse Source

compdfkit(win) - 注释、Form控件Load事件只触发一次

weixiangjie 1 year ago
parent
commit
934c620aaa

File diff suppressed because it is too large
+ 17 - 4
Demo/Examples/Compdfkit_Tools/Annotation/AnnotationControl/AnnotationControl.xaml.cs


+ 17 - 12
Demo/Examples/Compdfkit_Tools/Common/BarControl/FormBarControl.xaml.cs

@@ -24,6 +24,7 @@ namespace Compdfkit_Tools.PDFControl
 {
     public partial class CPDFFormBarControl : UserControl, INotifyPropertyChanged
     {
+        private bool isFirstLoad = true;
         enum FromType
         {
             UnKnown = -1,
@@ -71,20 +72,24 @@ namespace Compdfkit_Tools.PDFControl
 
         private void UserControl_Loaded(object sender, RoutedEventArgs e)
         {
-            foreach (KeyValuePair<string, string> data in ButtonDict)
+            if (isFirstLoad)
             {
-                string Path = data.Value;
-                string name = data.Key;
-
-                Geometry annotationGeometry = Geometry.Parse(Path);
-                Path path = new Path
+                foreach (KeyValuePair<string, string> data in ButtonDict)
                 {
-                    Width = 20,
-                    Height = 20,
-                    Data = annotationGeometry,
-                    Fill = new SolidColorBrush(Color.FromRgb(0x43, 0x47, 0x4D))
-                };
-                CreateButtonForPath(path, name);
+                    string Path = data.Value;
+                    string name = data.Key;
+
+                    Geometry annotationGeometry = Geometry.Parse(Path);
+                    Path path = new Path
+                    {
+                        Width = 20,
+                        Height = 20,
+                        Data = annotationGeometry,
+                        Fill = new SolidColorBrush(Color.FromRgb(0x43, 0x47, 0x4D))
+                    };
+                    CreateButtonForPath(path, name);
+                }
+                isFirstLoad = false;
             }
         }