Browse Source

批注

master
zhangxueyang 3 years ago
parent
commit
a7a596db31

+ 1
- 1
XHPZ.Desktop/MainWindow.xaml View File

5
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6
         xmlns:local="clr-namespace:XHPZ.Desktop"
6
         xmlns:local="clr-namespace:XHPZ.Desktop"
7
         mc:Ignorable="d"
7
         mc:Ignorable="d"
8
-        Title="MainWindow" Height="300" Width="300">
8
+        Title="智慧批注" Height="300" Width="300">
9
     <Grid>
9
     <Grid>
10
         <TextBlock Text="欢迎使用批注!" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="28"/>
10
         <TextBlock Text="欢迎使用批注!" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="28"/>
11
         <StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" HorizontalAlignment="Right"  Margin="10">
11
         <StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" HorizontalAlignment="Right"  Margin="10">

+ 9
- 0
XHPZ.Desktop/MyLicense.cs
File diff suppressed because it is too large
View File


+ 1
- 1
XHPZ.Desktop/PracticeWindow.xaml View File

10
     AllowsTransparency="True"
10
     AllowsTransparency="True"
11
     Background="Transparent"
11
     Background="Transparent"
12
     Opacity="1"
12
     Opacity="1"
13
-   
13
+   Loaded="Window_Loaded"
14
     ShowInTaskbar="False"
14
     ShowInTaskbar="False"
15
     WindowStyle="None">
15
     WindowStyle="None">
16
     <Grid>
16
     <Grid>

+ 203
- 3
XHPZ.Desktop/PracticeWindow.xaml.cs View File

24
     public partial class PracticeWindow : Window
24
     public partial class PracticeWindow : Window
25
     {
25
     {
26
         private DrawingAttributes drawingAttributes;
26
         private DrawingAttributes drawingAttributes;
27
+        private DrawingAttributes drawing;
28
+        /// <summary>
29
+        /// 屏幕宽
30
+        /// </summary>
31
+        internal double pwidth = SystemParameters.PrimaryScreenWidth;
32
+        /// <summary>
33
+        /// 屏幕高
34
+        /// </summary>
35
+        internal double pHeight = SystemParameters.PrimaryScreenHeight;
36
+        /// <summary>
37
+        /// 当前画笔颜色
38
+        /// </summary>
39
+        private Color Colour = Colors.Red;
40
+        /// <summary>
41
+        /// 当前画笔宽
42
+        /// </summary>
43
+        private int Wit = 2;
44
+        /// <summary>
45
+        /// A4点阵纸点阵宽度
46
+        /// </summary>
47
+        private const int A4_WIDTH = 5600;
48
+
49
+        /// <summary>
50
+        /// A4点阵纸点阵高度
51
+        /// </summary>
52
+        private const int A4_HEIGHT = 7920;
53
+        /// <summary>
54
+        /// 引用user32.dll动态链接库(windows api),
55
+        /// 使用库中定义 API:SetCursorPos
56
+        /// 设置光标位置
57
+        /// </summary>
58
+        [System.Runtime.InteropServices.DllImport("user32.dll")]
59
+        private static extern int SetCursorPos(int x, int y);
27
         public PracticeWindow()
60
         public PracticeWindow()
28
         {
61
         {
29
             InitializeComponent();
62
             InitializeComponent();
30
             InitPen();
63
             InitPen();
64
+            InitTQLPPen();
31
         }
65
         }
32
         /// <summary>
66
         /// <summary>
33
         /// 初始化
67
         /// 初始化
171
                     {
205
                     {
172
                         return;
206
                         return;
173
                     }
207
                     }
174
-                    stroke.Add(new System.Drawing.Point(cx, cy));
208
+                    //stroke.Add(new System.Drawing.Point(cx, cy));
175
 
209
 
176
                     double PropW = blackboard_canvas.ActualWidth / A4_HEIGHT;
210
                     double PropW = blackboard_canvas.ActualWidth / A4_HEIGHT;
177
                     double PropH = blackboard_canvas.ActualHeight / A4_WIDTH;
211
                     double PropH = blackboard_canvas.ActualHeight / A4_WIDTH;
283
                 isPenDown = false;
317
                 isPenDown = false;
284
                 APP.PenSerial = penSerial;
318
                 APP.PenSerial = penSerial;
285
 
319
 
286
-                stroke.Clear();
320
+                //stroke.Clear();
287
             }
321
             }
