Browse Source

自适应

#	XHWK.WKTool/XHMicroLessonSystemWindow.xaml
#	XHWK.WKTool/XHMicroLessonSystemWindow.xaml.cs
tags/录制修改前
zhangxueyang 4 years ago
parent
commit
f5115d52ad

+ 16
- 2
Common/system/PrimaryScreen.cs View File

@@ -142,9 +142,23 @@ namespace Common.system
142 142
         /// 缩放后的大小
143 143
         /// </summary>
144 144
         /// <returns></returns>
145
-        public static SizeF ScaleScreenSize()
145
+        public static SizeF ScaleScreenSize
146 146
         {
147
-            return new SizeF(((float)DESKTOP.Width) / (DpiX / 96f), ((float)DESKTOP.Height) / (DpiY / 96f));
147
+            get
148
+            {
149
+               return new SizeF(((float)DESKTOP.Width) / (DpiX / 96f), ((float)DESKTOP.Height) / (DpiY / 96f));
150
+            }
151
+        }
152
+        /// <summary>
153
+        /// 获取缩放后的工作区域大小
154
+        /// </summary>
155
+        public static RectangleF ScaleWorkingAreaSize
156
+        {
157
+            get
158
+            {
159
+                RectangleF rect = System.Windows.Forms.Screen.GetWorkingArea(new System.Drawing.Point((int)ScaleScreenSize.Width, (int)ScaleScreenSize.Height));
160
+                return new RectangleF(((float)rect.X) / (DpiX / 96f), ((float)rect.Y) / (DpiX / 96f), ((float)rect.Width) / (DpiX / 96f), ((float)rect.Height) / (DpiY / 96f));
161
+            }
148 162
         }
149 163
         #endregion
150 164
     }

+ 20
- 19
XHWK.WKTool/XHMicroLessonSystemWindow.xaml View File

@@ -8,7 +8,7 @@
8 8
         xmlns:gifLib="http://wpfanimatedgif.codeplex.com"
9 9
         xmlns:local="clr-namespace:XHWK.WKTool"
10 10
         mc:Ignorable="d"
11
-        Title="星火微课系统" Height="1036" Width="1276" 
11
+        Title="星火微课系统" Height="1036" Width="1290" 
12 12
     WindowStyle="None"  WindowStartupLocation="CenterScreen"  AllowsTransparency="True"  Background="Transparent"    ShowInTaskbar="True" ResizeMode="CanMinimize" BorderThickness="7">
13 13
     <Window.Effect>
14 14
         <DropShadowEffect BlurRadius="10" Color="#bababa" Direction="80" ShadowDepth="0"/>
@@ -139,14 +139,14 @@
139 139
         </RadialGradientBrush>
140 140
     </Window.BorderBrush>
141 141
 
142
-    <Viewbox Stretch="Fill">
143
-        <Grid x:Name="GridContent" Height="1036" Width="1276" >
142
+
143
+        <Grid x:Name="GridContent" Height="1030" Width="1276" >
144 144
 
145 145
             <!--分3行-->
146 146
             <Grid.RowDefinitions>
147
-                <RowDefinition Height="10.2*"/>
148
-                <RowDefinition Height="86*"/>
149
-                <RowDefinition Height="3.8*"/>
147
+                <RowDefinition Height="10*"/>
148
+                <RowDefinition Height="85*"/>
149
+                <RowDefinition Height="5*"/>
150 150
             </Grid.RowDefinitions>
151 151
             <Grid Grid.Row="0" Background="#2D8CF0" MouseLeftButtonDown="Window_MouseLeftButtonDown" Margin="0,0,0,0">
152 152
                 <Grid.RowDefinitions>
@@ -154,13 +154,12 @@
154 154
                     <RowDefinition Height="auto"/>
155 155
                 </Grid.RowDefinitions>
156 156
                 <!--第一行-->
157
-                <StackPanel Orientation="Horizontal" Grid.Row="0" x:Name="splOne">
158 157
                 <StackPanel Grid.Row="0" Orientation="Horizontal" Margin="10,2,10,0">
