Bläddra i källkod

封装简化代码

打印添加普通打印
tags/对接微服务前
张剑 3 år sedan
förälder
incheckning
3fcd5f6fbd

+ 2
- 2
XHWK.WKTool/App.config Visa fil

@@ -9,8 +9,8 @@
9 9
     <!--参数是否加密 0不加密 1加密-->
10 10
     <add key="IsParameterEncryption" value="0" />
11 11
     <!--版本号-->
12
-    <add key="VersionCode" value="99" />
13
-    <add key="VersionName" value="3.1.5" />
12
+    <add key="VersionCode" value="100" />
13
+    <add key="VersionName" value="3.1.6" />
14 14
     <!--皮肤样式 0白 1蓝 2黑色 -->
15 15
     <add key="SkinStyle" value="0" />
16 16
     <!--是否输出视频记录日志:0否-->

+ 425
- 0
XHWK.WKTool/Utils/ImageOperationUtil.cs Visa fil

@@ -0,0 +1,425 @@
1
+using System;
2
+using System.Drawing;
3
+using System.Linq;
4
+using System.Windows;
5
+using System.Windows.Controls;
6
+using System.Windows.Controls.Primitives;
7
+using System.Windows.Input;
8
+using System.Windows.Media;
9
+
10
+namespace XHWK.WKTool.Utils
11
+{
12
+    internal class ImageOperationUtil
13
+    {
14
+        #region 图片拉伸移动
15
+
16
+        private System.Windows.Point initialPoint;
17
+
18
+        private Thumb RectLeftUp;
19
+        private Thumb RectRightUp;
20
+        private Thumb RectLeftDown;
21
+        private Thumb RectRightDown;
22
+        private System.Windows.Shapes.Rectangle RectImgBorder;
23
+        private System.Windows.Controls.Image imgCanvas;
24
+        private Grid GridM;
25
+        private bool mouseDown = false;
26
+
27
+        public void setMouseDown(bool mouseDown) {
28
+            this.mouseDown = mouseDown;
29
+        }
30
+
31
+        public ImageOperationUtil(
32
+             Thumb RectLeftUp,
33
+             Thumb RectRightUp,
34
+             Thumb RectLeftDown,
35
+             Thumb RectRightDown,
36
+             System.Windows.Shapes.Rectangle RectImgBorder,
37
+             System.Windows.Controls.Image imgCanvas,
38
+             Grid GridM
39
+            )
40
+        {
41
+            this.RectLeftUp = RectLeftUp;
42
+            this.RectRightUp = RectRightUp;
43
+            this.RectLeftDown = RectLeftDown;
44
+            this.RectRightDown = RectRightDown;
45
+            this.RectImgBorder = RectImgBorder;
46
+            this.imgCanvas = imgCanvas;
47
+            this.GridM = GridM;
48
+        }
49
+
50
+        /// <summary>
51
+        /// 隐藏图片四个点和线
52
+        /// </summary>
53
+        public void HideAngleBorder()
54
+        {
55
+            RectLeftUp.Visibility = Visibility.Hidden;
56
+            RectRightUp.Visibility = Visibility.Hidden;
57
+            RectLeftDown.Visibility = Visibility.Hidden;
58
+            RectRightDown.Visibility = Visibility.Hidden;
59
+            RectImgBorder.Visibility = Visibility.Hidden;
60
+        }
61
+
62
+        private void ShowAngleBorder()
63
+        {
64
+            PointLocation();
65
+            RectLeftUp.Visibility = Visibility.Visible;
66
+            RectRightUp.Visibility = Visibility.Visible;
67
+            RectLeftDown.Visibility = Visibility.Visible;
68
+            RectRightDown.Visibility = Visibility.Visible;
69
+            RectImgBorder.Visibility = Visibility.Visible;
70
+        }
71
+
72
+        /// <summary>
73
+        /// 确定四个点和边框的位置大小
74
+        /// </summary>
75
+        private void PointLocation()
76
+        {
77
+            RectImgBorder.Width = imgCanvas.ActualWidth + 10.0;
78
+            RectImgBorder.Height = imgCanvas.ActualHeight + 10.0;
79
+            RectImgBorder.Margin = new Thickness(imgCanvas.Margin.Left - 5.0, imgCanvas.Margin.Top - 5.0, 0, 0);
80
+
81
+            Canvas.SetLeft(RectLeftUp, imgCanvas.Margin.Left - 10.0);
82
+            Canvas.SetTop(RectLeftUp, imgCanvas.Margin.Top - 10.0);
83
+
84
+            Canvas.SetLeft(RectRightUp, imgCanvas.Margin.Left + imgCanvas.ActualWidth - 10.0);
85
+            Canvas.SetTop(RectRightUp, imgCanvas.Margin.Top - 10.0);
86
+
87
+            Canvas.SetLeft(RectLeftDown, imgCanvas.Margin.Left - 10.0);
88
+            Canvas.SetTop(RectLeftDown, imgCanvas.Margin.Top + imgCanvas.ActualHeight - 10.0);
89
+
90
+            Canvas.SetLeft(RectRightDown, imgCanvas.Margin.Left + imgCanvas.ActualWidth - 10.0);
91
+            Canvas.SetTop(RectRightDown, imgCanvas.Margin.Top + imgCanvas.ActualHeight - 10.0);
92
+        }
93
+
94
+        public void PicEMap_MouseDown(object sender, MouseButtonEventArgs e)
95
+        {
96
+            System.Windows.Point point = e.GetPosition(imgCanvas);
97
+            initialPoint = point;
98
+
99
+            HideAngleBorder();
100
+        }
101
+
102
+        public void imgCanvas_MouseMove(object sender, MouseEventArgs e)
103
+        {
104
+            if (e.LeftButton == MouseButtonState.Pressed && mouseDown)
105
+            {
106
+                System.Windows.Point point = e.GetPosition(imgCanvas);
107
+                imgCanvas.Margin = new Thickness(imgCanvas.Margin.Left + (point.X - initialPoint.X), imgCanvas.Margin.Top + (point.Y - initialPoint.Y), 0, 0);
108
+                APP.PageDrawList[APP.PageContextData.currpage - 1].ImageLocation = new TranslateTransform
109
+                {
110
+                    X = imgCanvas.Margin.Left,
111
+                    Y = imgCanvas.Margin.Top
112
+                };
113
+                APP.PageDrawList[APP.PageContextData.currpage - 1].ImageSizes = new ScaleTransform
114
+                {
115
+                    CenterX = imgCanvas.ActualWidth,
116
+                    CenterY = imgCanvas.ActualHeight
117
+                };
118
+
119
+                APP.PageDrawList[APP.PageContextData.currpage - 1].IsImageLocation = false;
120
+            }
121
+        }
122
+
123
+        public void imgCanvas_MouseUp()
124
+        {
125
+            if (mouseDown)
126
+            {
127
+                ShowAngleBorder();
128
+            }
129
+        }
130
+
131
+        private PointF imgRightDown;
132
+
133
+        /// <summary>
134
+        /// 设置控件最上层
135
+        /// </summary>
136
+        /// <param name="element">
137
+        /// </param>
138
+        public void BringToFront(Thumb element)//图片置于最顶层显示
139
+        {
140
+            if (element == null)
141
+            {
142
+                return;
143
+            }
144
+
145
+            Canvas parent = element.Parent as Canvas;
146
+            if (parent == null)
147
+            {
148
+                return;
149
+            }
150
+
151
+            int maxZ = parent.Children.OfType<UIElement>()//linq语句,取Zindex的最大值
152
+              .Where(x => x != element)
153
+              .Select(x => Canvas.GetZIndex(x))
154
+              .Max();
155
+            Canvas.SetZIndex(element, maxZ + 1);
156
+        }
157
+
158
+        public void RectRightUp_DragStarted(object sender, System.Windows.Controls.Primitives.DragStartedEventArgs e)
159
+        {
160
+            try
161
+            {
162
+                Thumb thu = (Thumb)sender;
163
+                BringToFront(thu);
164
+
165
+                imgRightDown = new System.Drawing.PointF((float)(imgCanvas.Margin.Left + imgCanvas.ActualWidth), (float)(imgCanvas.Margin.Top + imgCanvas.ActualHeight));
166
+                HideAngleBorder();
167
+                switch (thu.Name)
168
+                {
169
+                    case "RectLeftUp":
170
+                        RectLeftUp.Visibility = Visibility.Visible;
171
+                        break;
172
+
173
+                    case "RectRightUp":
174
+                        RectRightUp.Visibility = Visibility.Visible;
175
+                        break;
176
+
177
+                    case "RectLeftDown":
178
+                        RectLeftDown.Visibility = Visibility.Visible;
179
+                        break;
180
+
181
+                    case "RectRightDown":
182
+                        RectRightDown.Visibility = Visibility.Visible;
183
+                        break;
184
+
185
+                    default:
186
+                        break;
187
+                }
188
+            }
189
+            catch (Exception ex)
190
+            {
191
+                MessageWindow.Show(ex.Message);
192
+            }
193
+        }
194
+
195
+        public void RectRightUp_DragDelta(object sender, DragDeltaEventArgs e)
196
+        {
197
+            try
198
+            {
199
+                if (mouseDown)
200
+                {
201
+                    Thumb thu = (Thumb)sender;
202
+
203
+                    #region 判断是否超出 暂无
204
+
205
+                    double plul = Canvas.GetLeft(RectLeftUp);
206
+                    double plut = Canvas.GetTop(RectLeftUp);
207
+                    double prdl = Canvas.GetLeft(RectRightDown);
208
+                    double prdt = Canvas.GetTop(RectRightDown);
209
+
210
+                    #endregion 判断是否超出 暂无
211
+
212
+                    double imgW = 0;
213
+                    double imgH = 0;
214
+                    double imgX = 0;
215
+                    double imgY = 0;
216
+                    switch (thu.Name)
217
+                    {
218
+                        case "RectLeftUp":
219
+
220
+                            #region 左上
221
+
222
+                            imgW = imgRightDown.X - (Mouse.GetPosition(GridM).X);
223
+                            imgH = imgRightDown.Y - (Mouse.GetPosition(GridM).Y);
224
+                            imgX = 0;
225
+                            imgY = 0;
226
+                            if (imgW < 50)
227
+                            {
228
+                                imgCanvas.Width = 50;
229
+                                imgX = imgCanvas.Margin.Left;
230
+                                Canvas.SetLeft(thu, Canvas.GetLeft(RectRightDown) - 50);
231
+                            }
232
+                            else
233
+                            {
234
+                                imgCanvas.Width = imgW;
235
+                                imgX = Mouse.GetPosition(GridM).X;
236
+                                Canvas.SetLeft(thu, Canvas.GetLeft(thu) + e.HorizontalChange);
237
+                            }
238
+                            if (imgH < 50)
239
+                            {
240
+                                imgCanvas.Height = 50;
241
+                                imgY = imgCanvas.Margin.Top;
242
+                                Canvas.SetTop(thu, Canvas.GetTop(RectRightDown) - 50);
243
+                            }
244
+                            else
245
+                            {
246
+                                imgCanvas.Height = imgH;
247
+                                imgY = Mouse.GetPosition(GridM).Y;
248
+                                Canvas.SetTop(thu, Canvas.GetTop(thu) + e.VerticalChange);
249
+                            }
250
+                            imgCanvas.Margin = new Thickness(imgX, imgY, 0, 0);
251
+
252
+                            #endregion 左上
253
+
254
+                            break;
255
+
256
+                        case "RectRightUp":
257
+
258
+                            #region 右上
259
+
260
+                            imgW = Mouse.GetPosition(GridM).X - imgCanvas.Margin.Left;
261
+                            imgH = imgRightDown.Y - (Mouse.GetPosition(GridM).Y);
262
+                            imgX = 0;
263
+                            imgY = 0;
264
+                            if (imgW < 50)
265
+                            {
266
+                                imgCanvas.Width = 50;
267
+                                imgX = imgCanvas.Margin.Left;
268
+                                Canvas.SetLeft(thu, Canvas.GetLeft(RectLeftUp) + 50);
269
+                            }
270
+                            else
271
+                            {
272
+                                imgCanvas.Width = imgW;
273
+                                imgX = imgCanvas.Margin.Left;
274
+                                Canvas.SetLeft(thu, Canvas.GetLeft(thu) + e.HorizontalChange);
275
+                            }
276
+                            if (imgH < 50)
277
+                            {
278
+                                imgCanvas.Height = 50;
279
+                                imgY = imgCanvas.Margin.Top;
280
+                                Canvas.SetTop(thu, Canvas.GetTop(RectRightDown) - 50);
281
+                            }
282
+                            else
283
+                            {
284
+                                imgCanvas.Height = imgH;
285
+                                imgY = Mouse.GetPosition(GridM).Y;
286
+                                Canvas.SetTop(thu, Canvas.GetTop(thu) + e.VerticalChange);
287
+                            }
288
+                            imgCanvas.Margin = new Thickness(imgX, imgY, 0, 0);
289
+
290
+                            #endregion 右上
291
+
292
+                            break;
293
+
294
+                        case "RectLeftDown":
295
+
296
+                            #region 左下
297
+
298
+                            imgW = imgRightDown.X - (Mouse.GetPosition(GridM).X);
299
+                            imgH = Mouse.GetPosition(GridM).Y - imgCanvas.Margin.Top;
300
+                            imgX = 0;
301
+                            imgY = 0;
302
+                            if (imgW < 50)
303
+                            {
304
+                                imgCanvas.Width = 50;
305
+                                imgX = imgCanvas.Margin.Left;
306
+                                Canvas.SetLeft(thu, Canvas.GetLeft(RectRightDown) - 50);
307
+                            }
308
+                            else
309
+                            {
310
+                                imgCanvas.Width = imgW;
311
+                                imgX = Mouse.GetPosition(GridM).X;
312
+                                Canvas.SetLeft(thu, Canvas.GetLeft(thu) + e.HorizontalChange);
313
+                            }
314
+                            if (imgH < 50)
315
+                            {
316
+                                imgCanvas.Height = 50;
317
+                                imgY = imgCanvas.Margin.Top;
318
+                                Canvas.SetTop(thu, Canvas.GetTop(RectLeftUp) + 50);
319
+                            }
320
+                            else
321
+                            {
322
+                                imgCanvas.Height = imgH;
323
+                                imgY = imgCanvas.Margin.Top;
324
+                                Canvas.SetTop(thu, Canvas.GetTop(thu) + e.VerticalChange);
325
+                            }
326
+                            imgCanvas.Margin = new Thickness(imgX, imgY, 0, 0);
327
+                            //imgCanvas.Width = imgRightDown.X - (Mouse.GetPosition(GridM).X);
328
+                            //imgCanvas.Height = Mouse.GetPosition(GridM).Y - imgCanvas.Margin.Top;
329
+                            //imgCanvas.Margin = new Thickness(Mouse.GetPosition(GridM).X, imgCanvas.Margin.Top, 0, 0);
330
+
331
+                            #endregion 左下
332
+
333
+                            break;
334
+
335
+                        case "RectRightDown":
336
+
337
+                            #region 右下
338
+
339
+                            imgW = Mouse.GetPosition(GridM).X - imgCanvas.Margin.Left;
340
+                            imgH = Mouse.GetPosition(GridM).Y - imgCanvas.Margin.Top;
341
+                            if (imgW < 50)
342
+                            {
343
+                                imgCanvas.Width = 50;
344
+                                Canvas.SetLeft(thu, Canvas.GetLeft(RectLeftUp) + 50);
345
+                            }
346
+                            else
347
+                            {
348
+                                imgCanvas.Width = imgW;
349
+                                Canvas.SetLeft(thu, Canvas.GetLeft(thu) + e.HorizontalChange);
350
+                            }
351
+                            if (imgH < 50)
352
+                            {
353
+                                imgCanvas.Height = 50;
354
+                                Canvas.SetTop(thu, Canvas.GetTop(RectLeftUp) + 50);
355
+                            }
356
+                            else
357
+                            {
358
+                                imgCanvas.Height = imgH;
359
+                                Canvas.SetTop(thu, Canvas.GetTop(thu) + e.VerticalChange);
360
+                            }
361
+                            //imgCanvas.Margin = new Thickness(imgX, imgY, 0, 0);
362
+                            //imgCanvas.Width += e.HorizontalChange;
363
+                            //imgCanvas.Height += e.VerticalChange;
364
+
365
+                            #endregion 右下
366
+
367
+                            break;
368
+
369
+                        default:
370
+                            break;
371
+                    }
372
+                    APP.PageDrawList[APP.PageContextData.currpage - 1].ImageLocation = new TranslateTransform
373
+                    {
374
+                        X = imgCanvas.Margin.Left,
375
+                        Y = imgCanvas.Margin.Top
376
+                    };
377
+                    APP.PageDrawList[APP.PageContextData.currpage - 1].ImageSizes = new ScaleTransform
378
+                    {
379
+                        CenterX = imgCanvas.ActualWidth,
380
+                        CenterY = imgCanvas.ActualHeight
381
+                    };
382
+                    APP.PageDrawList[APP.PageContextData.currpage - 1].IsImageLocation = false;
383
+                }
384
+            }
385
+            catch (Exception)
386
+            {
387
+                MessageWindow.Show("图片过小!");
388
+            }
389
+        }
390
+
391
+        public void RectRightUp_DragCompleted()
392
+        {
393
+            ShowAngleBorder();
394
+        }
395
+
396
+        /// <summary>
397
+        /// 点击标题栏 隐藏截图的四个点和线
398
+        /// </summary>
399
+        /// <param name="sender">
400
+        /// </param>
401
+        /// <param name="e">
402
+        /// </param>
403
+        public void Grid_MouseDown()
404
+        {
405
+            HideAngleBorder();
406
+        }
407
+
408
+        /// <summary>
409
+        /// 鼠标左键点击事件
410
+        /// </summary>
411
+        /// <param name="sender">
412
+        /// </param>
413
+        /// <param name="e">
414
+        /// </param>
415
+        public void Window_MouseLeftButtonDown_1()
416
+        {
417
+            if (RectImgBorder.Visibility != Visibility.Hidden)
418
+            {
419
+                HideAngleBorder();
420
+            }
421
+        }
422
+
423
+        #endregion 图片拉伸移动
424
+    }
425
+}

