zhangxueyang před 3 roky
rodič
revize
ab385f6d5d

+ 62
- 62
Common/system/PdfTrunImage.cs Zobrazit soubor

@@ -1,4 +1,4 @@
1
-using O2S.Components.PDFRender4NET;
1
+//using O2S.Components.PDFRender4NET;
2 2
 
3 3
 using System.Collections.Generic;
4 4
 using System.Drawing;
@@ -17,72 +17,72 @@ namespace Common.system
17 17
     /// <seealso cref="http://www.hrangel.com.br/index.php/2006/12/04/converter-pdf-para-imagem-jpeg-em-c/"/>
18 18
     public class PdfTrunImage
19 19
     {
20
-        public enum Definition
21
-        {
22
-            One = 1, Two = 2, Three = 3, Four = 4, Five = 5, Six = 6, Seven = 7, Eight = 8, Nine = 9, Ten = 10
23
-        }
20
+        //public enum Definition
21
+        //{
22
+        //    One = 1, Two = 2, Three = 3, Four = 4, Five = 5, Six = 6, Seven = 7, Eight = 8, Nine = 9, Ten = 10
23
+        //}
24 24
 
25
-        /// <summary>
26
-        /// 将PDF文档转换为图片的方法
27
-        /// </summary>
28
-        /// <param name="pdfInputPath">PDF文件路径</param>
29
-        /// <param name="imageOutputPath">图片输出路径</param>
30
-        /// <param name="imageName">生成图片的名字</param>
31
-        /// <param name="startPageNum">从PDF文档的第几页开始转换</param>
32
-        /// <param name="endPageNum">从PDF文档的第几页开始停止转换</param>
33
-        /// <param name="imageFormat">设置所需图片格式</param>
34
-        /// <param name="definition">设置图片的清晰度,数字越大越清晰</param>
35
-        public static List<string> ConvertPDF2Image(string pdfInputPath, string imageOutputPath,
36
-            string imageName, int startPageNum, int endPageNum, ImageFormat imageFormat, Definition definition)
37
-        {
38
-            List<string> images = new List<string>();
39
-            try
40
-            {
41
-                PDFFile pdfFile = PDFFile.Open(pdfInputPath);
25
+        ///// <summary>
26
+        ///// 将PDF文档转换为图片的方法
27
+        ///// </summary>
28
+        ///// <param name="pdfInputPath">PDF文件路径</param>
29
+        ///// <param name="imageOutputPath">图片输出路径</param>
30
+        ///// <param name="imageName">生成图片的名字</param>
31
+        ///// <param name="startPageNum">从PDF文档的第几页开始转换</param>
32
+        ///// <param name="endPageNum">从PDF文档的第几页开始停止转换</param>
33
+        ///// <param name="imageFormat">设置所需图片格式</param>
34
+        ///// <param name="definition">设置图片的清晰度,数字越大越清晰</param>
35
+        //public static List<string> ConvertPDF2Image(string pdfInputPath, string imageOutputPath,
36
+        //    string imageName, int startPageNum, int endPageNum, ImageFormat imageFormat, Definition definition)
37
+        //{
38
+        //    List<string> images = new List<string>();
39
+        //    try
40
+        //    {
41
+        //        PDFFile pdfFile = PDFFile.Open(pdfInputPath);
42 42
 
43
-                if (!Directory.Exists(imageOutputPath))
44
-                {
45
-                    Directory.CreateDirectory(imageOutputPath);
46
-                }
43
+        //        if (!Directory.Exists(imageOutputPath))
44
+        //        {
45
+        //            Directory.CreateDirectory(imageOutputPath);
46
+        //        }
47 47
 
48
-                // validate pageNum
49
-                if (startPageNum <= 0)
50
-                {
51
-                    startPageNum = 1;
52
-                }
48
+        //        // validate pageNum
49
+        //        if (startPageNum <= 0)
50
+        //        {
51
+        //            startPageNum = 1;
52
+        //        }
53 53
 
54
-                if (endPageNum == 0 || endPageNum > pdfFile.PageCount)
55
-                {
56
-                    endPageNum = pdfFile.PageCount;
57
-                }
58
-                if (startPageNum > endPageNum)
59
-                {
60
-                    int tempPageNum = startPageNum;
61
-                    startPageNum = endPageNum;
62
-                    endPageNum = startPageNum;
63
-                }
54
+        //        if (endPageNum == 0 || endPageNum > pdfFile.PageCount)
55
+        //        {
56
+        //            endPageNum = pdfFile.PageCount;
57
+        //        }
58
+        //        if (startPageNum > endPageNum)
59
+        //        {
60
+        //            int tempPageNum = startPageNum;
61
+        //            startPageNum = endPageNum;
62
+        //            endPageNum = startPageNum;
63
+        //        }
64 64
 
65
-                // start to convert each page
66
-                for (int i = startPageNum; i <= endPageNum; i++)
67
-                {
68
-                    Bitmap pageImage = pdfFile.GetPageImage(i - 1, 56 * (int)definition);
69
-                    string imgPath = imageOutputPath + imageName + i.ToString() + "." + imageFormat.ToString();
70
-                    pageImage.Save(imgPath, imageFormat);
71
-                    images.Add(imgPath);
72
-                    // 返回的图片绝对路径集合
73
-                    pageImage.Dispose();
74
-                }
65
+        //        // start to convert each page
66
+        //        for (int i = startPageNum; i <= endPageNum; i++)
67
+        //        {
68
+        //            Bitmap pageImage = pdfFile.GetPageImage(i - 1, 56 * (int)definition);
69
+        //            string imgPath = imageOutputPath + imageName + i.ToString() + "." + imageFormat.ToString();
70
+        //            pageImage.Save(imgPath, imageFormat);
71
+        //            images.Add(imgPath);
72
+        //            // 返回的图片绝对路径集合
73
+        //            pageImage.Dispose();
74
+        //        }
75 75
 
76
-                pdfFile.Dispose();
77
-                return images;
78
-            }
79
-            catch (System.Exception ex)
80
-            {
81
-                LogHelper.WriteErrLog("PDF转图片" +
82
-                    "【PdfTrunImage】" + ex.Message, ex);
83
-                images = new List<string>();
84
-                return images;
85
-            }
86
-        }
76
+        //        pdfFile.Dispose();
77
+        //        return images;
78
+        //    }
79
+        //    catch (System.Exception ex)
80
+        //    {
81
+        //        LogHelper.WriteErrLog("PDF转图片" +
82
+        //            "【PdfTrunImage】" + ex.Message, ex);
83
+        //        images = new List<string>();
84
+        //        return images;
85
+        //    }
86
+        //}
87 87
     }
