Browse Source

页面编辑 -纵向 横向互换优化

OYXH\oyxh 1 year ago
parent
commit
1a86f07732
1 changed files with 53 additions and 18 deletions
  1. 53 18
      PDF Office/ViewModels/Dialog/PageEditDialogs/InsertDialogViewModel.cs

+ 53 - 18
PDF Office/ViewModels/Dialog/PageEditDialogs/InsertDialogViewModel.cs

@@ -31,6 +31,9 @@ namespace PDF_Master.ViewModels.Dialog.PageEditDialogs
 
         private Size size = new Size();
 
+        private int height;
+        private int width;
+
         private string currentPageSize;
 
         /// <summary>
@@ -85,6 +88,15 @@ namespace PDF_Master.ViewModels.Dialog.PageEditDialogs
             set
             {
                 SetProperty(ref customWidth, value);
+                if ((string.IsNullOrEmpty(value) == false))
+                {
+                    Model.width = int.Parse(value);
+                    if (IsVerticalSelected == false && IsCustomSelected)
+                    {
+                        width = int.Parse(CustomHeight);
+                        height = int.Parse(value);
+                    }
+                }
             }
         }
 
@@ -99,6 +111,15 @@ namespace PDF_Master.ViewModels.Dialog.PageEditDialogs
             set
             {
                 SetProperty(ref customHeight, value);
+                if ((string.IsNullOrEmpty(value) == false))
+                {
+                    Model.height = int.Parse(value);
+                    if (IsVerticalSelected == false && IsCustomSelected)
+                    {
+                        height = int.Parse(CustomWidth);
+                        width = int.Parse(value);
+                    }
+                }
             }
         }
 
@@ -142,6 +163,9 @@ namespace PDF_Master.ViewModels.Dialog.PageEditDialogs
 
                         Model.width = Convert.ToInt32(pageSizeInfo.Width);
                         Model.height = Convert.ToInt32(pageSizeInfo.Height);
+
+                        height = Model.height;
+                        width = Model.width;
                     }
                 }
             }
@@ -178,6 +202,9 @@ namespace PDF_Master.ViewModels.Dialog.PageEditDialogs
 
                     Model.width = Convert.ToInt32(size.Width);
                     Model.height = Convert.ToInt32(size.Height);
+
+                    height = Model.height;
+                    width = Model.width;
                 }
             }
         }
@@ -201,6 +228,9 @@ namespace PDF_Master.ViewModels.Dialog.PageEditDialogs
                     CustomHeight = pageSizeInfo.Height;
                     Model.width = Convert.ToInt32(pageSizeInfo.Width);
                     Model.height = Convert.ToInt32(pageSizeInfo.Height);
+
+                    height = Model.height;
+                    width = Model.width;
                 }
             }
         }
@@ -230,16 +260,18 @@ namespace PDF_Master.ViewModels.Dialog.PageEditDialogs
                 SetProperty(ref isVerticalSelected, value);
                 if (isVerticalSelected)
                 {
-                    if (IsCustomSelected)
-                    {
-                        Model.height = int.Parse(CustomWidth);
-                        Model.width = int.Parse(CustomHeight);
-                    }
-
-                    if (Model.height != 0 && Model.width != 0)
+                    if (height != 0 && width != 0)
                     {
-                        CustomHeight = Model.height.ToString();
-                        CustomWidth = Model.width.ToString();
+                        if (height.ToString() != CustomHeight)
+                        {
+                            CustomHeight = height.ToString();
+                        }
+                        if (width.ToString() != CustomWidth)
+                        {
+                            CustomWidth = width.ToString();
+                        }
+                        Model.width = width;
+                        Model.height = height;
                     }
                 }
             }
@@ -257,19 +289,22 @@ namespace PDF_Master.ViewModels.Dialog.PageEditDialogs
                 {
                     if (IsCustomSelected)
                     {
-                        Model.height = int.Parse(CustomWidth);
-                        Model.width = int.Parse(CustomHeight);
-
-                        CustomHeight = Model.height.ToString();
-                        CustomWidth = Model.width.ToString();
+                        height = Model.height;
+                        width = Model.width;
                     }
-                    else
+                    if (width != 0 && height != 0)
                     {
-                        if (Model.height != 0 && Model.width != 0)
+                        if (CustomHeight != width.ToString())
                         {
-                            CustomHeight = Model.width.ToString();
-                            CustomWidth = Model.height.ToString();
+                            CustomHeight = width.ToString();
                         }
+                        if (CustomWidth != height.ToString())
+                        {
+                            CustomWidth = height.ToString();
+                        }
+
+                        Model.width = height;
+                        Model.height = width;
                     }
                 }
             }