159 158
                     <Image Source="./Images/microLessonSystem_0.png"/>
160 159
                     <TextBlock Text="星火微课系统" FontSize="14" Padding="5,0,0,0" Foreground="#FFFFFF"/>
161 160
                 </StackPanel>
162 161
 
163
-                <StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Right" Margin="10,2,10,0">
162
+                <StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Right" Margin="10,2,20,0">
164 163
                     <Button Cursor="Hand" x:Name="btnLoginType" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Margin="0,0,10,0" Click="BtnLoginType_Click">
165 164
                         <StackPanel Orientation="Horizontal">
166 165
                             <Image Source="./Images/microLessonSystem_9.png"/>
@@ -177,10 +176,10 @@
177 176
                         <Image Source="./Images/microLessonSystem_10.png"/>
178 177
                     </Button>
179 178
                 </StackPanel>
180
-                </StackPanel>
179
+          
181 180
 
182 181
                 <!--第二行-->
183
-                <StackPanel Grid.Row="1" x:Name="splTwo" Orientation="Horizontal">
182
+          
184 183
                 <StackPanel Grid.Row="1" Orientation="Horizontal" Margin="10,6,0,0">
185 184
                     <Button Cursor="Hand" x:Name="btnScreenRecording" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Click="BtnScreenRecording_Click" Margin="30,0,0,0">
186 185
                         <StackPanel Orientation="Vertical">
@@ -257,10 +256,12 @@
257 256
                         </StackPanel>
258 257
                     </Button>
259 258
                 </StackPanel>
260
-                </StackPanel>
259
+
260
+      
261 261
             </Grid>
262
+
262 263
             <!--主内容-->
263
-            <Grid Grid.Row="1" x:Name="GridMain" Width="1276" Visibility="Visible">
264
+            <Grid Grid.Row="1" x:Name="GridMain" Visibility="Visible">
264 265
                 <ScrollViewer x:Name="scroMain" VerticalScrollBarVisibility="Visible">
265 266
                     <Grid x:Name="gridM"  Margin="0,0,0,0" Background="#FFFFFF" Visibility="Visible" Height="1780">
266 267
                         <Grid>
@@ -551,19 +552,19 @@
551 552
                     <Button Cursor="Hand" x:Name="btnWhite" Background="#FFFFFF" Width="20" Height="20" Click="BtnWhite_Click" Margin="0,2,0,0" Visibility="Collapsed"/>
552 553
 
553 554
 
554
-                    <Button Cursor="Hand" x:Name="btnRed" Background="#FF0000" Width="20" Height="20" Margin="5,2,0,0" Click="BtnRed_Click">
555
+                    <Button Cursor="Hand" x:Name="btnRed" Background="#FF0000" Width="20" Height="20" Margin="5,-15,0,0" Click="BtnRed_Click">
555 556
                         <Image x:Name="imgRed" Source=".\Images\microLessonSystem_999.png" Width="12" Visibility="Visible"/>
556 557
                     </Button>
557
-                    <Button Cursor="Hand" x:Name="btnGray" Background="#333333" Width="20" Height="20" Margin="5,2,0,0" Click="BtnGray_Click">
558
+                <Button Cursor="Hand" x:Name="btnGray" Background="#333333" Width="20" Height="20" Margin="5,-15,0,0" Click="BtnGray_Click">
558 559
                         <Image x:Name="imgGray" Source=".\Images\microLessonSystem_999.png" Width="12" Visibility="Collapsed"/>
559 560
                     </Button>
560
-                    <Button Cursor="Hand" x:Name="btnCyanBlue" Background="#63D600" Width="20" Height="20" Margin="5,2,0,0" Click="BtnCyanBlue_Click">
561
+                <Button Cursor="Hand" x:Name="btnCyanBlue" Background="#63D600" Width="20" Height="20" Margin="5,-15,0,0" Click="BtnCyanBlue_Click">
561 562
                         <Image x:Name="imgCyanBlue" Source=".\Images\microLessonSystem_999.png" Width="12" Visibility="Collapsed"/>
