Quellcode durchsuchen

zhao:解决冲突

tags/录制修改前
耀 vor 4 Jahren
Ursprung
Commit
4969a87e84
35 geänderte Dateien mit 4336 neuen und 79 gelöschten Zeilen
  1. 28
    25
      Common/system/ImageHelper.cs
  2. 181
    0
      XHWK.Model/AppModel.cs
  3. 43
    0
      XHWK.Model/EntityBase.cs
  4. 2
    0
      XHWK.WKTool/App.config
  5. 6
    1
      XHWK.WKTool/App.cs
  6. 162
    0
      XHWK.WKTool/Controls/ArrowTool.cs
  7. 79
    0
      XHWK.WKTool/Controls/EllipseTool.cs
  8. 107
    0
      XHWK.WKTool/Controls/ImageEditBar.cs
  9. 42
    0
      XHWK.WKTool/Controls/KeyboardTextBox.cs
  10. 79
    0
      XHWK.WKTool/Controls/LineTool.cs
  11. 747
    0
      XHWK.WKTool/Controls/MainImage.cs
  12. 79
    0
      XHWK.WKTool/Controls/RectangleTool.cs
  13. 235
    0
      XHWK.WKTool/Controls/SizeColorBar.cs
  14. 102
    0
      XHWK.WKTool/Controls/TextBoxControl.cs
  15. 109
    0
      XHWK.WKTool/Controls/TextTool.cs
  16. 142
    0
      XHWK.WKTool/Controls/ToolButton.cs
  17. 43
    0
      XHWK.WKTool/Controls/ZoomThumb.cs
  18. 19
    0
      XHWK.WKTool/Converters/ColorConverter.cs
  19. 25
    0
      XHWK.WKTool/Converters/SizeConverter.cs
  20. 19
    0
      XHWK.WKTool/Converters/ToolConverter.cs
  21. 6
    6
      XHWK.WKTool/CountdownWindow.xaml
  22. 130
    9
      XHWK.WKTool/CountdownWindow.xaml.cs
  23. 49
    0
      XHWK.WKTool/Helpers/ScreenHelper.cs
  24. 26
    0
      XHWK.WKTool/Helpers/WpfHelper.cs
  25. 100
    0
      XHWK.WKTool/JieTuWindow.xaml
  26. 498
    0
      XHWK.WKTool/JieTuWindow.xaml.cs
  27. 179
    0
      XHWK.WKTool/Models/AppModel.cs
  28. 16
    0
      XHWK.WKTool/Models/Direction.cs
  29. 51
    0
      XHWK.WKTool/Models/EntityBase.cs
  30. 37
    0
      XHWK.WKTool/Models/Limit.cs
  31. 16
    0
      XHWK.WKTool/Models/Tool.cs
  32. 699
    0
      XHWK.WKTool/Themes/Generic.xaml
  33. 35
    17
      XHWK.WKTool/XHMicroLessonSystemWindow.xaml
  34. 211
    21
      XHWK.WKTool/XHMicroLessonSystemWindow.xaml.cs
  35. 34
    0
      XHWK.WKTool/XHWK.WKTool.csproj

+ 28
- 25
Common/system/ImageHelper.cs Datei anzeigen

@@ -74,7 +74,35 @@ namespace Common.system
74 74
                 return null;
75 75
             }
76 76
         }
77
+        #region 获取RGB
77 78
 
79
+        private static Bitmap _Bitmap = null;
80
+        private static StringBuilder sb = new StringBuilder();
81
+
82
+        public static string GetRGB(int x, int y)
83
+        {
84
+            sb = new StringBuilder();
85
+            try
86
+            {
87
+                System.Drawing.Color color = _Bitmap.GetPixel(x, y);
88
+
89
+                sb.Append("RGB:(");
90
+                sb.Append(color.R.ToString());
91
+                sb.Append(",");
92
+                sb.Append(color.G.ToString());
93
+                sb.Append(",");
94
+                sb.Append(color.B.ToString());
95
+                sb.Append(")");
96
+            }
97
+            catch (Exception ex)
98
+            {
99
+                LogHelper.WriteErrLog("ImageHelper(GetRGB)" + ex.Message, ex);
100
+            }
101
+
102
+            return sb.ToString();
103
+        }
104
+
105
+        #endregion 获取RGB
78 106
         #region 截图统一方法
79 107
         /// <summary>
80 108
         /// 截图通用方法 创建人:赵耀 创建时间:2020年8月11日
@@ -134,31 +162,6 @@ namespace Common.system
134 162
             FileToolsCommon.CreateDirectory(TempPath);
135 163
             return TempPath;
136 164
         }
137
-        private static Bitmap _Bitmap = null;
138
-
139
-        public static string GetRGB(int x, int y)
140
-        {
141
-            StringBuilder sb = new StringBuilder();
142
-            try
143
-            {
144
-                System.Drawing.Color color = _Bitmap.GetPixel(x, y);
145
-
146
-                sb.Append("RGB:(");
147
-                sb.Append(color.R.ToString());
148
-                sb.Append(",");
149
-                sb.Append(color.G.ToString());
150
-                sb.Append(",");
151
-                sb.Append(color.B.ToString());
152
-                sb.Append(")");
153
-            }
154
-            catch (Exception ex)
155
-            {
156
-                throw ex;
157
-            }
158
-
159
-            return sb.ToString();
160
-        }
161
-
162 165
         #endregion 截图统一方法
163 166
 
164 167
         #region 图片压缩

+ 181
- 0
XHWK.Model/AppModel.cs Datei anzeigen

@@ -0,0 +1,181 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+
7
+namespace XHWK.Model
8
+{
9
+    public class AppModel : EntityBase
10
+    {
11
+        public AppModel()
12
+        {
13
+            _Current = this;
14
+        }
15
+
16
+        #region 属性 Current
17
+
18
+        private static AppModel _Current = null;
19
+
20
+        public static AppModel Current => _Current;
21
+
22
+        #endregion 属性 Current
23
+
24
+        #region 属性 MaskLeftWidth
25
+
26
+        private double _MaskLeftWidth = ScreenshotWindow.ScreenWidth;
27
+
28
+        public double MaskLeftWidth
29
+        {
30
+            get => _MaskLeftWidth;
31
+            set
32
+            {
33
+                _MaskLeftWidth = value;
34
+                ShowSizeLeft = value;
35
+                RaisePropertyChanged(() => MaskLeftWidth);
36
+            }
37
+        }
38
+
39
+        #endregion 属性 MaskLeftWidth
40
+
41
+        #region 属性 MaskRightWidth
42
+
43
+        private double _MaskRightWidth = 0;
44
+
45
+        public double MaskRightWidth
46
+        {
47
+            get => _MaskRightWidth;
48
+            set
49
+            {
50
+                _MaskRightWidth = value;
51
+                RaisePropertyChanged(() => MaskRightWidth);
52
+            }
53
+        }
54
+
55
+        #endregion 属性 MaskRightWidth
56
+
57
+        #region 属性 MaskTopWidth
58
+
59
+        private double _MaskTopWidth = 0;
60
+
61
+        public double MaskTopWidth
62
+        {
63
+            get => _MaskTopWidth;
64
+            set
65
+            {
66
+                _MaskTopWidth = value;
67
+                RaisePropertyChanged(() => MaskTopWidth);
68
+            }
69
+        }
70
+
71
+        #endregion 属性 MaskTopWidth
72
+
73
+        #region 属性 MaskTopHeight
74
+
75
+        private double _MaskTopHeight = 0;
76
+
77
+        public double MaskTopHeight
78
+        {
79
+            get => _MaskTopHeight;
80
+            set
81
+            {
82
+                _MaskTopHeight = value;
83
+                ShowSizeTop = MaskTopHeight < 40 ? MaskTopHeight : MaskTopHeight - 40;
84
+                RaisePropertyChanged(() => MaskTopHeight);
85
+            }
86
+        }
87
+
88
+        #endregion 属性 MaskTopHeight
89
+
90
+        #region 属性 MaskBottomHeight
91
+
92
+        private double _MaskBottomHeight = 0;
93
+
94
+        public double MaskBottomHeight
95
+        {
96
+            get => _MaskBottomHeight;
97
+            set
98
+            {
99
+                _MaskBottomHeight = value;
100
+                RaisePropertyChanged(() => MaskBottomHeight);
101
+            }
102
+        }
103
+
104
+        #endregion 属性 MaskBottomHeight
105
+
106
+        #region 属性 ShowSize
107
+
108
+        private string _ShowSize = "0 × 0";
109
+
110
+        public string ShowSize
111
+        {
112
+            get => _ShowSize;
113
+            set
114
+            {
115
+                _ShowSize = value;
116
+                RaisePropertyChanged(() => ShowSize);
117
+            }
118
+        }
119
+
120
+        private static StringBuilder sb = new StringBuilder();
121
+
122
+        public void ChangeShowSize()
123
+        {
124
+            sb = new StringBuilder();
125
+            sb.Append((int)(ScreenshotWindow.Current.MainImage.Width * ScreenshotWindow.ScreenScale));
126
+            sb.Append(" × ");
127
+            sb.Append((int)(ScreenshotWindow.Current.MainImage.Height * ScreenshotWindow.ScreenScale));
128
+            ShowSize = sb.ToString();
129
+        }
130
+
131
+        #endregion 属性 ShowSize
132
+
133
+        #region 属性 ShowSizeLeft
134
+
135
+        private double _ShowSizeLeft = 0;
136
+
137
+        public double ShowSizeLeft
138
+        {
139
+            get => _ShowSizeLeft;
140
+            set
141
+            {
142
+                _ShowSizeLeft = value;
143
+                RaisePropertyChanged(() => ShowSizeLeft);
144
+            }
145
+        }
146
+
147
+        #endregion 属性 ShowSizeLeft
148
+
149
+        #region 属性 ShowSizeTop
150
+
151
+        private double _ShowSizeTop = 0;
152
+
153
+        public double ShowSizeTop
154
+        {
155
+            get => _ShowSizeTop;
156
+            set
157
+            {
158
+                _ShowSizeTop = value;
159
+                RaisePropertyChanged(() => ShowSizeTop);
160
+            }
161
+        }
162
+
163
+        #endregion 属性 ShowSizeTop
164
+
165
+        #region 属性 ShowRGB
166
+
167
+        private string _ShowRGB = string.Empty;
168
+
169
+        public string ShowRGB
170
+        {
171
+            get => _ShowRGB;
172
+            set
173
+            {
174
+                _ShowRGB = value;
175
+                RaisePropertyChanged(() => ShowRGB);
176
+            }
177
+        }
178
+
179
+        #endregion 属性 ShowRGB
180
+    }
181
+}

+ 43
- 0
XHWK.Model/EntityBase.cs Datei anzeigen

@@ -0,0 +1,43 @@
1
+using System;
2
+using System.Linq.Expressions;
3
+
4
+namespace XHWK.Model
5
+{
6
+    /// <summary>
7
+    /// singba:20120807
8
+    /// 这个基类只作为INotifyPropertyChanged的实现,不再是Entity的基类
9
+    /// </summary>
10
+    public class EntityBase : System.ComponentModel.INotifyPropertyChanged
11
+    {
12
+        #region INotifyPropertyChanged Members
13
+
14
+        public virtual event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
15
+
16
+        protected virtual void RaisePropertyChanged(string name)
17
+        {
18
+            if (PropertyChanged != null)
19
+            {
20
+                PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(name));
21
+            }
22
+        }
23
+
24
+        protected virtual void RaisePropertyChanged<TProperty>(Expression<Func<TProperty>> property)
25
+        {
26
+            LambdaExpression lambda = property;
27
+            MemberExpression memberExpression;
28
+            if (lambda.Body is UnaryExpression)
29
+            {
30
+                UnaryExpression unaryExpression = (UnaryExpression)lambda.Body;
31
+                memberExpression = (MemberExpression)unaryExpression.Operand;
32
+            }
33
+            else
34
+            {
35
+                memberExpression = (MemberExpression)lambda.Body;
36
+            }
37
+
38
+            RaisePropertyChanged(memberExpression.Member.Name);
39
+        }
40
+
41
+        #endregion INotifyPropertyChanged Members
42
+    }
43
+}

+ 2
- 0
XHWK.WKTool/App.config Datei anzeigen

@@ -10,6 +10,8 @@
10 10
     <add key="VideoSavePath" value="D:\星火微课" />
11 11
     <!--视频格式 1、MP4 2、FlV 3、AVI-->
12 12
     <add key="VideoType" value="1" />
13
+    <!--声音 true 有 false 无-->
14
+    <add key="IsSound" value="true"/>
13 15
     <!--图片压缩质量-->
14 16
     <add key="ImageCompressionLevel" value="50"/>
15 17
     <!--用户名-->

+ 6
- 1
XHWK.WKTool/App.cs Datei anzeigen

@@ -1,4 +1,5 @@
1
-using Common.system;
1
+using ComeCapture;
2
+using Common.system;
2 3
 
3 4
 using System;
4 5
 using System.Diagnostics;
@@ -46,6 +47,10 @@ namespace XHWK.WKTool
46 47
         /// </summary>
47 48
         public static LoginWindow W_LoginWindow = null;
48 49
         /// <summary>
50
+        /// 截图
51
+        /// </summary>
52
+        public static JieTuWindow W_JieTuWindow = null;
53
+        /// <summary>
49 54
         /// 登陆状态 false 未登录 true已登陆
50 55
         /// </summary>
51 56
         public static bool IsLoginType = false;

+ 162
- 0
XHWK.WKTool/Controls/ArrowTool.cs Datei anzeigen

@@ -0,0 +1,162 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Windows;
4
+using System.Windows.Controls;
5
+using System.Windows.Media;
6
+
7
+namespace ComeCapture.Controls
8
+{
9
+    public class ArrowTool : StackPanel
10
+    {
11
+        private readonly StreamGeometry geometry = new StreamGeometry();
12
+
13
+        static ArrowTool()
14
+        {
15
+            DefaultStyleKeyProperty.OverrideMetadata(typeof(ArrowTool), new FrameworkPropertyMetadata(typeof(ArrowTool)));
16
+        }
17
+
18
+        public ArrowTool()
19
+        {
20
+            _Current = this;
21
+        }
22
+
23
+        public List<Point> CreateArrow(Point start, Point end)
24
+        {
25
+            double tan = Math.Atan((end.Y - start.Y) / (end.X - start.X));
26
+            double Move0 = tan - ArrowAngle;
27
+            double Move1 = tan + ArrowAngle;
28
+            int convert = end.X > start.X ? -1 : 1;
29
+            double X0 = end.X + ((convert * ArrowLength) * Math.Cos(Move0));
30
+            double Y0 = end.Y + ((convert * ArrowLength) * Math.Sin(Move0));
31
+            double X1 = end.X + ((convert * ArrowLength) * Math.Cos(Move1));
32
+            double Y1 = end.Y + ((convert * ArrowLength) * Math.Sin(Move1));
33
+            Point point3 = new Point(X0, Y0);
34
+            Point point5 = new Point(X1, Y1);
35
+            Point point2 = new Point(X0 + 0.25 * (X1 - X0), Y0 + 0.25 * (Y1 - Y0));
36
+            Point point4 = new Point(X0 + 0.75 * (X1 - X0), Y0 + 0.75 * (Y1 - Y0));
37
+            return new List<Point>()
38
+            {
39
+                start,
40
+                new Point(X0 + 0.25 * (X1 - X0), Y0 + 0.25 * (Y1 - Y0)),
41
+                new Point(X0, Y0),
42
+                end,
43
+                new Point(X1, Y1),
44
+                new Point(X0 + 0.75 * (X1 - X0), Y0 + 0.75 * (Y1 - Y0)),
45
+                start
46
+            };
47
+        }
48
+
49
+        #region 属性 Current
50
+
51
+        private static ArrowTool _Current = null;
52
+
53
+        public static ArrowTool Current => _Current;
54
+
55
+        #endregion 属性 Current
56
+
57
+        #region LineThickness DependencyProperty
58
+
59
+        public double LineThickness
60
+        {
61
+            get => (double)GetValue(LineThicknessProperty);
62
+            set => SetValue(LineThicknessProperty, value);
63
+        }
64
+
65
+        public static readonly DependencyProperty LineThicknessProperty =
66
+                DependencyProperty.Register("LineThickness", typeof(double), typeof(ArrowTool),
67
+                new PropertyMetadata(5.0, new PropertyChangedCallback(ArrowTool.OnLineThicknessPropertyChanged)));
68
+
69
+        private static void OnLineThicknessPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
70
+        {
71
+            if (obj is ArrowTool)
72
+            {
73
+                (obj as ArrowTool).OnLineThicknessValueChanged();
74
+            }
75
+        }
76
+
77
+        protected void OnLineThicknessValueChanged()
78
+        {
79
+            ArrowLength = LineThickness * 2 + 7;
80
+        }
81
+
82
+        #endregion LineThickness DependencyProperty
83
+
84
+        #region LineBrush DependencyProperty
85
+
86
+        public SolidColorBrush LineBrush
87
+        {
88
+            get => (SolidColorBrush)GetValue(LineBrushProperty);
89
+            set => SetValue(LineBrushProperty, value);
90
+        }
91
+
92
+        public static readonly DependencyProperty LineBrushProperty =
93
+                DependencyProperty.Register("LineBrush", typeof(SolidColorBrush), typeof(ArrowTool),
94
+                new PropertyMetadata(new SolidColorBrush(Colors.Red), new PropertyChangedCallback(ArrowTool.OnLineBrushPropertyChanged)));
95
+
96
+        private static void OnLineBrushPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
97
+        {
98
+            if (obj is ArrowTool)
99
+            {
100
+                (obj as ArrowTool).OnLineBrushValueChanged();
101
+            }
102
+        }
103
+
104
+        protected void OnLineBrushValueChanged()
105
+        {
106
+        }
107
+
108
+        #endregion LineBrush DependencyProperty
109
+
110
+        #region ArrowLength DependencyProperty
111
+
112
+        public double ArrowLength
113
+        {
114
+            get => (double)GetValue(ArrowLengthProperty);
115
+            set => SetValue(ArrowLengthProperty, value);
116
+        }
117
+
118
+        public static readonly DependencyProperty ArrowLengthProperty =
119
+                DependencyProperty.Register("ArrowLength", typeof(double), typeof(ArrowTool),
120
+                new PropertyMetadata(17.0, new PropertyChangedCallback(ArrowTool.OnArrowLengthPropertyChanged)));
121
+
122
+        private static void OnArrowLengthPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
123
+        {
124
+            if (obj is ArrowTool)
125
+            {
126
+                (obj as ArrowTool).OnArrowLengthValueChanged();
127
+            }
128
+        }
129
+
130
+        protected void OnArrowLengthValueChanged()
131
+        {
132
+        }
133
+
134
+        #endregion ArrowLength DependencyProperty
135
+
136
+        #region ArrowAngle DependencyProperty
137
+
138
+        public double ArrowAngle
139
+        {
140
+            get => (double)GetValue(ArrowAngleProperty);
141
+            set => SetValue(ArrowAngleProperty, value);
142
+        }
143
+
144
+        public static readonly DependencyProperty ArrowAngleProperty =
145
+                DependencyProperty.Register("ArrowAngle", typeof(double), typeof(ArrowTool),
146
+                new PropertyMetadata(0.45, new PropertyChangedCallback(ArrowTool.OnArrowAnglePropertyChanged)));
147
+
148
+        private static void OnArrowAnglePropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
149
+        {
150
+            if (obj is ArrowTool)
151
+            {
152
+                (obj as ArrowTool).OnArrowAngleValueChanged();
153
+            }
154
+        }
155
+
156
+        protected void OnArrowAngleValueChanged()
157
+        {
158
+        }
159
+
160
+        #endregion ArrowAngle DependencyProperty
161
+    }
162
+}

+ 79
- 0
XHWK.WKTool/Controls/EllipseTool.cs Datei anzeigen

@@ -0,0 +1,79 @@
1
+using System.Windows;
2
+using System.Windows.Controls;
3
+using System.Windows.Media;
4
+
5
+namespace ComeCapture.Controls
6
+{
7
+    public class EllipseTool : StackPanel
8
+    {
9
+        static EllipseTool()
10
+        {
11
+            DefaultStyleKeyProperty.OverrideMetadata(typeof(EllipseTool), new FrameworkPropertyMetadata(typeof(EllipseTool)));
12
+        }
13
+
14
+        public EllipseTool()
15
+        {
16
+            _Current = this;
17
+        }
18
+
19
+        #region 属性 Current
20
+
21
+        private static EllipseTool _Current = null;
22
+
23
+        public static EllipseTool Current => _Current;
24
+
25
+        #endregion 属性 Current
26
+
27
+        #region LineThickness DependencyProperty
28
+
29
+        public double LineThickness
30
+        {
31
+            get => (double)GetValue(LineThicknessProperty);
32
+            set => SetValue(LineThicknessProperty, value);
33
+        }
34
+
35
+        public static readonly DependencyProperty LineThicknessProperty =
36
+                DependencyProperty.Register("LineThickness", typeof(double), typeof(EllipseTool),
37
+                new PropertyMetadata(5.0, new PropertyChangedCallback(EllipseTool.OnLineThicknessPropertyChanged)));
38
+
39
+        private static void OnLineThicknessPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
40
+        {
41
+            if (obj is EllipseTool)
42
+            {
43
+                (obj as EllipseTool).OnLineThicknessValueChanged();
44
+            }
45
+        }
46
+
47
+        protected void OnLineThicknessValueChanged()
48
+        {
49
+        }
50
+
51
+        #endregion LineThickness DependencyProperty
52
+
53
+        #region LineBrush DependencyProperty
54
+
55
+        public SolidColorBrush LineBrush
56
+        {
57
+            get => (SolidColorBrush)GetValue(LineBrushProperty);
58
+            set => SetValue(LineBrushProperty, value);
59
+        }
60
+
61
+        public static readonly DependencyProperty LineBrushProperty =
62
+                DependencyProperty.Register("LineBrush", typeof(SolidColorBrush), typeof(EllipseTool),
63
+                new PropertyMetadata(new SolidColorBrush(Colors.Red), new PropertyChangedCallback(EllipseTool.OnLineBrushPropertyChanged)));
64
+
65
+        private static void OnLineBrushPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
66
+        {
67
+            if (obj is EllipseTool)
68
+            {
69
+                (obj as EllipseTool).OnLineBrushValueChanged();
70
+            }
71
+        }
72
+
73
+        protected void OnLineBrushValueChanged()
74
+        {
75
+        }
76
+
77
+        #endregion LineBrush DependencyProperty
78
+    }
79
+}

+ 107
- 0
XHWK.WKTool/Controls/ImageEditBar.cs Datei anzeigen