+ 32
- 341
XHWK.WKTool/XHMicroLessonSystemWindow.xaml.cs Visa fil

@@ -123,6 +123,7 @@ namespace XHWK.WKTool
123 123
         private static extern int SetCursorPos(int x, int y);
124 124
 
125 125
         private LuoBoPenUtil luoBoPenUtil;
126
+        private ImageOperationUtil imageOperationUtil;
126 127
 
127 128
         /// <summary>
128 129
         /// 主页面
@@ -174,6 +175,16 @@ namespace XHWK.WKTool
174 175
             new Aspose.Words.License().SetLicense(new MemoryStream(license));
175 176
             new Aspose.Pdf.License().SetLicense(new MemoryStream(license));
176 177
             new Aspose.Slides.License().SetLicense(new MemoryStream(license));
178
+
179
+            imageOperationUtil = new ImageOperationUtil(
180
+                RectLeftUp,
181
+               RectRightUp,
182
+                RectLeftDown,
183
+                 RectRightDown,
184
+                RectImgBorder,
185
+                imgCanvas,
186
+                GridM
187
+        );
177 188
         }
178 189
 
179 190
         /// <summary>
@@ -1281,6 +1292,7 @@ namespace XHWK.WKTool
1281 1292
         private void imgCanvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
1282 1293
         {
1283 1294
             mouseDown = true;
1295
+            imageOperationUtil.setMouseDown(mouseDown);
1284 1296
         }