288
             //if (APP.pageData.currpage > 0)
322
             //if (APP.pageData.currpage > 0)
289
             //{
323
             //{
318
             else
352
             else
319
             {
353
             {
320
                 isPenDown = true;
354
                 isPenDown = true;
321
-                APP.W_ScreenRecordingToolbarWindow.PenPractice();
355
+                if (APP.W_PracticeWindow != null && APP.W_PracticeWindow.Visibility == Visibility.Hidden)
356
+                {
357
+                    PenPractice();
358
+                }
322
             }
359
             }
323
         }
360
         }
361
+
362
+        void PenPractice()
363
+        {
364
+            Dispatcher.Invoke(() =>
365
+            {
366
+                if (APP.W_PracticeWindow == null)
367
+                {
368
+                    APP.W_PracticeWindow = new PracticeWindow
369
+                    {
370
+                        Width = pwidth,
371
+                        Height = pHeight,
372
+                        Left = 0,
373
+                        Top = 0
374
+                    };
375
+                }
376
+                APP.W_PracticeWindow.Topmost = true;
377
+                APP.W_PracticeWindow.Initialize();
378
+                APP.W_PracticeWindow.Show();
379
+            });
380
+        }
324
         /// <summary>
381
         /// <summary>
325
         /// 电池电量
382
         /// 电池电量
326
         /// </summary>
383
         /// </summary>
404
                 MessageBox.Show(ex.Message);
461
                 MessageBox.Show(ex.Message);
405
             }
462
             }
406
         }
463
         }