@@ -0,0 +1,107 @@
1
+using ComeCapture.Models;
2
+
3
+using System.Windows;
4
+using System.Windows.Controls;
5
+
6
+namespace ComeCapture.Controls
7
+{
8
+    public class ImageEditBar : Control
9
+    {
10
+        static ImageEditBar()
11
+        {
12
+            DefaultStyleKeyProperty.OverrideMetadata(typeof(ImageEditBar), new FrameworkPropertyMetadata(typeof(ImageEditBar)));
13
+        }
14
+
15
+        public ImageEditBar()
16
+        {
17
+            _Current = this;
18
+        }
19
+
20
+        #region 属性 Current
21
+
22
+        private static ImageEditBar _Current = null;
23
+
24
+        public static ImageEditBar Current
25
+        {
26
+            get => _Current;
27
+            set => _Current = value;
28
+        }
29
+
30
+        #endregion 属性 Current
31
+
32
+        #region 定位
33
+
34
+        public void ResetCanvas()
35
+        {
36
+            ResetCanvasLeft();
37
+            ResetCanvasTop();
38
+        }
39
+
40
+        #endregion 定位
41
+
42
+        #region CanvasLeft DependencyProperty
43
+
44
+        public double CanvasLeft
45
+        {
46
+            get => (double)GetValue(CanvasLeftProperty);
47
+            set => SetValue(CanvasLeftProperty, value);
48
+        }
49
+
50
+        public static readonly DependencyProperty CanvasLeftProperty =
51
+                DependencyProperty.Register("CanvasLeft", typeof(double), typeof(ImageEditBar),
52
+                new PropertyMetadata(0.0, new PropertyChangedCallback(ImageEditBar.OnCanvasLeftPropertyChanged)));
53
+
54
+        private static void OnCanvasLeftPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
55
+        {
56
+            if (obj is ImageEditBar)
57
+            {
58
+                (obj as ImageEditBar).OnCanvasLeftValueChanged();
59
+            }
60
+        }
61
+
62
+        protected void OnCanvasLeftValueChanged()
63
+        {
64
+        }
65
+
66
+        private void ResetCanvasLeft()
67
+        {
68
+            CanvasLeft = AppModel.Current.MaskRightWidth > JieTuWindow.ScreenWidth - Width ? 0 : JieTuWindow.ScreenWidth - AppModel.Current.MaskRightWidth - Width;
69
+        }
70
+
71
+        #endregion CanvasLeft DependencyProperty
72
+
73
+        #region CanvasTop DependencyProperty
74
+
75
+        public double CanvasTop
76
+        {
77
+            get => (double)GetValue(CanvasTopProperty);
78
+            set => SetValue(CanvasTopProperty, value);
79
+        }
80
+
81
+        public static readonly DependencyProperty CanvasTopProperty =
82
+                DependencyProperty.Register("CanvasTop", typeof(double), typeof(ImageEditBar),
83
+                new PropertyMetadata(0.0, new PropertyChangedCallback(ImageEditBar.OnCanvasTopPropertyChanged)));
84
+
85
+        private static void OnCanvasTopPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
86
+        {
87
+            if (obj is ImageEditBar)
88
+            {
89
+                (obj as ImageEditBar).OnCanvasTopValueChanged();
90
+            }
91
+        }
92
+
93
+        protected void OnCanvasTopValueChanged()
94
+        {
95
+        }
96
+
97
+        private void ResetCanvasTop()
98
+        {
99
+            int need = 30 + (SizeColorBar.Current.Selected == Tool.Null ? 0 : 37);
100
+            CanvasTop = AppModel.Current.MaskBottomHeight >= need ? JieTuWindow.ScreenHeight - AppModel.Current.MaskBottomHeight + 5
101
+                : AppModel.Current.MaskTopHeight >= need ? AppModel.Current.MaskTopHeight - 30
102
+                : AppModel.Current.MaskTopHeight;
103
+        }
104
+
105
+        #endregion CanvasTop DependencyProperty
106
+    }
107
+}

+ 42
- 0
XHWK.WKTool/Controls/KeyboardTextBox.cs Datei anzeigen

@@ -0,0 +1,42 @@
1
+using System.Windows;
2
+using System.Windows.Controls;
3
+using System.Windows.Input;
4
+
5
+namespace ComeCapture.Controls
6
+{
7
+    public class KeyboardTextBox : Control
8
+    {
9
+        static KeyboardTextBox()
10
+        {
11
+            DefaultStyleKeyProperty.OverrideMetadata(typeof(KeyboardTextBox), new FrameworkPropertyMetadata(typeof(KeyboardTextBox)));
12
+        }
13
+
14
+        public KeyboardTextBox()
15
+        {
16
+            AddHandler(PreviewKeyDownEvent, new KeyEventHandler(Keyboard_KeyDown));
17
+            DataContext = AppModel.Current;
18
+        }
19
+
20
+        #region 键盘事件:只允许输入数字以及字母
21
+
22
+        private void Keyboard_KeyDown(object sender, KeyEventArgs e)
23
+        {
24
+            int key = (int)e.Key;
25
+            TextBox textbox = e.OriginalSource as TextBox;
26
+            //A-Z
27
+            if (key >= 44 && key <= 69)
28
+            {
29
+                textbox.Text = e.Key.ToString();
30
+                textbox.Select(1, 0);
31
+            }
32
+            else if (key >= 34 && key <= 43) //0 - 9,
33
+            {
34
+                textbox.Text = e.Key.ToString().Substring(1);
35
+                textbox.Select(1, 0);
36
+            }
37
+            e.Handled = true;
38
+        }
39
+
40
+        #endregion 键盘事件:只允许输入数字以及字母
41
+    }
42
+}

+ 79
- 0
XHWK.WKTool/Controls/LineTool.cs Datei anzeigen

@@ -0,0 +1,79 @@
1
+using System.Windows;
2
+using System.Windows.Controls;
3
+using System.Windows.Media;
4
+
5
+namespace ComeCapture.Controls
6
+{
7
+    public class LineTool : StackPanel
8
+    {
9
+        static LineTool()
10
+        {
11
+            DefaultStyleKeyProperty.OverrideMetadata(typeof(LineTool), new FrameworkPropertyMetadata(typeof(LineTool)));
12
+        }
13
+
14
+        public LineTool()
15
+        {
16
+            _Current = this;
17
+        }
18
+
19
+        #region 属性 Current
20
+
21
+        private static LineTool _Current = null;
22
+
23
+        public static LineTool Current => _Current;
24
+
25
+        #endregion 属性 Current
26
+
27
+        #region LineThickness DependencyProperty
28
+
29
+        public double LineThickness
30
+        {
31
+            get => (double)GetValue(LineThicknessProperty);
32
+            set => SetValue(LineThicknessProperty, value);
33
+        }
34
+
35
+        public static readonly DependencyProperty LineThicknessProperty =
36
+                DependencyProperty.Register("LineThickness", typeof(double), typeof(LineTool),
37
+                new PropertyMetadata(5.0, new PropertyChangedCallback(LineTool.OnLineThicknessPropertyChanged)));
38
+
39
+        private static void OnLineThicknessPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
40
+        {
41
+            if (obj is LineTool)
42
+            {
43
+                (obj as LineTool).OnLineThicknessValueChanged();
44
+            }
45
+        }
46
+
47
+        protected void OnLineThicknessValueChanged()
48
+        {
49
+        }
50
+
51
+        #endregion LineThickness DependencyProperty
52
+
53
+        #region LineBrush DependencyProperty
54
+
55
+        public SolidColorBrush LineBrush
56
+        {
57
+            get => (SolidColorBrush)GetValue(LineBrushProperty);
58
+            set => SetValue(LineBrushProperty, value);
59
+        }
60
+
61
+        public static readonly DependencyProperty LineBrushProperty =
62
+                DependencyProperty.Register("LineBrush", typeof(SolidColorBrush), typeof(LineTool),
63
+                new PropertyMetadata(new SolidColorBrush(Colors.Red), new PropertyChangedCallback(LineTool.OnLineBrushPropertyChanged)));
64
+
65
+        private static void OnLineBrushPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
66
+        {
67
+            if (obj is LineTool)
68
+            {
69
+                (obj as LineTool).OnLineBrushValueChanged();
70
+            }
71
+        }
72
+
73
+        protected void OnLineBrushValueChanged()
74
+        {
75
+        }
76
+
77
+        #endregion LineBrush DependencyProperty
78
+    }
79
+}

+ 747
- 0
XHWK.WKTool/Controls/MainImage.cs Datei anzeigen

@@ -0,0 +1,747 @@
1
+using ComeCapture.Helpers;
2
+using ComeCapture.Models;
3
+using Common.system;
4
+using System.Collections.Generic;
5
+using System.Linq;
6
+using System.Windows;
7
+using System.Windows.Controls;
8
+using System.Windows.Controls.Primitives;
9
+using System.Windows.Input;
10
+using System.Windows.Media;
11
+using System.Windows.Shapes;
12
+
13
+namespace ComeCapture.Controls
14
+{
15
+    public class MainImage : Control
16
+    {
17
+        public Point point;
18
+
19
+        private Rectangle _Rectangle = null;
20
+        private Ellipse _Ellipse = null;
21
+        private List<Point> points = null;
22
+        private Path _Line = null;
23
+        private readonly StreamGeometry geometry = new StreamGeometry();
24
+        public TextBoxControl _Text = null;
25
+        private Path _Arrow = null;
26
+
27
+        static MainImage()
28
+        {
29
+            DefaultStyleKeyProperty.OverrideMetadata(typeof(MainImage), new FrameworkPropertyMetadata(typeof(MainImage)));
30
+        }
31
+
32
+        public MainImage()
33
+        {
34
+            _Current = this;
35
+            AddHandler(Thumb.DragStartedEvent, new DragStartedEventHandler(OnDragStart));
36
+            AddHandler(Thumb.DragCompletedEvent, new DragCompletedEventHandler(OnDragCompleted));
37
+            AddHandler(Thumb.DragDeltaEvent, new DragDeltaEventHandler(OnDragDelta));
38
+            AddHandler(MouseMoveEvent, new MouseEventHandler(OnMove));
39
+            Limit = new Limit();
40
+        }
41
+
42
+        #region 属性 Current
43
+
44
+        private static MainImage _Current = null;
45
+
46
+        public static MainImage Current
47
+        {
48
+            get => _Current;
49
+            set => _Current = value;
50
+        }
51
+
52
+        #endregion 属性 Current
53
+
54
+        #region MoveCursor DependencyProperty
55
+
56
+        public Cursor MoveCursor
57
+        {
58
+            get => (Cursor)GetValue(MoveCursorProperty);
59
+            set => SetValue(MoveCursorProperty, value);
60
+        }
61
+
62
+        public static readonly DependencyProperty MoveCursorProperty =
63
+                DependencyProperty.Register("MoveCursor", typeof(Cursor), typeof(MainImage),
64
+                new PropertyMetadata(Cursors.SizeAll, new PropertyChangedCallback(MainImage.OnMoveCursorPropertyChanged)));
65
+
66
+        private static void OnMoveCursorPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
67
+        {
68
+            if (obj is MainImage)
69
+            {
70
+                (obj as MainImage).OnMoveCursorValueChanged();
71
+            }
72
+        }
73
+
74
+        protected void OnMoveCursorValueChanged()
75
+        {
76
+        }
77
+
78
+        #endregion MoveCursor DependencyProperty
79
+
80
+        #region Direction DependencyProperty
81
+
82
+        public Direction Direction
83
+        {
84
+            get => (Direction)GetValue(DirectionProperty);
85
+            set => SetValue(DirectionProperty, value);
86
+        }
87
+
88
+        public static readonly DependencyProperty DirectionProperty =
89
+                DependencyProperty.Register("Direction", typeof(Direction), typeof(MainImage),
90
+                new PropertyMetadata(Direction.Null, new PropertyChangedCallback(MainImage.OnDirectionPropertyChanged)));
91
+
92
+        private static void OnDirectionPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
93
+        {
94
+            if (obj is MainImage)
95
+            {
96
+                (obj as MainImage).OnDirectionValueChanged();
97
+            }
98
+        }
99
+
100
+        protected void OnDirectionValueChanged()
101
+        {
102
+        }
103
+
104
+        #endregion Direction DependencyProperty
105
+
106
+        #region Limit DependencyProperty
107
+
108
+        public Limit Limit
109
+        {
110
+            get => (Limit)GetValue(LimitProperty);
111
+            set => SetValue(LimitProperty, value);
112
+        }
113
+
114
+        public static readonly DependencyProperty LimitProperty =
115
+                DependencyProperty.Register("Limit", typeof(Limit), typeof(MainImage),
116
+                new PropertyMetadata(null, new PropertyChangedCallback(MainImage.OnLimitPropertyChanged)));
117
+
118
+        private static void OnLimitPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
119
+        {
120
+            if (obj is MainImage)
121
+            {
122
+                (obj as MainImage).OnLimitValueChanged();
123
+            }
124
+        }
125
+
126
+        protected void OnLimitValueChanged()
127
+        {
128
+        }
129
+
130
+        #endregion Limit DependencyProperty
131
+
132
+        #region ZoomThumbVisibility DependencyProperty
133
+
134
+        public Visibility ZoomThumbVisibility
135
+        {
136
+            get => (Visibility)GetValue(ZoomThumbVisibilityProperty);
137
+            set => SetValue(ZoomThumbVisibilityProperty, value);
138
+        }
139
+
140
+        public static readonly DependencyProperty ZoomThumbVisibilityProperty =
141
+                DependencyProperty.Register("ZoomThumbVisibility", typeof(Visibility), typeof(MainImage),
142
+                new PropertyMetadata(Visibility.Visible, new PropertyChangedCallback(MainImage.OnZoomThumbVisibilityPropertyChanged)));
143
+
144
+        private static void OnZoomThumbVisibilityPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
145
+        {
146
+            if (obj is MainImage)
147
+            {
148
+                (obj as MainImage).OnZoomThumbVisibilityValueChanged();
149
+            }
150
+        }
151
+
152
+        protected void OnZoomThumbVisibilityValueChanged()
153
+        {
154
+        }
155
+
156
+        #endregion ZoomThumbVisibility DependencyProperty
157
+
158
+        #region 开始滑动事件
159
+
160
+        private void OnDragStart(object sender, DragStartedEventArgs e)
161
+        {
162
+            Direction = (e.OriginalSource as ZoomThumb).Direction;
163
+            if (SizeColorBar.Current.Selected != Tool.Null)
164
+            {
165
+                point = Mouse.GetPosition(this);
166
+                if (SizeColorBar.Current.Selected == Tool.Text)
167
+                {
168
+                    DrawText();
169
+                }
170
+            }
171
+        }
172
+
173
+        #endregion 开始滑动事件
174
+
175
+        #region 滑动中事件
176
+
177
+        private void OnDragDelta(object sender, DragDeltaEventArgs e)
178
+        {
179
+            double X = e.HorizontalChange;
180
+            double Y = e.VerticalChange;
181
+            switch (Direction)
182
+            {
183
+                case Direction.Move:
184
+                    if (SizeColorBar.Current.Selected == Tool.Null)
185
+                    {
186
+                        OnMove(X, Y);
187
+                    }
188
+                    else
189
+                    {
190
+                        switch (SizeColorBar.Current.Selected)
191
+                        {
192
+                            case Tool.Rectangle:
193
+                                DrawRectangle(X, Y);
194
+                                break;
195
+
196
+                            case Tool.Ellipse:
197
+                                DrawEllipse(X, Y);
198
+                                break;
199
+
200
+                            case Tool.Arrow:
201
+                                DrawArrow(X, Y);
202
+                                break;
203
+
204
+                            case Tool.Line:
205
+                                DrawLine(X, Y);
206
+                                break;
207
+
208
+                            case Tool.Text:
209
+                                break;
210
+
211
+                            default:
212
+                                break;
213
+                        }
214
+                    }
215
+                    break;
216
+
217
+                case Direction.Null:
218
+                    break;
219
+
220
+                default:
221
+                    string str = Direction.ToString();
222
+                    if (X != 0)
223
+                    {
224
+                        if (str.Contains("Left"))
225
+                        {
226
+                            Left(X);
227
+                        }
228
+                        if (str.Contains("Right"))
229
+                        {
230
+                            Right(X);
231
+                        }
232
+                    }
233
+                    if (Y != 0)
234
+                    {
235
+                        if (str.Contains("Top"))
236
+                        {
237
+                            Top(Y);
238
+                        }
239
+                        if (str.Contains("Bottom"))
240
+                        {
241
+                            Bottom(Y);
242
+                        }
243
+                    }
244
+                    AppModel.Current.ChangeShowSize();
245
+                    break;
246
+            }
247
+            ImageEditBar.Current.ResetCanvas();
248
+            SizeColorBar.Current.ResetCanvas();
249
+        }
250
+
251
+        #endregion 滑动中事件
252
+
253
+        #region 滑动结束事件
254
+
255
+        private void OnDragCompleted(object sender, DragCompletedEventArgs e)
256
+        {
257
+            if (Direction == Direction.Move && SizeColorBar.Current.Selected != Tool.Null)
258
+            {
259
+                switch (SizeColorBar.Current.Selected)
260
+                {
261
+                    case Tool.Rectangle:
262
+                        if (_Rectangle != null)
263
+                        {
264
+                            ResetLimit(Canvas.GetLeft(_Rectangle), Canvas.GetTop(_Rectangle), Canvas.GetLeft(_Rectangle) + _Rectangle.Width, Canvas.GetTop(_Rectangle) + _Rectangle.Height);
265
+                            JieTuWindow.Register(_Rectangle);
266
+                            _Rectangle = null;
267
+                        }
268
+                        break;
269
+
270
+                    case Tool.Ellipse:
271
+                        if (_Ellipse != null)
272
+                        {
273
+                            ResetLimit(Canvas.GetLeft(_Ellipse), Canvas.GetTop(_Ellipse), Canvas.GetLeft(_Ellipse) + _Ellipse.Width, Canvas.GetTop(_Ellipse) + _Ellipse.Height);
274
+                            JieTuWindow.Register(_Ellipse);
275
+                            _Ellipse = null;
276
+                        }
277
+                        break;
278
+
279
+                    case Tool.Arrow:
280
+                        if (_Arrow != null)
281
+                        {
282
+                            geometry.Clear();
283
+                            ResetLimit(points.Min(p => p.X), points.Min(p => p.Y), points.Max(p => p.X), points.Max(p => p.Y));
284
+                            points = null;
285
+                            JieTuWindow.Register(_Arrow);
286
+                            _Arrow = null;
287
+                        }
288
+                        break;
289
+
290
+                    case Tool.Line:
291
+                        if (_Line != null)
292
+                        {
293
+                            geometry.Clear();
294
+                            ResetLimit(points.Min(p => p.X), points.Min(p => p.Y), points.Max(p => p.X), points.Max(p => p.Y));
295
+                            points = null;
296
+                            JieTuWindow.Register(_Line);
297
+                            _Line = null;
298
+                        }
299
+                        break;
300
+
301
+                    case Tool.Text:
302
+                        break;
303
+
304
+                    default:
305
+                        break;
306
+                }
307
+            }
308
+            Direction = Direction.Null;
309
+        }
310
+
311
+        #endregion 滑动结束事件
312
+
313
+        #region 画矩形
314
+
315
+        private void DrawRectangle(double X, double Y)
316
+        {
317
+            if (_Rectangle == null)
318
+            {
319
+                _Rectangle = new Rectangle()
320
+                {
321
+                    Fill = new SolidColorBrush(Colors.Transparent),
322
+                    Stroke = RectangleTool.Current.LineBrush,
323
+                    StrokeThickness = RectangleTool.Current.LineThickness
324
+                };
325
+                Panel.SetZIndex(_Rectangle, -1);
326
+                JieTuWindow.AddControl(_Rectangle);
327
+            }
328
+            if (X > 0)
329
+            {
330
+                Canvas.SetLeft(_Rectangle, point.X + AppModel.Current.MaskLeftWidth);
331
+                _Rectangle.Width = X < Width - point.X ? X : Width - point.X;
332
+            }
333
+            else
334
+            {
335
+                Canvas.SetLeft(_Rectangle, -X < point.X ? point.X + X + AppModel.Current.MaskLeftWidth : AppModel.Current.MaskLeftWidth);
336
+                _Rectangle.Width = -X < point.X ? -X : point.X;
337
+            }
338
+            if (Y > 0)
339
+            {
340
+                Canvas.SetTop(_Rectangle, point.Y + AppModel.Current.MaskTopHeight);
341
+                _Rectangle.Height = Y < Height - point.Y ? Y : Height - point.Y;
342
+            }
343
+            else
344
+            {
345
+                Canvas.SetTop(_Rectangle, -Y < point.Y ? point.Y + Y + AppModel.Current.MaskTopHeight : AppModel.Current.MaskTopHeight);
346
+                _Rectangle.Height = -Y < point.Y ? -Y : point.Y;
347
+            }
348
+        }
349
+
350
+        #endregion 画矩形
351
+
352
+        #region 画椭圆
353
+
354
+        private void DrawEllipse(double X, double Y)
355
+        {
356
+            if (_Ellipse == null)
357
+            {
358
+                _Ellipse = new Ellipse()
359
+                {
360
+                    Fill = new SolidColorBrush(Colors.Transparent),
361
+                    Stroke = EllipseTool.Current.LineBrush,
362
+                    StrokeThickness = EllipseTool.Current.LineThickness
363
+                };
364
+                Panel.SetZIndex(_Ellipse, -1);
365
+                JieTuWindow.AddControl(_Ellipse);
366
+            }
367
+            if (X > 0)
368
+            {
369
+                Canvas.SetLeft(_Ellipse, point.X + AppModel.Current.MaskLeftWidth);
370
+                _Ellipse.Width = X < Width - point.X ? X : Width - point.X;
371
+            }
372
+            else
373
+            {
374
+                Canvas.SetLeft(_Ellipse, -X < point.X ? point.X + X + AppModel.Current.MaskLeftWidth : AppModel.Current.MaskLeftWidth);
375
+                _Ellipse.Width = -X < point.X ? -X : point.X;
376
+            }
377
+            if (Y > 0)
378
+            {
379
+                Canvas.SetTop(_Ellipse, point.Y + AppModel.Current.MaskTopHeight);
380
+                _Ellipse.Height = Y < Height - point.Y ? Y : Height - point.Y;
381
+            }
382
+            else
383
+            {
384
+                Canvas.SetTop(_Ellipse, -Y < point.Y ? point.Y + Y + AppModel.Current.MaskTopHeight : AppModel.Current.MaskTopHeight);
385
+                _Ellipse.Height = -Y < point.Y ? -Y : point.Y;
386
+            }
387
+        }
388
+
389
+        #endregion 画椭圆
390
+
391
+        #region 画箭头
392
+
393
+        private void DrawArrow(double X, double Y)
394
+        {
395
+            Point screen = new Point(point.X + AppModel.Current.MaskLeftWidth, point.Y + AppModel.Current.MaskTopHeight);
396
+            if (_Arrow == null)
397
+            {
398
+                _Arrow = new Path()
399
+                {
400
+                    Fill = ArrowTool.Current.LineBrush,
401
+                    StrokeThickness = ArrowTool.Current.LineThickness
402
+                };
403
+                Panel.SetZIndex(_Arrow, -1);
404
+                JieTuWindow.AddControl(_Arrow);
405
+            }
406
+            Point point2 = new Point(screen.X + X, screen.Y + Y);
407
+            point2.X = point2.X < AppModel.Current.MaskLeftWidth ? AppModel.Current.MaskLeftWidth : point2.X > AppModel.Current.MaskLeftWidth + Width ? AppModel.Current.MaskLeftWidth + Width : point2.X;
408
+            point2.Y = point2.Y < AppModel.Current.MaskTopHeight ? AppModel.Current.MaskTopHeight : point2.Y > AppModel.Current.MaskTopHeight + Height ? AppModel.Current.MaskTopHeight + Height : point2.Y;
409
+            points = ArrowTool.Current.CreateArrow(screen, point2);
410
+
411
+            using (StreamGeometryContext ctx = geometry.Open())
412
+            {
413
+                for (int i = 0; i < points.Count; i++)
414
+                {
415
+                    if (i == 0)
416
+                    {
417
+                        ctx.BeginFigure(points[0], true, false);
418
+                    }
419
+                    else
420
+                    {
421
+                        ctx.LineTo(points[i], true, true);
422
+                    }
423
+                }
424
+            }
425
+            _Arrow.Data = geometry.Clone();
426
+        }
427
+
428
+        #endregion 画箭头
429
+
430
+        #region 画刷
431
+
432
+        private void DrawLine(double X, double Y)
433
+        {
434
+            Point screen = new Point(point.X + AppModel.Current.MaskLeftWidth, point.Y + AppModel.Current.MaskTopHeight);
435
+            if (_Line == null)
436
+            {
437
+                _Line = new Path()
438
+                {
439
+                    Stroke = LineTool.Current.LineBrush,
440
+                    StrokeThickness = LineTool.Current.LineThickness
441
+                };
442
+                points = new List<Point>
443
+                {
444
+                    screen
445
+                };
446
+                Panel.SetZIndex(_Line, -1);
447
+                JieTuWindow.AddControl(_Line);
448
+            }
449
+            Point point2 = new Point(screen.X + X, screen.Y + Y);
450
+            point2.X = point2.X < AppModel.Current.MaskLeftWidth ? AppModel.Current.MaskLeftWidth : point2.X > AppModel.Current.MaskLeftWidth + Width ? AppModel.Current.MaskLeftWidth + Width : point2.X;
451
+            point2.Y = point2.Y < AppModel.Current.MaskTopHeight ? AppModel.Current.MaskTopHeight : point2.Y > AppModel.Current.MaskTopHeight + Height ? AppModel.Current.MaskTopHeight + Height : point2.Y;
452
+            points.Add(point2);
453
+            using (StreamGeometryContext ctx = geometry.Open())
454
+            {
455
+                for (int i = 0; i < points.Count; i++)
456
+                {
457
+                    if (i == 0)
458
+                    {
459
+                        ctx.BeginFigure(points[0], true, false);
460
+                    }
461
+                    else
462
+                    {
463
+                        ctx.LineTo(points[i], true, true);
464
+                    }
465
+                }
466
+            }
467
+            _Line.Data = geometry.Clone();
468
+        }
469
+
470
+        #endregion 画刷
471
+
472
+        #region 添加输入框
473
+
474
+        private void DrawText()
475
+        {
476
+            if (_Text != null)
477
+            {
478
+                Focus();
479
+            }
480
+            else
481
+            {
482
+                _Text = new TextBoxControl()
483
+                {
484
+                    FontSize = TextTool.Current.FontSize,
485
+                    Foreground = TextTool.Current.LineBrush
486
+                };
487
+                if (point.X > Width - 36)
488
+                {
489
+                    point.X = Width - 36;
490
+                }
491
+                if (point.Y > Height - 22)
492
+                {
493
+                    point.Y = Height - 22;
494
+                }
495
+                Point screen = new Point(point.X + AppModel.Current.MaskLeftWidth, point.Y + AppModel.Current.MaskTopHeight);
496
+                Canvas.SetLeft(_Text, screen.X);
497
+                Canvas.SetTop(_Text, screen.Y);
498
+                JieTuWindow.AddControl(_Text);
499
+            }
500
+        }
501
+
502
+        #endregion 添加输入框
503
+
504
+        #region 拖动截图区域
505
+
506
+        private void OnMove(double X, double Y)
507
+        {
508
+            #region X轴移动
509
+
510
+            if (X > 0)
511
+            {
512
+                double max = AppModel.Current.MaskRightWidth > Limit.Left - AppModel.Current.MaskLeftWidth ? Limit.Left - AppModel.Current.MaskLeftWidth : AppModel.Current.MaskRightWidth;
513
+                if (X > max)
514
+                {
515
+                    X = max;
516
+                }
517
+            }
518
+            else
519
+            {
520
+                double max = AppModel.Current.MaskLeftWidth > AppModel.Current.MaskLeftWidth + Width - Limit.Right ? AppModel.Current.MaskLeftWidth + Width - Limit.Right : AppModel.Current.MaskLeftWidth;
521
+                if (-X > max)
522
+                {
523
+                    X = -max;
524
+                }
525
+            }
526
+            if (X != 0)
527
+            {
528
+                AppModel.Current.MaskLeftWidth += X;
529
+                AppModel.Current.MaskRightWidth -= X;
530
+                Canvas.SetLeft(this, Canvas.GetLeft(this) + X);
531
+            }
532
+
533
+            #endregion X轴移动
534
+
535
+            #region Y轴移动
536
+
537
+            if (Y > 0)
538
+            {
539
+                double max = AppModel.Current.MaskBottomHeight > Limit.Top - AppModel.Current.MaskTopHeight ? Limit.Top - AppModel.Current.MaskTopHeight : AppModel.Current.MaskBottomHeight;
540
+                if (Y > max)
541
+                {
542
+                    Y = max;
543
+                }
544
+            }
545
+            else
546
+            {
547
+                double max = AppModel.Current.MaskTopHeight > AppModel.Current.MaskTopHeight + Height - Limit.Bottom ? AppModel.Current.MaskTopHeight + Height - Limit.Bottom : AppModel.Current.MaskTopHeight;
548
+                if (-Y > max)
549
+                {
550
+                    Y = -max;
551
+                }
552
+            }
553
+            if (Y != 0)
554
+            {
555
+                AppModel.Current.MaskTopHeight += Y;
556
+                AppModel.Current.MaskBottomHeight -= Y;
557
+                Canvas.SetTop(this, Canvas.GetTop(this) + Y);
558
+            }
559
+
560
+            #endregion Y轴移动
561
+        }
562
+
563
+        #endregion 拖动截图区域
564
+
565
+        #region 左缩放
566
+
567
+        private void Left(double X)
568
+        {
569
+            if (X > 0)
570
+            {
571
+                double max = JieTuWindow.Current.list.Count == 0 ? Width - JieTuWindow.MinSize
572
+                    : Limit.Left - AppModel.Current.MaskLeftWidth < Width - JieTuWindow.MinSize ? Limit.Left - AppModel.Current.MaskLeftWidth
573
+                    : Width - JieTuWindow.MinSize;
574
+                if (X > max)
575
+                {
576
+                    X = max;
577
+                }
578
+            }
579
+            else
580
+            {
581
+                double max = AppModel.Current.MaskLeftWidth;
582
+                if (-X > max)
583
+                {
584
+                    X = -max;
585
+                }
586
+            }
587
+            if (X != 0)
588
+            {
589
+                Width -= X;
590
+                Canvas.SetLeft(this, Canvas.GetLeft(this) + X);
591
+                AppModel.Current.MaskLeftWidth += X;
592
+                AppModel.Current.MaskTopWidth -= X;
593
+            }
594
+        }
595
+
596
+        #endregion 左缩放
597
+
598
+        #region 右缩放
599
+
600
+        private void Right(double X)
601
+        {
602
+            if (X > 0)
603
+            {
604
+                double max = AppModel.Current.MaskRightWidth;
605
+                if (X > max)
606
+                {
607
+                    X = max;
608
+                }
609
+            }
610
+            else
611
+            {
612
+                double max = JieTuWindow.Current.list.Count == 0 ? Width - JieTuWindow.MinSize
613
+                    : AppModel.Current.MaskLeftWidth + Width - Limit.Right < Width - JieTuWindow.MinSize ? AppModel.Current.MaskLeftWidth + Width - Limit.Right
614
+                    : Width - JieTuWindow.MinSize;
615
+                if (-X > max)
616
+                {
617
+                    X = -max;
618
+                }
619
+            }
620
+            if (X != 0)
621
+            {
622
+                Width += X;
623
+                AppModel.Current.MaskRightWidth -= X;
624
+                AppModel.Current.MaskTopWidth += X;
625
+            }
626
+        }
627
+
628
+        #endregion 右缩放
629
+
630
+        #region 上缩放
631
+
632
+        private void Top(double Y)
633
+        {
634
+            if (Y > 0)
635
+            {
636
+                double max = JieTuWindow.Current.list.Count == 0 ? Height - JieTuWindow.MinSize
637
+                    : Limit.Top - AppModel.Current.MaskTopHeight < Height - JieTuWindow.MinSize ? Limit.Top - AppModel.Current.MaskTopHeight
638
+                    : Height - JieTuWindow.MinSize;
639
+                if (Y > max)
640
+                {
641
+                    Y = max;
642
+                }
643
+            }
644
+            else
645
+            {
646
+                double max = AppModel.Current.MaskLeftWidth;
647
+                if (-Y > max)
648
+                {
649
+                    Y = -max;
650
+                }
651
+            }
652
+            if (Y != 0)
653
+            {
654
+                Height -= Y;
655
+                Canvas.SetTop(this, Canvas.GetTop(this) + Y);
656
+                AppModel.Current.MaskTopHeight += Y;
657
+            }
658
+        }
659
+
660
+        #endregion 上缩放
661
+
662
+        #region 下缩放
663
+
664
+        private void Bottom(double Y)
665
+        {
666
+            if (Y > 0)
667
+            {
668
+                double max = AppModel.Current.MaskBottomHeight;
669
+                if (Y > max)
670
+                {
671
+                    Y = max;
672
+                }
673
+            }
674
+            else
675
+            {
676
+                double max = JieTuWindow.Current.list.Count == 0 ? Height - JieTuWindow.MinSize
677
+                    : AppModel.Current.MaskTopHeight + Height - Limit.Bottom < Height - JieTuWindow.MinSize ? AppModel.Current.MaskTopHeight + Height - Limit.Bottom
678
+                    : Height - JieTuWindow.MinSize;
679
+                if (-Y > max)
680
+                {
681
+                    Y = -max;
682
+                }
683
+            }
684
+            if (Y != 0)
685
+            {
686
+                Height += Y;
687
+                AppModel.Current.MaskBottomHeight -= Y;
688
+            }
689
+        }
690
+
691
+        #endregion 下缩放
692
+
693
+        #region 刷新RGB
694
+
695
+        private void OnMove(object sender, MouseEventArgs e)
696
+        {
697
+            Point point = PointToScreen(e.GetPosition(this));
698
+            AppModel.Current.ShowRGB = ImageHelper.GetRGB((int)point.X, (int)point.Y);
699
+        }
700
+
701
+        #endregion 刷新RGB
702
+
703
+        #region 计算图片移动的极限值
704
+
705
+        public void ResetLimit(double left, double top, double right, double bottom)
706
+        {
707
+            ResetLeft(left);
708
+            ResetTop(top);
709
+            ResetRight(right);
710
+            ResetButtom(bottom);
711
+        }
712
+
713
+        private void ResetLeft(double value)
714
+        {
715
+            if (value < Limit.Left)
716
+            {
717
+                Limit.Left = value;
718
+            }
719
+        }
720
+
721
+        private void ResetTop(double value)
722
+        {
723
+            if (value < Limit.Top)
724
+            {
725
+                Limit.Top = value;
726
+            }
727
+        }
728
+
729
+        private void ResetRight(double value)
730
+        {
731
+            if (value > Limit.Right)
732
+            {
733
+                Limit.Right = value;
734
+            }
735
+        }
736
+
737
+        private void ResetButtom(double value)
738
+        {
739
+            if (value > Limit.Bottom)
740
+            {
741
+                Limit.Bottom = value;
742
+            }
743
+        }
744
+
745
+        #endregion 计算图片移动的极限值
746
+    }
747
+}