1285 1297
 
1286 1298
         #endregion 画笔
@@ -1415,6 +1427,7 @@ namespace XHWK.WKTool
1415 1427
                         imgDocumentation.Source = null;
1416 1428
                         BitmapImage bitImg = new BitmapImage(new Uri(APP.PageDrawList[APP.PageContextData.currpage - 1].PageImagePath));
1417 1429
                         mouseDown = false;
1430
+                        imageOperationUtil.setMouseDown(mouseDown);
1418 1431
                         APP.PageDrawList[APP.PageContextData.currpage - 1].ImageLocation = new TranslateTransform
1419 1432
                         {
1420 1433
                             X = 0.1,
@@ -1835,6 +1848,7 @@ namespace XHWK.WKTool
1835 1848
                                 imgDocumentation.Source = null;
1836 1849
                                 BitmapImage bitImg = new BitmapImage(new Uri(APP.PageDrawList[APP.PageContextData.currpage - 1].PageImagePath));
1837 1850
                                 mouseDown = false;
1851
+                                imageOperationUtil.setMouseDown(mouseDown);
1838 1852
                                 APP.PageDrawList[APP.PageContextData.currpage - 1].ImageLocation = new TranslateTransform
1839 1853
                                 {
1840 1854
                                     X = 0.1,
@@ -3276,6 +3290,7 @@ namespace XHWK.WKTool
3276 3290
             if (APP.PageContextData.currpage > 1)
3277 3291
             {
3278 3292
                 mouseDown = false;
3293
+                imageOperationUtil.setMouseDown(mouseDown);
3279 3294
                 HideAngleBorder();
3280 3295
 
3281 3296
                 APP.PageContextData.currpage -= 1;
@@ -3295,6 +3310,7 @@ namespace XHWK.WKTool
3295 3310
             if (APP.PageContextData.currpage < APP.PageContextData.pagenum)
3296 3311
             {
3297 3312
                 mouseDown = false;
3313
+                imageOperationUtil.setMouseDown(mouseDown);
3298 3314
                 HideAngleBorder();
3299 3315
 
3300 3316
                 APP.PageContextData.currpage += 1;
@@ -3348,6 +3364,7 @@ namespace XHWK.WKTool
3348 3364
                         if (APP.PageDrawList[APP.PageContextData.currpage - 1].ImageLocation != null && APP.PageDrawList[APP.PageContextData.currpage - 1].ImageLocation.X > 0)
3349 3365
                         {
3350 3366
                             mouseDown = false;
3367
+                            imageOperationUtil.setMouseDown(mouseDown);
3351 3368
                             ImgXY();
3352 3369
                         }
3353 3370
                     }
@@ -3385,6 +3402,7 @@ namespace XHWK.WKTool
3385 3402
             }
3386 3403
             img.CaptureMouse();
3387 3404
             mouseDown = true;
3405
+            imageOperationUtil.setMouseDown(mouseDown);
3388 3406
             mouseXY = e.GetPosition(img);
3389 3407
             //Console.WriteLine("mouseXY.X = " + mouseXY.X + "; mouseXY.Y = " + mouseXY.Y);
3390 3408
         }
@@ -3398,6 +3416,7 @@ namespace XHWK.WKTool
3398 3416
             }
