Explorar el Código

代码优化

master
张剑 hace 1 año
padre
commit
3d13fcc42c

+ 1
- 0
XHWK.WKTool/Converters/ColorConverter.cs Ver fichero

@@ -8,6 +8,7 @@ namespace ComeCapture.Converters
8 8
     {
9 9
         public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
10 10
         {
11
+            // ReSharper disable once PossibleNullReferenceException
11 12
             return new SolidColorBrush((Color)System.Windows.Media.ColorConverter.ConvertFromString(value.ToString()));
12 13
         }
13 14
 

+ 1
- 1
XHWK.WKTool/Converters/SizeConverter.cs Ver fichero

@@ -7,7 +7,7 @@ namespace ComeCapture.Converters
7 7
     {
8 8
         public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
9 9
         {
10
-            return int.Parse(value.ToString()) == int.Parse(parameter.ToString());
10
+            return parameter != null && value != null && int.Parse(value.ToString()) == int.Parse(parameter.ToString());
11 11
         }
12 12
 
13 13
         public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)

+ 1
- 1
XHWK.WKTool/Converters/ToolConverter.cs Ver fichero

@@ -8,7 +8,7 @@ namespace ComeCapture.Converters
8 8
     {
9 9
         public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
10 10
         {
11
-            return value.ToString() == parameter.ToString() ? Visibility.Visible : Visibility.Collapsed;
11
+            return parameter != null && value != null && value.ToString() == parameter.ToString() ? Visibility.Visible : Visibility.Collapsed;
12 12
         }
13 13
 
14 14
         public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)

+ 36
- 36
XHWK.WKTool/Models/AppModel.cs Ver fichero

@@ -8,27 +8,27 @@ namespace ComeCapture
8 8
     {
9 9
         public AppModel()
10 10
         {
11
-            _Current = this;
11
+            _current = this;
12 12
         }
13 13
 
14 14
         #region 属性 Current
15 15
 
16
-        private static AppModel _Current = null;
16
+        private static AppModel _current;
17 17
 
18
-        public static AppModel Current => _Current;
18
+        public static AppModel Current => _current;
19 19
 
20 20
         #endregion 属性 Current
21 21
 
22 22
         #region 属性 MaskLeftWidth
23 23
 
24
-        private double _MaskLeftWidth = JieTuWindow.ScreenWidth;
24
+        private double _maskLeftWidth = JieTuWindow.ScreenWidth;
25 25
 
26 26
         public double MaskLeftWidth
27 27
         {
28
-            get => _MaskLeftWidth;
28
+            get => _maskLeftWidth;
29 29
             set
30 30
             {
31
-                _MaskLeftWidth = value;
31
+                _maskLeftWidth = value;
32 32
                 ShowSizeLeft = value;
33 33
                 RaisePropertyChanged(() => MaskLeftWidth);
34 34
             }
@@ -38,14 +38,14 @@ namespace ComeCapture
38 38
 
39 39
         #region 属性 MaskRightWidth
40 40
 
41
-        private double _MaskRightWidth = 0;
41
+        private double _maskRightWidth;
42 42
 
43 43
         public double MaskRightWidth
44 44
         {
45
-            get => _MaskRightWidth;
45
+            get => _maskRightWidth;
46 46
             set
47 47
             {
48
-                _MaskRightWidth = value;
48
+                _maskRightWidth = value;
49 49
                 RaisePropertyChanged(() => MaskRightWidth);
50 50
             }
51 51
         }
@@ -54,14 +54,14 @@ namespace ComeCapture
54 54
 
55 55
         #region 属性 MaskTopWidth
56 56
 
57
-        private double _MaskTopWidth = 0;
57
+        private double _maskTopWidth;
58 58
 
59 59
         public double MaskTopWidth
60 60
         {
61
-            get => _MaskTopWidth;
61
+            get => _maskTopWidth;
62 62
             set
63 63
             {
64
-                _MaskTopWidth = value;
64
+                _maskTopWidth = value;
65 65
                 RaisePropertyChanged(() => MaskTopWidth);
66 66
             }
67 67
         }
@@ -70,14 +70,14 @@ namespace ComeCapture
70 70
 
71 71
         #region 属性 MaskTopHeight
72 72
 
73
-        private double _MaskTopHeight = 0;
73
+        private double _maskTopHeight;
74 74
 
75 75
         public double MaskTopHeight
76 76
         {
77
-            get => _MaskTopHeight;
77
+            get => _maskTopHeight;
78 78
             set
79 79
             {
80
-                _MaskTopHeight = value;
80
+                _maskTopHeight = value;
81 81
                 ShowSizeTop = MaskTopHeight < 40 ? MaskTopHeight : MaskTopHeight - 40;
82 82
                 RaisePropertyChanged(() => MaskTopHeight);
83 83
             }
@@ -87,14 +87,14 @@ namespace ComeCapture
87 87
 
88 88
         #region 属性 MaskBottomHeight
89 89
 
90
-        private double _MaskBottomHeight = 0;
90
+        private double _maskBottomHeight;
91 91
 
92 92
         public double MaskBottomHeight
93 93
         {
94
-            get => _MaskBottomHeight;
94
+            get => _maskBottomHeight;
95 95
             set
96 96
             {
97
-                _MaskBottomHeight = value;
97
+                _maskBottomHeight = value;
98 98
                 RaisePropertyChanged(() => MaskBottomHeight);
99 99
             }
100 100
         }
@@ -103,41 +103,41 @@ namespace ComeCapture
103 103
 
104 104
         #region 属性 ShowSize
105 105
 
106
-        private string _ShowSize = "0 × 0";
106
+        private string _showSize = "0 × 0";
107 107
 
108 108
         public string ShowSize
109 109
         {
110
-            get => _ShowSize;
110
+            get => _showSize;
111 111
             set
112 112
             {
113
-                _ShowSize = value;
113
+                _showSize = value;
114 114
                 RaisePropertyChanged(() => ShowSize);
115 115
             }
116 116
         }
117 117
 
118
-        private static StringBuilder sb = new StringBuilder();
118
+        private static StringBuilder _sb = new StringBuilder();
119 119
 
120 120
         public void ChangeShowSize()
121 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();
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 127
         }
128 128
 
129 129
         #endregion 属性 ShowSize
130 130
 
131 131
         #region 属性 ShowSizeLeft
132 132
 
133
-        private double _ShowSizeLeft = 0;
133
+        private double _showSizeLeft;
134 134
 
135 135
         public double ShowSizeLeft
136 136
         {
137
-            get => _ShowSizeLeft;
137
+            get => _showSizeLeft;
138 138
             set
139 139
             {
140
-                _ShowSizeLeft = value;
140
+                _showSizeLeft = value;
141 141
                 RaisePropertyChanged(() => ShowSizeLeft);
142 142
             }
143 143
         }
@@ -146,14 +146,14 @@ namespace ComeCapture
146 146
 
147 147
         #region 属性 ShowSizeTop
148 148
 
149
-        private double _ShowSizeTop = 0;
149
+        private double _showSizeTop;
150 150
 
151 151
         public double ShowSizeTop
152 152
         {
153
-            get => _ShowSizeTop;
153
+            get => _showSizeTop;
154 154
             set
155 155
             {
156
-                _ShowSizeTop = value;
156
+                _showSizeTop = value;
157 157
                 RaisePropertyChanged(() => ShowSizeTop);
158 158
             }
159 159
         }
@@ -162,14 +162,14 @@ namespace ComeCapture
162 162
 
163 163
         #region 属性 ShowRGB
164 164
 
165
-        private string _ShowRGB = string.Empty;
165
+        private string _showRgb = string.Empty;
166 166
 
167 167
         public string ShowRGB
168 168
         {
169
-            get => _ShowRGB;
169
+            get => _showRgb;
170 170
             set
171 171
             {
172
-                _ShowRGB = value;
172
+                _showRgb = value;
173 173
                 RaisePropertyChanged(() => ShowRGB);
174 174
             }
175 175
         }

+ 16
- 12
XHWK.WKTool/Models/DownloadInfoModel.cs Ver fichero

@@ -2,6 +2,8 @@
2 2
 
3 3
 namespace Common.Model
4 4
 {
5
+    using System;
6
+
5 7
     /// <summary>
6 8
     /// 下载模型
7 9
     /// 创建人:赵耀
@@ -41,10 +43,11 @@ namespace Common.Model
41 43
             get => _isNewTask;
42 44
             set => _isNewTask = value;
43 45
         }
46
+
44 47
         /// <summary>
45 48
         /// 是否重新下载
46 49
         /// </summary>
47
-        private bool _isReStart = false;
50
+        private bool _isReStart;
48 51
 
49 52
         /// <summary>
50 53
         /// 是否重新下载
@@ -92,25 +95,26 @@ namespace Common.Model
92 95
 
93 96
             set
94 97
             {
95
-                List<string> UTF8ValueList = new List<string>();
98
+                List<string> utf8ValueList = new List<string>();
96 99
                 foreach (string val in value)
97 100
                 {
98
-                    string path = val.Substring(0, val.LastIndexOf("/") + 1);
99
-                    string name = val.Substring(val.LastIndexOf("/") + 1);
100
-                    string UTF8Name = System.Web.HttpUtility.UrlEncode(name);
101
-                    string UTF8Url = path + UTF8Name;
102
-                    UTF8ValueList.Add(UTF8Url);
103
-                    _downloadUrlList = UTF8ValueList;
101
+                    string path = val.Substring(0, val.LastIndexOf("/", StringComparison.Ordinal) + 1);
102
+                    string name = val.Substring(val.LastIndexOf("/", StringComparison.Ordinal) + 1);
103
+                    string utf8Name = System.Web.HttpUtility.UrlEncode(name);
104
+                    string utf8Url = path + utf8Name;
105
+                    utf8ValueList.Add(utf8Url);
106
+                    _downloadUrlList = utf8ValueList;
104 107
                 }
105
-                ;
106 108
             }
107 109
         }
110
+
108 111
         /// <summary>
109 112
         /// 是否支持断点续传
110 113
         /// 在任务开始后,如果需要暂停,应先通过这个判断是否支持
111 114
         /// 默认设为false
112 115
         /// </summary>
113
-        private bool _IsSupportMultiThreading = false;
116
+        private bool _isSupportMultiThreading;
117
+
114 118
         /// <summary>
115 119
         /// 是否支持断点续传
116 120
         /// 在任务开始后,如果需要暂停,应先通过这个判断是否支持
@@ -118,8 +122,8 @@ namespace Common.Model
118 122
         /// </summary>
119 123
         public bool IsSupportMultiThreading
120 124
         {
121
-            get => _IsSupportMultiThreading;
122
-            set => _IsSupportMultiThreading = value;
125
+            get => _isSupportMultiThreading;
126
+            set => _isSupportMultiThreading = value;
123 127
         }
124 128
         /// <summary>
125 129
         /// 线程任务列表

+ 1
- 0
XHWK.WKTool/Models/EntityBase.cs Ver fichero

@@ -25,6 +25,7 @@ namespace ComeCapture.Models
25 25
         {
26 26
             if (PropertyChanged != null)
27 27
             {
28
+                // ReSharper disable once PolymorphicFieldLikeEventInvocation
28 29
                 PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(name));
29 30
             }
30 31
         }

+ 1
- 6
XHWK.WKTool/Models/FileDirectoryData.cs Ver fichero

@@ -1,9 +1,4 @@
1
-using System;
2
-using System.Collections.Generic;
3
-using System.Collections.ObjectModel;
4
-using System.Linq;
5
-using System.Text;
6
-using System.Threading.Tasks;
1
+using System.Collections.ObjectModel;
7 2
 
8 3
 using XHWK.Model;
9 4
 

+ 1
- 7
XHWK.WKTool/Models/FileDirectoryModel.cs Ver fichero

@@ -1,10 +1,4 @@
1
-using System;
2
-using System.Collections.Generic;
3
-using System.Linq;
4
-using System.Text;
5
-using System.Threading.Tasks;
6
-
7
-using XHWK.Model;
1
+using XHWK.Model;
8 2
 
9 3
 namespace XHWK.WKTool.Models
10 4
 {

+ 0
- 4
XHWK.WKTool/Models/Limit.cs Ver fichero

@@ -14,10 +14,6 @@
14 14
         {
15 15
             return MemberwiseClone() as Limit;
16 16
         }
17
-
18
-        public Limit()
19
-        {
20
-        }
21 17
     }
22 18
 
23 19
     /// <summary>

+ 14
- 6
XHWK.WKTool/Models/ModelCanvas.cs Ver fichero

@@ -10,20 +10,28 @@
10 10
             set { _name = value; OnPropertyChanged("Name"); }
11 11
         }