+ 79
- 0
XHWK.WKTool/Controls/RectangleTool.cs Datei anzeigen

@@ -0,0 +1,79 @@
1
+using System.Windows;
2
+using System.Windows.Controls;
3
+using System.Windows.Media;
4
+
5
+namespace ComeCapture.Controls
6
+{
7
+    public class RectangleTool : StackPanel
8
+    {
9
+        static RectangleTool()
10
+        {
11
+            DefaultStyleKeyProperty.OverrideMetadata(typeof(RectangleTool), new FrameworkPropertyMetadata(typeof(RectangleTool)));
12
+        }
13
+
14
+        public RectangleTool()
15
+        {
16
+            _Current = this;
17
+        }
18
+
19
+        #region 属性 Current
20
+
21
+        private static RectangleTool _Current = null;
22
+
23
+        public static RectangleTool Current => _Current;
24
+
25
+        #endregion 属性 Current
26
+
27
+        #region LineThickness DependencyProperty
28
+
29
+        public double LineThickness
30
+        {
31
+            get => (double)GetValue(LineThicknessProperty);
32
+            set => SetValue(LineThicknessProperty, value);
33
+        }
34
+
35
+        public static readonly DependencyProperty LineThicknessProperty =
36
+                DependencyProperty.Register("LineThickness", typeof(double), typeof(RectangleTool),
37
+                new PropertyMetadata(5.0, new PropertyChangedCallback(RectangleTool.OnLineThicknessPropertyChanged)));
38
+
39
+        private static void OnLineThicknessPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
40
+        {
41
+            if (obj is RectangleTool)
42
+            {
43
+                (obj as RectangleTool).OnLineThicknessValueChanged();
44
+            }
45
+        }
46
+
47
+        protected void OnLineThicknessValueChanged()
48
+        {
49
+        }
50
+
51
+        #endregion LineThickness DependencyProperty
52
+
53
+        #region LineBrush DependencyProperty
54
+
55
+        public SolidColorBrush LineBrush
56
+        {
57
+            get => (SolidColorBrush)GetValue(LineBrushProperty);
58
+            set => SetValue(LineBrushProperty, value);
59
+        }
60
+
61
+        public static readonly DependencyProperty LineBrushProperty =
62
+                DependencyProperty.Register("LineBrush", typeof(SolidColorBrush), typeof(RectangleTool),
63
+                new PropertyMetadata(new SolidColorBrush(Colors.Red), new PropertyChangedCallback(RectangleTool.OnLineBrushPropertyChanged)));
64
+
65
+        private static void OnLineBrushPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
66
+        {
67
+            if (obj is RectangleTool)
68
+            {
69
+                (obj as RectangleTool).OnLineBrushValueChanged();
70
+            }
71
+        }
72
+
73
+        protected void OnLineBrushValueChanged()
74
+        {
75
+        }
76
+
77
+        #endregion LineBrush DependencyProperty
78
+    }
79
+}

+ 235
- 0
XHWK.WKTool/Controls/SizeColorBar.cs Datei anzeigen

@@ -0,0 +1,235 @@
1
+using ComeCapture.Models;
2
+
3
+using System.Collections.Generic;
4
+using System.Windows;
5
+using System.Windows.Controls;
6
+using System.Windows.Input;
7
+using System.Windows.Media;
8
+
9
+namespace ComeCapture.Controls
10
+{
11
+    [TemplatePart(Name = "PART_RectangleTool", Type = typeof(RectangleTool))]
12
+    [TemplatePart(Name = "PART_EllipseTool", Type = typeof(EllipseTool))]
13
+    [TemplatePart(Name = "PART_ArrowTool", Type = typeof(ArrowTool))]
14
+    [TemplatePart(Name = "PART_LineTool", Type = typeof(LineTool))]
15
+    [TemplatePart(Name = "PART_TextTool", Type = typeof(TextTool))]
16
+    public class SizeColorBar : Control
17
+    {
18
+        private RectangleTool _RectangleTool;
19
+        private EllipseTool _EllipseTool;
20
+        private LineTool _LineTool;
21
+        private TextTool _TextTool;
22
+        private ArrowTool _ArrowTool;
23
+
24
+        static SizeColorBar()
25
+        {
26
+            DefaultStyleKeyProperty.OverrideMetadata(typeof(SizeColorBar), new FrameworkPropertyMetadata(typeof(SizeColorBar)));
27
+        }
28
+
29
+        public SizeColorBar()
30
+        {
31
+            _Current = this;
32
+        }
33
+
34
+        public override void OnApplyTemplate()
35
+        {
36
+            base.OnApplyTemplate();
37
+            _RectangleTool = GetTemplateChild("PART_RectangleTool") as RectangleTool;
38
+            _EllipseTool = GetTemplateChild("PART_EllipseTool") as EllipseTool;
39
+            _ArrowTool = GetTemplateChild("PART_ArrowTool") as ArrowTool;
40
+            _LineTool = GetTemplateChild("PART_LineTool") as LineTool;
41
+            _TextTool = GetTemplateChild("PART_TextTool") as TextTool;
42
+        }
43
+
44
+        public void ChangeColor(SolidColorBrush brush)
45
+        {
46
+            switch (Selected)
47
+            {
48
+                case Tool.Rectangle:
49
+                    _RectangleTool.LineBrush = brush;
50
+                    break;
51
+
52
+                case Tool.Ellipse:
53
+                    _EllipseTool.LineBrush = brush;
54
+                    break;
55
+
56
+                case Tool.Arrow:
57
+                    _ArrowTool.LineBrush = brush;
58
+                    break;
59
+
60
+                case Tool.Line:
61
+                    _LineTool.LineBrush = brush;
62
+                    break;
63
+
64
+                case Tool.Text:
65
+                    _TextTool.LineBrush = brush;
66
+                    break;
67
+
68
+                default:
69
+                    break;
70
+            }
71
+        }
72
+
73
+        #region 属性 Current
74
+
75
+        private static SizeColorBar _Current = null;
76
+
77
+        public static SizeColorBar Current
78
+        {
79
+            get => _Current;
80
+            set => _Current = value;
81
+        }
82
+
83
+        #endregion 属性 Current
84
+
85
+        #region 属性 ColorBars
86
+
87
+        private static List<SolidColorBrush> _ColorBars;
88
+
89
+        public static List<SolidColorBrush> ColorBars
90
+        {
91
+            get
92
+            {
93
+                if (_ColorBars == null)
94
+                {
95
+                    _ColorBars = new List<SolidColorBrush>()
96
+                    {
97
+                        new SolidColorBrush(Colors.Black),
98
+                        new SolidColorBrush(Colors.Gray),
99
+                        new SolidColorBrush(Colors.Firebrick),
100
+                        new SolidColorBrush(Colors.Orange),
101
+                        new SolidColorBrush(Colors.ForestGreen),
102
+                        new SolidColorBrush(Colors.Blue),
103
+                        new SolidColorBrush(Colors.Maroon),
104
+                        new SolidColorBrush(Colors.CadetBlue),
105
+                        new SolidColorBrush(Colors.HotPink),
106
+
107
+                        new SolidColorBrush(Colors.White),
108
+                        new SolidColorBrush(Colors.LightGray),
109
+                        new SolidColorBrush(Colors.Red),
110
+                        new SolidColorBrush(Colors.Yellow),
111
+                        new SolidColorBrush(Colors.YellowGreen),
112
+                        new SolidColorBrush(Colors.DodgerBlue),
113
+                        new SolidColorBrush(Colors.Magenta),
114
+                        new SolidColorBrush(Colors.Cyan),
115
+                        new SolidColorBrush(Colors.MistyRose)
116
+                    };
117
+                }
118
+                return _ColorBars;
119
+            }
120
+            set => _ColorBars = value;
121
+        }
122
+
123
+        #endregion 属性 ColorBars
124
+
125
+        #region 定位
126
+
127
+        public void ResetCanvas()
128
+        {
129
+            ResetCanvasLeft();
130
+            ResetCanvasTop();
131
+        }
132
+
133
+        #endregion 定位
134
+
135
+        #region CanvasLeft DependencyProperty
136
+
137
+        public double CanvasLeft
138
+        {
139
+            get => (double)GetValue(CanvasLeftProperty);
140
+            set => SetValue(CanvasLeftProperty, value);
141
+        }
142
+
143
+        public static readonly DependencyProperty CanvasLeftProperty =
144
+                DependencyProperty.Register("CanvasLeft", typeof(double), typeof(SizeColorBar),
145
+                new PropertyMetadata(0.0, new PropertyChangedCallback(SizeColorBar.OnCanvasLeftPropertyChanged)));
146
+
147
+        private static void OnCanvasLeftPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
148
+        {
149
+            if (obj is SizeColorBar)
150
+            {
151
+                (obj as SizeColorBar).OnCanvasLeftValueChanged();
152
+            }
153
+        }
154
+
155
+        protected void OnCanvasLeftValueChanged()
156
+        {
157
+        }
158
+
159
+        private void ResetCanvasLeft()
160
+        {
161
+            CanvasLeft = ImageEditBar.Current.CanvasLeft;
162
+        }
163
+
164
+        #endregion CanvasLeft DependencyProperty
165
+
166
+        #region CanvasTop DependencyProperty
167
+
168
+        public double CanvasTop
169
+        {
170
+            get => (double)GetValue(CanvasTopProperty);
171
+            set => SetValue(CanvasTopProperty, value);
172
+        }
173
+
174
+        public static readonly DependencyProperty CanvasTopProperty =
175
+                DependencyProperty.Register("CanvasTop", typeof(double), typeof(SizeColorBar),
176
+                new PropertyMetadata(0.0, new PropertyChangedCallback(SizeColorBar.OnCanvasTopPropertyChanged)));
177
+
178
+        private static void OnCanvasTopPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
179
+        {
180
+            if (obj is SizeColorBar)
181
+            {
182
+                (obj as SizeColorBar).OnCanvasTopValueChanged();
183
+            }
184
+        }
185
+
186
+        protected void OnCanvasTopValueChanged()
187
+        {
188
+        }
189
+
190
+        private void ResetCanvasTop()
191
+        {
192
+            CanvasTop = AppModel.Current.MaskBottomHeight >= 67 ? JieTuWindow.ScreenHeight - AppModel.Current.MaskBottomHeight + 32
193
+                : AppModel.Current.MaskTopHeight >= 67 ? AppModel.Current.MaskTopHeight - 67
194
+                : AppModel.Current.MaskTopHeight + 30;
195
+        }
196
+
197
+        #endregion CanvasTop DependencyProperty
198
+
199
+        #region Selected DependencyProperty
200
+
201
+        public Tool Selected
202
+        {
203
+            get => (Tool)GetValue(SelectedProperty);
204
+            set => SetValue(SelectedProperty, value);
205
+        }
206
+
207
+        public static readonly DependencyProperty SelectedProperty =
208
+                DependencyProperty.Register("Selected", typeof(Tool), typeof(SizeColorBar),
209
+                new PropertyMetadata(Tool.Null, new PropertyChangedCallback(SizeColorBar.OnSelectedPropertyChanged)));
210
+
211
+        private static void OnSelectedPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
212
+        {
213
+            if (obj is SizeColorBar)
214
+            {
215
+                (obj as SizeColorBar).OnSelectedValueChanged();
216
+            }
217
+        }
218
+
219
+        protected void OnSelectedValueChanged()
220
+        {
221
+            ImageEditBar.Current.ResetCanvas();
222
+            ResetCanvas();
223
+            if (Selected == Tool.Null)
224
+            {
225
+                JieTuWindow.Current.MainImage.MoveCursor = Cursors.SizeAll;
226
+            }
227
+            else
228
+            {
229
+                JieTuWindow.Current.MainImage.MoveCursor = Cursors.Pen;
230
+            }
231
+        }
232
+
233
+        #endregion Selected DependencyProperty
234
+    }
235
+}

+ 102
- 0
XHWK.WKTool/Controls/TextBoxControl.cs Datei anzeigen

@@ -0,0 +1,102 @@
1
+using System.Windows;
2
+using System.Windows.Controls;
3
+using System.Windows.Media;
4
+
5
+namespace ComeCapture.Controls
6
+{
7
+    [TemplatePart(Name = "PART_TextBox", Type = typeof(TextBox))]
8
+    public class TextBoxControl : Control
9
+    {
10
+        public TextBox _TextBox;
11
+
12
+        static TextBoxControl()
13
+        {
14
+            DefaultStyleKeyProperty.OverrideMetadata(typeof(TextBoxControl), new FrameworkPropertyMetadata(typeof(TextBoxControl)));
15
+        }
16
+
17
+        public TextBoxControl()
18
+        {
19
+            AddHandler(GotFocusEvent, new RoutedEventHandler((sender, e) =>
20
+            {
21
+                MyFocus = true;
22
+            }));
23
+            AddHandler(LostFocusEvent, new RoutedEventHandler((sender, e) =>
24
+            {
25
+                MyFocus = false;
26
+            }));
27
+        }
28
+
29
+        public override void OnApplyTemplate()
30
+        {
31
+            base.OnApplyTemplate();
32
+            _TextBox = GetTemplateChild("PART_TextBox") as TextBox;
33
+            _TextBox.MaxWidth = JieTuWindow.Current.MainImage.Width - JieTuWindow.Current.MainImage.point.X - 3;
34
+            _TextBox.MaxHeight = JieTuWindow.Current.MainImage.Height - JieTuWindow.Current.MainImage.point.Y - 3;
35
+        }
36
+
37
+        #region BorderColor DependencyProperty
38
+
39
+        public Color BorderColor
40
+        {
41
+            get => (Color)GetValue(BorderColorProperty);
42
+            set => SetValue(BorderColorProperty, value);
43
+        }
44
+
45
+        public static readonly DependencyProperty BorderColorProperty =
46
+                DependencyProperty.Register("BorderColor", typeof(Color), typeof(TextBoxControl),
47
+                new PropertyMetadata(Colors.Transparent, new PropertyChangedCallback(TextBoxControl.OnBorderColorPropertyChanged)));
48
+
49
+        private static void OnBorderColorPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
50
+        {
51
+            if (obj is TextBoxControl)
52
+            {
53
+                (obj as TextBoxControl).OnBorderColorValueChanged();
54
+            }
55
+        }
56
+
57
+        protected void OnBorderColorValueChanged()
58
+        {
59
+        }
60
+
61
+        #endregion BorderColor DependencyProperty
62
+
63
+        #region MyFocus DependencyProperty
64
+
65
+        public bool MyFocus
66
+        {
67
+            get => (bool)GetValue(MyFocusProperty);
68
+            set => SetValue(MyFocusProperty, value);
69
+        }
70
+
71
+        public static readonly DependencyProperty MyFocusProperty =
72
+                DependencyProperty.Register("MyFocus", typeof(bool), typeof(TextBoxControl),
73
+                new PropertyMetadata(true, new PropertyChangedCallback(TextBoxControl.OnMyFocusPropertyChanged)));
74
+
75
+        private static void OnMyFocusPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
76
+        {
77
+            if (obj is TextBoxControl)
78
+            {
79
+                (obj as TextBoxControl).OnMyFocusValueChanged();
80
+            }
81
+        }
82
+
83
+        protected void OnMyFocusValueChanged()
84
+        {
85
+            if (!MyFocus)
86
+            {
87
+                if (string.IsNullOrEmpty(_TextBox.Text))
88
+                {
89
+                    JieTuWindow.RemoveControl(this);
90
+                }
91
+                else
92
+                {
93
+                    JieTuWindow.Current.MainImage.ResetLimit(Canvas.GetLeft(this), Canvas.GetTop(this), (Canvas.GetLeft(this) + ActualWidth), (Canvas.GetTop(this) + ActualHeight));
94
+                    JieTuWindow.Register(this);
95
+                }
96
+                JieTuWindow.Current.MainImage._Text = null;
97
+            }
98
+        }
99
+
100
+        #endregion MyFocus DependencyProperty
101
+    }
102
+}