3399 3417
             img.ReleaseMouseCapture();
3400 3418
             mouseDown = false;
3419
+            imageOperationUtil.setMouseDown(mouseDown);
3401 3420
         }
3402 3421
 
3403 3422
         private void IMG1_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
@@ -3441,7 +3460,6 @@ namespace XHWK.WKTool
3441 3460
                 X = transform.X,
3442 3461
                 Y = transform.Y
3443 3462
             };
3444
-            //APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation = false;
3445 3463
         }
3446 3464
 
3447 3465
         private void IMG1_MouseWheel(object sender, MouseWheelEventArgs e)
@@ -3452,10 +3470,9 @@ namespace XHWK.WKTool
3452 3470
                 return;
3453 3471
             }
3454 3472
             System.Windows.Point point = e.GetPosition(img);
3455
-            //Console.WriteLine("point.X = " + point.X + "; point.Y=" + point.Y);
3473
+          
3456 3474
             System.Windows.Point PicLocate = e.GetPosition(imgCanvas);
3457
-            //Console.WriteLine("PicEmap.X = " + PicLocate.X + "; PicEmap.Y=" + PicLocate.Y);
3458
-
3475
+           
3459 3476
             TransformGroup group = IMG.FindResource("Imageview") as TransformGroup;
3460 3477
             double delta = e.Delta * 0.001;