562 563
                     </Button>
563
-                    <Button Cursor="Hand" x:Name="btnYellow" Background="#FFBC00" Width="20" Height="20" Margin="5,2,0,0" Click="BtnYellow_Click">
564
+                <Button Cursor="Hand" x:Name="btnYellow" Background="#FFBC00" Width="20" Height="20" Margin="5,-15,0,0" Click="BtnYellow_Click">
564 565
                         <Image x:Name="imgYellow" Source=".\Images\microLessonSystem_999.png" Width="12" Visibility="Collapsed"/>
565 566
                     </Button>
566
-                    <Button Cursor="Hand" x:Name="btnBlue" Background="#00B4FC" Width="20" Height="20" Margin="5,2,0,0" Click="BtnBlue_Click">
567
+                <Button Cursor="Hand" x:Name="btnBlue" Background="#00B4FC" Width="20" Height="20" Margin="5,-15,0,0" Click="BtnBlue_Click">
567 568
                         <Image x:Name="imgBlue" Source=".\Images\microLessonSystem_999.png" Width="12" Visibility="Collapsed"/>
568 569
                     </Button>
569 570
                     <TextBlock Text="粗细:" FontSize="14" Padding="15,5,0,0" Margin="5,5,0,0"/>
@@ -581,7 +582,7 @@
581 582
                     <TextBlock x:Name="txbNotConnected" Text="未连接" FontSize="14" Padding="0,5,5,0"/>
582 583
                 </StackPanel>
583 584
             </Grid>
584
-            <Button Content="Button" HorizontalAlignment="Left" Margin="584,40,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click"/>
585
+   
585 586
         </Grid>
586
-    </Viewbox>
587
+
587 588
 </Window>

+ 170
- 37
XHWK.WKTool/XHMicroLessonSystemWindow.xaml.cs View File

@@ -28,6 +28,8 @@ using System.Diagnostics;
28 28
 using System.Runtime.InteropServices;
29 29
 using System.Windows.Controls.Primitives;
30 30
 using System.Drawing;
31
+using System.Linq;
32
+
31 33
 
32 34
 namespace XHWK.WKTool