+ 109
- 0
XHWK.WKTool/Controls/TextTool.cs Datei anzeigen

@@ -0,0 +1,109 @@
1
+using System.Collections.Generic;
2
+using System.Windows;
3
+using System.Windows.Controls;
4
+using System.Windows.Media;
5
+
6
+namespace ComeCapture.Controls
7
+{
8
+    public class TextTool : StackPanel
9
+    {
10
+        static TextTool()
11
+        {
12
+            DefaultStyleKeyProperty.OverrideMetadata(typeof(TextTool), new FrameworkPropertyMetadata(typeof(TextTool)));
13
+        }
14
+
15
+        public TextTool()
16
+        {
17
+            _Current = this;
18
+        }
19
+
20
+        #region 属性 Current
21
+
22
+        private static TextTool _Current = null;
23
+
24
+        public static TextTool Current => _Current;
25
+
26
+        #endregion 属性 Current
27
+
28
+        #region 属性 FontSizes
29
+
30
+        private static Dictionary<int, int> _FontSizes;
31
+
32
+        public static Dictionary<int, int> FontSizes
33
+        {
34
+            get
35
+            {
36
+                if (_FontSizes == null)
37
+                {
38
+                    _FontSizes = new Dictionary<int, int>()
39
+                    {
40
+                        { 8,8},
41
+                        { 10,10},
42
+                        { 12,12},
43
+                        { 14,14},
44
+                        { 16,16},
45
+                        { 18,18},
46
+                        { 20,20},
47
+                        { 22,22}
48
+                    };
49
+                }
50
+                return _FontSizes;
51
+            }
52
+            set => _FontSizes = value;
53
+        }
54
+
55
+        #endregion 属性 FontSizes
56
+
57
+        #region FontSize DependencyProperty
58
+
59
+        public int FontSize
60
+        {
61
+            get => (int)GetValue(FontSizeProperty);
62
+            set => SetValue(FontSizeProperty, value);
63
+        }
64
+
65
+        public static readonly DependencyProperty FontSizeProperty =
66
+                DependencyProperty.Register("FontSize", typeof(int), typeof(TextTool),
67
+                new PropertyMetadata(12, new PropertyChangedCallback(TextTool.OnFontSizePropertyChanged)));
68
+
69
+        private static void OnFontSizePropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
70
+        {
71
+            if (obj is TextTool)
72
+            {
73
+                (obj as TextTool).OnFontSizeValueChanged();
74
+            }
75
+        }
76
+
77
+        protected void OnFontSizeValueChanged()
78
+        {
79
+        }
80
+
81
+        #endregion FontSize DependencyProperty
82
+
83
+        #region LineBrush DependencyProperty
84
+
85
+        public SolidColorBrush LineBrush
86
+        {
87
+            get => (SolidColorBrush)GetValue(LineBrushProperty);
88
+            set => SetValue(LineBrushProperty, value);
89
+        }
90
+
91
+        public static readonly DependencyProperty LineBrushProperty =
92
+                DependencyProperty.Register("LineBrush", typeof(SolidColorBrush), typeof(TextTool),
93
+                new PropertyMetadata(new SolidColorBrush(Colors.Red), new PropertyChangedCallback(TextTool.OnLineBrushPropertyChanged)));
94
+
95
+        private static void OnLineBrushPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
96
+        {
97
+            if (obj is TextTool)
98
+            {
99
+                (obj as TextTool).OnLineBrushValueChanged();
100
+            }
101
+        }
102
+
103
+        protected void OnLineBrushValueChanged()
104
+        {
105
+        }
106
+
107
+        #endregion LineBrush DependencyProperty
108
+    }
109
+}

+ 142
- 0
XHWK.WKTool/Controls/ToolButton.cs Datei anzeigen

@@ -0,0 +1,142 @@
1
+using ComeCapture.Models;
2
+
3
+using System.Windows;
4
+using System.Windows.Controls;
5
+using System.Windows.Media;
6
+
7
+namespace ComeCapture.Controls
8
+{
9
+    public class ToolButton : RadioButton
10
+    {
11
+        static ToolButton()
12
+        {
13
+            DefaultStyleKeyProperty.OverrideMetadata(
14
+                typeof(ToolButton),
15
+                new FrameworkPropertyMetadata(typeof(ToolButton))
16
+                );
17
+        }
18
+
19
+        #region 覆写点击事件(可弹起)
20
+
21
+        protected override void OnClick()
22
+        {
23
+            if (IsImageEditBar)
24
+            {
25
+                switch (Tool)
26
+                {
27
+                    case Tool.Revoke:
28
+                        JieTuWindow.Current.OnRevoke();
29
+                        break;
30
+
31
+                    case Tool.Save:
32
+                        JieTuWindow.Current.OnSave();
33
+                        break;
34
+
35
+                    case Tool.Cancel:
36
+                        JieTuWindow.Current.OnCancel();
37
+                        break;
38
+
39
+                    case Tool.OK:
40
+                        JieTuWindow.Current.OnOK();
41
+                        break;
42
+
43
+                    default:
44
+                        IsChecked = !IsChecked;
45
+                        SizeColorBar.Current.Selected = IsChecked == true ? Tool : Tool.Null;
46
+                        break;
47
+                }
48
+            }
49
+            else
50
+            {
51
+                if (IsChecked == false)
52
+                {
53
+                    IsChecked = true;
54
+                    if (LineColor != null)
55
+                    {
56
+                        SizeColorBar.Current.ChangeColor(LineColor);
57
+                    }
58
+                }
59
+            }
60
+        }
61
+
62
+        #endregion 覆写点击事件(可弹起)
63
+
64
+        #region Tool DependencyProperty
65
+
66
+        public Tool Tool
67
+        {
68
+            get => (Tool)GetValue(ToolProperty);
69
+            set => SetValue(ToolProperty, value);
70
+        }
71
+
72
+        public static readonly DependencyProperty ToolProperty =
73
+                DependencyProperty.Register("Tool", typeof(Tool), typeof(ToolButton),
74
+                new PropertyMetadata(Tool.Null, new PropertyChangedCallback(ToolButton.OnToolPropertyChanged)));
75
+
76
+        private static void OnToolPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
77
+        {
78
+            if (obj is ToolButton)
79
+            {
80
+                (obj as ToolButton).OnToolValueChanged();
81
+            }
82
+        }
83
+
84
+        protected void OnToolValueChanged()
85
+        {
86
+        }
87
+
88
+        #endregion Tool DependencyProperty
89
+
90
+        #region IsImageEditBar DependencyProperty
91
+
92
+        public bool IsImageEditBar
93
+        {
94
+            get => (bool)GetValue(IsImageEditBarProperty);
95
+            set => SetValue(IsImageEditBarProperty, value);
96
+        }
97
+
98
+        public static readonly DependencyProperty IsImageEditBarProperty =
99
+                DependencyProperty.Register("IsImageEditBar", typeof(bool), typeof(ToolButton),
100
+                new PropertyMetadata(false, new PropertyChangedCallback(ToolButton.OnIsImageEditBarPropertyChanged)));
101
+
102
+        private static void OnIsImageEditBarPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
103
+        {
104
+            if (obj is ToolButton)
105
+            {
106
+                (obj as ToolButton).OnIsImageEditBarValueChanged();
107
+            }
108
+        }
109
+
110
+        protected void OnIsImageEditBarValueChanged()
111
+        {
112
+        }
113
+
114
+        #endregion IsImageEditBar DependencyProperty
115
+
116
+        #region LineColor DependencyProperty
117
+
118
+        public SolidColorBrush LineColor
119
+        {
120
+            get => (SolidColorBrush)GetValue(LineColorProperty);
121
+            set => SetValue(LineColorProperty, value);
122
+        }
123
+
124
+        public static readonly DependencyProperty LineColorProperty =
125
+                DependencyProperty.Register("LineColor", typeof(SolidColorBrush), typeof(ToolButton),
126
+                new PropertyMetadata(null, new PropertyChangedCallback(ToolButton.OnLineColorPropertyChanged)));
127
+
128
+        private static void OnLineColorPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
129
+        {
130
+            if (obj is ToolButton)
131
+            {
132
+                (obj as ToolButton).OnLineColorValueChanged();
133
+            }
134
+        }
135
+
136
+        protected void OnLineColorValueChanged()
137
+        {
138
+        }
139
+
140
+        #endregion LineColor DependencyProperty
141
+    }
142
+}

+ 43
- 0
XHWK.WKTool/Controls/ZoomThumb.cs Datei anzeigen

@@ -0,0 +1,43 @@
1
+using ComeCapture.Models;
2
+
3
+using System.Windows;
4
+using System.Windows.Controls.Primitives;
5
+
6
+namespace ComeCapture.Controls
7
+{
8
+    public class ZoomThumb : Thumb
9
+    {
10
+        #region Direction DependencyProperty
11
+
12
+        public Direction Direction
13
+        {
14
+            get => (Direction)GetValue(DirectionProperty);
15
+            set => SetValue(DirectionProperty, value);
16
+        }
17
+
18
+        public static readonly DependencyProperty DirectionProperty =
19
+                DependencyProperty.Register("Direction", typeof(Direction), typeof(ZoomThumb),
20
+                new PropertyMetadata(Direction.Null, new PropertyChangedCallback(ZoomThumb.OnDirectionPropertyChanged)));
21
+
22
+        private static void OnDirectionPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
23
+        {
24
+            if (obj is ZoomThumb)
25
+            {
26
+                (obj as ZoomThumb).OnDirectionValueChanged();
27
+            }
28
+        }
29
+
30
+        protected void OnDirectionValueChanged()
31
+        {
32
+            if (Direction == Direction.Move)
33
+            {
34
+                MouseDoubleClick += (sender, e) =>
35
+                {
36
+                    JieTuWindow.Current.OnOK();
37
+                };
38
+            }
39
+        }
40
+
41
+        #endregion Direction DependencyProperty
42
+    }
43
+}

+ 19
- 0
XHWK.WKTool/Converters/ColorConverter.cs Datei anzeigen

@@ -0,0 +1,19 @@
1
+using System;
2
+using System.Windows.Data;
3
+using System.Windows.Media;
4
+
5
+namespace ComeCapture.Converters
6
+{
7
+    public class ColorConverter : IValueConverter
8
+    {
9
+        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
10
+        {
11
+            return new SolidColorBrush((Color)System.Windows.Media.ColorConverter.ConvertFromString(value.ToString()));
12
+        }
13
+
14
+        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
15
+        {
16
+            return null;
17
+        }
18
+    }
19
+}

+ 25
- 0
XHWK.WKTool/Converters/SizeConverter.cs Datei anzeigen

@@ -0,0 +1,25 @@
1
+using System;
2
+using System.Windows.Data;
3
+
4
+namespace ComeCapture.Converters
5
+{
6
+    public class SizeConverter : IValueConverter
7
+    {
8
+        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
9
+        {
10
+            return int.Parse(value.ToString()) == int.Parse(parameter.ToString());
11
+        }
12
+
13
+        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
14
+        {
15
+            if ((bool)value)
16
+            {
17
+                return parameter;
18
+            }
19
+            else
20
+            {
21
+                return null;
22
+            }
23
+        }
24
+    }
25
+}

+ 19
- 0
XHWK.WKTool/Converters/ToolConverter.cs Datei anzeigen

@@ -0,0 +1,19 @@
1
+using System;
2
+using System.Windows;
3
+using System.Windows.Data;
4
+
5
+namespace ComeCapture.Converters
6
+{
7
+    public class ToolConverter : IValueConverter
8
+    {
9
+        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
10
+        {
11
+            return value.ToString() == parameter.ToString() ? Visibility.Visible : Visibility.Collapsed;
12
+        }
13
+
14
+        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
15
+        {
16
+            return null;
17
+        }
18
+    }
19
+}

+ 6
- 6
XHWK.WKTool/CountdownWindow.xaml Datei anzeigen

@@ -14,13 +14,13 @@
14 14
         <SolidColorBrush Opacity="0.96" Color="#292C2E" />
15 15
     </Window.Background>
16 16
     <Grid>
17
-        <Image x:Name="ImgGif"
17
+        <!--<Image x:Name="ImgGif"
18 18
                     Width="600"
19 19
                     Height="600"
20
-                    gifLib:ImageBehavior.AnimatedSource=".\Images\countdown.gif" MediaElement.MediaEnded="Image_MediaEnded"/>
21
-        <!--<Image x:Name="imgLoding"
22
-                    Width="300"
23
-                    Height="300"
24
-                    Source=".\Images\countdown_3.png" />-->
20
+                    gifLib:ImageBehavior.AnimatedSource=".\Images\countdown.gif" MediaElement.MediaEnded="Image_MediaEnded"/>-->
21
+        <Image x:Name="imgLoding"
22
+                    Width="600"
23
+                    Height="600"
24
+                    Source=".\Images\countdown_3.png" />
25 25
     </Grid>
26 26
 </Window>

+ 130
- 9
XHWK.WKTool/CountdownWindow.xaml.cs Datei anzeigen

@@ -1,6 +1,8 @@
1 1
 using System;
2
+using System.Threading;
2 3
 using System.Windows;
3 4
 using System.Windows.Controls;
5
+using System.Windows.Media.Imaging;
4 6
 using System.Windows.Threading;
5 7
 
6 8
 namespace XHWK.WKTool
@@ -10,7 +12,24 @@ namespace XHWK.WKTool
10 12
     /// </summary>
11 13
     public partial class CountdownWindow : Window