3461 3478
             DowheelZoom(group, point, delta);
@@ -3475,15 +3492,7 @@ namespace XHWK.WKTool
3475 3492
             TranslateTransform transform1 = group.Children[1] as TranslateTransform;
3476 3493
             transform1.X = -1 * ((pointToContent.X * transform.ScaleX) - point.X);
3477 3494
             transform1.Y = -1 * ((pointToContent.Y * transform.ScaleY) - point.Y);
3478
-            //LogHelper.WriteInfoLog("【img宽高】" + imgCanvas.ActualWidth.ToString() + ":"
3479
-            //     + imgCanvas.ActualHeight.ToString() + "百分比:" + transform.ScaleX.ToString() + ":" + transform.ScaleY.ToString()
3480
-            //    );
3481
-
3482
-            //Console.WriteLine("transform.ScaleX = " + transform.ScaleX + "; transform.ScaleY = " + transform.ScaleY);
3483
-
3484
-            //APP.PageDrawList[APP.pageData.currpage - 1].ImageSize = new ScaleTransform();
3485
-            //APP.PageDrawList[APP.pageData.currpage - 1].ImageSize.ScaleX = transform.ScaleX;
3486
-            //APP.PageDrawList[APP.pageData.currpage - 1].ImageSize.ScaleY = transform.ScaleY;
3495
+   
3487 3496
             APP.PageDrawList[APP.PageContextData.currpage - 1].ImageLocation = new TranslateTransform