88 88
 }

+ 1
- 1
XHPZ.Desktop/APP.cs Zobrazit soubor

@@ -57,7 +57,7 @@ namespace XHPZ.Desktop
57 57
         /// <summary>
58 58
         /// 批注
59 59
         /// </summary>
60
-        //public static PracticeWindow W_PracticeWindow = null;
60
+        public static PracticeWindow W_PracticeWindow = null;
61 61
         #endregion
62 62
         #endregion
63 63
 

+ 4
- 4
XHPZ.Desktop/MainWindow.xaml Zobrazit soubor

@@ -5,12 +5,12 @@
5 5
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6 6
         xmlns:local="clr-namespace:XHPZ.Desktop"
7 7
         mc:Ignorable="d"
8
-        Title="MainWindow" Height="450" Width="800">
8
+        Title="MainWindow" Height="300" Width="300">
9 9
     <Grid>
10
-        <TextBlock Text="欢迎使用批注!" FontSize="28"/>
11
-        <StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" HorizontalAlignment="Right">
10
+        <TextBlock Text="欢迎使用批注!" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="28"/>
11
+        <StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" HorizontalAlignment="Right"  Margin="10">
12 12
             <TextBlock Text="设备状态:" FontSize="18"/>
13
-            <TextBlock x:Name="x" Text="未连接" FontSize="18"/>
13
+            <TextBlock x:Name="txbType" Text="未连接" FontSize="18"/>
14 14
         </StackPanel>
15 15
     </Grid>
16 16
 </Window>

+ 28
- 0
XHPZ.Desktop/MainWindow.xaml.cs Zobrazit soubor