12 12
 
13
-        private string _Pic;
13
+        private string _pic;
14 14
 
15 15
         public string Pic
16 16
         {
17
-            get => _Pic;
18
-            set { _Pic = value; OnPropertyChanged("Pic"); }
17
+            get => _pic;
18
+            set
19
+            {
20
+                _pic = value;
21
+                OnPropertyChanged("Pic");
22
+            }
19 23
         }
20 24
 
21
-        private bool _Selected;
25
+        private bool _selected;
22 26
 
23 27
         public bool Selected
24 28
         {
25
-            get => _Selected;
26
-            set { _Selected = value; OnPropertyChanged("Selected"); }
29
+            get => _selected;
30
+            set
31
+            {
32
+                _selected = value;
33
+                OnPropertyChanged("Selected");
34
+            }
27 35
         }
28 36
     }
29 37
 }

+ 10
- 10
XHWK.WKTool/Models/Tool.cs Ver fichero

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

+ 1
- 1
XHWK.WKTool/ScreenRecordingToolbarWindow.xaml.cs Ver fichero

@@ -942,7 +942,7 @@ namespace XHWK.WKTool
942 942
                             (
943 943
                                 () =>
944 944
                                 {
945
-                                    MouseEventCommon.GetCursorPos(out MouseEventCommon.POINT pointRecord);
945
+                                    MouseEventCommon.GetCursorPos(out MouseEventCommon.Point pointRecord);
946 946
                                     if (pointRecord.X >= this.Left && pointRecord.X < this.Left + this.ActualWidth && pointRecord.Y >= this.Top && pointRecord.Y < this.Top + this.ActualHeight)
947 947
                                     {
948 948
                                         //LblMessage.Content = "在区域内:("+ pointRecord.X+","+pointRecord.Y+") ("+ Left + ","+Top+")";

+ 5
- 5
XHWK.WKTool/Utils/DataConvertCommon.cs Ver fichero

@@ -19,15 +19,15 @@
19 19
         public static TChild ParentClassCopy<TParent, TChild>(TParent parent) where TChild : TParent, new()
20 20
         {
21 21
             TChild child = new TChild();
22
-            System.Type ParentType = typeof(TParent);
23
-            System.Reflection.PropertyInfo[] Properties = ParentType.GetProperties();
24
-            foreach (System.Reflection.PropertyInfo Propertie in Properties)
22
+            System.Type parentType = typeof(TParent);
23
+            System.Reflection.PropertyInfo[] properties = parentType.GetProperties();
24
+            foreach (System.Reflection.PropertyInfo propertie in properties)
25 25
             {
26 26
                 //循环遍历属性
27
-                if (Propertie.CanRead && Propertie.CanWrite)
27
+                if (propertie.CanRead && propertie.CanWrite)
28 28
                 {
29 29
                     //进行属性拷贝
30
-                    Propertie.SetValue(child, Propertie.GetValue(parent, null), null);
30
+                    propertie.SetValue(child, propertie.GetValue(parent, null), null);
31 31
                 }
32 32
             }
33 33
             return child;

+ 6
- 5
XHWK.WKTool/Utils/MouseEventCommon.cs Ver fichero

@@ -23,7 +23,7 @@ namespace Common.system
23 23
         /// </summary>
24 24
         /// <returns>获取成功返回真</returns>   
25 25
         [DllImport("user32.dll", CharSet = CharSet.Auto)]
26
-        public static extern bool GetCursorPos(out POINT pt);
26
+        public static extern bool GetCursorPos(out Point pt);
27 27
 
28 28
         /// <summary>
29 29
         /// 鼠标点击左键
@@ -33,7 +33,7 @@ namespace Common.system
33 33
         /// <param name="data"></param>
34 34
         public static void MouseLefClickEvent(int dx, int dy, int data)
35 35
         {
36
-            GetCursorPos(out POINT pointRecord);
36
+            GetCursorPos(out Point pointRecord);
37 37
             mouse_event((int)MouseEventFlag.MiddleDown, pointRecord.X, pointRecord.Y, data, 0);
38 38
             mouse_event((int)MouseEventFlag.MiddleUp, pointRecord.X, pointRecord.Y, data, 0);
39 39
         }
@@ -48,16 +48,17 @@ namespace Common.system
48 48
         /// <param name="data"></param>
49 49
         public static void MouseMiddleClickEvent(int data)
50 50
         {
51
-            GetCursorPos(out POINT pointRecord);
51
+            GetCursorPos(out Point pointRecord);
52 52
             mouse_event((int)MouseEventFlag.MiddleDown, pointRecord.X, pointRecord.Y, data, 0);
53 53
             mouse_event((int)MouseEventFlag.MiddleUp, pointRecord.X, pointRecord.Y, data, 0);
54 54
         }
55 55
 
56
-        public struct POINT
56
+        public struct Point
57 57
         {
58 58
             public int X;
59 59
             public int Y;
60
-            public POINT(int x, int y)
60
+
61
+            public Point(int x, int y)
61 62
             {
62 63
                 this.X = x;
63 64
                 this.Y = y;

+ 1
- 1
XHWK.WKTool/XHWK.WKTool.csproj.user Ver fichero

@@ -1,6 +1,6 @@
1 1
 <?xml version="1.0" encoding="utf-8"?>
2 2
 <Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3 3
   <PropertyGroup>
4
-    <ProjectView>ProjectFiles</ProjectView>
4
+    <ProjectView>ShowAllFiles</ProjectView>
5 5
   </PropertyGroup>
6 6
 </Project>

Loading…
Cancelar
Guardar