3488 3497
             {
3489 3498
                 X = transform1.X,
@@ -3695,358 +3704,43 @@ namespace XHWK.WKTool
3695 3704
 
3696 3705
         #region 图片拉伸移动
3697 3706
 
3698
-        private System.Windows.Point initialPoint;
3699
-
3700 3707
         /// <summary>
3701 3708
         /// 隐藏图片四个点和线
3702 3709
         /// </summary>
3703 3710
         private void HideAngleBorder()
3704 3711
         {
3705
-            RectLeftUp.Visibility = Visibility.Hidden;
3706
-            RectRightUp.Visibility = Visibility.Hidden;
3707
-            RectLeftDown.Visibility = Visibility.Hidden;
3708
-            RectRightDown.Visibility = Visibility.Hidden;
3709
-            RectImgBorder.Visibility = Visibility.Hidden;
3710
-        }
3711
-
3712
-        private void ShowAngleBorder()
3713
-        {
3714
-            PointLocation();
3715
-            RectLeftUp.Visibility = Visibility.Visible;
3716
-            RectRightUp.Visibility = Visibility.Visible;
3717
-            RectLeftDown.Visibility = Visibility.Visible;
3718
-            RectRightDown.Visibility = Visibility.Visible;
3719
-            RectImgBorder.Visibility = Visibility.Visible;
3720
-        }
3721
-
3722
-        /// <summary>
3723
-        /// 确定四个点和边框的位置大小
3724
-        /// </summary>
3725
-        private void PointLocation()
3726
-        {
3727
-            RectImgBorder.Width = imgCanvas.ActualWidth + 10.0;
3728
-            RectImgBorder.Height = imgCanvas.ActualHeight + 10.0;
3729
-            RectImgBorder.Margin = new Thickness(imgCanvas.Margin.Left - 5.0, imgCanvas.Margin.Top - 5.0, 0, 0);
3730
-
3731
-            Canvas.SetLeft(RectLeftUp, imgCanvas.Margin.Left - 10.0);
3732
-            Canvas.SetTop(RectLeftUp, imgCanvas.Margin.Top - 10.0);
3733
-
3734
-            Canvas.SetLeft(RectRightUp, imgCanvas.Margin.Left + imgCanvas.ActualWidth - 10.0);
3735
-            Canvas.SetTop(RectRightUp, imgCanvas.Margin.Top - 10.0);
3736
-
3737
-            Canvas.SetLeft(RectLeftDown, imgCanvas.Margin.Left - 10.0);
3738
-            Canvas.SetTop(RectLeftDown, imgCanvas.Margin.Top + imgCanvas.ActualHeight - 10.0);
3739
-
3740
-            Canvas.SetLeft(RectRightDown, imgCanvas.Margin.Left + imgCanvas.ActualWidth - 10.0);
3741
-            Canvas.SetTop(RectRightDown, imgCanvas.Margin.Top + imgCanvas.ActualHeight - 10.0);
3712
+            imageOperationUtil.HideAngleBorder();
3742 3713
         }
3743 3714
 
3715
+   
3744 3716
         private void PicEMap_MouseDown(object sender, MouseButtonEventArgs e)
3745 3717
         {
3746
-            System.Windows.Point point = e.GetPosition(imgCanvas);
3747
-            initialPoint = point;
3748
-
3749
-            HideAngleBorder();
3718
+            imageOperationUtil.PicEMap_MouseDown(sender, e);
3750 3719
         }
3751 3720
 
3752 3721
         private void imgCanvas_MouseMove(object sender, MouseEventArgs e)
3753 3722
         {
3754
-            if (e.LeftButton == MouseButtonState.Pressed && mouseDown)
3755
-            {
3756
-                System.Windows.Point point = e.GetPosition(imgCanvas);
3757
-                imgCanvas.Margin = new Thickness(imgCanvas.Margin.Left + (point.X - initialPoint.X), imgCanvas.Margin.Top + (point.Y - initialPoint.Y), 0, 0);
3758
-                APP.PageDrawList[APP.PageContextData.currpage - 1].ImageLocation = new TranslateTransform
3759
-                {
3760
-                    X = imgCanvas.Margin.Left,
3761
-                    Y = imgCanvas.Margin.Top
3762
-                };
3763
-                APP.PageDrawList[APP.PageContextData.currpage - 1].ImageSizes = new ScaleTransform
3764
-                {
3765
-                    CenterX = imgCanvas.ActualWidth,
3766
-                    CenterY = imgCanvas.ActualHeight
3767
-                };
3768
-
3769
-                APP.PageDrawList[APP.PageContextData.currpage - 1].IsImageLocation = false;
3770
-            }
3723
+            imageOperationUtil.imgCanvas_MouseMove(sender,e);
3771 3724
         }
3772 3725
 
3773 3726
         private void imgCanvas_MouseUp(object sender, MouseButtonEventArgs e)
3774 3727
         {
3775
-            if (mouseDown)
3776
-            {
3777
-                ShowAngleBorder();
3778
-            }
3779
-        }
3780
-
3781
-        private PointF imgRightDown;
3782
-
3783
-        /// <summary>
3784
-        /// 设置控件最上层
3785
-        /// </summary>
3786
-        /// <param name="element">
3787
-        /// </param>
3788
-        public void BringToFront(Thumb element)//图片置于最顶层显示
3789
-        {
3790
-            if (element == null)
3791
-            {
3792
-                return;
3793
-            }
3794
-
3795
-            Canvas parent = element.Parent as Canvas;
3796
-            if (parent == null)
3797
-            {
3798
-                return;
3799
-            }
3800
-
3801
-            int maxZ = parent.Children.OfType<UIElement>()//linq语句,取Zindex的最大值
3802
-              .Where(x => x != element)
3803
-              .Select(x => Canvas.GetZIndex(x))
3804
-              .Max();
3805
-            Canvas.SetZIndex(element, maxZ + 1);
3728
+            imageOperationUtil.imgCanvas_MouseUp();
3806 3729
         }
3807 3730
 
3808 3731
         private void RectRightUp_DragStarted(object sender, System.Windows.Controls.Primitives.DragStartedEventArgs e)
3809 3732
         {
3810
-            try
3811
-            {
3812
-                Thumb thu = (Thumb)sender;
3813
-                BringToFront(thu);
3814
-
3815
-                imgRightDown = new System.Drawing.PointF((float)(imgCanvas.Margin.Left + imgCanvas.ActualWidth), (float)(imgCanvas.Margin.Top + imgCanvas.ActualHeight));
3816
-                HideAngleBorder();
3817
-                switch (thu.Name)
3818
-                {
3819
-                    case "RectLeftUp":
3820
-                        RectLeftUp.Visibility = Visibility.Visible;
3821
-                        break;
3822
-
3823
-                    case "RectRightUp":
3824
-                        RectRightUp.Visibility = Visibility.Visible;
3825
-                        break;
3826
-
3827
-                    case "RectLeftDown":
3828
-                        RectLeftDown.Visibility = Visibility.Visible;
3829
-                        break;
3830
-
3831
-                    case "RectRightDown":
3832
-                        RectRightDown.Visibility = Visibility.Visible;
3833
-                        break;
3834
-
3835
-                    default:
3836
-                        break;
3837
-                }
3838
-            }
3839
-            catch (Exception ex)
3840
-            {
3841
-                MessageWindow.Show(ex.Message);
3842
-            }
3733
+            imageOperationUtil.RectRightUp_DragStarted(sender, e);
3843 3734
         }
3844 3735
 
3845 3736
         private void RectRightUp_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e)