12 14
     {
15
+        /// <summary>
16
+        /// 计时用
17
+        /// </summary>
18
+        private TimeSpan _timeSpan = new TimeSpan(0, 0, 0, 0, 0);
13 19
         DispatcherTimer timer = null;
20
+        /// <summary>
21
+        /// 状态
22
+        /// </summary>
23
+        private State _state = State.End;
24
+        /// <summary>
25
+        /// 计时器状态
26
+        /// </summary>
27
+        private enum State
28
+        {
29
+            Start,
30
+            Pause,
31
+            End
32
+        }
14 33
         public CountdownWindow()
15 34
         {
16 35
             InitializeComponent();
@@ -22,14 +41,116 @@ namespace XHWK.WKTool
22 41
             //this.Hide();
23 42
             //MediaElement.Position
24 43
             //((MediaElement)((object)ImgGif)).Position= TimeSpan.Zero;
25
-            timer = new DispatcherTimer
44
+            //timer = new DispatcherTimer
45
+            //{
46
+            //    Interval = TimeSpan.FromMilliseconds(2500)
47
+            //};
48
+            //timer.Tick += Timer_Tick;
49
+            //timer.Start();
50
+
51
+
52
+
53
+            if (timer == null)
54
+            {
55
+                timer = new DispatcherTimer();
56
+                timer.Tick += OnTimer;
57
+                timer.Interval = new TimeSpan(0, 0, 0, 1);
58
+                timer.IsEnabled = true;
59
+                timer.Start();
60
+            }
61
+            timer.Interval = new TimeSpan(0, 0, 0, 1);
62
+            Stack();
63
+
64
+      
65
+                // 开启线程
66
+                Thread tr = new Thread(new ThreadStart(Countdown))
67
+                {
68
+                    IsBackground = true
69
+                };
70
+                tr.Start();
71
+           
72
+        }
73
+        private void Countdown()
74
+        {
75
+            while (_timeSpan.Seconds <= 2)
26 76
             {
27
-                Interval = TimeSpan.FromMilliseconds(2500)
28
-            };
29
-            timer.Tick += Timer_Tick;
30
-            timer.Start();
77
+              
78
+                if (_timeSpan.Seconds > 1)
79
+                {
80
+                    Dispatcher.Invoke(
81
+                  DispatcherPriority.Normal,
82
+                  new Action(() => { imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown_1.png")); })
83
+                  );
84
+                 
85
+                }
86
+                else if(_timeSpan.Seconds > 0)
87
+                {
88
+                    Dispatcher.Invoke(
89
+                  DispatcherPriority.Normal,
90
+                  new Action(() => { imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown_2.png")); })
91
+                  );
92
+                    
93
+                }
94
+                Thread.Sleep(888);
95
+            }
96
+
97
+
98
+                _state = State.End;
99
+                Dispatcher.Invoke(
100
+                    DispatcherPriority.Normal,
101
+                    new Action(() => { this.Hide(); })
102
+                    );
103
+          
104
+        }
105
+        /// <summary>
106
+        /// 结束
107
+        /// </summary>
108
+        /// <param name="sender"></param>
109
+        /// <param name="e"></param>
110
+        private void End()
111
+        {
112
+            _state = State.End;
31 113
         }
32 114
 
115
+        /// <summary>
116
+        /// 时钟回调
117
+        /// </summary>
118
+        /// <param name="sender"></param>
119
+        /// <param name="e"></param>
120
+        private void OnTimer(object sender, EventArgs e)
121
+        {
122
+            switch (_state)
123
+            {
124
+                case State.Start:
125
+                    {
126
+                        _timeSpan += new TimeSpan(0, 0, 0, 1);
127
+                    }
128
+                    break;
129
+
130
+                case State.Pause:
131
+                    {
132
+                    }
133
+                    break;
134
+
135
+                case State.End:
136
+                    {
137
+                        _timeSpan = new TimeSpan();
138
+                        //_timeSpan = new TimeSpan(0, 23, 12, 45, 54);
139
+                    }
140
+                    break;
141
+            }
142
+
143
+         
144
+        }
145
+        /// <summary>
146
+        /// 开始
147
+        /// </summary>
148
+        /// <param name="sender"></param>
149
+        /// <param name="e"></param>
150
+        private void Stack()
151
+        {
152
+            _state = State.Start;
153
+        }
33 154
         private void Timer_Tick(object sender, EventArgs e)
34 155
         {
35 156
             this.Hide();
@@ -44,10 +165,10 @@ namespace XHWK.WKTool
44 165
         private void Window_ContentRendered(object sender, EventArgs e)
45 166
         {
46 167
             //Thread.Sleep(800);
47
-            ////imgLoding.Source= new BitmapImage(new Uri("pack://application:,,/Images/countdown_2.png"));
48
-            ////Thread.Sleep(300);
49
-            ////imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown_1.png"));
50
-            ////Thread.Sleep(300);
168
+            //imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown_2.png"));
169
+            //Thread.Sleep(800);
170
+            //imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown_1.png"));
171
+            //Thread.Sleep(300);
51 172
             //this.Hide();
52 173
 
53 174
             //Initialize();

+ 49
- 0
XHWK.WKTool/Helpers/ScreenHelper.cs Datei anzeigen

@@ -0,0 +1,49 @@
1
+using System;
2
+using System.Drawing;
3
+using System.Runtime.InteropServices;
4
+
5
+namespace ComeCapture.Helpers
6
+{
7
+    public static class ScreenHelper
8
+    {
9
+        [DllImport("user32.dll", EntryPoint = "ReleaseDC")]
10
+        public static extern IntPtr ReleaseDC(
11
+            IntPtr hWnd,
12
+            IntPtr hDc
13
+            );
14
+
15
+        [DllImport("gdi32.dll")]
16
+        public static extern int GetDeviceCaps(
17
+            IntPtr hdc, // handle to DC
18
+            int nIndex // index of capability
19
+            );
20
+
21
+        public static System.Drawing.Size GetPhysicalDisplaySize()
22
+        {
23
+            Graphics g = Graphics.FromHwnd(IntPtr.Zero);
24
+            IntPtr desktop = g.GetHdc();
25
+            int physicalScreenHeight = GetDeviceCaps(desktop, (int)DeviceCap.Desktopvertres);
26
+            int physicalScreenWidth = GetDeviceCaps(desktop, (int)DeviceCap.Desktophorzres);
27
+            ReleaseDC(IntPtr.Zero, desktop);
28
+            g.Dispose();
29
+            return new System.Drawing.Size(physicalScreenWidth, physicalScreenHeight);
30
+        }
31
+
32
+        public enum DeviceCap
33
+        {
34
+            Desktopvertres = 117,
35
+            Desktophorzres = 118
36
+        }
37
+
38
+        public static void ResetScreenScale()
39
+        {
40
+            using (Graphics g = Graphics.FromHwnd(IntPtr.Zero))
41
+            {
42
+                IntPtr desktop = g.GetHdc();
43
+                int physicalScreenWidth = GetDeviceCaps(desktop, (int)DeviceCap.Desktophorzres);
44
+                JieTuWindow.ScreenScale = physicalScreenWidth * 1.0000 / JieTuWindow.ScreenWidth;
45
+                g.Dispose();
46
+            }
47
+        }
48
+    }
49
+}

+ 26
- 0
XHWK.WKTool/Helpers/WpfHelper.cs Datei anzeigen

@@ -0,0 +1,26 @@
1
+using System;
2
+using System.Windows.Threading;
3
+
4
+namespace ComeCapture.Helpers
5
+{
6
+    public static class WpfHelper
7
+    {
8
+        public static Dispatcher MainDispatcher { get; set; }
9
+
10
+        public static void SafeRun(this Action action)
11
+        {
12
+            if (MainDispatcher == null)
13
+            {
14
+                action();
15
+                return;
16
+            }
17
+
18
+            if (!MainDispatcher.CheckAccess())
19
+            {
20
+                MainDispatcher.BeginInvoke(action);
21
+                return;
22
+            }
23
+            action();
24
+        }
25
+    }
26
+}

+ 100
- 0
XHWK.WKTool/JieTuWindow.xaml Datei anzeigen

@@ -0,0 +1,100 @@
1
+<Window
2
+    x:Class="ComeCapture.JieTuWindow"
3
+    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4
+    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5
+    xmlns:ctrl="clr-namespace:ComeCapture.Controls"
6
+    xmlns:local="clr-namespace:ComeCapture"
7
+    Title="MainWindow"
8
+    Closed="Window_Closed"
9
+    Cursor="Cross"
10
+    FontFamily="Microsoft YaHei"
11
+    KeyDown="Window_KeyDown"
12
+    MouseLeftButtonDown="Window_MouseLeftButtonDown"
13
+    MouseLeftButtonUp="Window_MouseLeftButtonUp"
14
+    MouseMove="Window_MouseMove"
15
+    ResizeMode="NoResize"
16
+    ShowInTaskbar="False"
17
+    Topmost="True"
18
+    WindowState="Maximized"
19
+    WindowStyle="None">
20
+    <Window.Template>
21
+        <ControlTemplate TargetType="Window">
22
+            <Border
23
+                Margin="0"
24
+                Padding="0"
25
+                Background="{TemplateBinding Background}">
26
+                <ContentControl Content="{TemplateBinding Content}" />
27
+            </Border>
28
+        </ControlTemplate>
29
+    </Window.Template>
30
+    <Grid>
31
+        <Canvas
32
+            x:Name="MainCanvas"
33
+            Margin="0,0"
34
+            Background="Transparent">
35
+            <!--  遮罩  -->
36
+            <Canvas
37
+                x:Name="MaskLeft"
38
+                Canvas.Left="0"
39
+                Canvas.Top="0"
40
+                Width="{Binding MaskLeftWidth}"
41
+                Background="Black"
42
+                Opacity="0.5" />
43
+            <Canvas
44
+                x:Name="MaskRight"
45
+                Canvas.Top="0"
46
+                Canvas.Right="0"
47
+                Width="{Binding MaskRightWidth}"
48
+                Background="Black"
49
+                Opacity="0.5" />
50
+            <Canvas
51
+                x:Name="MaskTop"
52
+                Canvas.Left="{Binding ElementName=MaskLeft, Path=Width}"
53
+                Canvas.Top="0"
54
+                Width="{Binding MaskTopWidth}"
55
+                Height="{Binding MaskTopHeight}"
56
+                Background="Black"
57
+                Opacity="0.5" />
58
+            <Canvas
59
+                x:Name="MaskBottom"
60
+                Canvas.Left="{Binding ElementName=MaskLeft, Path=Width}"
61
+                Canvas.Bottom="0"
62
+                Width="{Binding ElementName=MaskTop, Path=Width}"
63
+                Height="{Binding MaskBottomHeight}"
64
+                Background="Black"
65
+                Opacity="0.5" />
66
+
67
+            <!--  尺寸和RGB  -->
68
+            <StackPanel
69
+                x:Name="SizeRGB"
70
+                Canvas.Left="{Binding ShowSizeLeft}"
71
+                Canvas.Top="{Binding ShowSizeTop}"
72
+                Width="200"
73
+                Background="Black"
74
+                Opacity="0.7">
75
+                <TextBlock
76
+                    x:Name="Show_Size"
77
+                    Height="20"
78
+                    Padding="10,4,10,0"
79
+                    FontSize="12"
80
+                    Foreground="White"
81
+                    Text="{Binding ShowSize}"
82
+                    TextAlignment="Left"
83
+                    Visibility="Collapsed" />
84
+                <TextBlock
85
+                    x:Name="Show_RGB"
86
+                    Height="20"
87
+                    Padding="10,1,10,0"
88
+                    FontSize="12"
89
+                    Foreground="White"
90
+                    Text="{Binding ShowRGB}"
91
+                    TextAlignment="Left"
92
+                    Visibility="Collapsed" />
93
+            </StackPanel>
94
+
95
+            <ctrl:MainImage x:Name="MainImage" />
96
+            <ctrl:ImageEditBar x:Name="ImageEditBar" />
97
+            <ctrl:SizeColorBar x:Name="SizeColorBar" />
98
+        </Canvas>
99
+    </Grid>
100
+</Window>

+ 498
- 0
XHWK.WKTool/JieTuWindow.xaml.cs Datei anzeigen

@@ -0,0 +1,498 @@
1
+
2
+using ComeCapture.Controls;
3
+using ComeCapture.Helpers;
4
+using ComeCapture.Models;
5
+using Common.system;
6
+
7
+
8
+using System;
9
+using System.Collections.Generic;
10
+using System.Drawing;
11
+using System.IO;
12
+using System.Threading;
13
+using System.Windows;
14
+using System.Windows.Controls;
15
+using System.Windows.Input;
16
+using System.Windows.Media;
17
+using System.Windows.Media.Imaging;
18
+
19
+namespace ComeCapture
20
+{
21
+    /// <summary>
22
+    /// 截图 MainWindow.xaml 的交互逻辑
23
+    /// </summary>
24
+    public partial class JieTuWindow : Window
25
+    {
26
+        public static double ScreenWidth = SystemParameters.PrimaryScreenWidth;
27
+        public static double ScreenHeight = SystemParameters.PrimaryScreenHeight;
28
+        public static double ScreenScale = 1;
29
+        public static int MinSize = 10;
30
+        internal double pwidth = SystemParameters.PrimaryScreenWidth;
31
+
32
+        internal double pHeight = SystemParameters.PrimaryScreenHeight;
33
+
34
+        //画图注册名称集合
35
+        public List<NameAndLimit> list = new List<NameAndLimit>();
36
+
37
+        //画图注册名称
38
+        public int num = 1;
39
+
40
+        //是否截图开始
41
+        private bool _IsMouseDown = false;
42
+
43
+        //是否截图完毕
44
+        private bool _IsCapture = false;
45
+
46
+        private double _X0 = 0;
47
+        private double _Y0 = 0;
48
+
49
+        //private IntPtr BitmapPtr = IntPtr.Zero;
50
+        //private IntPtr JieTuBitmapPtr = IntPtr.Zero;
51
+        /// <summary>
52
+        /// 截图
53
+        /// </summary>
54
+        public JieTuWindow()
55
+        {
56
+            _Current = this;
57
+            InitializeComponent();
58
+            DataContext = new AppModel();
59
+            initialization();
60
+            Screenshot();
61
+            MaxWindow();
62
+            MaskLeft.Height = ScreenHeight;
63
+            MaskRight.Height = ScreenHeight;
64
+            //计算Windows项目缩放比例
65
+            ScreenHelper.ResetScreenScale();
66
+            //RemoveControl();
67
+            //AllowsTransparency = "True"
68
+        }
69
+
70
+        public void Screenshot()
71
+        {
72
+            //IntPtr BitmapPtr = IntPtr.Zero;
73
+            //Background = new ImageBrush(ImageHelper.GetFullBitmapSource(out BitmapPtr));
74
+
75
+            string time = GetTimeStamp();
76
+            string tempPath = AppDomain.CurrentDomain.BaseDirectory + "temp\\";
77
+            if (!Directory.Exists(tempPath))
78
+            {
79
+                Directory.CreateDirectory(tempPath);
80
+            }
81
+            string imagePath = Path.Combine(tempPath, time + ".jpg");
82
+            Background = new ImageBrush(ImageHelper.GetScreenshot(new Rectangle(0, 0, 0, 0), imagePath));
83
+        }
84
+
85
+        public void initialization()
86
+        {
87
+            Background = null;
88
+            _IsMouseDown = false;
89
+            _IsCapture = false;
90
+            ImageEditBar.Current.Visibility = Visibility.Collapsed;
91
+            SizeColorBar.Current.Visibility = Visibility.Collapsed;
92
+            SizeRGB.Visibility = Visibility.Collapsed;
93
+            MainImage.Visibility = Visibility.Collapsed;
94
+            DataContext = new AppModel();
95
+            WpfHelper.MainDispatcher = Dispatcher;
96
+        }
97
+
98
+        #region 属性 Current
99
+
100
+        private static JieTuWindow _Current = null;
101
+
102
+        public static JieTuWindow Current => _Current;
103
+
104
+        #endregion 属性 Current
105
+
106
+        #region 全屏+置顶
107
+
108
+        private void MaxWindow()
109
+        {
110
+            Left = 0;
111
+            Top = 0;
112
+            Width = ScreenWidth;
113
+            Height = ScreenHeight;
114
+            Activate();
115
+        }
116
+
117
+        #endregion 全屏+置顶
118
+
119
+        #region 注册画图
120
+
121
+        public static void Register(object control)
122
+        {
123
+            string name = "Draw" + _Current.num;
124
+            _Current.MainCanvas.RegisterName(name, control);
125
+            _Current.list.Add(new NameAndLimit(name));
126
+            _Current.num++;
127
+        }
128
+
129
+        #endregion 注册画图
130
+
131
+        #region 截图区域添加画图
132
+
133
+        public static void AddControl(UIElement e)
134
+        {
135
+            _Current.MainCanvas.Children.Add(e);
136
+        }
137
+
138
+        #endregion 截图区域添加画图
139
+
140
+        #region 截图区域撤回画图
141
+
142
+        public static void RemoveControl(UIElement e)
143
+        {
144
+            _Current.MainCanvas.Children.Remove(e);
145
+        }
146
+
147
+        #endregion 截图区域撤回画图
148
+
149
+        #region 撤销
150
+
151
+        public void OnRevoke()
152
+        {
153
+            if (list.Count > 0)
154
+            {
155
+                string name = list[list.Count - 1].Name;
156
+                object obj = MainCanvas.FindName(name);
157
+                if (obj != null)
158
+                {
159
+                    MainCanvas.Children.Remove(obj as UIElement);
160
+                    MainCanvas.UnregisterName(name);
161
+                    list.RemoveAt(list.Count - 1);
162
+                    MainImage.Limit = list.Count == 0 ? new Limit() : list[list.Count - 1].Limit;
163
+                }
164
+            }
165
+        }
166
+
167
+        #endregion 撤销
168
+
169
+        #region 保存
170
+
171
+        public void OnSave()
172
+        {
173
+            //var sfd = new Microsoft.Win32.SaveFileDialog
174
+            //{
175
+            //    FileName = "截图" + DateTime.Now.ToString("yyyyMMddhhmmss"),
176
+            //    Filter = "png|*.png",
177
+            //    AddExtension = true,
178
+            //    RestoreDirectory = true
179
+            //};
180
+            //if (sfd.ShowDialog() == true)
181
+            //{
182
+            //    Hidden();
183
+            //    Thread t = new Thread(new ThreadStart(() =>
184
+            //    {
185
+            //        Thread.Sleep(200);
186
+            //        WpfHelper.SafeRun(() =>
187
+            //        {
188
+            //            var source = GetCapture();
189
+            //            if (source != null)
190
+            //            {
191
+            //                ImageHelper.SaveToPng(source, sfd.FileName);
192
+            //                Shared.TeachingData.FilePath = sfd.FileName;
193
+            //                //Thread.Sleep(200);
194
+            //            }
195
+            //            Close();
196
+            //            if (ChangeTextEvent != null)
197
+            //            {
198
+            //                ChangeTextEvent("关闭窗口");
199
+            //            }
200
+            //            //Go(sfd.FileName);
201
+            //        });
202
+            //    }))
203
+            //    {
204
+            //        IsBackground = true
205
+            //    };
206
+            //    t.Start();
207
+            //}
208
+        }
209
+
210
+        #endregion 保存
211
+
212
+        ////定义事件
213
+        //public event ChangeTextHandler ChangeTextEvent;
214
+
215
+        #region 获取截图
216
+
217
+        private void GetCapture()
218
+        {
219
+
220
+            string time = GetTimeStamp();
221
+            string tempPath = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
222
+            if (!Directory.Exists(tempPath))
223
+            {
224
+                Directory.CreateDirectory(tempPath);
225
+            }
226
+            string imagePath = Path.Combine(tempPath, time + ".jpg");
227
+            LogHelper.WriteInfoLog(imagePath);
228
+            //this.Close();
229
+            //string imagePath = ImageHelper.GetImagePath(out string serverSavePath);
230
+
231
+            //BitmapSource bitmap = ImageHelper.GetBitmapSource((int)AppModel.Current.MaskLeftWidth + 1, (int)AppModel.Current.MaskTopHeight + 1, (int)MainImage.ActualWidth - 2, (int)MainImage.ActualHeight - 2, out JieTuBitmapPtr);
232
+            BitmapImage bitmap = ImageHelper.GetScreenshot(new Rectangle((int)AppModel.Current.MaskLeftWidth + 1, (int)AppModel.Current.MaskTopHeight + 1, (int)MainImage.ActualWidth - 2, (int)MainImage.ActualHeight - 2), imagePath);
233
+            _IsMouseDown = false;
234
+            _IsCapture = false;
235
+            ImageEditBar.Current.Visibility = Visibility.Collapsed;
236
+            SizeColorBar.Current.Visibility = Visibility.Collapsed;
237
+            SizeRGB.Visibility = Visibility.Collapsed;
238
+            MainImage.Visibility = Visibility.Collapsed;
239
+            DataContext = new AppModel();
240
+            Background = new ImageBrush(ImageHelper.GetScreenshot(new Rectangle(0, 0, 0, 0), imagePath));//zxy
241
+            WpfHelper.MainDispatcher = Dispatcher;
242
+            MaxWindow();
243
+            MaskLeft.Height = ScreenHeight;
244
+            MaskRight.Height = ScreenHeight;
245
+            //计算Windows项目缩放比例
246
+            ScreenHelper.ResetScreenScale();
247
+            if (bitmap != null)
248
+            {
249
+                //Shared.TeachingData.REQ_InteractiveLaunch.teacherpic = serverSavePath;
250
+                //Shared.TeachingData.FilePath = imagePath;
251
+            }
252
+
253
+            ///修改为统一截图时存储到服务器 修改人:赵耀 修改时间:2020年8月11日
254
+            //if (bitmap != null)
255
+            //{
256
+            //    TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0);
257
+            //    string httpurl = Convert.ToInt64(ts.TotalMilliseconds).ToString() + ".png";
258
+            //    string path = ZConfig.classRoomImagePath() + httpurl.Substring(httpurl.LastIndexOf('/') + 1);
259
+            //    Shared.TeachingData.REQ_InteractiveLaunch.teacherpic = ZConfig.dbImagePath() + httpurl;
260
+            //    Shared.TeachingData.FilePath = path;
261
+            // FileInfo fi = new FileInfo(path); var di = fi.Directory; if (!di.Exists) {
262
+            // di.Create();
263
+            //}
264
+
265
+            //    using (var fs = System.IO.File.Create(path))
266
+            //    {
267
+            //        BitmapEncoder encoder = new PngBitmapEncoder();
268
+            //        encoder.Frames.Add(BitmapFrame.Create(bitmap));
269
+            //        encoder.Save(fs);
270
+            //        bitmap = null;
271
+            //        encoder = null;
272
+            //    }
273
+            //}
274
+            //Dispose();
275
+            //GC.Collect();
276
+            //ImageHelper.DeleteObject(BitmapPtr);
277
+            //ImageHelper.DeleteObject(JieTuBitmapPtr);
278
+            initialization();
279
+            Owner = null;
280
+            WindowState = WindowState.Minimized;
281
+            Visibility = Visibility.Hidden;
282
+            ShowInTaskbar = false;
283
+            //this.Hide();
284
+            //if (ChangeTextEvent != null)
285
+            //{
286
+            //    ChangeTextEvent("关闭窗口");
287
+            //}
288
+        }
289
+
290
+        #endregion 获取截图
291
+        /// <summary>
292
+        /// 获取时间戳
293
+        /// </summary>
294
+        /// <returns></returns>
295
+        public string GetTimeStamp()
296
+        {
297
+            TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0);
298
+            return Convert.ToInt64(ts.TotalMilliseconds).ToString();
299
+        }
300
+        #region 退出截图
301
+
302
+        public void OnCancel()
303
+        {
304
+            //Close();
305
+            //ImageHelper.DeleteObject(BitmapPtr);
306
+            //ImageHelper.DeleteObject(JieTuBitmapPtr);
307
+            initialization();
308
+            Owner = null;
309
+            WindowState = WindowState.Minimized;
310
+            Visibility = Visibility.Hidden;
311
+            ShowInTaskbar = false;
312
+            //this.Hide();
313
+            //_Bitmap.Dispose();
314
+        }
315
+
316
+        #endregion 退出截图
317
+
318
+        #region 完成截图
319
+
320
+        public void OnOK()
321
+        {
322
+            Hidden();
323
+
324
+            Thread t = new Thread(new ThreadStart(() =>
325
+            {
326
+                Thread.Sleep(50);
327
+                //Thread.Sleep(200);
328
+                WpfHelper.SafeRun(() =>
329
+                {
330
+                    /*var source = */
331
+                    GetCapture();
332
+                    //Shared.TeachingData.Source = source;
333
+                    //if (source != null)
334
+                    //{
335
+                    //    TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0);
336
+                    //    string httpurl = Convert.ToInt64(ts.TotalMilliseconds).ToString() + ".png";
337
+                    //    string path = ZConfig.classRoomImagePath() + httpurl.Substring(httpurl.LastIndexOf('/') + 1);
338
+                    //    Shared.TeachingData.REQ_InteractiveLaunch.teacherpic = ZConfig.dbImagePath() + httpurl;
339
+                    //    ImageHelper.SaveToPng(source, path);
340
+                    //    Shared.TeachingData.FilePath = path;
341
+                    //    //Clipboard.SetImage(source);
342
+                    //}
343
+                    //Close();
344
+                    //if (ChangeTextEvent != null)
345
+                    //{
346
+                    //    ChangeTextEvent("关闭窗口");
347
+                    //}
348
+                });
349
+            }))
350
+            {
351
+                IsBackground = true
352
+            };
353
+            t.Start();
354
+        }
355
+
356
+        #endregion 完成截图
357
+
358
+        #region 截图前隐藏窗口
359
+
360
+        private void Hidden()
361
+        {
362
+            //隐藏尺寸RGB框
363
+            if (AppModel.Current.MaskTopHeight < 40)
364
+            {
365
+                SizeRGB.Visibility = Visibility.Collapsed;
366
+            }
367
+            int need = SizeColorBar.Current.Selected == Tool.Null ? 30 : 67;
368
+            if (AppModel.Current.MaskBottomHeight < need && AppModel.Current.MaskTopHeight < need)
369
+            {
370
+                ImageEditBar.Current.Visibility = Visibility.Collapsed;
371
+                SizeColorBar.Current.Visibility = Visibility.Collapsed;
372
+            }
373
+            MainImage.ZoomThumbVisibility = Visibility.Collapsed;
374
+        }
375
+
376
+        #endregion 截图前隐藏窗口
377
+
378
+        #region 鼠标及键盘事件
379
+
380
+        private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
381
+        {
382
+            if (_IsCapture)
383
+            {
384
+                return;
385
+            }
386
+            System.Windows.Point point = e.GetPosition(this);
387
+            _X0 = point.X;
388
+            _Y0 = point.Y;
389
+            _IsMouseDown = true;
390
+            Canvas.SetLeft(MainImage, _X0);
391
+            Canvas.SetTop(MainImage, _Y0);
392
+            AppModel.Current.MaskLeftWidth = _X0;
393
+            AppModel.Current.MaskRightWidth = ScreenWidth - _X0;
394
+            AppModel.Current.MaskTopHeight = _Y0;
395
+            Show_Size.Visibility = Visibility.Visible;
396
+        }
397
+
398
+        private void Window_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
399
+        {
400
+            if (!_IsMouseDown || _IsCapture)
401
+            {
402
+                return;
403
+            }
404
+            _IsMouseDown = false;
405
+            if (MainImage.Width >= MinSize && MainImage.Height >= MinSize)
406
+            {
407
+                _IsCapture = true;
408
+                ImageEditBar.Current.Visibility = Visibility.Visible;
409
+                ImageEditBar.Current.ResetCanvas();
410
+                Cursor = Cursors.Arrow;
411
+            }
412
+        }
413
+
414
+        private void Window_MouseMove(object sender, MouseEventArgs e)
415
+        {
416
+            System.Windows.Point point = e.GetPosition(this);
417
+            System.Windows.Point screenP = PointToScreen(point);
418
+            try
419
+            {
420
+                AppModel.Current.ShowRGB = ImageHelper.GetRGB((int)screenP.X, (int)screenP.Y);
421
+            }
422
+            catch (Exception ex)
423
+            {
424
+                MessageBox.Show(ex.Message);
425
+            }
426
+            if (_IsCapture)
427
+            {
428
+                return;
429
+            }
430
+
431
+            if (Show_RGB.Visibility == Visibility.Collapsed)
432
+            {
433
+                Show_RGB.Visibility = Visibility.Visible;
434
+            }
435
+
436
+            if (_IsMouseDown)
437
+            {
438
+                double w = point.X - _X0;
439
+                double h = point.Y - _Y0;
440
+                if (w < MinSize || h < MinSize)
441
+                {
442
+                    return;
443
+                }
444
+                if (MainImage.Visibility == Visibility.Collapsed)
445
+                {
446
+                    MainImage.Visibility = Visibility.Visible;
447
+                }
448
+                AppModel.Current.MaskRightWidth = ScreenWidth - point.X;
449
+                AppModel.Current.MaskTopWidth = w;
450
+                AppModel.Current.MaskBottomHeight = ScreenHeight - point.Y;
451
+                AppModel.Current.ChangeShowSize();
452
+                MainImage.Width = w;
453
+                MainImage.Height = h;
454
+            }
455
+            else
456
+            {
457
+                AppModel.Current.ShowSizeLeft = point.X;
458
+                AppModel.Current.ShowSizeTop = ScreenHeight - point.Y < 30 ? point.Y - 30 : point.Y + 10;
459
+            }
460
+        }
461
+
462
+        private void Window_KeyDown(object sender, KeyEventArgs e)
463
+        {
464
+            if (e.Key == Key.Escape)
465
+            {
466
+                initialization();
467
+                Owner = null;
468
+                WindowState = WindowState.Minimized;
469
+                Visibility = Visibility.Hidden;
470
+                ShowInTaskbar = false;
471
+            }
472
+        }
473
+
474
+        #endregion 鼠标及键盘事件
475
+
476
+        /// <summary>
477
+        /// 关闭时清除tool页记录的截图数据
478
+        /// </summary>
479
+        /// <param name="sender"></param>
480
+        /// <param name="e"></param>
481
+        private void Window_Closed(object sender, EventArgs e)
482
+        {
483
+            click_closeJietuWindowClick();
484
+        }
485
+
486
+        /// <summary>
487
+        /// 非正常关闭时jietuWindow=null;
488
+        /// </summary>
489
+        /// <param name="sender"></param>
490
+        /// <param name="e"></param>
491
+        public delegate void CloseJietuWindowClick();
492
+
493
+        /// <summary>
494
+        /// 非正常关闭时jietuWindow=null;
495
+        /// </summary>
496
+        public event CloseJietuWindowClick click_closeJietuWindowClick;
497
+    }
498
+}

+ 179
- 0
XHWK.WKTool/Models/AppModel.cs Datei anzeigen

@@ -0,0 +1,179 @@
1
+using ComeCapture.Models;
2
+
3
+using System.Text;
4
+
5
+namespace ComeCapture
6
+{
7
+    public class AppModel : EntityBase
8
+    {
9
+        public AppModel()
10
+        {
11
+            _Current = this;
12
+        }
13
+
14
+        #region 属性 Current
15
+
16
+        private static AppModel _Current = null;
17
+
18
+        public static AppModel Current => _Current;
19
+
20
+        #endregion 属性 Current
21
+
22
+        #region 属性 MaskLeftWidth
23
+
24
+        private double _MaskLeftWidth = JieTuWindow.ScreenWidth;
25
+
26
+        public double MaskLeftWidth
27
+        {
28
+            get => _MaskLeftWidth;
29
+            set
30
+            {
31
+                _MaskLeftWidth = value;
32
+                ShowSizeLeft = value;
33
+                RaisePropertyChanged(() => MaskLeftWidth);
34
+            }
35
+        }
36
+
37
+        #endregion 属性 MaskLeftWidth
38
+
39
+        #region 属性 MaskRightWidth
40
+
41
+        private double _MaskRightWidth = 0;
42
+
43
+        public double MaskRightWidth
44
+        {
45
+            get => _MaskRightWidth;
46
+            set
47
+            {
48
+                _MaskRightWidth = value;
49
+                RaisePropertyChanged(() => MaskRightWidth);
50
+            }
51
+        }
52
+
53
+        #endregion 属性 MaskRightWidth
54
+
55
+        #region 属性 MaskTopWidth
56
+
57
+        private double _MaskTopWidth = 0;
58
+
59
+        public double MaskTopWidth
60
+        {
61
+            get => _MaskTopWidth;
62
+            set
63
+            {
64
+                _MaskTopWidth = value;
65
+                RaisePropertyChanged(() => MaskTopWidth);
66
+            }
67
+        }
68
+
69
+        #endregion 属性 MaskTopWidth
70
+
71
+        #region 属性 MaskTopHeight
72
+
73
+        private double _MaskTopHeight = 0;
74
+
75
+        public double MaskTopHeight
76
+        {
77
+            get => _MaskTopHeight;
78
+            set
79
+            {
80
+                _MaskTopHeight = value;
81
+                ShowSizeTop = MaskTopHeight < 40 ? MaskTopHeight : MaskTopHeight - 40;
82
+                RaisePropertyChanged(() => MaskTopHeight);
83
+            }
84
+        }
85
+
86
+        #endregion 属性 MaskTopHeight
87
+
88
+        #region 属性 MaskBottomHeight
89
+
90
+        private double _MaskBottomHeight = 0;
91
+
92
+        public double MaskBottomHeight
93
+        {
94
+            get => _MaskBottomHeight;
95
+            set
96
+            {
97
+                _MaskBottomHeight = value;
98
+                RaisePropertyChanged(() => MaskBottomHeight);
99
+            }
100
+        }
101
+
102
+        #endregion 属性 MaskBottomHeight
103
+
104
+        #region 属性 ShowSize
105
+
106
+        private string _ShowSize = "0 × 0";
107
+
108
+        public string ShowSize
109
+        {
110
+            get => _ShowSize;
111
+            set
112
+            {
113
+                _ShowSize = value;
114
+                RaisePropertyChanged(() => ShowSize);
115
+            }
116
+        }
117
+
118
+        private static StringBuilder sb = new StringBuilder();
119
+
120
+        public void ChangeShowSize()
121
+        {
122
+            sb = new StringBuilder();
123
+            sb.Append((int)(JieTuWindow.Current.MainImage.Width * JieTuWindow.ScreenScale));
124
+            sb.Append(" × ");
125
+            sb.Append((int)(JieTuWindow.Current.MainImage.Height * JieTuWindow.ScreenScale));
126
+            ShowSize = sb.ToString();
127
+        }
128
+
129
+        #endregion 属性 ShowSize
130
+
131
+        #region 属性 ShowSizeLeft
132
+
133
+        private double _ShowSizeLeft = 0;
134
+
135
+        public double ShowSizeLeft
136
+        {
137
+            get => _ShowSizeLeft;
138
+            set
139
+            {
140
+                _ShowSizeLeft = value;
141
+                RaisePropertyChanged(() => ShowSizeLeft);
142
+            }
143
+        }
144
+
145
+        #endregion 属性 ShowSizeLeft
146
+
147
+        #region 属性 ShowSizeTop
148
+
149
+        private double _ShowSizeTop = 0;
150
+
151
+        public double ShowSizeTop
152
+        {
153
+            get => _ShowSizeTop;
154
+            set
155
+            {
156
+                _ShowSizeTop = value;
157
+                RaisePropertyChanged(() => ShowSizeTop);
158
+            }
159
+        }
160
+
161
+        #endregion 属性 ShowSizeTop
162
+
163
+        #region 属性 ShowRGB
164
+
165
+        private string _ShowRGB = string.Empty;
166
+
167
+        public string ShowRGB
168
+        {
169
+            get => _ShowRGB;
170
+            set
171
+            {
172
+                _ShowRGB = value;
173
+                RaisePropertyChanged(() => ShowRGB);
174
+            }
175
+        }
176
+
177
+        #endregion 属性 ShowRGB
178
+    }
179
+}

+ 16
- 0
XHWK.WKTool/Models/Direction.cs Datei anzeigen

@@ -0,0 +1,16 @@
1
+namespace ComeCapture.Models
2
+{
3
+    public enum Direction
4
+    {
5
+        Null = 0,
6
+        Move = 1,
7
+        LeftTop = 2,
8
+        LeftMiddle = 3,
9
+        LeftBottom = 4,
10
+        MiddleTop = 5,
11
+        MiddleBottom = 6,
12
+        RightTop = 7,
13
+        RightMiddle = 8,
14
+        RightBottom = 9
15
+    }
16
+}

+ 51
- 0
XHWK.WKTool/Models/EntityBase.cs Datei anzeigen

@@ -0,0 +1,51 @@
1
+/*
2
+ * author      : singba singba@163.com
3
+ * version     : 20161221
4
+ * source      : AF.Core
5
+ * license     : free use or modify
6
+ * description : 通用类型基类
7
+ */
8
+
9
+using System;
10
+using System.Linq.Expressions;
11
+
12
+namespace ComeCapture.Models
13
+{
14
+    /// <summary>
15
+    /// singba:20120807
16
+    /// 这个基类只作为INotifyPropertyChanged的实现,不再是Entity的基类
17
+    /// </summary>
18
+    public class EntityBase : System.ComponentModel.INotifyPropertyChanged
19
+    {
20
+        #region INotifyPropertyChanged Members
21
+
22
+        public virtual event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
23
+
24
+        protected virtual void RaisePropertyChanged(string name)
25
+        {
26
+            if (PropertyChanged != null)
27
+            {
28
+                PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(name));
29
+            }
30
+        }
31
+
32
+        protected virtual void RaisePropertyChanged<TProperty>(Expression<Func<TProperty>> property)
33
+        {
34
+            LambdaExpression lambda = property;
35
+            MemberExpression memberExpression;
36
+            if (lambda.Body is UnaryExpression)
37
+            {
38
+                UnaryExpression unaryExpression = (UnaryExpression)lambda.Body;
39
+                memberExpression = (MemberExpression)unaryExpression.Operand;
40
+            }
41
+            else
42
+            {
43
+                memberExpression = (MemberExpression)lambda.Body;
44
+            }
45
+
46
+            RaisePropertyChanged(memberExpression.Member.Name);
47
+        }
48
+
49
+        #endregion INotifyPropertyChanged Members
50
+    }
51
+}

+ 37
- 0
XHWK.WKTool/Models/Limit.cs Datei anzeigen

@@ -0,0 +1,37 @@
1
+namespace ComeCapture.Models
2
+{
3
+    /// <summary>
4
+    /// 图片移动的极限值
5
+    /// </summary>
6
+    public class Limit
7
+    {
8
+        public double Left { get; set; } = JieTuWindow.ScreenWidth;
9
+        public double Right { get; set; } = 0;
10
+        public double Top { get; set; } = JieTuWindow.ScreenHeight;
11
+        public double Bottom { get; set; } = 0;
12
+
13
+        public Limit Clone()
14
+        {
15
+            return MemberwiseClone() as Limit;
16
+        }
17
+
18
+        public Limit()
19
+        {
20
+        }
21
+    }
22
+
23
+    /// <summary>
24
+    /// 注册名称以及对应图片极限值
25
+    /// </summary>
26
+    public class NameAndLimit
27
+    {
28
+        public string Name { get; set; }
29
+        public Limit Limit { get; set; }
30
+
31
+        public NameAndLimit(string name)
32
+        {
33
+            Name = name;
34
+            Limit = JieTuWindow.Current.MainImage.Limit.Clone();
35
+        }
36
+    }
37
+}

+ 16
- 0
XHWK.WKTool/Models/Tool.cs Datei anzeigen

@@ -0,0 +1,16 @@
1
+namespace ComeCapture.Models
2
+{
3
+    public enum Tool
4
+    {
5
+        Null,//无状态可移动
6
+        Rectangle,//长方形
7
+        Ellipse,//圆形
8
+        Line,//画刷
9
+        Text,//文字
10
+        Arrow,//箭头
11
+        Revoke,//撤销
12
+        Save,//保存
13
+        Cancel,//退出截图
14
+        OK//完成截图
15
+    }
16
+}

+ 699
- 0
XHWK.WKTool/Themes/Generic.xaml Datei anzeigen

@@ -0,0 +1,699 @@
1
+<ResourceDictionary
2
+    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3
+    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4
+    xmlns:control="clr-namespace:ComeCapture.Controls"
5
+    xmlns:converter="clr-namespace:ComeCapture.Converters"
6
+    xmlns:sys="clr-namespace:System;assembly=mscorlib">
7
+
8
+    <SolidColorBrush x:Key="BaseColor" Color="#2ecc71" />
9
+    <SolidColorBrush x:Key="ToolButtonBorder" Color="#9EA0A1" />
10
+    <SolidColorBrush x:Key="ToolButtonHoverBackground" Color="#DEE3E9" />
11
+    <SolidColorBrush x:Key="ToolColor" Color="#478cde" />
12
+    <SolidColorBrush x:Key="StackPanelColor" Color="#EAEEF5" />
13
+
14
+    <sys:Double x:Key="Small">2</sys:Double>
15
+    <sys:Double x:Key="Medium">5</sys:Double>
16
+    <sys:Double x:Key="Large">8</sys:Double>
17
+
18
+    <!--<converter:ToolConverter x:Key="ToolConverter" />
19
+    <converter:SizeConverter x:Key="SizeConverter" />
20
+    <converter:ColorConverter x:Key="ColorConverter" />-->
21
+
22
+    <converter:ToolConverter x:Key="ToolConverter"/>
23
+    <converter:SizeConverter x:Key="SizeConverter"/>
24
+    <converter:ColorConverter x:Key="ColorConverter"/>
25
+
26
+    <!--  移动滑块  -->
27
+    <Style x:Key="MoveThumb" TargetType="{x:Type control:ZoomThumb}">
28
+        <Setter Property="Template">
29
+            <Setter.Value>
30
+                <ControlTemplate TargetType="{x:Type control:ZoomThumb}">
31
+                    <Rectangle
32
+                        Fill="Transparent"
33
+                        SnapsToDevicePixels="True"
34
+                        Stroke="LimeGreen"
35
+                        StrokeThickness="1" />
36
+                </ControlTemplate>
37
+            </Setter.Value>
38
+        </Setter>
39
+    </Style>
40
+
41
+    <!--  拉伸滑块  -->
42
+    <Style x:Key="ZoomThumb" TargetType="{x:Type control:ZoomThumb}">
43
+        <Setter Property="Visibility" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type control:MainImage}}, Path=ZoomThumbVisibility}" />
44
+        <Setter Property="Margin" Value="-3" />
45
+        <Setter Property="Template">
46
+            <Setter.Value>
47
+                <ControlTemplate TargetType="{x:Type control:ZoomThumb}">
48
+                    <Border
49
+                        Width="6"
50
+                        Height="6"
51
+                        Background="{StaticResource BaseColor}" />
52
+                </ControlTemplate>
53
+            </Setter.Value>
54
+        </Setter>
55
+    </Style>
56
+
57
+    <!--  截图区域  -->
58
+    <Style TargetType="{x:Type control:MainImage}">
59
+        <Setter Property="Visibility" Value="Collapsed" />
60
+        <Setter Property="Template">
61
+            <Setter.Value>
62
+                <ControlTemplate TargetType="{x:Type control:MainImage}">
63
+                    <Grid>
64
+                        <Grid.ColumnDefinitions>
65
+                            <ColumnDefinition Width="*" />
66
+                            <ColumnDefinition Width="*" />
67
+                            <ColumnDefinition Width="*" />
68
+                        </Grid.ColumnDefinitions>
69
+                        <Grid.RowDefinitions>
70
+                            <RowDefinition Height="*" />
71
+                            <RowDefinition Height="*" />
72
+                            <RowDefinition Height="*" />
73
+                        </Grid.RowDefinitions>
74
+                        <control:ZoomThumb
75
+                            Grid.RowSpan="3"
76
+                            Grid.ColumnSpan="3"
77
+                            Cursor="{Binding RelativeSource={RelativeSource AncestorType=control:MainImage}, Path=MoveCursor}"
78
+                            Direction="Move"
79
+                            Style="{StaticResource MoveThumb}" />
80
+                        <control:ZoomThumb
81
+                            HorizontalAlignment="Left"
82
+                            VerticalAlignment="Top"
83
+                            Cursor="SizeNWSE"
84
+                            Direction="LeftTop"
85
+                            Style="{StaticResource ZoomThumb}" />
86
+                        <control:ZoomThumb
87
+                            Grid.Row="1"
88
+                            HorizontalAlignment="Left"
89
+                            Cursor="SizeWE"
90
+                            Direction="LeftMiddle"
91
+                            Style="{StaticResource ZoomThumb}" />
92
+                        <control:ZoomThumb
93
+                            Grid.Row="2"
94
+                            HorizontalAlignment="Left"
95
+                            VerticalAlignment="Bottom"
96
+                            Cursor="SizeNESW"
97
+                            Direction="LeftBottom"
98
+                            Style="{StaticResource ZoomThumb}" />
99
+                        <control:ZoomThumb
100
+                            Grid.Column="1"
101
+                            VerticalAlignment="Top"
102
+                            Cursor="SizeNS"
103
+                            Direction="MiddleTop"
104
+                            Style="{StaticResource ZoomThumb}" />
105
+                        <control:ZoomThumb
106
+                            Grid.Row="2"
107
+                            Grid.Column="1"
108
+                            VerticalAlignment="Bottom"
109
+                            Cursor="SizeNS"
110
+                            Direction="MiddleBottom"
111
+                            Style="{StaticResource ZoomThumb}" />
112
+                        <control:ZoomThumb
113
+                            Grid.Column="2"
114
+                            HorizontalAlignment="Right"
115
+                            VerticalAlignment="Top"
116
+                            Cursor="SizeNESW"
117
+                            Direction="RightTop"
118
+                            Style="{StaticResource ZoomThumb}" />
119
+                        <control:ZoomThumb
120
+                            Grid.Row="1"
121
+                            Grid.Column="2"
122
+                            HorizontalAlignment="Right"
123
+                            Cursor="SizeWE"
124
+                            Direction="RightMiddle"
125
+                            Style="{StaticResource ZoomThumb}" />
126
+                        <control:ZoomThumb
127
+                            Grid.Row="2"
128
+                            Grid.Column="2"
129
+                            HorizontalAlignment="Right"
130
+                            VerticalAlignment="Bottom"
131
+                            Cursor="SizeNWSE"
132
+                            Direction="RightBottom"
133
+                            Style="{StaticResource ZoomThumb}" />
134
+                    </Grid>
135
+                </ControlTemplate>
136
+            </Setter.Value>
137
+        </Setter>
138
+    </Style>
139
+
140
+    <!--  按钮  -->
141
+    <Style x:Key="BaseButton" TargetType="{x:Type ButtonBase}">
142
+        <Setter Property="BorderBrush" Value="Transparent" />
143
+        <Setter Property="Background" Value="Transparent" />
144
+        <Setter Property="Template">
145
+            <Setter.Value>
146
+                <ControlTemplate TargetType="{x:Type control:ToolButton}">
147
+                    <Border
148
+                        Background="{TemplateBinding Background}"
149
+                        BorderBrush="{TemplateBinding BorderBrush}"
150
+                        BorderThickness="1"
151
+                        CornerRadius="1">
152
+                        <ContentControl Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" />
153
+                    </Border>
154
+                    <ControlTemplate.Triggers>
155
+                        <Trigger Property="IsMouseOver" Value="True">
156
+                            <Setter Property="BorderBrush" Value="{StaticResource ToolButtonBorder}" />
157
+                            <Setter Property="Background" Value="{StaticResource ToolButtonHoverBackground}" />
158
+                        </Trigger>
159
+                        <Trigger Property="IsChecked" Value="True">
160
+                            <Setter Property="BorderBrush" Value="{StaticResource ToolButtonBorder}" />
161
+                            <Setter Property="Background" Value="{StaticResource ToolButtonHoverBackground}" />
162
+                        </Trigger>
163
+                    </ControlTemplate.Triggers>
164
+                </ControlTemplate>
165
+            </Setter.Value>
166
+        </Setter>
167
+    </Style>
168
+
169
+    <!--  工具按钮  -->
170
+    <Style
171
+        x:Key="ToolButton"
172
+        BasedOn="{StaticResource BaseButton}"
173
+        TargetType="{x:Type control:ToolButton}">
174
+        <Setter Property="Margin" Value="3" />
175
+        <Setter Property="Width" Value="24" />
176
+        <Setter Property="Height" Value="19" />
177
+        <Setter Property="IsImageEditBar" Value="True" />
178
+        <Setter Property="GroupName" Value="Tools" />
179
+    </Style>
180
+
181
+    <!--  尺寸按钮  -->
182
+    <Style
183
+        x:Key="SizeButton"
184
+        BasedOn="{StaticResource BaseButton}"
185
+        TargetType="{x:Type control:ToolButton}">
186
+        <Setter Property="Margin" Value="1,5" />
187
+        <Setter Property="Width" Value="24" />
188
+        <Setter Property="Height" Value="25" />
189
+    </Style>
190
+
191
+    <!--  颜色按钮  -->
192
+    <Style x:Key="ColorButton" TargetType="{x:Type control:ToolButton}">
193
+        <Setter Property="Width" Value="16" />
194
+        <Setter Property="Height" Value="16" />
195
+        <Setter Property="BorderBrush" Value="Transparent" />
196
+        <Setter Property="Template">
197
+            <Setter.Value>
198
+                <ControlTemplate TargetType="{x:Type control:ToolButton}">
199
+                    <Border
200
+                        Background="{TemplateBinding Background}"
201
+                        BorderBrush="{TemplateBinding BorderBrush}"
202
+                        BorderThickness="1"
203
+                        CornerRadius="1">
204
+                        <ContentControl
205
+                            HorizontalAlignment="Stretch"
206
+                            VerticalAlignment="Stretch"
207
+                            Content="{TemplateBinding Content}"
208
+                            ContentTemplate="{TemplateBinding ContentTemplate}" />
209
+                    </Border>
210
+                    <ControlTemplate.Triggers>
211
+                        <Trigger Property="IsMouseOver" Value="True">
212
+                            <Setter Property="BorderBrush" Value="{StaticResource ToolButtonBorder}" />
213
+                            <Setter Property="Background" Value="White" />
214
+                        </Trigger>
215
+                        <Trigger Property="IsChecked" Value="True">
216
+                            <Setter Property="BorderBrush" Value="{StaticResource ToolButtonBorder}" />
217
+                            <Setter Property="Background" Value="White" />
218
+                        </Trigger>
219
+                    </ControlTemplate.Triggers>
220
+                </ControlTemplate>
221
+            </Setter.Value>
222
+        </Setter>
223
+    </Style>
224
+
225
+    <!--  工具栏  -->
226
+    <Style TargetType="{x:Type control:ImageEditBar}">
227
+        <Setter Property="Width" Value="270" />
228
+        <Setter Property="Height" Value="25" />
229
+        <Setter Property="Visibility" Value="Collapsed" />
230
+        <Setter Property="Background" Value="{StaticResource StackPanelColor}" />
231
+        <Setter Property="Cursor" Value="Arrow" />
232
+        <Setter Property="Canvas.Left" Value="{Binding RelativeSource={RelativeSource Self}, Path=CanvasLeft}" />
233
+        <Setter Property="Canvas.Top" Value="{Binding RelativeSource={RelativeSource Self}, Path=CanvasTop}" />
234
+        <Setter Property="Template">
235
+            <Setter.Value>
236
+                <ControlTemplate TargetType="{x:Type control:ImageEditBar}">
237
+                    <StackPanel
238
+                        Width="60"
239
+                        Height="{TemplateBinding Height}"
240
+                        HorizontalAlignment="Right"
241
+                        Background="{TemplateBinding Background}"
242
+                        Orientation="Horizontal">
243
+                        <!--<control:ToolButton Tool="Rectangle" ToolTip="矩形工具" Style="{StaticResource ToolButton}">
244
+                            <Rectangle Width="17" Height="14" Stroke="{StaticResource ToolColor}" StrokeThickness="2" Fill="White" />
245
+                        </control:ToolButton>
246
+                        <control:ToolButton Tool="Ellipse"  ToolTip="椭圆工具" Style="{StaticResource ToolButton}">
247
+                            <Ellipse Width="17" Height="14" Stroke="{StaticResource ToolColor}" StrokeThickness="2" Fill="White" />
248
+                        </control:ToolButton>
249
+                        <control:ToolButton Tool="Arrow" ToolTip="箭头工具" Style="{StaticResource ToolButton}">
250
+                            <Image Width="18" Height="15" Source="/ComeCapture;component/Resources/箭头.png" />
251
+                        </control:ToolButton>
252
+                        <control:ToolButton Tool="Line" ToolTip="画刷工具" Style="{StaticResource ToolButton}">
253
+                            <Image Width="18" Height="15" Source="/ComeCapture;component/Resources/笔刷.png" />
254
+                        </control:ToolButton>
255
+                        <control:ToolButton Tool="Text" ToolTip="文字工具" Style="{StaticResource ToolButton}">
256
+                            <TextBlock Text="A" FontSize="19" TextAlignment="Center" Margin="0,-4,0,0" FontWeight="Bold" Foreground="{StaticResource ToolColor}" />
257
+                        </control:ToolButton>
258
+                        <control:ToolButton Tool="Revoke" ToolTip="撤销编辑" Style="{StaticResource ToolButton}">
259
+                            <Image Margin="0,-1,0,1" Width="18" Height="15" Source="/ComeCapture;component/Resources/后退.png" />
260
+                        </control:ToolButton>
261
+                        <control:ToolButton Tool="Save" ToolTip="保存" Style="{StaticResource ToolButton}">
262
+                            <Image Margin="0,1,0,-1" Width="18" Height="15" Source="/ComeCapture;component/Resources/保存.png" />
263
+                        </control:ToolButton>-->
264
+                        <control:ToolButton Cursor="Hand"
265
+                            Style="{StaticResource ToolButton}"
266
+                            Tool="Cancel"
267
+                            ToolTip="退出截图">
268
+                            <Grid Width="17" Height="14">
269
+                                <Path
270
+                                    Data="M 4,2 L 15,13"
271
+                                    Stroke="Red"
272
+                                    StrokeThickness="4" />
273
+                                <Path
274
+                                    Data="M 4,13 L 15,2"
275
+                                    Stroke="Red"
276
+                                    StrokeThickness="4" />
277
+                            </Grid>
278
+                        </control:ToolButton>
279
+                        <control:ToolButton Cursor="Hand"
280
+                            Style="{StaticResource ToolButton}"
281
+                            Tool="OK"
282
+                            ToolTip="完成截图">
283
+                            <Grid Width="17" Height="14">
284
+                                <Path
285
+                                    Data="M 2,7 L 7,12 L 16,2"
286
+                                    Stroke="Green"
287
+                                    StrokeThickness="4" />
288
+                            </Grid>
289
+                        </control:ToolButton>
290
+                    </StackPanel>
291
+                </ControlTemplate>
292
+            </Setter.Value>
293
+        </Setter>
294
+    </Style>
295
+
296
+    <!--  尺寸颜色栏基础样式  -->
297
+    <Style x:Key="BaseSizeColor" TargetType="{x:Type StackPanel}">
298
+        <Setter Property="Width" Value="270" />
299
+        <Setter Property="Height" Value="35" />
300
+        <Setter Property="Orientation" Value="Horizontal" />
301
+        <Setter Property="Visibility" Value="Collapsed" />
302
+        <Setter Property="Background" Value="{StaticResource StackPanelColor}" />
303
+    </Style>
304
+
305
+    <!--  颜色板Item  -->
306
+    <Style x:Key="ColorBoxItem" TargetType="{x:Type ListBoxItem}">
307
+        <Setter Property="Template">
308
+            <Setter.Value>
309
+                <ControlTemplate TargetType="{x:Type ListBoxItem}">
310
+                    <ContentControl Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" />
311
+                </ControlTemplate>
312
+            </Setter.Value>
313
+        </Setter>
314
+    </Style>
315
+
316
+    <!--  颜色板  -->
317
+    <Style x:Key="ColorBarStyle" TargetType="{x:Type ListBox}">
318
+        <Setter Property="BorderThickness" Value="0" />
319
+        <Setter Property="Background" Value="Transparent" />
320
+        <Setter Property="ItemsSource" Value="{x:Static control:SizeColorBar.ColorBars}" />
321
+        <Setter Property="ItemContainerStyle" Value="{StaticResource ColorBoxItem}" />
322
+        <Setter Property="ItemsPanel">
323
+            <Setter.Value>
324
+                <ItemsPanelTemplate>
325
+                    <UniformGrid
326
+                        Height="32"
327
+                        Columns="9"
328
+                        Rows="2" />
329
+                </ItemsPanelTemplate>
330
+            </Setter.Value>
331
+        </Setter>
332
+    </Style>
333
+
334
+    <!--  尺寸颜色栏  -->
335
+    <Style TargetType="{x:Type control:SizeColorBar}">
336
+        <Setter Property="Canvas.Left" Value="{Binding RelativeSource={RelativeSource Self}, Path=CanvasLeft}" />
337
+        <Setter Property="Canvas.Top" Value="{Binding RelativeSource={RelativeSource Self}, Path=CanvasTop}" />
338
+        <Setter Property="Template">
339
+            <Setter.Value>
340
+                <ControlTemplate TargetType="{x:Type control:SizeColorBar}">
341
+                    <Grid>
342
+
343
+                        <control:RectangleTool
344
+                            x:Name="PART_RectangleTool"
345
+                            Style="{StaticResource BaseSizeColor}"
346
+                            Visibility="{Binding RelativeSource={RelativeSource AncestorType=control:SizeColorBar}, Path=Selected, Converter={StaticResource ToolConverter}, ConverterParameter=Rectangle}">
347
+                            <control:ToolButton
348
+                                GroupName="RectangleTool"
349
+                                IsChecked="{Binding ElementName=PART_RectangleTool, Path=LineThickness, Converter={StaticResource SizeConverter}, ConverterParameter={StaticResource Small}}"
350
+                                Style="{StaticResource SizeButton}">
351
+                                <Ellipse
352
+                                    Width="{StaticResource Small}"
353
+                                    Height="{StaticResource Small}"
354
+                                    Fill="{StaticResource ToolColor}" />
355
+                            </control:ToolButton>
356
+                            <control:ToolButton
357
+                                GroupName="RectangleTool"
358
+                                IsChecked="{Binding ElementName=PART_RectangleTool, Path=LineThickness, Converter={StaticResource SizeConverter}, ConverterParameter={StaticResource Medium}}"
359
+                                Style="{StaticResource SizeButton}">
360
+                                <Ellipse
361
+                                    Width="{StaticResource Medium}"
362
+                                    Height="{StaticResource Medium}"
363
+                                    Fill="{StaticResource ToolColor}" />
364
+                            </control:ToolButton>
365
+                            <control:ToolButton
366
+                                GroupName="RectangleTool"
367
+                                IsChecked="{Binding ElementName=PART_RectangleTool, Path=LineThickness, Converter={StaticResource SizeConverter}, ConverterParameter={StaticResource Large}}"
368
+                                Style="{StaticResource SizeButton}">
369
+                                <Ellipse
370
+                                    Width="{StaticResource Large}"
371
+                                    Height="{StaticResource Large}"
372
+                                    Fill="{StaticResource ToolColor}" />
373
+                            </control:ToolButton>
374
+                            <Grid
375
+                                Width="29"
376
+                                Height="29"
377
+                                Margin="5,0,5,0"
378
+                                Background="White">
379
+                                <Border BorderBrush="{StaticResource ToolButtonBorder}" BorderThickness="1">
380
+                                    <Canvas
381
+                                        Width="25"
382
+                                        Height="25"
383
+                                        Background="{Binding ElementName=PART_RectangleTool, Path=LineBrush}" />
384
+                                </Border>
385
+                            </Grid>
386
+                            <ListBox Style="{StaticResource ColorBarStyle}">
387
+                                <ListBox.ItemTemplate>
388
+                                    <DataTemplate>
389
+                                        <control:ToolButton
390
+                                            GroupName="RectangleColor"
391
+                                            LineColor="{Binding ., Converter={StaticResource ColorConverter}}"
392
+                                            Style="{StaticResource ColorButton}">
393
+                                            <Rectangle
394
+                                                Width="12"
395
+                                                Height="12"
396
+                                                Fill="{Binding}"
397
+                                                Stroke="{StaticResource ToolButtonBorder}"
398
+                                                StrokeThickness="1" />
399
+                                        </control:ToolButton>
400
+                                    </DataTemplate>
401
+                                </ListBox.ItemTemplate>
402
+                            </ListBox>
403
+                        </control:RectangleTool>
404
+
405
+                        <control:EllipseTool
406
+                            x:Name="PART_EllipseTool"
407
+                            Style="{StaticResource BaseSizeColor}"
408
+                            Visibility="{Binding RelativeSource={RelativeSource AncestorType=control:SizeColorBar}, Path=Selected, Converter={StaticResource ToolConverter}, ConverterParameter=Ellipse}">
409
+                            <control:ToolButton
410
+                                GroupName="EllipseTool"
411
+                                IsChecked="{Binding ElementName=PART_EllipseTool, Path=LineThickness, Converter={StaticResource SizeConverter}, ConverterParameter={StaticResource Small}}"
412
+                                Style="{StaticResource SizeButton}">
413
+                                <Ellipse
414
+                                    Width="{StaticResource Small}"
415
+                                    Height="{StaticResource Small}"
416
+                                    Fill="{StaticResource ToolColor}" />
417
+                            </control:ToolButton>
418
+                            <control:ToolButton
419
+                                GroupName="EllipseTool"
420
+                                IsChecked="{Binding ElementName=PART_EllipseTool, Path=LineThickness, Converter={StaticResource SizeConverter}, ConverterParameter={StaticResource Medium}}"
421
+                                Style="{StaticResource SizeButton}">
422
+                                <Ellipse
423
+                                    Width="{StaticResource Medium}"
424
+                                    Height="{StaticResource Medium}"
425
+                                    Fill="{StaticResource ToolColor}" />
426
+                            </control:ToolButton>
427
+                            <control:ToolButton
428
+                                GroupName="EllipseTool"
429
+                                IsChecked="{Binding ElementName=PART_EllipseTool, Path=LineThickness, Converter={StaticResource SizeConverter}, ConverterParameter={StaticResource Large}}"
430
+                                Style="{StaticResource SizeButton}">
431
+                                <Ellipse
432
+                                    Width="{StaticResource Large}"
433
+                                    Height="{StaticResource Large}"
434
+                                    Fill="{StaticResource ToolColor}" />
435
+                            </control:ToolButton>
436
+
437
+                            <Grid
438
+                                Width="29"
439
+                                Height="29"
440
+                                Margin="5,0"
441
+                                Background="White">
442
+                                <Border BorderBrush="{StaticResource ToolButtonBorder}" BorderThickness="1">
443
+                                    <Canvas
444
+                                        Width="25"
445
+                                        Height="25"
446
+                                        Background="{Binding ElementName=PART_EllipseTool, Path=LineBrush}" />
447
+                                </Border>
448
+                            </Grid>
449
+                            <ListBox Style="{StaticResource ColorBarStyle}">
450
+                                <ListBox.ItemTemplate>
451
+                                    <DataTemplate>
452
+                                        <control:ToolButton
453
+                                            GroupName="EllipseColor"
454
+                                            LineColor="{Binding ., Converter={StaticResource ColorConverter}}"
455
+                                            Style="{StaticResource ColorButton}">
456
+                                            <Rectangle
457
+                                                Width="12"
458
+                                                Height="12"
459
+                                                Fill="{Binding}"
460
+                                                Stroke="{StaticResource ToolButtonBorder}"
461
+                                                StrokeThickness="1" />
462
+                                        </control:ToolButton>
463
+                                    </DataTemplate>
464
+                                </ListBox.ItemTemplate>
465
+                            </ListBox>
466
+                        </control:EllipseTool>
467
+
468
+                        <control:ArrowTool
469
+                            x:Name="PART_ArrowTool"
470
+                            Style="{StaticResource BaseSizeColor}"
471
+                            Visibility="{Binding RelativeSource={RelativeSource AncestorType=control:SizeColorBar}, Path=Selected, Converter={StaticResource ToolConverter}, ConverterParameter=Arrow}">
472
+                            <control:ToolButton
473
+                                GroupName="ArrowTool"
474
+                                IsChecked="{Binding ElementName=PART_ArrowTool, Path=LineThickness, Converter={StaticResource SizeConverter}, ConverterParameter={StaticResource Small}}"
475
+                                Style="{StaticResource SizeButton}">
476
+                                <Ellipse
477
+                                    Width="{StaticResource Small}"
478
+                                    Height="{StaticResource Small}"
479
+                                    Fill="{StaticResource ToolColor}" />
480
+                            </control:ToolButton>
481
+                            <control:ToolButton
482
+                                GroupName="ArrowTool"
483
+                                IsChecked="{Binding ElementName=PART_ArrowTool, Path=LineThickness, Converter={StaticResource SizeConverter}, ConverterParameter={StaticResource Medium}}"
484
+                                Style="{StaticResource SizeButton}">
485
+                                <Ellipse
486
+                                    Width="{StaticResource Medium}"
487
+                                    Height="{StaticResource Medium}"
488
+                                    Fill="{StaticResource ToolColor}" />
489
+                            </control:ToolButton>
490
+                            <control:ToolButton
491
+                                GroupName="ArrowTool"
492
+                                IsChecked="{Binding ElementName=PART_ArrowTool, Path=LineThickness, Converter={StaticResource SizeConverter}, ConverterParameter={StaticResource Large}}"
493
+                                Style="{StaticResource SizeButton}">
494
+                                <Ellipse
495
+                                    Width="{StaticResource Large}"
496
+                                    Height="{StaticResource Large}"
497
+                                    Fill="{StaticResource ToolColor}" />
498
+                            </control:ToolButton>
499
+
500
+                            <Grid
501
+                                Width="29"
502
+                                Height="29"
503
+                                Margin="5,0"
504
+                                Background="White">
505
+                                <Border BorderBrush="{StaticResource ToolButtonBorder}" BorderThickness="1">
506
+                                    <Canvas
507
+                                        Width="25"
508
+                                        Height="25"
509
+                                        Background="{Binding ElementName=PART_ArrowTool, Path=LineBrush}" />
510
+                                </Border>
511
+                            </Grid>
512
+                            <ListBox Style="{StaticResource ColorBarStyle}">
513
+                                <ListBox.ItemTemplate>
514
+                                    <DataTemplate>
515
+                                        <control:ToolButton
516
+                                            GroupName="ArrowColor"
517
+                                            LineColor="{Binding ., Converter={StaticResource ColorConverter}}"
518
+                                            Style="{StaticResource ColorButton}">
519
+                                            <Rectangle
520
+                                                Width="12"
521
+                                                Height="12"
522
+                                                Fill="{Binding}"
523
+                                                Stroke="{StaticResource ToolButtonBorder}"
524
+                                                StrokeThickness="1" />
525
+                                        </control:ToolButton>
526
+                                    </DataTemplate>
527
+                                </ListBox.ItemTemplate>
528
+                            </ListBox>
529
+                        </control:ArrowTool>
530
+
531
+                        <control:LineTool
532
+                            x:Name="PART_LineTool"
533
+                            Style="{StaticResource BaseSizeColor}"
534
+                            Visibility="{Binding RelativeSource={RelativeSource AncestorType=control:SizeColorBar}, Path=Selected, Converter={StaticResource ToolConverter}, ConverterParameter=Line}">
535
+                            <control:ToolButton
536
+                                GroupName="LineTool"
537
+                                IsChecked="{Binding ElementName=PART_LineTool, Path=LineThickness, Converter={StaticResource SizeConverter}, ConverterParameter={StaticResource Small}}"
538
+                                Style="{StaticResource SizeButton}">
539
+                                <Ellipse
540
+                                    Width="{StaticResource Small}"
541
+                                    Height="{StaticResource Small}"
542
+                                    Fill="{StaticResource ToolColor}" />
543
+                            </control:ToolButton>
544
+                            <control:ToolButton
545
+                                GroupName="LineTool"
546
+                                IsChecked="{Binding ElementName=PART_LineTool, Path=LineThickness, Converter={StaticResource SizeConverter}, ConverterParameter={StaticResource Medium}}"
547
+                                Style="{StaticResource SizeButton}">
548
+                                <Ellipse
549
+                                    Width="{StaticResource Medium}"
550
+                                    Height="{StaticResource Medium}"
551
+                                    Fill="{StaticResource ToolColor}" />
552
+                            </control:ToolButton>
553
+                            <control:ToolButton
554
+                                GroupName="LineTool"
555
+                                IsChecked="{Binding ElementName=PART_LineTool, Path=LineThickness, Converter={StaticResource SizeConverter}, ConverterParameter={StaticResource Large}}"
556
+                                Style="{StaticResource SizeButton}">
557
+                                <Ellipse
558
+                                    Width="{StaticResource Large}"
559
+                                    Height="{StaticResource Large}"
560
+                                    Fill="{StaticResource ToolColor}" />
561
+                            </control:ToolButton>
562
+
563
+                            <Grid
564
+                                Width="29"
565
+                                Height="29"
566
+                                Margin="5,0"
567
+                                Background="White">
568
+                                <Border BorderBrush="{StaticResource ToolButtonBorder}" BorderThickness="1">
569
+                                    <Canvas
570
+                                        Width="25"
571
+                                        Height="25"
572
+                                        Background="{Binding ElementName=PART_LineTool, Path=LineBrush}" />
573
+                                </Border>
574
+                            </Grid>
575
+                            <ListBox Style="{StaticResource ColorBarStyle}">
576
+                                <ListBox.ItemTemplate>
577
+                                    <DataTemplate>
578
+                                        <control:ToolButton
579
+                                            GroupName="LineColor"
580
+                                            LineColor="{Binding ., Converter={StaticResource ColorConverter}}"
581
+                                            Style="{StaticResource ColorButton}">
582
+                                            <Rectangle
583
+                                                Width="12"
584
+                                                Height="12"
585
+                                                Fill="{Binding}"
586
+                                                Stroke="{StaticResource ToolButtonBorder}"
587
+                                                StrokeThickness="1" />
588
+                                        </control:ToolButton>
589
+                                    </DataTemplate>
590
+                                </ListBox.ItemTemplate>
591
+                            </ListBox>
592
+                        </control:LineTool>
593
+
594
+                        <control:TextTool
595
+                            x:Name="PART_TextTool"
596
+                            Style="{StaticResource BaseSizeColor}"
597
+                            Visibility="{Binding RelativeSource={RelativeSource AncestorType=control:SizeColorBar}, Path=Selected, Converter={StaticResource ToolConverter}, ConverterParameter=Text}">
598
+                            <TextBlock
599
+                                Width="24"
600
+                                Height="30"
601
+                                Margin="3,2"
602
+                                FontSize="23"
603
+                                FontWeight="Bold"
604
+                                Foreground="{StaticResource ToolColor}"
605
+                                Text="A"
606
+                                TextAlignment="Center" />
607
+                            <ComboBox
608
+                                Width="42"
609
+                                Height="21"
610
+                                Margin="0,7,6,7"
611
+                                DisplayMemberPath="Key"
612
+                                ItemsSource="{x:Static control:TextTool.FontSizes}"
613
+                                SelectedItem="12"
614
+                                SelectedValue="{Binding ElementName=PART_TextTool, Path=FontSize}"
615
+                                SelectedValuePath="Key"
616
+                                Style="{x:Null}" />
617
+
618
+                            <Grid
619
+                                Width="29"
620
+                                Height="29"
621
+                                Margin="5,0"
622
+                                Background="White">
623
+                                <Border BorderBrush="{StaticResource ToolButtonBorder}" BorderThickness="1">
624
+                                    <Canvas
625
+                                        Width="25"
626
+                                        Height="25"
627
+                                        Background="{Binding ElementName=PART_TextTool, Path=LineBrush}" />
628
+                                </Border>
629
+                            </Grid>
630
+                            <ListBox Style="{StaticResource ColorBarStyle}">
631
+                                <ListBox.ItemTemplate>
632
+                                    <DataTemplate>
633
+                                        <control:ToolButton
634
+                                            GroupName="TextColor"
635
+                                            LineColor="{Binding ., Converter={StaticResource ColorConverter}}"
636
+                                            Style="{StaticResource ColorButton}">
637
+                                            <Rectangle
638
+                                                Width="12"
639
+                                                Height="12"
640
+                                                Fill="{Binding}"
641
+                                                Stroke="{StaticResource ToolButtonBorder}"
642
+                                                StrokeThickness="1" />
643
+                                        </control:ToolButton>
644
+                                    </DataTemplate>
645
+                                </ListBox.ItemTemplate>
646
+                            </ListBox>
647
+                        </control:TextTool>
648
+                    </Grid>
649
+                </ControlTemplate>
650
+            </Setter.Value>
651
+        </Setter>
652
+    </Style>
653
+
654
+    <!--  文字输入框  -->
655
+    <Style TargetType="{x:Type control:TextBoxControl}">
656
+        <Setter Property="Template">
657
+            <Setter.Value>
658
+                <ControlTemplate TargetType="{x:Type control:TextBoxControl}">
659
+                    <Grid FocusManager.FocusedElement="{Binding ElementName=PART_TextBox}">
660
+                        <Border
661
+                            Width="{Binding ElementName=PART_TextBox, Path=Width}"
662
+                            Height="{Binding ElementName=PART_TextBox, Path=Height}"
663
+                            BorderThickness="3">
664
+                            <Border.BorderBrush>
665
+                                <LinearGradientBrush MappingMode="Absolute" SpreadMethod="Repeat" StartPoint="0,5" EndPoint="5,0">
666
+                                    <LinearGradientBrush.GradientStops>
667
+                                        <GradientStop Offset="0" Color="{Binding RelativeSource={RelativeSource AncestorType=control:TextBoxControl}, Path=BorderColor}" />
668
+                                        <GradientStop Offset="0.2" Color="{Binding RelativeSource={RelativeSource AncestorType=control:TextBoxControl}, Path=BorderColor}" />
669
+                                        <GradientStop Offset="0.4" Color="Transparent" />
670
+                                        <GradientStop Offset="0.6" Color="Transparent" />
671
+                                        <GradientStop Offset="0.8" Color="{Binding RelativeSource={RelativeSource AncestorType=control:TextBoxControl}, Path=BorderColor}" />
672
+                                        <GradientStop Offset="1" Color="{Binding RelativeSource={RelativeSource AncestorType=control:TextBoxControl}, Path=BorderColor}" />
673
+                                    </LinearGradientBrush.GradientStops>
674
+                                </LinearGradientBrush>
675
+                            </Border.BorderBrush>
676
+                            <TextBox
677
+                                Name="PART_TextBox"
678
+                                MinWidth="30"
679
+                                AcceptsReturn="True"
680
+                                Background="Transparent"
681
+                                BorderThickness="0"
682
+                                FontSize="{TemplateBinding FontSize}"
683
+                                Foreground="{TemplateBinding Foreground}"
684
+                                TextWrapping="Wrap" />
685
+                        </Border>
686
+                    </Grid>
687
+                    <ControlTemplate.Triggers>
688
+                        <Trigger Property="IsMouseOver" Value="True">
689
+                            <Setter Property="BorderColor" Value="Blue" />
690
+                        </Trigger>
691
+                        <Trigger Property="MyFocus" Value="True">
692
+                            <Setter Property="BorderColor" Value="Blue" />
693
+                        </Trigger>
694
+                    </ControlTemplate.Triggers>
695
+                </ControlTemplate>
696
+            </Setter.Value>
697
+        </Setter>
698
+    </Style>
699
+</ResourceDictionary>

+ 35
- 17
XHWK.WKTool/XHMicroLessonSystemWindow.xaml Datei anzeigen

@@ -122,21 +122,39 @@
122 122
                 </StackPanel>
123 123
             </Grid>
124 124
             <!--主内容-->
125
-            <Grid Grid.Row="1" x:Name="GridMain"  Margin="20,0,20,0" Background="#FFFFFF" Height="793.700787401575" Width="1142.51968503937" Visibility="Visible">
126
-                <Grid.RowDefinitions>
127
-                    <RowDefinition Height="auto"/>
128
-                </Grid.RowDefinitions>
129
-                
130
-                <Image Grid.Row="0" x:Name="imgCanvas" Height="760"/>
131
-                <InkCanvas Grid.Row="0" x:Name="blackboard_canvas" Background="Transparent" Visibility="Visible">
132
-                </InkCanvas>
125
+            <Grid Grid.Row="1" x:Name="GridMain"  Margin="20,0,20,0" Background="#FFFFFF" Height="793.700787401575" Width="1142.51968503937" Visibility="Collapsed">
126
+                <Grid.Resources>
127
+                    <TransformGroup x:Key="ImageTransformResource">
128
+                        <ScaleTransform />
129
+                        <TranslateTransform />
130
+                    </TransformGroup>
131
+                </Grid.Resources>
132
+                <Grid.ColumnDefinitions>
133
+                    <ColumnDefinition Width="79*" />
134
+                    <ColumnDefinition Width="1063*"/>
135
+                </Grid.ColumnDefinitions>
136
+                <Rectangle Grid.Column="0" x:Name="MasterImage"
137
+MouseLeftButtonDown="MasterImage_MouseLeftButtonDown"
138
+MouseLeftButtonUp="MasterImage_MouseLeftButtonUp"
139
+MouseMove="MasterImage_MouseMove"
140
+MouseWheel="MasterImage_MouseWheel" Grid.ColumnSpan="2" Margin="0,0,0.4,-0.299">
141
+                    <Rectangle.Fill>
142
+                        <VisualBrush Transform="{StaticResource ImageTransformResource}" Stretch="Uniform">
143
+                            <VisualBrush.Visual>
144
+                                <Image x:Name="imgCanvas" Height="760"/>
145
+                            </VisualBrush.Visual>
146
+                        </VisualBrush>
147
+                    </Rectangle.Fill>
148
+                </Rectangle>
133 149
 
150
+                <!--<Image Grid.Row="0" x:Name="imgCanvas" Height="760"/>-->
151
+                <InkCanvas Grid.Row="0" x:Name="blackboard_canvas" Background="Transparent" Visibility="Visible" Grid.ColumnSpan="2" Margin="0,0,0.4,-0.299"/>
134 152
                 <!--摄像头-->
135
-                <wfi:WindowsFormsHost Grid.Row="0" Grid.Column="0" x:Name="wfhCamera" Height="124" Width="172" HorizontalAlignment="Right" Margin="10,10,10,10" VerticalAlignment="Top">
153
+                <wfi:WindowsFormsHost Grid.Row="0" Grid.Column="1" x:Name="wfhCamera" Height="124" Width="172" HorizontalAlignment="Right" Margin="0,10,10.4,0" VerticalAlignment="Top">
136 154
                     <aforge:VideoSourcePlayer x:Name="player" Height="124" Width="172"  />
137 155
                 </wfi:WindowsFormsHost>
138 156
                 <StackPanel Grid.Row="0" Orientation="Horizontal" Background="#FFFFFF" Width="240" HorizontalAlignment="Right"
139
-            Height="58" Margin="0,700,50,0">
157
+            Height="58" Margin="0,718,50.4,17.701" Grid.Column="1">
140 158
                     <Button Cursor="Hand" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}"
