zhangxueyang před 3 roky
rodič
revize
a7a596db31

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

@@ -5,7 +5,7 @@
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="300" Width="300">
8
+        Title="智慧批注" Height="300" Width="300">
9 9
     <Grid>
10 10
         <TextBlock Text="欢迎使用批注!" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="28"/>
11 11
         <StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" HorizontalAlignment="Right"  Margin="10">

+ 9
- 0
XHPZ.Desktop/MyLicense.cs
Diff nebyl zobrazen, protože je příliš veliký
Zobrazit soubor


+ 1
- 1
XHPZ.Desktop/PracticeWindow.xaml Zobrazit soubor

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

+ 203
- 3
XHPZ.Desktop/PracticeWindow.xaml.cs Zobrazit soubor

@@ -24,10 +24,44 @@ namespace XHPZ.Desktop
24 24
     public partial class PracticeWindow : Window
25 25
     {
26 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 60
         public PracticeWindow()
28 61
         {
29 62
             InitializeComponent();
30 63
             InitPen();
64
+            InitTQLPPen();
31 65
         }
32 66
         /// <summary>
33 67
         /// 初始化
@@ -171,7 +205,7 @@ namespace XHPZ.Desktop
171 205
                     {
172 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 210
                     double PropW = blackboard_canvas.ActualWidth / A4_HEIGHT;
177 211
                     double PropH = blackboard_canvas.ActualHeight / A4_WIDTH;
@@ -283,7 +317,7 @@ namespace XHPZ.Desktop
283 317
                 isPenDown = false;
284 318
                 APP.PenSerial = penSerial;
285 319
 
286
-                stroke.Clear();
320
+                //stroke.Clear();
287 321
             }
288 322
             //if (APP.pageData.currpage > 0)
289 323
             //{
@@ -318,9 +352,32 @@ namespace XHPZ.Desktop
318 352
             else
319 353
             {
320 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 381
         /// <summary>
325 382
         /// 电池电量
326 383
         /// </summary>
@@ -404,5 +461,148 @@ namespace XHPZ.Desktop
404 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 Zobrazit soubor

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

+ 1
- 0
XHPZ.Desktop/XHPZ.Desktop.csproj Zobrazit soubor

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

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