3846 3737
         {
3847
-            try
3848
-            {
3849
-                if (mouseDown)
3850
-                {
3851
-                    Thumb thu = (Thumb)sender;
3852
-
3853
-                    #region 判断是否超出 暂无
3854
-
3855
-                    double plul = Canvas.GetLeft(RectLeftUp);
3856
-                    double plut = Canvas.GetTop(RectLeftUp);
3857
-                    double prdl = Canvas.GetLeft(RectRightDown);
3858
-                    double prdt = Canvas.GetTop(RectRightDown);
3859
-
3860
-                    #endregion 判断是否超出 暂无
3861
-
3862
-                    //Canvas.SetLeft(thu, Canvas.GetLeft(thu) + e.HorizontalChange);
3863
-                    //Canvas.SetTop(thu, Canvas.GetTop(thu) + e.VerticalChange);
3864
-                    double imgW = 0;
3865
-                    double imgH = 0;
3866
-                    double imgX = 0;
3867
-                    double imgY = 0;
3868
-                    switch (thu.Name)
3869
-                    {
3870
-                        case "RectLeftUp":
3871
-
3872
-                            #region 左上
3873
-
3874
-                            imgW = imgRightDown.X - (Mouse.GetPosition(GridM).X);
3875
-                            imgH = imgRightDown.Y - (Mouse.GetPosition(GridM).Y);
3876
-                            imgX = 0;
3877
-                            imgY = 0;
3878
-                            if (imgW < 50)
3879
-                            {
3880
-                                imgCanvas.Width = 50;
3881
-                                imgX = imgCanvas.Margin.Left;
3882
-                                Canvas.SetLeft(thu, Canvas.GetLeft(RectRightDown) - 50);
3883
-                            }
3884
-                            else
3885
-                            {
3886
-                                imgCanvas.Width = imgW;
3887
-                                imgX = Mouse.GetPosition(GridM).X;
3888
-                                Canvas.SetLeft(thu, Canvas.GetLeft(thu) + e.HorizontalChange);
3889
-                            }
3890
-                            if (imgH < 50)
3891
-                            {
3892
-                                imgCanvas.Height = 50;
3893
-                                imgY = imgCanvas.Margin.Top;
3894
-                                Canvas.SetTop(thu, Canvas.GetTop(RectRightDown) - 50);
3895
-                            }
3896
-                            else
3897
-                            {
3898
-                                imgCanvas.Height = imgH;
3899
-                                imgY = Mouse.GetPosition(GridM).Y;
3900
-                                Canvas.SetTop(thu, Canvas.GetTop(thu) + e.VerticalChange);
3901
-                            }
3902
-                            imgCanvas.Margin = new Thickness(imgX, imgY, 0, 0);
3903
-
3904
-                            #endregion 左上
3905
-
3906
-                            break;
3907
-
3908
-                        case "RectRightUp":
3909
-
3910
-                            #region 右上
3911
-
3912
-                            imgW = Mouse.GetPosition(GridM).X - imgCanvas.Margin.Left;
3913
-                            imgH = imgRightDown.Y - (Mouse.GetPosition(GridM).Y);
3914
-                            imgX = 0;
3915
-                            imgY = 0;
3916
-                            if (imgW < 50)
3917
-                            {
3918
-                                imgCanvas.Width = 50;
3919
-                                imgX = imgCanvas.Margin.Left;
3920
-                                Canvas.SetLeft(thu, Canvas.GetLeft(RectLeftUp) + 50);
3921
-                            }
3922
-                            else
3923
-                            {
3924
-                                imgCanvas.Width = imgW;
3925
-                                imgX = imgCanvas.Margin.Left;
3926
-                                Canvas.SetLeft(thu, Canvas.GetLeft(thu) + e.HorizontalChange);
3927
-                            }
3928
-                            if (imgH < 50)
3929
-                            {
3930
-                                imgCanvas.Height = 50;
3931
-                                imgY = imgCanvas.Margin.Top;
3932
-                                Canvas.SetTop(thu, Canvas.GetTop(RectRightDown) - 50);
3933
-                            }
3934
-                            else
3935
-                            {
3936
-                                imgCanvas.Height = imgH;
3937
-                                imgY = Mouse.GetPosition(GridM).Y;
3938
-                                Canvas.SetTop(thu, Canvas.GetTop(thu) + e.VerticalChange);
3939
-                            }
3940
-                            imgCanvas.Margin = new Thickness(imgX, imgY, 0, 0);
3941
-
3942
-                            #endregion 右上
3943
-
3944
-                            break;
3945
-
3946
-                        case "RectLeftDown":
3947
-
3948
-                            #region 左下
3949
-
3950
-                            imgW = imgRightDown.X - (Mouse.GetPosition(GridM).X);
3951
-                            imgH = Mouse.GetPosition(GridM).Y - imgCanvas.Margin.Top;
3952
-                            imgX = 0;
3953
-                            imgY = 0;
3954
-                            if (imgW < 50)
3955
-                            {
3956
-                                imgCanvas.Width = 50;
3957
-                                imgX = imgCanvas.Margin.Left;
3958
-                                Canvas.SetLeft(thu, Canvas.GetLeft(RectRightDown) - 50);
3959
-                            }
3960
-                            else
3961
-                            {
3962
-                                imgCanvas.Width = imgW;
3963
-                                imgX = Mouse.GetPosition(GridM).X;
3964
-                                Canvas.SetLeft(thu, Canvas.GetLeft(thu) + e.HorizontalChange);
3965
-                            }
3966
-                            if (imgH < 50)
3967
-                            {
3968
-                                imgCanvas.Height = 50;
3969
-                                imgY = imgCanvas.Margin.Top;
3970
-                                Canvas.SetTop(thu, Canvas.GetTop(RectLeftUp) + 50);
3971
-                            }
3972
-                            else
3973
-                            {
3974
-                                imgCanvas.Height = imgH;
3975
-                                imgY = imgCanvas.Margin.Top;
3976
-                                Canvas.SetTop(thu, Canvas.GetTop(thu) + e.VerticalChange);
3977
-                            }
3978
-                            imgCanvas.Margin = new Thickness(imgX, imgY, 0, 0);
3979
-                            //imgCanvas.Width = imgRightDown.X - (Mouse.GetPosition(GridM).X);
3980
-                            //imgCanvas.Height = Mouse.GetPosition(GridM).Y - imgCanvas.Margin.Top;
3981
-                            //imgCanvas.Margin = new Thickness(Mouse.GetPosition(GridM).X, imgCanvas.Margin.Top, 0, 0);
3982
-
3983
-                            #endregion 左下
3984
-
3985
-                            break;
3986
-
3987
-                        case "RectRightDown":
3988
-
3989
-                            #region 右下
3990
-
3991
-                            imgW = Mouse.GetPosition(GridM).X - imgCanvas.Margin.Left;
3992
-                            imgH = Mouse.GetPosition(GridM).Y - imgCanvas.Margin.Top;
3993
-                            if (imgW < 50)
3994
-                            {
3995
-                                imgCanvas.Width = 50;
3996
-                                Canvas.SetLeft(thu, Canvas.GetLeft(RectLeftUp) + 50);
3997
-                            }
3998
-                            else
3999
-                            {
4000
-                                imgCanvas.Width = imgW;
4001
-                                Canvas.SetLeft(thu, Canvas.GetLeft(thu) + e.HorizontalChange);
4002
-                            }
4003
-                            if (imgH < 50)
4004
-                            {
4005
-                                imgCanvas.Height = 50;
4006
-                                Canvas.SetTop(thu, Canvas.GetTop(RectLeftUp) + 50);
4007
-                            }
4008
-                            else
4009
-                            {
4010
-                                imgCanvas.Height = imgH;
4011
-                                Canvas.SetTop(thu, Canvas.GetTop(thu) + e.VerticalChange);
4012
-                            }
4013
-                            //imgCanvas.Margin = new Thickness(imgX, imgY, 0, 0);
4014
-                            //imgCanvas.Width += e.HorizontalChange;
4015
-                            //imgCanvas.Height += e.VerticalChange;
4016
-
4017
-                            #endregion 右下
4018
-
4019
-                            break;
4020
-
4021
-                        default:
4022
-                            break;
4023
-                    }
4024
-                    APP.PageDrawList[APP.PageContextData.currpage - 1].ImageLocation = new TranslateTransform
4025
-                    {
4026
-                        X = imgCanvas.Margin.Left,
4027
-                        Y = imgCanvas.Margin.Top
4028
-                    };
4029
-                    APP.PageDrawList[APP.PageContextData.currpage - 1].ImageSizes = new ScaleTransform
4030
-                    {
4031
-                        CenterX = imgCanvas.ActualWidth,
4032
-                        CenterY = imgCanvas.ActualHeight
4033
-                    };
4034
-                    APP.PageDrawList[APP.PageContextData.currpage - 1].IsImageLocation = false;
4035
-                }
4036
-                //lbl1.Content = imgCanvas.Margin.Left + "," + imgCanvas.Margin.Top;
4037
-                //lbl2.Content = (imgCanvas.Margin.Left+ imgCanvas.Width) +"," + imgCanvas.Margin.Top;
4038
-                //lbl3.Content = imgCanvas.Margin.Left + "," + (imgCanvas.Margin.Top+ imgCanvas.Height);
4039
-                //lbl4.Content= (imgCanvas.Margin.Left + imgCanvas.Width )+ "," + (imgCanvas.Margin.Top + imgCanvas.Height);
4040
-            }
4041
-            catch (Exception)
4042
-            {
4043
-                MessageWindow.Show("图片过小!");
4044
-            }
3738
+            imageOperationUtil.RectRightUp_DragDelta(sender, e);
4045 3739
         }