141 159
                     x:Name="last_button"
142 160
                     Width="60"
@@ -193,7 +211,7 @@
193 211
                 </StackPanel>
194 212
             </Grid>
195 213
             <!--设置-->
196
-            <Grid Grid.Row="1" x:Name="gridSetUp" Margin="20,0,20,0" Background="#FFFFFF" Visibility="Collapsed">
214
+            <Grid Grid.Row="1" x:Name="gridSetUp" Margin="20,0,20,0" Background="#FFFFFF" Visibility="Visible">
197 215
                 <Grid.RowDefinitions>
198 216
                     <RowDefinition Height="120"/>
199 217
                     <RowDefinition Height="90"/>
@@ -210,9 +228,9 @@
210 228
                 </StackPanel>
211 229
                 <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Left">
212 230
                     <TextBlock Text="视频格式" FontSize="16" Foreground="#2D8CF0"/>
213
-                    <RadioButton Cursor="Hand" Content="MP4" FontSize="14" Foreground="#333333" Margin="10,2,0,0" IsChecked="True"/>
214
-                    <RadioButton Cursor="Hand" Content="FLV" FontSize="14" Foreground="#333333" Margin="20,2,0,0"/>
215
-                    <RadioButton Cursor="Hand" Content="AVI" FontSize="14" Foreground="#333333" Margin="20,2,0,0"/>
231
+                    <RadioButton x:Name="rbnMP4" Cursor="Hand" Content="MP4" FontSize="14" Foreground="#333333" Margin="10,2,0,0" IsChecked="True"/>
232
+                    <RadioButton x:Name="rbnFLV" Cursor="Hand" Content="FLV" FontSize="14" Foreground="#333333" Margin="20,2,0,0"/>
233
+                    <RadioButton x:Name="rbnAVI" Cursor="Hand" Content="AVI" FontSize="14" Foreground="#333333" Margin="20,2,0,0"/>
216 234
                 </StackPanel>