@@ -21,10 +21,38 @@ namespace XHPZ.Desktop
21 21
     /// </summary>
22 22
     public partial class MainWindow : Window
23 23
     {
24
+        /// <summary>
25
+        /// 屏幕宽
26
+        /// </summary>
27
+        internal double pwidth = SystemParameters.PrimaryScreenWidth;
28
+        /// <summary>
29
+        /// 屏幕高
30
+        /// </summary>
31
+        internal double pHeight = SystemParameters.PrimaryScreenHeight;
24 32
         public MainWindow()
25 33
         {
26 34
             InitializeComponent();
27 35
             LogHelper.WriteInfoLog("启动");
36
+
37
+
38
+
39
+           if(APP.W_PracticeWindow==null)
40
+            {
41
+                APP.W_PracticeWindow = new PracticeWindow
42
+                {
43
+                    Width = pwidth,
44
+                    Height = pHeight,
45
+                    Left = 0,
46
+                    Top = 0
47
+                };
48
+            }
49
+            APP.W_PracticeWindow.Topmost = true;
50
+            APP.W_PracticeWindow.Initialize();
51
+            APP.W_PracticeWindow.Show();
28 52
         }
29 53
     }
54
+
55
+
56
+
57
+
30 58
 }

+ 20
- 0
XHPZ.Desktop/PracticeWindow.xaml Zobrazit soubor

@@ -0,0 +1,20 @@
1
+<Window x:Class="XHPZ.Desktop.PracticeWindow"
2
+        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3
+        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4
+        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5
+        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6
+        xmlns:local="clr-namespace:XHPZ.Desktop"
7
+        mc:Ignorable="d"
8
+        Title="PracticeWindow" Width="1280"
9
+    Height="800"
10
+    AllowsTransparency="True"
11
+    Background="Transparent"
12
+    Opacity="1"
13
+   
14
+    ShowInTaskbar="False"
15
+    WindowStyle="None">
16
+    <Grid>
17
+        <Image x:Name="imgCanvas"/>
18
+        <InkCanvas Grid.Row="0" x:Name="blackboard_canvas" PreviewMouseRightButtonDown="blackboard_canvas_PreviewMouseRightButtonDown" Background="#021B1919" Visibility="Visible" Grid.ColumnSpan="2"/>
19
+    </Grid>
20
+</Window>

+ 408
- 0
XHPZ.Desktop/PracticeWindow.xaml.cs Zobrazit soubor