4046 3740
 
4047 3741
         private void RectRightUp_DragCompleted(object sender, System.Windows.Controls.Primitives.DragCompletedEventArgs e)
4048 3742
         {
4049
-            ShowAngleBorder();
3743
+            imageOperationUtil.RectRightUp_DragCompleted();
4050 3744
         }
4051 3745
 
4052 3746
         /// <summary>
@@ -4058,7 +3752,7 @@ namespace XHWK.WKTool
4058 3752
         /// </param>
4059 3753
         private void Grid_MouseDown(object sender, MouseButtonEventArgs e)
4060 3754
         {
4061
-            HideAngleBorder();
3755
+            imageOperationUtil.Grid_MouseDown();
4062 3756
         }
4063 3757
 
4064 3758
         /// <summary>
@@ -4070,10 +3764,7 @@ namespace XHWK.WKTool
4070 3764
         /// </param>
4071 3765
         private void Window_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
4072 3766
         {
4073
-            if (RectImgBorder.Visibility != Visibility.Hidden)
4074
-            {
4075
-                HideAngleBorder();
4076
-            }
3767
+            imageOperationUtil.Window_MouseLeftButtonDown_1();
4077 3768
         }
4078 3769
 
4079 3770
         #endregion 图片拉伸移动

+ 1
- 0
XHWK.WKTool/XHWK.WKTool.csproj Visa fil

@@ -316,6 +316,7 @@
316 316
     <Compile Include="system\SplashScreen.cs" />
317 317
     <Compile Include="system\XmlUtilHelper.cs" />
318 318
     <Compile Include="system\ZJClippingBorder.cs" />
319
+    <Compile Include="Utils\ImageOperationUtil.cs" />
319 320
     <Compile Include="Utils\pen\TQLPen\PenEvents.cs" />
320 321
     <Compile Include="Utils\pen\TQLPen\Pentiming.cs" />
321 322
     <Compile Include="UControl\UC_MultiRangeSlider.xaml.cs">

+ 1
- 1
星火微课/星火微课-正式.iss Visa fil

@@ -3,7 +3,7 @@
3 3
 
4 4
 #define MyAppName "星火微课"  
5 5
 #define MyAppDir "xhwk"
6
-#define MyAppVersion "3.1.5"
6
+#define MyAppVersion "3.1.6"
7 7
 #define MyAppPublisher "河南星火燎原软件科技有限公司"
8 8
 #define MyAppURL "http://www.xhkjedu.com/"
9 9
 #define MySourcePath "D:\Project\CSharp\xhwkclient\XHWK.WKTool\bin\x86\Debug\"

Laddar…
Avbryt
Spara