217 235
                 <StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Left">
218 236
                     <TextBlock Text="头像位置" FontSize="16" Foreground="#2D8CF0"/>
@@ -223,11 +241,11 @@
223 241
                 </StackPanel>
224 242
                 <StackPanel Grid.Row="3" Orientation="Horizontal" HorizontalAlignment="Left">
225 243
                     <TextBlock Text="视频声音" FontSize="16" Foreground="#2D8CF0"/>
226
-                    <RadioButton Cursor="Hand" Content="有" FontSize="14" Foreground="#333333" Margin="10,2,0,0" IsChecked="True"/>
227
-                    <RadioButton Cursor="Hand" Content="无" FontSize="14" Foreground="#333333" Margin="20,2,0,0"/>
244
+                    <RadioButton x:Name="rbnY" Cursor="Hand" Content="有" FontSize="14" Foreground="#333333" Margin="10,2,0,0" IsChecked="True"/>
245
+                    <RadioButton x:Name="rbnN" Cursor="Hand" Content="无" FontSize="14" Foreground="#333333" Margin="20,2,0,0"/>
228 246
                 </StackPanel>
229 247
                 <StackPanel Grid.Row="4" Orientation="Horizontal" HorizontalAlignment="Left">
230
-                    <TextBlock Text="文件路径" FontSize="16" Foreground="#2D8CF0" Padding="2,36,10,0"/>
248
+                    <TextBlock x:Name="txbFilePath" Text="文件路径" FontSize="16" Foreground="#2D8CF0" Padding="2,36,10,0"/>
231 249
                     <!--输入框-->