33 35
 {
@@ -109,17 +111,14 @@ namespace XHWK.WKTool
109 111
         {
110 112
             new Aspose.Pdf.License().SetLicense(new MemoryStream(Convert.FromBase64String("PExpY2Vuc2U+CiAgPERhdGE+CiAgICA8TGljZW5zZWRUbz5TdXpob3UgQXVuYm94IFNvZnR3YXJlIENvLiwgTHRkLjwvTGljZW5zZWRUbz4KICAgIDxFbWFpbFRvPnNhbGVzQGF1bnRlYy5jb208L0VtYWlsVG8+CiAgICA8TGljZW5zZVR5cGU+RGV2ZWxvcGVyIE9FTTwvTGljZW5zZVR5cGU+CiAgICA8TGljZW5zZU5vdGU+TGltaXRlZCB0byAxIGRldmVsb3BlciwgdW5saW1pdGVkIHBoeXNpY2FsIGxvY2F0aW9uczwvTGljZW5zZU5vdGU+CiAgICA8T3JkZXJJRD4xOTA4MjYwODA3NTM8L09yZGVySUQ+CiAgICA8VXNlcklEPjEzNDk3NjAwNjwvVXNlcklEPgogICAgPE9FTT5UaGlzIGlzIGEgcmVkaXN0cmlidXRhYmxlIGxpY2Vuc2U8L09FTT4KICAgIDxQcm9kdWN0cz4KICAgICAgPFByb2R1Y3Q+QXNwb3NlLlRvdGFsIGZvciAuTkVUPC9Qcm9kdWN0PgogICAgPC9Qcm9kdWN0cz4KICAgIDxFZGl0aW9uVHlwZT5FbnRlcnByaXNlPC9FZGl0aW9uVHlwZT4KICAgIDxTZXJpYWxOdW1iZXI+M2U0NGRlMzAtZmNkMi00MTA2LWIzNWQtNDZjNmEzNzE1ZmMyPC9TZXJpYWxOdW1iZXI+CiAgICA8U3Vic2NyaXB0aW9uRXhwaXJ5PjIwMjAwODI3PC9TdWJzY3JpcHRpb25FeHBpcnk+CiAgICA8TGljZW5zZVZlcnNpb24+My4wPC9MaWNlbnNlVmVyc2lvbj4KICAgIDxMaWNlbnNlSW5zdHJ1Y3Rpb25zPmh0dHBzOi8vcHVyY2hhc2UuYXNwb3NlLmNvbS9wb2xpY2llcy91c2UtbGljZW5zZTwvTGljZW5zZUluc3RydWN0aW9ucz4KICA8L0RhdGE+CiAgPFNpZ25hdHVyZT53UGJtNUt3ZTYvRFZXWFNIY1o4d2FiVEFQQXlSR0pEOGI3L00zVkV4YWZpQnd5U2h3YWtrNGI5N2c2eGtnTjhtbUFGY3J0c0cwd1ZDcnp6MytVYk9iQjRYUndTZWxsTFdXeXNDL0haTDNpN01SMC9jZUFxaVZFOU0rWndOQkR4RnlRbE9uYTFQajhQMzhzR1grQ3ZsemJLZFZPZXk1S3A2dDN5c0dqYWtaL1E9PC9TaWduYXR1cmU+CjwvTGljZW5zZT4=")));
111 113
             InitializeComponent();
112
-            double proportion = 1036.0 / 1276.0;
113
-            Width = proportion * (PrimaryScreen.ScaleScreenSize().Height - 40);
114
-            Height =/*1276-*/ PrimaryScreen.ScaleScreenSize().Height - 40;
115
-            GridContent.Width = Width;
116
-            GridContent.Height = Width;
117
-
114
+            double proportion = 1036.0 / 1290.0;
115
+            Width =  (PrimaryScreen.ScaleWorkingAreaSize.Height)/proportion-(BorderThickness.Left+ BorderThickness.Right) ;
116
+            Height = PrimaryScreen.ScaleWorkingAreaSize.Height-(BorderThickness.Top+BorderThickness.Bottom);
117
+            GridContent.Width = Width-14;
118
+            GridContent.Height = Height;
118 119
 
119
-            double splProportion = 1036.0 / 1276.0;
120
+ 
120 121
 
121
-            splOne.Height = 20;
122
-            splTwo.Height = 40;
123 122
 
124 123
             //GridMain.Height= PrimaryScreen.ScaleScreenSize().Height - 40;
125 124
 
@@ -2720,14 +2719,14 @@ namespace XHWK.WKTool
2720 2719
             }
2721 2720
             catch (Exception ex)
2722 2721
             {
2723
-                if(ex.Message.ToString().Equals("{\"The document appears to be corrupted and cannot be loaded.\"}"))
2724
-                {
2725
-                    MessageWindow.Show("Word文件无效或者Word文件被加密!");
2726
-                }
2727
-                else
2728
-                {
2729
-                    MessageWindow.Show("文档已打开,请关闭后重试!");
2730
-                }
2722
+                //if(ex.Message.ToString().Equals("{\"The document appears to be corrupted and cannot be loaded.\"}"))
2723
+                //{
2724
+                //    MessageWindow.Show("Word文件无效或者Word文件被加密!");
2725
+                //}
2726
+                //else
2727
+                //{
2728
+                    MessageWindow.Show("该文件无法使用!");
2729
+                //}
2731 2730
                 LogHelper.WriteErrLog("【导入方法(ConvertWordToImage)】错误日志:" + ex.Message, ex);
2732 2731
             }
2733 2732
             return images;
@@ -3432,12 +3431,30 @@ namespace XHWK.WKTool
3432 3431
             }