@@ -0,0 +1,408 @@
1
+using Common.system;
2
+using System;
3
+using System.Collections.Generic;
4
+using System.Linq;
5
+using System.Text;
6
+using System.Threading;
7
+using System.Threading.Tasks;
8
+using System.Windows;
9
+using System.Windows.Controls;
10
+using System.Windows.Data;
11
+using System.Windows.Documents;
12
+using System.Windows.Ink;
13
+using System.Windows.Input;
14
+using System.Windows.Media;
15
+using System.Windows.Media.Imaging;
16
+using System.Windows.Shapes;
17
+using TStudyDigitalPen.HID;
18
+
19
+namespace XHPZ.Desktop
20
+{
21
+    /// <summary>
22
+    /// PracticeWindow.xaml 的交互逻辑
23
+    /// </summary>
24
+    public partial class PracticeWindow : Window
25
+    {
26
+        private DrawingAttributes drawingAttributes;
27
+        public PracticeWindow()
28
+        {
29
+            InitializeComponent();
30
+            InitPen();
31
+        }
32
+        /// <summary>
33
+        /// 初始化
34
+        /// </summary>
35
+        /// <param name="_imgPath"></param>
36
+        public void Initialize(string _imgPath = null)
37
+        {
38
+            blackboard_canvas.Strokes.Clear();
39
+            blackboard_canvas.UseCustomCursor = true;
40
+            //创建 DrawingAttributes 类的一个实例  
41
+            drawingAttributes = new DrawingAttributes();
42
+            blackboard_canvas.DefaultDrawingAttributes = drawingAttributes;
43
+            Pen();
44
+        }
45
+        public void InitPen()
46
+        {
47
+            //stroke = new List<System.Drawing.Point>();
48
+            //获取点阵笔实例,并绑定点阵笔事件
49
+            //将授权文件内容传入,获取点阵笔对象实例
50
+            APP.digitalPen = DigitalPenHID.GetInstance(certificates.MyLicense.Bytes);
51
+            //绑定笔连接事件
52
+            APP.digitalPen.PenConnected += OnPenConnect;
53
+            //绑定笔断开事件
54
+            APP.digitalPen.PenDisconnect += OnPenDisconnect;
55
+            //绑定笔书写输出坐标事件
56
+            APP.digitalPen.PenCoordinate += OnPenCoordinate;
57
+            //绑定抬笔事件
58
+            APP.digitalPen.PenUp += OnPenUp;
59
+            //绑定落笔事件
60
+            APP.digitalPen.PenDown += OnPenDown;
61
+            APP.digitalPen.PenBatteryCapacity += OnBatteryCapacity;
62
+            APP.digitalPen.PenMemoryFillLevel += OnMemoryFillLevel;
63
+            //完成初始化点阵笔,开始与点阵笔通信
64
+            ERROR_CODE ER = APP.digitalPen.Start();
65
+            //判断是否成功
66
+            //if (ER != ERROR_CODE.ERROR_OK)
67
+            //{
68
+            //    MessageWindow.Show("初始化失败,授权过期,返回值:" + ER.ToString());
69
+            //}
70
+        }
71
+        /// <summary>
72
+        /// 画笔
73
+        /// </summary>
74
+        public void Pen()
75
+        {
76
+            blackboard_canvas.EditingMode = InkCanvasEditingMode.Ink;
77
+            blackboard_canvas.UseCustomCursor = true;
78
+            drawingAttributes.FitToCurve = true;
79
+            drawingAttributes.IgnorePressure = false;
80
+            blackboard_canvas.Cursor = Cursors.Pen;
81
+        }
82
+        /// <summary>
83
+        /// 笔连接
84
+        /// </summary>
85
+        /// <param name="time">时间戳,1970年1月1日到现在的总毫秒数</param>
86
+        /// <param name="penSerial">点阵笔序列号</param>
87
+        /// <param name="penType">点阵笔型号编号</param>
88
+        private void OnPenConnect(ulong time, string penSerial, int penType)
89
+        {
90
+            if (CheckAccess())
91
+            {
92
+                Action<ulong, string, int> action = new Action<ulong, string, int>(OnPenConnect);
93
+                Dispatcher.Invoke(action, new object[] { time, penSerial, penType });
94
+            }
95
+            else
96
+            {
97
+                APP.PenSerial = penSerial;
98
+                APP.PenStatus = true;
99
+                this.penSerial = penSerial;
100
+                //连接后,在获取笔数据前,可以清除笔内的历史数据
101
+                //APP.digitalPen.ClearMemory(penSerial);
102
+
103
+                //开始接收笔数据
104
+                APP.digitalPen.GetPenData(penSerial);
105
+                //UpdateDevStatus();
106
+                ////Dispatcher.Invoke(new Action(() =>
107
+                ////{
108
+                ////    txbNotConnected.Text = "已连接";
109
+                ////    txbNotConnecteds.Text = "已连接";
110
+                ////}));
111
+
112
+            }
113
+        }
114
+        /// <summary>
115
+        /// 笔断开
116
+        /// </summary>
117
+        /// <param name="time">时间戳,1970年1月1日到现在的总毫秒数</param>
118
+        /// <param name="penSerial">点阵笔序列号</param>
119
+        /// <param name="penType">点阵笔型号编号</param>
120
+        private void OnPenDisconnect(ulong time, string penSerial, int penType)
121
+        {
122
+            if (CheckAccess())
123
+            {
124
+                Action<ulong, string, int> action = new Action<ulong, string, int>(OnPenDisconnect);
125
+                Dispatcher.Invoke(action, new object[] { time, penSerial, penType });
126
+            }
127
+            else
128
+            {
129
+                APP.PenSerial = penSerial;
130
+                APP.PenStatus = false;
131
+                //UpdateDevStatus();
132
+                ////Dispatcher.Invoke(new Action(() =>
133
+                ////{
134
+                ////    txbNotConnected.Text = "未连接";
135
+                ////    txbNotConnecteds.Text = "未连接";
136
+                ////}));
137
+            }
138
+        }
139
+        /// <summary>
140
+        /// 笔序列号
141
+        /// </summary>
142
+        private string penSerial;
143
+
144
+        /// <summary>
145
+        /// 笔是否在点
146
+        /// </summary>
147
+        private bool isPenDown;
148
+        /// <summary>
149
+        /// 笔书写,收到坐标
150
+        /// </summary>
151
+        /// <param name="time">时间戳,1970年1月1日到现在的总毫秒数</param>
152
+        /// <param name="penSerial">点阵笔序列号</param>
153
+        /// <param name="penType">点阵笔型号编号</param>
154
+        /// <param name="pageSerial">点阵地址</param>
155
+        /// <param name="cx">x坐标</param>
156
+        /// <param name="cy">y坐标</param>
157
+        /// <param name="force">压力值</param>
158
+        private void OnPenCoordinate(ulong time, string penSerial, int penType, string pageSerial, int cx, int cy, byte force)
159
+        {
160
+            if (this.Visibility == Visibility.Visible)
161
+            {
162
+                if (CheckAccess())
163
+                {
164
+                    Action<ulong, string, int, string, int, int, byte> ac = new Action<ulong, string, int, string, int, int, byte>(OnPenCoordinate);
165
+                    Dispatcher.Invoke(ac, new object[] { time, pageSerial, penType, pageSerial, cx, cy, force });
166
+                }
167
+                else
168
+                {
169
+                    //判断是否是落笔后输出的坐标,在设置悬浮模式下,落笔前的悬浮坐标不绘制
170
+                    if (!isPenDown)
171
+                    {
172
+                        return;
173
+                    }
174
+                    stroke.Add(new System.Drawing.Point(cx, cy));
175
+
176
+                    double PropW = blackboard_canvas.ActualWidth / A4_HEIGHT;
177
+                    double PropH = blackboard_canvas.ActualHeight / A4_WIDTH;
178
+                    //点
179
+                    double testX = cy * PropW;
180
+                    double testY = (A4_WIDTH - cx) * PropH;
181
+                    //pageSerial //点阵IP地址  与打印的页面关联
182
+                    if (true)
183
+                    {
184
+                        Dispatcher.Invoke(new Action(() =>
185
+                        {
186
+                            float Pressure = force / 100f;
187
+                            ////添加笔画
188
+                            //myblackboard.changepages(testX, testY, false, Color, PenSize, APP.pageData.currpage - 1, Pressure);
189
+
190
+                            if (isFirst)
191
+                            {
192
+                                stylusPoint.X = testX;
193
+                                stylusPoint.Y = testY;
194
+                                //_color.A = (byte)(Pressure * 255f);
195
+                                //stylusPoint.PressureFactor = Pressure;
196
+
197
+                                //for(int i=0;i<100;i++)
198
+                                //{
199
+                                //    stylusPoint.X--;
200
+                                //    stylusPoint.Y--;
201
+                                //    stylusPoints.Add(stylusPoint);
202
+                                //}
203
+                                stylusPoints.Add(stylusPoint);
204
+                                if (stylusPoints.Count > 1)
205
+                                {
206
+                                    drawing = new DrawingAttributes
207
+                                    {
208
+                                        Color = Colour,
209
+                                        Width = Wit * 4.5,
210
+                                        Height = Wit * 4.5,
211
+                                        FitToCurve = true,
212
+                                        IgnorePressure = false
213
+                                    };
214
+
215
+                                    //blackboard_canvas.Strokes = new StrokeCollection();
216
+                                    strokes = new Stroke(stylusPoints);
217
+
218
+
219
+                                    strokes.DrawingAttributes = drawing;
220
+                                    //blackboard_canvas.Strokes.Add(strokes);
221
+
222
+                                    blackboard_canvas.Strokes.Add(strokes);
223
+                                    isFirst = false;
224
+                                }
225
+                            }
226
+                            else
227
+                            {
228
+                                if (blackboard_canvas.Strokes.Count > 0)
229
+                                {
230
+                                    stylusPoint.X = testX;
231
+                                    stylusPoint.Y = testY;
232
+                                    stylusPoints.Add(stylusPoint);
233
+                                    strokes = new Stroke(stylusPoints);
234
+                                    drawing = new DrawingAttributes
235
+                                    {
236
+                                        Color = Colour,
237
+                                        Width = Wit * 4.5,
238
+                                        Height = Wit * 4.5,
239
+                                        FitToCurve = true,
240
+                                        IgnorePressure = false
241
+                                    };
242
+                                    strokes.DrawingAttributes = drawing;
243
+
244
+                                    //viewModel.InkStrokes.Add(strokes);
245
+                                    blackboard_canvas.Strokes[blackboard_canvas.Strokes.Count - 1] = strokes;
246
+                                }
247
+                            }
248
+
249
+                            //设置鼠标位置
250
+                            if (testX > 0 && testY > 0)
251
+                            {
252
+                                //System.Windows.Point getP = scroMain.PointToScreen(new System.Windows.Point(testX, testY - scroMain.VerticalOffset));
253
+                                SetCursorPos((int)((float)testX * (PrimaryScreen.DpiX / 96f)), (int)((float)testY * (PrimaryScreen.DpiY / 96f)));
254
+                            }
255
+                        }));
256
+                    }
257
+
258
+                }
259
+            }
260
+        }
261
+        bool isFirst = true;
262
+        private StylusPointCollection stylusPoints = new StylusPointCollection();
263
+        private StylusPoint stylusPoint = new StylusPoint();
264
+        private Stroke strokes;
265
+
266
+
267
+
268
+        /// <summary>
269
+        /// 抬笔
270
+        /// </summary>
271
+        /// <param name="time">时间戳,1970年1月1日到现在的总毫秒数</param>
272
+        /// <param name="penSerial">点阵笔序列号</param>
273
+        /// <param name="penType">点阵笔型号编号</param>
274
+        private void OnPenUp(ulong time, string penSerial, int penType)
275
+        {
276
+            if (CheckAccess())
277
+            {
278
+                Action<ulong, string, int> action = new Action<ulong, string, int>(OnPenUp);
279
+                Dispatcher.Invoke(action, new object[] { time, penSerial, penType });
280
+            }
281
+            else
282
+            {
283
+                isPenDown = false;
284
+                APP.PenSerial = penSerial;
285
+
286
+                stroke.Clear();
287
+            }
288
+            //if (APP.pageData.currpage > 0)
289
+            //{
290
+            //    Dispatcher.Invoke(new Action(() =>
291
+            //    {
292
+            //        myblackboard.changepages(0, 0, true, Color, PenSize, APP.pageData.currpage - 1, 0);
293
+            //    }));
294
+            //}
295
+
296
+
297
+            if (strokes != null && strokes.StylusPoints.Count > 1)
298
+            {
299
+                isFirst = true;
300
+            }
301
+            stylusPoints = new StylusPointCollection();
302
+            stylusPoint = new StylusPoint();
303
+            strokes = null;
304
+        }
305
+        /// <summary>
306
+        /// 落笔
307
+        /// </summary>
308
+        /// <param name="time">时间戳,1970年1月1日到现在的总毫秒数</param>
309
+        /// <param name="penSerial">点阵笔序列号</param>
310
+        /// <param name="penType">点阵笔型号编号</param>
311
+        private void OnPenDown(ulong time, string penSerial, int penType)
312
+        {
313
+            if (CheckAccess())
314
+            {
315
+                Action<ulong, string, int> action = new Action<ulong, string, int>(OnPenDown);
316
+                Dispatcher.Invoke(action, new object[] { time, penSerial, penType });
317
+            }
318
+            else
319
+            {
320
+                isPenDown = true;
321
+                APP.W_ScreenRecordingToolbarWindow.PenPractice();
322
+            }
323
+        }
324
+        /// <summary>
325
+        /// 电池电量
326
+        /// </summary>
327
+        /// <param name="time"></param>
328
+        /// <param name="penSerial"></param>
329
+        /// <param name="penType"></param>
330
+        /// <param name="capacity"></param>
331
+        private void OnBatteryCapacity(ulong time, string penSerial, int penType, byte capacity)
332
+        {
333
+            if (CheckAccess())
334
+            {
335
+                Action<ulong, string, int, byte> action = new Action<ulong, string, int, byte>(OnBatteryCapacity);
336
+                Dispatcher.Invoke(action, new object[] { time, penSerial, penType, capacity });
337
+            }
338
+            else
339
+            {
340
+                //System.Windows.MessageWindow.Show("电池电量:" + capacity.ToString());
341
+            }
342
+        }
343
+        /// <summary>
344
+        /// 已用存储
345
+        /// </summary>
346
+        /// <param name="time"></param>
347
+        /// <param name="penSerial"></param>
348
+        /// <param name="penType"></param>
349
+        /// <param name="fillLevel"></param>
350
+        private void OnMemoryFillLevel(ulong time, string penSerial, int penType, byte fillLevel)
351
+        {
352
+            if (CheckAccess())
353
+            {
354
+                Action<ulong, string, int, byte> action = new Action<ulong, string, int, byte>(OnMemoryFillLevel);
355
+                Dispatcher.Invoke(action, new object[] { time, penSerial, penType, fillLevel });
356
+            }
357
+            else
358
+            {
359
+                //System.Windows.MessageWindow.Show("存储:" + fillLevel.ToString());
360
+            }
361
+        }
362
+        /// <summary>
363
+        /// 退出批注
364
+        /// </summary>
365
+        /// <param name="sender"></param>
366
+        /// <param name="e"></param>
367
+        private void blackboard_canvas_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
368
+        {
369
+            ReturnPractice();
370
+            SwitchPages();
371
+        }
372
+        /// <summary>
373
+        /// 退出批注并清空画板
374
+        /// </summary>
375
+        public void ReturnPractice()
376
+        {
377
+            blackboard_canvas.Strokes.Clear();
378
+            new Thread(new ThreadStart(new Action(() =>
379
+            {
380
+
381
+                Thread.Sleep(500);
382
+                Dispatcher.Invoke(() =>
383
+                {
384
+                    Owner = null;
385
+                    APP.W_PracticeWindow.Hide();
386
+                });
387
+            }))).Start();
388
+        }
389
+        /// <summary>
390
+        /// 鼠标中建点击
391
+        /// </summary>
392
+        void SwitchPages()
393
+        {
394
+            try
395
+            {
396
+                new Thread(() =>
397
+                {
398
+                    Thread.Sleep(500);
399
+                    MouseEventCommon.MouseMiddleClickEvent(0);
400
+                }).Start();
401
+            }
402
+            catch (Exception ex)
403
+            {
404
+                MessageBox.Show(ex.Message);
405
+            }
406
+        }
407
+    }
408
+}