232 250
                     <Border Background="#CDD6E0" Width="525" Height="43" CornerRadius="3">
233 251
                         <TextBox x:Name="txbStoragePath" Text="D:\" FontSize="16" Foreground="#333333" Padding="5,12,2,2" Width="523" Height="42" BorderBrush="{x:Null}" BorderThickness="0"/>

+ 211
- 21
XHWK.WKTool/XHMicroLessonSystemWindow.xaml.cs Datei anzeigen

@@ -17,6 +17,23 @@ using System.Windows.Media.Imaging;
17 17
 
18 18
 using XHWK.Model;
19 19
 
20
+
21
+using System;
22
+using System.Collections.Generic;
23
+
24
+using System.Text;
25
+using System.Windows;
26
+using System.Windows.Controls;
27
+using System.Windows.Data;
28
+using System.Windows.Documents;
29
+using System.Windows.Input;
30
+using System.Windows.Media;
31
+using System.Windows.Media.Imaging;
32
+using System.Windows.Navigation;
33
+using System.Windows.Shapes;
34
+using System.Diagnostics;
35
+using ComeCapture;
36
+
20 37
 namespace XHWK.WKTool
21 38
 {
22 39
     /// <summary>
@@ -34,6 +51,8 @@ namespace XHWK.WKTool
34 51
         public readonly BlackboardNew myblackboard;
35 52
         private System.Windows.Forms.DialogResult result;
36 53
         private System.Windows.Forms.OpenFileDialog ofd;
54
+        //声明一个 DrawingAttributes 类型的变量  
55
+        DrawingAttributes drawingAttributes;
37 56
         #endregion
38 57
 
39 58
         #region 初始化
@@ -47,6 +66,17 @@ namespace XHWK.WKTool
47 66
             APP.pageData.pagenum = 1;
48 67
             APP.pageData.currpage = 1;
49 68
             DataContext = APP.pageData;
69
+
70
+            txbStoragePath.Text = FileToolsCommon.GetConfigValue("VideoType");
71
+            if (FileToolsCommon.GetConfigValue("IsSound").Equals("true"))
72
+            {
73
+                rbnY.IsChecked = true;
74
+            }
75
+            else
76
+            {
77
+                rbnN.IsChecked = true;
78
+            }
79
+            txbStoragePath.Text = FileToolsCommon.GetConfigValue("VideoSavePath");
50 80
             Initialize();
51 81
         }
52 82
         /// <summary>
@@ -173,6 +203,56 @@ namespace XHWK.WKTool
173 203
         /// <param name="e"></param>
174 204
         private void BtnSave_Click(object sender, RoutedEventArgs e)
175 205
         {
206
+            #region 合法性判断
207
+            if (string.IsNullOrWhiteSpace(txbStoragePath.Text.Trim()))
208
+            {
209
+                System.Windows.MessageBox.Show("路径不可为空!");
210
+                return;
211
+            }
212
+            string temp = FileToolsCommon.GetLegalPath(txbStoragePath.Text) + APP.WKData.WkName.Trim() + "/";
213
+            if (!APP.WKData.WkPath.Equals(temp))
214
+            {
215
+                APP.WKData.WkPath = FileToolsCommon.GetLegalPath(txbStoragePath.Text) + APP.WKData.WkName.Trim() + "/";
216
+                if (FileToolsCommon.IsExistDirectory(APP.WKData.WkPath))
217
+                {
218
+                    //微课已存在
219
+                    MessageBoxResult dr = System.Windows.MessageBox.Show("讲解已存在是否覆盖?", "提示", MessageBoxButton.OKCancel);
220
+                    if (dr == MessageBoxResult.OK)
221
+                    {
222
+                        FileToolsCommon.DeleteDirectory(APP.WKData.WkPath);
223
+                    }
224
+                    else
225
+                    {
226
+                        return;
227
+                    }
228
+                }
229
+                //创建文件夹
230
+                FileToolsCommon.CreateDirectory(APP.WKData.WkPath);
231
+            }
232
+            #endregion
233
+
234
+
235
+            if (rbnMP4.IsChecked == true)
236
+            {
237
+                //存储文件
238
+                FileToolsCommon.SetConfigValue("VideoType", "1");
239
+            }
240
+            else if (rbnFLV.IsChecked == true)
241
+            {
242
+                FileToolsCommon.SetConfigValue("VideoType", "2");
243
+            }
244
+            else
245
+            {
246
+                FileToolsCommon.SetConfigValue("VideoType", "3");
247
+            }
248
+            if (rbnY.IsChecked == true)
249
+            {
250
+                FileToolsCommon.SetConfigValue("IsSound", "true");
251
+            }
252
+            else
253
+            {
254
+                FileToolsCommon.SetConfigValue("IsSound", "false");
255
+            }
176 256
             GridMain.Visibility = Visibility.Visible;
177 257
             gridSetUp.Visibility = Visibility.Collapsed;
178 258
         }
@@ -223,8 +303,6 @@ namespace XHWK.WKTool
223 303
             //设置 DrawingAttributes 的 Color 属性设置颜色  
224 304
             drawingAttributes.Color = Colors.White;
225 305
         }
226
-        //声明一个 DrawingAttributes 类型的变量  
227
-        DrawingAttributes drawingAttributes;
228 306
         /// <summary>
229 307
         /// 画笔颜色事件 红色
230 308
         /// </summary>
@@ -273,7 +351,7 @@ namespace XHWK.WKTool
273 351
             drawingAttributes.Color = Colors.DeepSkyBlue;
274 352
         }
275 353
         /// <summary>
276
-        /// 画笔粗细 细
354
+        /// 画笔粗细事件
277 355
         /// </summary>
278 356
         /// <param name="sender"></param>
279 357
         /// <param name="e"></param>
@@ -283,7 +361,7 @@ namespace XHWK.WKTool
283 361
             drawingAttributes.Height = 1;
284 362
         }
285 363
         /// <summary>
286
-        /// 画笔粗细 中
364
+        /// 画笔粗细事件
287 365
         /// </summary>
288 366
         /// <param name="sender"></param>
289 367
         /// <param name="e"></param>
@@ -293,7 +371,7 @@ namespace XHWK.WKTool
293 371
             drawingAttributes.Height = 3;
294 372
         }
295 373
         /// <summary>
296
-        /// 画笔粗细 粗
374
+        /// 画笔粗细事件
297 375
         /// </summary>
298 376
         /// <param name="sender"></param>
299 377
         /// <param name="e"></param>
@@ -303,7 +381,7 @@ namespace XHWK.WKTool
303 381
             drawingAttributes.Height = 5;
304 382
         }
305 383
         /// <summary>
306
-        /// 登陆
384
+        /// 登陆事件
307 385
         /// </summary>
308 386
         /// <param name="sender"></param>
309 387
         /// <param name="e"></param>
@@ -347,9 +425,39 @@ namespace XHWK.WKTool
347 425
                 Login();
348 426
                 return;
349 427
             }
428
+            string time = GetTimeStamp();
429
+            string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + time + ".jpg";
430
+            ImageHelper.GetScreenshot(new System.Drawing.Rectangle(0, 0, 0, 0), desktopPath);
431
+
432
+            if (APP.W_JieTuWindow != null)
433
+            {
434
+                APP.W_JieTuWindow.initialization();
435
+                APP.W_JieTuWindow.Screenshot();
436
+                APP.W_JieTuWindow.WindowState = WindowState.Maximized;
437
+                APP.W_JieTuWindow.Visibility = Visibility.Visible;
438
+            }
439
+            else
440
+            {
441
+                APP.W_JieTuWindow = new JieTuWindow();
442
+                // 订阅事件
443
+                //APP.W_JieTuWindow.ChangeTextEvent += new ChangeTextHandler(frm_ChangeTextEvent);
444
+                //APP.W_JieTuWindow.click_closeJietuWindowClick += JietuWindow_click_closeJietuWindowClick;
445
+                APP.W_JieTuWindow.Show();
446
+            }
447
+
448
+            //imgCanvas.Source = new BitmapImage(new Uri(desktopPath));
350 449
         }
351 450
         /// <summary>
352
-        /// 导入
451
+        /// 获取时间戳
452
+        /// </summary>
453
+        /// <returns></returns>
454
+        public string GetTimeStamp()
455
+        {
456
+            TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0);
457
+            return Convert.ToInt64(ts.TotalSeconds).ToString();
458
+        }
459
+        /// <summary>
460
+        /// 导入事件
353 461
         /// </summary>
354 462
         /// <param name="sender"></param>
355 463
         /// <param name="e"></param>
@@ -401,15 +509,30 @@ namespace XHWK.WKTool
401 509
                     string filepath = ofd.FileName;
402 510
                     string path = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
403 511
                     APP.Paths = ConvertWordToImage(filepath, path, "", 0, 0, null, 0).ToArray();
404
-                    if (!string.IsNullOrWhiteSpace(txbCurrpage.Text) && Convert.ToInt32(txbCurrpage.Text) < APP.Paths.Length)
512
+
513
+                    for (int i = 0; i < APP.Paths.Length; i++)
514
+                    {
515
+                        APP.pageData.pagenum += 1;
516
+                        //APP.pageData.currpage = APP.pageData.pagenum;
517
+                        //myblackboard.changepage(APP.pageData.currpage - 1);
518
+                    }
519
+                    if (APP.pageData.pagenum > 1)
520
+                    {
521
+                        APP.pageData.pagenum -= 1;
522
+                    }
523
+                    if (APP.pageData.currpage > 1)
405 524
                     {
406
-                        imgCanvas.Source = new BitmapImage(new Uri(APP.Paths[Convert.ToInt32(txbCurrpage.Text) - 1]));
525
+                        //APP.pageData.currpage -= 1;
526
+                        //myblackboard.changepage(APP.pageData.currpage - 1);
527
+                    }
528
+                    if (!string.IsNullOrWhiteSpace(txbCurrpage.Text) && APP.pageData.currpage < APP.Paths.Length)
529
+                    {
530
+                        imgCanvas.Source = new BitmapImage(new Uri(APP.Paths[APP.pageData.currpage - 1]));
407 531
                     }
408 532
                     else
409 533
                     {
410 534
                         imgCanvas.Source = null;
411 535
                     }
412
-
413 536
                 }
414 537
             }
415 538
         }
@@ -442,7 +565,7 @@ namespace XHWK.WKTool
442 565
         /// <summary>
443 566
         /// 图片
444 567
         /// </summary>
445
-        List<string> RsImgName =null; 
568
+        List<string> RsImgName = null;
446 569
         /// <summary>
447 570
         /// 是否开始截图计数
448 571
         /// </summary>
@@ -678,7 +801,7 @@ namespace XHWK.WKTool
678 801
         #endregion
679 802
 
680 803
         /// <summary>
681
-        /// 增加
804
+        /// 增加事件
682 805
         /// </summary>
683 806
         /// <param name="sender"></param>
684 807
         /// <param name="e"></param>
@@ -691,7 +814,7 @@ namespace XHWK.WKTool
691 814
             }
692 815
         }
693 816
         /// <summary>
694
-        /// 打印
817
+        /// 打印事件
695 818
         /// </summary>
696 819
         /// <param name="sender"></param>
697 820
         /// <param name="e"></param>
@@ -725,9 +848,9 @@ namespace XHWK.WKTool
725 848
                 myblackboard.changepage(APP.pageData.currpage - 1);
726 849
                 if (APP.Paths.Length > 0)
727 850
                 {
728
-                    if (!string.IsNullOrWhiteSpace(txbCurrpage.Text) && Convert.ToInt32(txbCurrpage.Text) < APP.Paths.Length && Convert.ToInt32(txbCurrpage.Text) > 1)
851
+                    if (!string.IsNullOrWhiteSpace(txbCurrpage.Text) && APP.pageData.currpage < APP.Paths.Length&& APP.pageData.currpage > 0)
729 852
                     {
730
-                        imgCanvas.Source = new BitmapImage(new Uri(APP.Paths[Convert.ToInt32(txbCurrpage.Text) - 2]));
853
+                        imgCanvas.Source = new BitmapImage(new Uri(APP.Paths[APP.pageData.currpage - 1]));
731 854
                     }
732 855
                     else
733 856
                     {
@@ -750,9 +873,10 @@ namespace XHWK.WKTool
750 873
                 myblackboard.changepage(APP.pageData.currpage - 1);
751 874
                 if (APP.Paths.Length > 0)
752 875
                 {
753
-                    if (!string.IsNullOrWhiteSpace(txbCurrpage.Text) && Convert.ToInt32(txbCurrpage.Text) + 1 < APP.Paths.Length)
876
+
877
+                    if (!string.IsNullOrWhiteSpace(txbCurrpage.Text) && APP.pageData.currpage < APP.Paths.Length)
754 878
                     {
755
-                        imgCanvas.Source = new BitmapImage(new Uri(APP.Paths[Convert.ToInt32(txbCurrpage.Text)]));
879
+                        imgCanvas.Source = new BitmapImage(new Uri(APP.Paths[APP.pageData.currpage-1]));
756 880
                     }
757 881
                     else
758 882
                     {
@@ -794,9 +918,9 @@ namespace XHWK.WKTool
794 918
                 Aspose.Words.Document doc = new Aspose.Words.Document(wordInputPath);
795 919
                 // validate parameter
796 920
                 if (doc == null) { throw new Exception("Word文件无效或者Word文件被加密!"); }
797
-                if (imageOutputPath.Trim().Length == 0) { imageOutputPath = Path.GetDirectoryName(wordInputPath); }
921
+                if (imageOutputPath.Trim().Length == 0) { imageOutputPath = System.IO.Path.GetDirectoryName(wordInputPath); }
798 922
                 if (!Directory.Exists(imageOutputPath)) { Directory.CreateDirectory(imageOutputPath); }
799
-                if (imageName.Trim().Length == 0) { imageName = Path.GetFileNameWithoutExtension(wordInputPath); }
923
+                if (imageName.Trim().Length == 0) { imageName = System.IO.Path.GetFileNameWithoutExtension(wordInputPath); }
800 924
                 if (startPageNum <= 0) { startPageNum = 1; }
801 925
                 if (endPageNum > doc.PageCount || endPageNum <= 0) { endPageNum = doc.PageCount; }
802 926
                 if (startPageNum > endPageNum) { int tempPageNum = startPageNum; startPageNum = endPageNum; endPageNum = startPageNum; }
@@ -812,8 +936,8 @@ namespace XHWK.WKTool
812 936
                 for (int i = startPageNum; i <= endPageNum; i++)
813 937
                 {
814 938
                     imageSaveOptions.PageIndex = i - 1;
815
-                    doc.Save(Path.Combine(imageOutputPath, imageName) + "_" + APP.num.ToString() + "." + imageFormat.ToString(), imageSaveOptions);
816
-                    images.Add(Path.Combine(imageOutputPath, imageName) + "_" + APP.num.ToString() + "." + imageFormat.ToString());
939
+                    doc.Save(System.IO.Path.Combine(imageOutputPath, imageName) + "_" + APP.num.ToString() + "." + imageFormat.ToString(), imageSaveOptions);
940
+                    images.Add(System.IO.Path.Combine(imageOutputPath, imageName) + "_" + APP.num.ToString() + "." + imageFormat.ToString());
817 941
                     APP.num++;
818 942
                 }
819 943
                 imageSaveOptions = null;
@@ -852,5 +976,71 @@ namespace XHWK.WKTool
852 976
 
853 977
             return sf;
854 978
         }
979
+
980
+
981
+
982
+
983
+
984
+
985
+        private bool m_IsMouseLeftButtonDown;
986
+
987
+        private void MasterImage_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
988
+        {
989
+            Rectangle rectangle = sender as Rectangle;
990
+            if (rectangle == null)
991
+                return;
992
+
993
+            rectangle.ReleaseMouseCapture();
994
+            m_IsMouseLeftButtonDown = false;
995
+        }
996
+
997
+        private Point m_PreviousMousePoint;
998
+        private void MasterImage_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
999
+        {
1000
+            Rectangle rectangle = sender as Rectangle;
1001
+            if (rectangle == null)
1002
+                return;
1003
+
1004
+            rectangle.CaptureMouse();
1005
+            m_IsMouseLeftButtonDown = true;
1006
+            m_PreviousMousePoint = e.GetPosition(rectangle);
1007
+        }
1008
+
1009
+        private void MasterImage_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
1010
+        {
1011
+            Rectangle rectangle = sender as Rectangle;
1012
+            if (rectangle == null)
1013
+                return;
1014
+
1015
+            if (m_IsMouseLeftButtonDown)
1016
+                DoImageMove(rectangle, e);
1017
+        }
1018
+
1019
+        private void DoImageMove(Rectangle rectangle, System.Windows.Input.MouseEventArgs e)
1020
+        {
1021
+            //Debug.Assert(e.LeftButton == MouseButtonState.Pressed); 
1022
+            if (e.LeftButton != MouseButtonState.Pressed)
1023
+                return;
1024
+
1025
+            TransformGroup group = GridMain.FindResource("ImageTransformResource") as TransformGroup;
1026
+            Debug.Assert(group != null);
1027
+            TranslateTransform transform = group.Children[1] as TranslateTransform;
1028
+            Point position = e.GetPosition(rectangle);
1029
+            transform.X += position.X - m_PreviousMousePoint.X;
1030
+            transform.Y += position.Y - m_PreviousMousePoint.Y;
1031
+
1032
+            m_PreviousMousePoint = position;
1033
+        }
1034
+
1035
+        private void MasterImage_MouseWheel(object sender, MouseWheelEventArgs e)
1036
+        {
1037
+            TransformGroup group = GridMain.FindResource("ImageTransformResource") as TransformGroup;
1038
+            Debug.Assert(group != null);
1039
+            ScaleTransform transform = group.Children[0] as ScaleTransform;
1040
+            transform.ScaleX += e.Delta * 0.001;
1041
+            transform.ScaleY += e.Delta * 0.001;
1042
+        }
1043
+
1044
+
855 1045
     }
856 1046
 }

+ 34
- 0
XHWK.WKTool/XHWK.WKTool.csproj Datei anzeigen

@@ -82,6 +82,21 @@
82 82
     </Reference>
83 83
   </ItemGroup>
84 84
   <ItemGroup>
85
+    <Compile Include="Controls\ArrowTool.cs" />
86
+    <Compile Include="Controls\EllipseTool.cs" />
87
+    <Compile Include="Controls\ImageEditBar.cs" />
88
+    <Compile Include="Controls\KeyboardTextBox.cs" />
89
+    <Compile Include="Controls\LineTool.cs" />
90
+    <Compile Include="Controls\MainImage.cs" />
91
+    <Compile Include="Controls\RectangleTool.cs" />
92
+    <Compile Include="Controls\SizeColorBar.cs" />
93
+    <Compile Include="Controls\TextBoxControl.cs" />
94
+    <Compile Include="Controls\TextTool.cs" />
95
+    <Compile Include="Controls\ToolButton.cs" />
96
+    <Compile Include="Controls\ZoomThumb.cs" />
97
+    <Compile Include="Converters\ColorConverter.cs" />
98
+    <Compile Include="Converters\SizeConverter.cs" />
99
+    <Compile Include="Converters\ToolConverter.cs" />
85 100
     <Compile Include="CountdownWindow.xaml.cs">
86 101
       <DependentUpon>CountdownWindow.xaml</DependentUpon>
87 102
     </Compile>
@@ -90,9 +105,19 @@
90 105
     <Compile Include="FileDirectoryWindow.xaml.cs">
91 106
       <DependentUpon>FileDirectoryWindow.xaml</DependentUpon>
92 107
     </Compile>
108
+    <Compile Include="Helpers\ScreenHelper.cs" />
109
+    <Compile Include="Helpers\WpfHelper.cs" />
110
+    <Compile Include="JieTuWindow.xaml.cs">
111
+      <DependentUpon>JieTuWindow.xaml</DependentUpon>
112
+    </Compile>
93 113
     <Compile Include="LoginWindow.xaml.cs">
94 114
       <DependentUpon>LoginWindow.xaml</DependentUpon>
95 115
     </Compile>
116
+    <Compile Include="Models\AppModel.cs" />
117
+    <Compile Include="Models\Direction.cs" />
118
+    <Compile Include="Models\EntityBase.cs" />
119
+    <Compile Include="Models\Limit.cs" />
120
+    <Compile Include="Models\Tool.cs" />
96 121
     <Compile Include="ScreenRecordingToolbarWindow.xaml.cs">
97 122
       <DependentUpon>ScreenRecordingToolbarWindow.xaml</DependentUpon>
98 123
     </Compile>
@@ -115,6 +140,14 @@
115 140
       <Generator>MSBuild:Compile</Generator>
116 141
       <SubType>Designer</SubType>
117 142
     </Page>
143
+    <Page Include="JieTuWindow.xaml">
144
+      <SubType>Designer</SubType>
145
+      <Generator>MSBuild:Compile</Generator>
146
+    </Page>
147
+    <Page Include="Themes\Generic.xaml">
148
+      <Generator>MSBuild:Compile</Generator>
149
+      <SubType>Designer</SubType>
150
+    </Page>
118 151
     <Page Include="XHMicroLessonSystemWindow.xaml">
119 152
       <Generator>MSBuild:Compile</Generator>
120 153
       <SubType>Designer</SubType>
@@ -247,5 +280,6 @@
247 280
     <Resource Include="Images\class_p2.png" />
248 281
     <Resource Include="Images\class_p3.png" />
249 282
   </ItemGroup>
283
+  <ItemGroup />
250 284
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
251 285
 </Project>

Laden…
Abbrechen
Speichern