464
+
465
+
466
+        #region 腾千里手写笔
467
+        /// <summary>
468
+        /// 是否在书写
469
+        /// </summary>
470
+        bool isTQLPenDown = false;
471
+        /// <summary>
472
+        /// TQL点阵笔宽高
473
+        /// </summary>
474
+        static float TQLA4_WIDTH = (float)1075 / (float)150 * (float)25.4 / (float)1.524; //OID4
475
+        static float TQLA4_HEIGHT = (float)1512 / (float)150 * (float)25.4 / (float)1.524;
476
+        /// <summary>
477
+        /// 初始化
478
+        /// </summary>
479
+        public void InitTQLPPen()
480
+        {
481
+            if (APP.TQLPenevents == null)
482
+            {
483
+                APP.TQLPenevents = new PenEvents();
484
+            }
485
+        }
486
+        /// <summary>
487
+        /// 笔落下
488
+        /// </summary>
489
+        public void TQLDown()
490
+        {
491
+            isTQLPenDown = true;
492
+            if(APP.W_PracticeWindow!=null&&APP.W_PracticeWindow.Visibility==Visibility.Hidden)
493
+            {
494
+                PenPractice();
495
+            }
496
+          
497
+            if (strokes != null && strokes.StylusPoints.Count > 1)
498
+            {
499
+                isFirst = true;
500
+            }
501
+            stylusPoints = new StylusPointCollection();
502
+            stylusPoint = new StylusPoint();
503
+            strokes = null;
504
+        }
505
+        /// <summary>
506
+        /// 笔抬起
507
+        /// </summary>
508
+        public void TQLUp()
509
+        {
510
+            isTQLPenDown = false;
511
+
512
+            if (strokes != null && strokes.StylusPoints.Count > 1)
513
+            {
514
+                isFirst = true;
515
+            }
516
+            stylusPoints = new StylusPointCollection();
517
+            stylusPoint = new StylusPoint();
518
+            strokes = null;
519
+        }
520
+        /// <summary>
521
+        /// 笔书写
522
+        /// </summary>
523
+        /// <param name="cx"></param>
524
+        /// <param name="cy"></param>
525
+        /// <param name="force"></param>
526
+        public void TQLPenWrite(double cx, double cy, int force)
527
+        {
528
+            if (this.Visibility == Visibility.Visible)
529
+            {
530
+                //判断是否是落笔后输出的坐标,在设置悬浮模式下,落笔前的悬浮坐标不绘制
531
+                if (!isTQLPenDown)
532
+                {
533
+                    return;
534
+                }
535
+                double PropW = blackboard_canvas.ActualWidth / TQLA4_HEIGHT;
536
+                double PropH = blackboard_canvas.ActualHeight / TQLA4_WIDTH;
537
+
538
+                double tempX = cy * PropW;
539
+                double tempY = (TQLA4_WIDTH - cx) * PropH;
540
+                Dispatcher.Invoke(new Action(() =>
541
+                {
542
+                    //0~1023,亦即有 1024 阶供应用软件后续应用之用,如笔锋笔触,暂无用
543
+                    float Pressure = (float)force / 1023f;
544
+                    //添加笔画
545
+                    if (isFirst)
546
+                    {
547
+                        stylusPoint.X = tempX;
548
+                        stylusPoint.Y = tempY;
549
+                        stylusPoints.Add(stylusPoint);
550
+                        if (stylusPoints.Count > 1)
551
+                        {
552
+                            drawing = new DrawingAttributes
553
+                            {
554
+                                Color = Colour,
555
+                                Width = Wit * 4.5,
556
+                                Height = Wit * 4.5,
557
+                                FitToCurve = true,
558
+                                IgnorePressure = false
559
+                            };
560
+
561
+                            strokes = new Stroke(stylusPoints);
562
+
563
+                            strokes.DrawingAttributes = drawing;
564
+
565
+                            blackboard_canvas.Strokes.Add(strokes);
566
+                            isFirst = false;
567
+                        }
568
+                    }
569
+                    else
570
+                    {
571
+                        if (blackboard_canvas.Strokes.Count > 0)
572
+                        {
573
+                            stylusPoint.X = tempX;
574
+                            stylusPoint.Y = tempY;
575
+                            stylusPoints.Add(stylusPoint);
576
+                            strokes = new Stroke(stylusPoints);
577
+                            drawing = new DrawingAttributes
578
+                            {
579
+                                Color = Colour,
580
+                                Width = Wit * 4.5,
581
+                                Height = Wit * 4.5,
582
+                                FitToCurve = true,
583
+                                IgnorePressure = false
584
+                            };
585
+                            strokes.DrawingAttributes = drawing;
586
+
587
+                            //viewModel.InkStrokes.Add(strokes);
588
+                            blackboard_canvas.Strokes[blackboard_canvas.Strokes.Count - 1] = strokes;
589
+                        }
590
+                    }
591
+
592
+                    //设置鼠标位置
593
+                    if (tempX > 0 && tempY > 0)
594
+                    {
595
+                        //System.Windows.Point getP = scroMain.PointToScreen(new System.Windows.Point(testX, testY - scroMain.VerticalOffset));
596
+                        SetCursorPos((int)((float)tempX * (PrimaryScreen.DpiX / 96f)), (int)((float)tempY * (PrimaryScreen.DpiY / 96f)));
597
+                    }
598
+                }));
599
+            }
600
+        }
601
+        #endregion
602
+
603
+        private void Window_Loaded(object sender, RoutedEventArgs e)
604
+        {
605
+            Hide();
606
+        }
407
     }
607
     }
408
 }
608
 }

+ 1
- 0
XHPZ.Desktop/TQLPen/PenEvents.cs View File

326
                     //form.AddLog("x:" + (dot.x + dot.fx / 100f).ToString() + ", " + "y:" + (dot.y + dot.fy / 100f).ToString());
326
                     //form.AddLog("x:" + (dot.x + dot.fx / 100f).ToString() + ", " + "y:" + (dot.y + dot.fy / 100f).ToString());
327
                 }
327
                 }
328
         }
328
         }
329
+
329
         /// <summary>
330
         /// <summary>
330
         /// 接收脱机数据
331
         /// 接收脱机数据
331
         /// </summary>
332
         /// </summary>

+ 1
- 0
XHPZ.Desktop/XHPZ.Desktop.csproj View File

73
     <Reference Include="PresentationFramework" />
73
     <Reference Include="PresentationFramework" />
74
   </ItemGroup>
74
   </ItemGroup>
75
   <ItemGroup>
75
   <ItemGroup>
76
+    <Compile Include="MyLicense.cs" />
76
     <Compile Include="TQLPen\PenEvents.cs" />
77
     <Compile Include="TQLPen\PenEvents.cs" />
77
     <Compile Include="TQLPen\Pentiming.cs" />
78
     <Compile Include="TQLPen\Pentiming.cs" />
78
     <Page Include="MainWindow.xaml">
79
     <Page Include="MainWindow.xaml">

Loading…
Cancel
Save