3433 3432
         }
3434 3433
         System.Drawing.PointF imgRightDown;
3434
+        /// <summary>
3435
+        /// 设置控件最上层
3436
+        /// </summary>
3437
+        /// <param name="element"></param>
3438
+        public void BringToFront(Thumb element)//图片置于最顶层显示
3439
+        {
3440
+            if (element == null) return;
3441
+            
3442
+            Canvas parent = element.Parent as Canvas;
3443
+            if (parent == null) return;
3444
+            var maxZ = parent.Children.OfType<UIElement>()//linq语句,取Zindex的最大值
3445
+              .Where(x => x != element)
3446
+              .Select(x => Canvas.GetZIndex(x))
3447
+              .Max();
3448
+            Canvas.SetZIndex(element, maxZ + 1);
3449
+        }
3435 3450
         private void RectRightUp_DragStarted(object sender, System.Windows.Controls.Primitives.DragStartedEventArgs e)
3436 3451
         {
3437 3452
             try
3438 3453
             {
3439 3454
              
3440 3455
                 Thumb thu = (Thumb)sender;
3456
+                BringToFront(thu);
3457
+
3441 3458
                 imgRightDown = new System.Drawing.PointF((float)(imgCanvas.Margin.Left + imgCanvas.ActualWidth), (float)(imgCanvas.Margin.Top + imgCanvas.ActualHeight));
3442 3459
                 HideAngleBorder();
3443 3460
                 switch (thu.Name)
@@ -3475,36 +3492,152 @@ namespace XHWK.WKTool
3475 3492
                 double plut = Canvas.GetTop(RectLeftUp);
3476 3493
                 double prdl = Canvas.GetLeft(RectRightDown);
3477 3494
                 double prdt = Canvas.GetTop(RectRightDown);
3478
-                if (prdl - plul > 50)
3479
-                {
3480
-                }
3481
-                if (prdt - plut > 50)
3482
-                {
3483
-                }
3484 3495
                 #endregion
3485
-                
3486
-                    Canvas.SetLeft(thu, Canvas.GetLeft(thu) + e.HorizontalChange);
3487
-                    Canvas.SetTop(thu, Canvas.GetTop(thu) + e.VerticalChange);
3496
+
3497
+                //Canvas.SetLeft(thu, Canvas.GetLeft(thu) + e.HorizontalChange);
3498
+                //Canvas.SetTop(thu, Canvas.GetTop(thu) + e.VerticalChange);
3499
+                double imgW = 0;
3500
+                double imgH = 0;
3501
+                double imgX = 0;
3502
+                double imgY = 0;
3488 3503
                 switch (thu.Name)
3489 3504
                 {
3490 3505
                     case "RectLeftUp":
3491
-                        imgCanvas.Width = imgRightDown.X - (Mouse.GetPosition(gridM).X);
3492
-                        imgCanvas.Height = imgRightDown.Y - (Mouse.GetPosition(gridM).Y);
3493
-                        imgCanvas.Margin = new Thickness(Mouse.GetPosition(gridM).X, Mouse.GetPosition(gridM).Y, 0, 0);
3506
+                        #region 左上
3507
+                        imgW = imgRightDown.X - (Mouse.GetPosition(gridM).X);
3508
+                        imgH = imgRightDown.Y - (Mouse.GetPosition(gridM).Y);
3509
+                        imgX = 0;
3510
+                        imgY = 0;
3511
+                        if (imgW < 50)
3512
+                        {
3513
+                            imgCanvas.Width = 50;
3514
+                            imgX = imgCanvas.Margin.Left;
3515
+                            Canvas.SetLeft(thu, Canvas.GetLeft(RectRightDown) - 50);
3516
+                        }
3517
+                        else
3518
+                        {
3519
+                            imgCanvas.Width = imgW;
3520
+                            imgX = Mouse.GetPosition(gridM).X;
3521
+                            Canvas.SetLeft(thu, Canvas.GetLeft(thu) + e.HorizontalChange);
3522
+                        }
3523
+                        if (imgH < 50)
3524
+                        {
3525
+                            imgCanvas.Height = 50;
3526
+                            imgY = imgCanvas.Margin.Top;
3527
+                            Canvas.SetTop(thu, Canvas.GetTop(RectRightDown) - 50);
3528
+                        }
3529
+                        else
3530
+                        {
3531
+                            imgCanvas.Height = imgH;
3532
+                            imgY = Mouse.GetPosition(gridM).Y;
3533
+                            Canvas.SetTop(thu, Canvas.GetTop(thu) + e.VerticalChange);
3534
+                        }
3535
+                        imgCanvas.Margin = new Thickness(imgX, imgY, 0, 0);
3536
+                        #endregion
3537
+                        //imgCanvas.Width = imgRightDown.X - (Mouse.GetPosition(gridM).X);
3538
+                        //imgCanvas.Height = imgRightDown.Y - (Mouse.GetPosition(gridM).Y);
3539
+                        //imgCanvas.Margin = new Thickness(Mouse.GetPosition(gridM).X, Mouse.GetPosition(gridM).Y, 0, 0);
3494 3540
                         break;
3495 3541
                     case "RectRightUp":
3496
-                        imgCanvas.Width = Mouse.GetPosition(gridM).X - imgCanvas.Margin.Left;
3497
-                        imgCanvas.Height = imgRightDown.Y - (Mouse.GetPosition(gridM).Y);
3498
-                        imgCanvas.Margin = new Thickness(imgCanvas.Margin.Left, Mouse.GetPosition(gridM).Y, 0, 0);
3542
+                        #region 右上
3543
+                        imgW = Mouse.GetPosition(gridM).X - imgCanvas.Margin.Left;
3544
+                        imgH = imgRightDown.Y - (Mouse.GetPosition(gridM).Y);
3545
+                        imgX = 0;
3546
+                        imgY = 0;
3547
+                        if (imgW < 50)
3548
+                        {
3549
+                            imgCanvas.Width = 50;
3550
+                            imgX = imgCanvas.Margin.Left;
3551
+                            Canvas.SetLeft(thu, Canvas.GetLeft(RectLeftUp) + 50);
3552
+                        }
3553
+                        else
3554
+                        {
3555
+                            imgCanvas.Width = imgW;
3556
+                            imgX = imgCanvas.Margin.Left;
3557
+                            Canvas.SetLeft(thu, Canvas.GetLeft(thu) + e.HorizontalChange);
3558
+                        }
3559
+                        if (imgH < 50)
3560
+                        {
3561
+                            imgCanvas.Height = 50;
3562
+                            imgY = imgCanvas.Margin.Top;
3563
+                            Canvas.SetTop(thu, Canvas.GetTop(RectRightDown) - 50);
3564
+                        }
3565
+                        else
3566
+                        {
3567
+                            imgCanvas.Height = imgH;
3568
+                            imgY = Mouse.GetPosition(gridM).Y;
3569
+                            Canvas.SetTop(thu, Canvas.GetTop(thu) + e.VerticalChange);
3570
+                        }
3571
+                        imgCanvas.Margin = new Thickness(imgX, imgY, 0, 0);
3572
+                        //imgCanvas.Width = Mouse.GetPosition(gridM).X - imgCanvas.Margin.Left;
3573
+                        //imgCanvas.Height = imgRightDown.Y - (Mouse.GetPosition(gridM).Y);
3574
+                        //imgCanvas.Margin = new Thickness(imgCanvas.Margin.Left, Mouse.GetPosition(gridM).Y, 0, 0);
3575
+                        #endregion
3499 3576
                         break;
3500 3577
                     case "RectLeftDown":
3501
-                        imgCanvas.Width = imgRightDown.X - (Mouse.GetPosition(gridM).X);
3502
-                        imgCanvas.Height = Mouse.GetPosition(gridM).Y - imgCanvas.Margin.Top;
3503
-                        imgCanvas.Margin = new Thickness(Mouse.GetPosition(gridM).X, imgCanvas.Margin.Top, 0, 0);
3578
+                        #region 左下
3579
+                        imgW = imgRightDown.X - (Mouse.GetPosition(gridM).X);
3580
+                        imgH = Mouse.GetPosition(gridM).Y - imgCanvas.Margin.Top;
3581
+                        imgX = 0;
3582
+                        imgY = 0;
3583
+                        if (imgW < 50)
3584
+                        {
3585
+                            imgCanvas.Width = 50;
3586
+                            imgX = imgCanvas.Margin.Left;
3587
+                            Canvas.SetLeft(thu, Canvas.GetLeft(RectRightDown) - 50);
3588
+                        }
3589
+                        else
3590
+                        {
3591
+                            imgCanvas.Width = imgW;
3592
+                            imgX = Mouse.GetPosition(gridM).X;
3593
+                            Canvas.SetLeft(thu, Canvas.GetLeft(thu) + e.HorizontalChange);
3594
+                        }
3595
+                        if (imgH < 50)
3596
+                        {
3597
+                            imgCanvas.Height = 50;
3598
+                            imgY = imgCanvas.Margin.Top;
3599
+                            Canvas.SetTop(thu, Canvas.GetTop(RectLeftUp) + 50);
3600
+                        }
3601
+                        else
3602
+                        {
3603
+                            imgCanvas.Height = imgH;
3604
+                            imgY = imgCanvas.Margin.Top;
3605
+                            Canvas.SetTop(thu, Canvas.GetTop(thu) + e.VerticalChange);
3606
+                        }
3607
+                        imgCanvas.Margin = new Thickness(imgX, imgY, 0, 0);
3608
+                        //imgCanvas.Width = imgRightDown.X - (Mouse.GetPosition(gridM).X);
3609
+                        //imgCanvas.Height = Mouse.GetPosition(gridM).Y - imgCanvas.Margin.Top;
3610
+                        //imgCanvas.Margin = new Thickness(Mouse.GetPosition(gridM).X, imgCanvas.Margin.Top, 0, 0);
3611
+                        #endregion
3504 3612
                         break;
3505 3613
                     case "RectRightDown":
3506
-                        imgCanvas.Width += e.HorizontalChange;
3507
-                        imgCanvas.Height += e.VerticalChange;
3614
+                        #region 右下
3615
+                        imgW = Mouse.GetPosition(gridM).X - imgCanvas.Margin.Left;
3616
+                        imgH = Mouse.GetPosition(gridM).Y - imgCanvas.Margin.Top;
3617
+                        if (imgW < 50)
3618
+                        {
3619
+                            imgCanvas.Width = 50;
3620
+                            Canvas.SetLeft(thu, Canvas.GetLeft(RectLeftUp) + 50);
3621
+                        }
3622
+                        else
3623
+                        {
3624
+                            imgCanvas.Width = imgW;
3625
+                            Canvas.SetLeft(thu, Canvas.GetLeft(thu) + e.HorizontalChange);
3626
+                        }
3627
+                        if (imgH < 50)
3628
+                        {
3629
+                            imgCanvas.Height = 50;
3630
+                            Canvas.SetTop(thu, Canvas.GetTop(RectLeftUp) + 50);
3631
+                        }
3632
+                        else
3633
+                        {
3634
+                            imgCanvas.Height = imgH;
3635
+                            Canvas.SetTop(thu, Canvas.GetTop(thu) + e.VerticalChange);
3636
+                        }
3637
+                        //imgCanvas.Margin = new Thickness(imgX, imgY, 0, 0);
3638
+                        //imgCanvas.Width += e.HorizontalChange;
3639
+                        //imgCanvas.Height += e.VerticalChange;
3640
+                        #endregion
3508 3641
                         break;
3509 3642
                     default:
3510 3643
                         break;

Loading…
Cancel
Save