+ 7
- 6
XHPZ.Desktop/XHPZ.Desktop.csproj Zobrazit soubor

@@ -78,8 +78,15 @@
78 78
       <DependentUpon>MainWindow.xaml</DependentUpon>
79 79
       <SubType>Code</SubType>
80 80
     </Compile>
81
+    <Page Include="PracticeWindow.xaml">
82
+      <SubType>Designer</SubType>
83
+      <Generator>MSBuild:Compile</Generator>
84
+    </Page>
81 85
   </ItemGroup>
82 86
   <ItemGroup>
87
+    <Compile Include="PracticeWindow.xaml.cs">
88
+      <DependentUpon>PracticeWindow.xaml</DependentUpon>
89
+    </Compile>
83 90
     <Compile Include="Properties\AssemblyInfo.cs">
84 91
       <SubType>Code</SubType>
85 92
     </Compile>
@@ -116,12 +123,6 @@
116 123
     <EmbeddedResource Include="CheckPoint.dll">
117 124
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
118 125
     </EmbeddedResource>
119
-    <EmbeddedResource Include="RobotDotMatrix.dll">
120
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
121
-    </EmbeddedResource>
122
-    <EmbeddedResource Include="RobotUsbWrapper.dll">
123
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
124
-    </EmbeddedResource>
125 126
     <EmbeddedResource Include="SonixUSB.dll">
126 127
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
127 128
     </EmbeddedResource>

Načítá se…
Zrušit
Uložit