Browse Source

Merge remote-tracking branch 'origin/zyy' into zhangxueyang

tags/录制修改前
zhangxueyang 4 years ago
parent
commit
76fef9e9f5

+ 212
- 2
Common/system/ImageHelper.cs View File

403
         /// <param name="ImgHeight">图片高</param>
403
         /// <param name="ImgHeight">图片高</param>
404
         public static void SaveUIToImage(FrameworkElement ui, string filePathName, int width, int height, int ImgWidth, int ImgHeight)
404
         public static void SaveUIToImage(FrameworkElement ui, string filePathName, int width, int height, int ImgWidth, int ImgHeight)
405
         {
405
         {
406
+            //SaveUI(ui, filePathName, width, height, ImgWidth, ImgHeight);
407
+            //return;
406
             try
408
             try
407
             {
409
             {
408
                 //在位图中呈现UI元素
410
                 //在位图中呈现UI元素
481
                 //Console.WriteLine(ex.Message);
483
                 //Console.WriteLine(ex.Message);
482
             }
484
             }
483
         }
485
         }
486
+        public static void SaveUI(FrameworkElement ui, string filePathName, int width, int height, int ImgWidth, int ImgHeight)
487
+        {
488
+            try
489
+            {
490
+                //在位图中呈现UI元素
491
+                RenderTargetBitmap bmp = new RenderTargetBitmap(width, height, PrimaryScreen.DpiX, PrimaryScreen.DpiY, PixelFormats.Pbgra32);
492
+                bmp.Render(ui);
493
+
494
+                BitmapEncoder encoder = new PngBitmapEncoder();
495
+                encoder.Frames.Add(BitmapFrame.Create(bmp));
496
+
497
+                SaveModel saveModel = new SaveModel();
498
+                saveModel.ImgWidth = ImgWidth;
499
+                saveModel.ImgHeight = ImgHeight;
500
+                saveModel.filePathName = filePathName;
501
+                saveModel.bmp = bmp;
502
+                //定义切割矩形
503
+                var cut = new Int32Rect(0, 0, width, height);
504
+
505
+                //计算Stride
506
+
507
+                var stride = bmp.Format.BitsPerPixel * cut.Width / 8;
484
 
508
 
485
-        private static void SaveImage(object obj)
509
+                //声明字节数组
510
+
511
+                byte[] data = new byte[cut.Height * stride];
512
+
513
+                //调用CopyPixels
514
+
515
+                bmp.CopyPixels(cut, data, stride, 0);
516
+
517
+                //saveModel.encoder =new PngBitmapEncoder();
518
+                //foreach (BitmapFrame eitem in encoder.Frames)
519
+                //{
520
+                //    saveModel.encoder = new PngBitmapEncoder();
521
+                //    saveModel.encoder.Frames.Add( eitem );
522
+                //}
523
+                Thread myThread = new Thread(SaveImage);
524
+                myThread.Start(saveModel);
525
+            }
526
+            catch (Exception ex)
527
+            {
528
+
529
+            }
530
+
531
+        }
532
+        public static void SaveImage(object model)
533
+        {
534
+            try
535
+            {
536
+                SaveModel saveModel = (SaveModel)model;
537
+                int ImgWidth = saveModel.ImgWidth;
538
+                int ImgHeight = saveModel.ImgHeight;
539
+                //BitmapEncoder encoder = saveModel.encoder;
540
+                RenderTargetBitmap bmp = saveModel.bmp;
541
+                BitmapEncoder encoder = new PngBitmapEncoder();
542
+                encoder.Frames.Add(BitmapFrame.Create(bmp));
543
+                string filePathName = saveModel.filePathName;
544
+            if (ImgWidth > 0)
545
+            {
546
+                Bitmap Img = new Bitmap(ImgWidth, ImgHeight);
547
+                try
548
+                {
549
+                    MemoryStream memoryStream = new MemoryStream();
550
+                    encoder.Save(memoryStream);
551
+                    new Thread(new ThreadStart(new Action(() =>
552
+                    {
553
+                        //System.Drawing.Image img = System.Drawing.Image.FromStream(memoryStream);
554
+                        Bitmap bit = new Bitmap(memoryStream);
555
+                        if (ImgWidth - 2 < bit.Width)
556
+                        {
557
+                            try
558
+                            {
559
+                                Graphics g = Graphics.FromImage(Img);
560
+                                //g.InterpolationMode = InterpolationMode.HighQualityBicubic;
561
+                                g.DrawImage(bit, new Rectangle(0, 0, ImgWidth, ImgHeight), new Rectangle(0, 0, bit.Width, bit.Height), GraphicsUnit.Pixel);
562
+                                g.Dispose();
563
+                            }
564
+                            catch
565
+                            {
566
+                                Img = bit;
567
+                            }
568
+                        }
569
+                        else
570
+                        {
571
+                            Img = bit;
572
+                        }
573
+                        Img.Save(filePathName);
574
+                        //Bitmap bitmap = CutImageWhitePart(Img);
575
+                        //FileToolsCommon.DeleteFile(filePathName);
576
+                        //bitmap.Save(filePathName);
577
+                        //bitmap.Dispose();
578
+                        memoryStream.Dispose();
579
+                        Img.Dispose();
580
+                        bit.Dispose();
581
+                    }))).Start();
582
+                }
583
+                catch (Exception ex)
584
+                {
585
+
586
+                }
587
+            }
588
+            else
589
+            {
590
+                //SaveImageModel sim = new SaveImageModel();
591
+                //sim.encoder = new PngBitmapEncoder();
592
+                //sim.encoder = new PngBitmapEncoder();
593
+                //BitmapFrame test= encoder.Frames[0];
594
+                //sim.encoder.Frames.Add(BitmapFrame.Create(test));
595
+                ////sim.encoder.Frames[0].CopyTo(encoder.Frames[0]);
596
+                ////sim.encoder.CopyTo(encoder);
597
+                ////encoder.CopyTo(sim.encoder);
598
+                //sim.FilePath = filePathName;
599
+                ////sim.bmp = new RenderTargetBitmap(width, height, PrimaryScreen.DpiX, PrimaryScreen.DpiY, PixelFormats.Pbgra32);
600
+                ////bmp.CopyTo(sim.bmp);
601
+                //Thread t1 = new Thread(SaveImage);
602
+                //t1.Start(sim);
603
+
604
+                System.IO.FileStream fs = new System.IO.FileStream(filePathName, System.IO.FileMode.Create);
605
+                encoder.Save(fs);
606
+                fs.Close();
607
+            }
608
+            }
609
+            catch (Exception ex)
610
+            {
611
+
612
+            }
613
+        }
614
+        /// <summary>
615
+        /// 截图转换成bitmap
616
+        /// </summary>
617
+        /// <param name="element"></param>
618
+        /// <param name="width">默认控件宽度</param>
619
+        /// <param name="height">默认控件高度</param>
620
+        /// <param name="x">默认0</param>
621
+        /// <param name="y">默认0</param>
622
+        /// <returns></returns>
623
+        public static Bitmap ToBitmap(FrameworkElement element, string filePathName, int width = 0, int height = 0, int x = 0, int y = 0)
624
+        {
625
+            if (width == 0) width = (int)element.ActualWidth;
626
+            if (height == 0) height = (int)element.ActualHeight;
627
+
628
+            var rtb = new RenderTargetBitmap(width, height, x, y, System.Windows.Media.PixelFormats.Default);
629
+            rtb.Render(element);
630
+            var bit = BitmapSourceToBitmap(rtb);
631
+
632
+            //测试代码
633
+            DirectoryInfo d = new DirectoryInfo(System.IO.Path.Combine(Directory.GetCurrentDirectory(), "Cache"));
634
+            if (!d.Exists) d.Create();
635
+            bit.Save(System.IO.Path.Combine(d.FullName, "控件截图.png"));
636
+
637
+            return bit;
638
+        }
639
+
640
+        /// <summary>
641
+        /// BitmapSource转Bitmap
642
+        /// </summary>
643
+        /// <param name="source"></param>
644
+        /// <returns></returns>
645
+        public static Bitmap BitmapSourceToBitmap(BitmapSource source)
646
+        {
647
+            return BitmapSourceToBitmap(source, source.PixelWidth, source.PixelHeight);
648
+        }
649
+
650
+        /// <summary>
651
+        /// Convert BitmapSource to Bitmap
652
+        /// </summary>
653
+        /// <param name="source"></param>
654
+        /// <returns></returns>
655
+        public static Bitmap BitmapSourceToBitmap(BitmapSource source, int width, int height)
656
+        {
657
+            Bitmap bmp = null;
658
+            try
659
+            {
660
+                System.Drawing.Imaging.PixelFormat format = System.Drawing.Imaging.PixelFormat.Format24bppRgb;
661
+                /*set the translate type according to the in param(source)*/
662
+                switch (source.Format.ToString())
663
+                {
664
+                    case "Rgb24":
665
+                    case "Bgr24": format = System.Drawing.Imaging.PixelFormat.Format24bppRgb; break;
666
+                    case "Bgra32": format = System.Drawing.Imaging.PixelFormat.Format32bppPArgb; break;
667
+                    case "Bgr32": format = System.Drawing.Imaging.PixelFormat.Format32bppRgb; break;
668
+                    case "Pbgra32": format = System.Drawing.Imaging.PixelFormat.Format32bppArgb; break;
669
+                }
670
+                bmp = new Bitmap(width, height, format);
671
+                BitmapData data = bmp.LockBits(new System.Drawing.Rectangle(System.Drawing.Point.Empty, bmp.Size),
672
+                    ImageLockMode.WriteOnly,
673
+                    format);
674
+                source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
675
+                bmp.UnlockBits(data);
676
+            }
677
+            catch
678
+            {
679
+                if (bmp != null)
680
+                {
681
+                    bmp.Dispose();
682
+                    bmp = null;
683
+                }
684
+            }
685
+
686
+            return bmp;
687
+        }
688
+        private static void SaveImage1(object obj)
486
         {
689
         {
487
             SaveImageModel sim = (SaveImageModel)obj;
690
             SaveImageModel sim = (SaveImageModel)obj;
488
             //RenderTargetBitmap bmp = sim.bmp;
691
             //RenderTargetBitmap bmp = sim.bmp;
627
         public BitmapEncoder encoder { get; set; }
830
         public BitmapEncoder encoder { get; set; }
628
         //public RenderTargetBitmap bmp { get; set; }
831
         //public RenderTargetBitmap bmp { get; set; }
629
     }
832
     }
630
-
833
+    public class SaveModel
834
+    {
835
+        public int ImgWidth { get; set; }
836
+        public int ImgHeight { get; set; }
837
+        public BitmapEncoder encoder { get; set; }
838
+        public string filePathName { get; set; }
839
+        public RenderTargetBitmap bmp { get; set; }
840
+    }
631
 }
841
 }

+ 1
- 1
XHWK.WKTool/CreateAMicroLessonWindow.xaml.cs View File

29
             ResizeMode = ResizeMode.NoResize;
29
             ResizeMode = ResizeMode.NoResize;
30
             if (!APP.CheckScreenCapturerRecorder())
30
             if (!APP.CheckScreenCapturerRecorder())
31
             {
31
             {
32
-                MessageWindow.Show("首次运行需安装环境,请在确定后依次点击“OK-Next>-Next>Install”完成安装!");
32
+                MessageWindow.Show("首次运行需安装环境,请在确定后依次点击“English-OK-Next>-Next>Install”完成安装!");
33
                 APP.InstallScreenCapturerRecorder();
33
                 APP.InstallScreenCapturerRecorder();
34
             }
34
             }
35
             txbStoragePath.Text = FileToolsCommon.GetConfigValue("VideoSavePath");
35
             txbStoragePath.Text = FileToolsCommon.GetConfigValue("VideoSavePath");

+ 7
- 5
XHWK.WKTool/PrintWindow.xaml.cs View File

235
             }
235
             }
236
             catch (Exception ex)
236
             catch (Exception ex)
237
             {
237
             {
238
-
239
-
240
-
241
                 Dispatcher.Invoke(() =>
238
                 Dispatcher.Invoke(() =>
242
                 {
239
                 {
243
                     btnClose.IsEnabled = true;
240
                     btnClose.IsEnabled = true;
335
                     bitmap = ImageHelper.ReadBitmapFile(_path);
332
                     bitmap = ImageHelper.ReadBitmapFile(_path);
336
                     g.DrawImage(bitmap, _rectangle);
333
                     g.DrawImage(bitmap, _rectangle);
337
                 }
334
                 }
338
-
339
-
335
+                #region 添加箭头
336
+                string Str = "↑";
337
+                SolidBrush mybrush= new SolidBrush(Color.Black);  //设置默认画刷颜色
338
+                Font myfont= new Font("黑体", 14);         //设置默认字体格式
339
+                g.DrawString(Str, myfont, mybrush,new Rectangle((int)wit - 50, 20,50,50));
340
+                
341
+                #endregion
340
                 backgroudImg.Save(_saveimg);
342
                 backgroudImg.Save(_saveimg);
341
 
343
 
342
                 g.Dispose();
344
                 g.Dispose();

+ 37
- 12
XHWK.WKTool/ScreenRecordingToolbarWindow.xaml.cs View File

56
         /// 状态
56
         /// 状态
57
         /// </summary>
57
         /// </summary>
58
         private State _state = State.End;
58
         private State _state = State.End;
59
-        /// <summary>
60
-        /// 计时用
61
-        /// </summary>
62
-        private TimeSpan _timeSpan = new TimeSpan(0, 0, 0, 0, 0);
59
+        
63
         private KeyboardHookCommon k_hook;
60
         private KeyboardHookCommon k_hook;
64
         /// <summary>
61
         /// <summary>
65
         /// 🖊状态 0红色 1蓝色 10红色批注内 11蓝色批注内
62
         /// 🖊状态 0红色 1蓝色 10红色批注内 11蓝色批注内
145
             {
142
             {
146
                 t = new DispatcherTimer();
143
                 t = new DispatcherTimer();
147
                 t.Tick += OnTimer;
144
                 t.Tick += OnTimer;
148
-                t.Interval = new TimeSpan(0, 0, 0, 1);
145
+                t.Interval = new TimeSpan(0, 0, 0,0, 300);
149
                 t.IsEnabled = true;
146
                 t.IsEnabled = true;
150
                 t.Start();
147
                 t.Start();
151
             }
148
             }
152
-            t.Interval = new TimeSpan(0, 0, 0, 1);
149
+            t.Interval = new TimeSpan(0, 0, 0, 0,300);
153
             //Stack();
150
             //Stack();
154
             //ImgRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar25.png"));
151
             //ImgRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar25.png"));
155
             //BtnRecordingScreen_Click(null, null);
152
             //BtnRecordingScreen_Click(null, null);
199
 
196
 
200
         #region 事件
197
         #region 事件
201
         /// <summary>
198
         /// <summary>
199
+        /// 记录上次执行时间
200
+        /// </summary>
201
+        private DateTime Recorddt = DateTime.Now;
202
+        DateTime SRTime = Convert.ToDateTime("2020-01-01 00:00:00");
203
+        /// <summary>
202
         /// 时钟回调
204
         /// 时钟回调
203
         /// </summary>
205
         /// </summary>
204
         /// <param name="sender"></param>
206
         /// <param name="sender"></param>
209
             {
211
             {
210
                 case State.Start:
212
                 case State.Start:
211
                     {
213
                     {
212
-                        _timeSpan += new TimeSpan(0, 0, 0, 1);
214
+                        DateTime dt = DateTime.Now;
215
+                        TimeSpan ts = dt.Subtract(Recorddt);//时间差   
216
+                        double tsmi = ts.TotalMilliseconds;
217
+                        if (tsmi > 500.0)
218
+                        {
219
+                            Recorddt = Recorddt.AddMilliseconds(500);
220
+                            SRTime = SRTime.AddMilliseconds(500);
221
+                        }
213
                     }
222
                     }
214
                     break;
223
                     break;
215
 
224
 
220
 
229
 
221
                 case State.End:
230
                 case State.End:
222
                     {
231
                     {
223
-                        _timeSpan = new TimeSpan();
224
-                        //_timeSpan = new TimeSpan(0, 23, 12, 45, 54);
232
+                        SRTime = Convert.ToDateTime("2020-01-01 00:00:00");
233
+                        //_timeSpan = new TimeSpan();
234
+                        ////_timeSpan = new TimeSpan(0, 23, 12, 45, 54);
225
                     }
235
                     }
226
                     break;
236
                     break;
227
             }
237
             }
228
 
238
 
229
-            string time = string.Format("{0:D2}:{1:D2}",/* _timeSpan.Hours,*/ _timeSpan.Minutes, _timeSpan.Seconds);
239
+            //string time = string.Format("{0:D2}:{1:D2}",/* _timeSpan.Hours,*/ _timeSpan.Minutes, _timeSpan.Seconds);
230
             //char[] times = time.ToCharArray();
240
             //char[] times = time.ToCharArray();
231
-            txbTime.Text = time;
241
+            if (SRTime.Hour > 0)
242
+            {
243
+                //Dispatcher.Invoke(() =>
244
+                //{
245
+                txbTime.Text = SRTime.ToString("HH:mm:ss");
246
+                //});
247
+            }
248
+            else
249
+            {
250
+                //Dispatcher.Invoke(() =>
251
+                //{
252
+                txbTime.Text = SRTime.ToString("mm:ss");
253
+                //});
254
+            }
232
         }
255
         }
256
+
233
         /// <summary>
257
         /// <summary>
234
         /// 开始
258
         /// 开始
235
         /// </summary>
259
         /// </summary>
237
         /// <param name="e"></param>
261
         /// <param name="e"></param>
238
         private void Stack()
262
         private void Stack()
239
         {
263
         {
264
+            Recorddt = DateTime.Now;
240
             _state = State.Start;
265
             _state = State.Start;
241
         }
266
         }
242
         /// <summary>
267
         /// <summary>
556
             {
581
             {
557
                 try
582
                 try
558
                 {
583
                 {
559
-                    if (_timeSpan.Minutes > 0 || _timeSpan.Seconds > 3)
584
+                    if (SRTime.Hour > 0 || SRTime.Minute > 0 || SRTime.Second > 3)
560
                     {
585
                     {
561
                         try
586
                         try
562
                         {
587
                         {

+ 39
- 43
XHWK.WKTool/XHMicroLessonSystemWindow.xaml View File

318
                              MouseWheel="IMG1_MouseWheel" >
318
                              MouseWheel="IMG1_MouseWheel" >
319
                                             </ContentControl>
319
                                             </ContentControl>
320
                                         </ScrollViewer>-->
320
                                         </ScrollViewer>-->
321
-                                    <!--图片表框 -->
322
-                                    <Rectangle x:Name="RectImgBorder" Cursor="SizeAll" Fill="#00000000" HorizontalAlignment="Left" Stroke="#2D8CF0" VerticalAlignment="Top" Width="300" Height="300" Visibility="Hidden" Margin="373,175,0,0" StrokeThickness="4" StrokeDashArray="4 4" SnapsToDevicePixels="True"/>
323
-                                    <Image Name="imgCanvas" Height="0" VerticalAlignment="Top" HorizontalAlignment="Left" Stretch="Fill" MouseDown="PicEMap_MouseDown" RenderTransform="{StaticResource Imageview}" MouseLeftButtonDown="imgCanvas_MouseLeftButtonDown" Focusable="True" MouseMove="imgCanvas_MouseMove" MouseUp="imgCanvas_MouseUp"/>
324
-                                    <!--四个点 -->
325
-                                    <Canvas>
326
-                                        <Thumb x:Name="RectLeftUp" Cursor="SizeNWSE"  HorizontalAlignment="Left" Height="20"  VerticalAlignment="Top" Width="20" Visibility="Hidden" Canvas.Left="314" Canvas.Top="157" Background="White" BorderBrush="#2D8CF0" BorderThickness="2"  DragDelta="RectRightUp_DragDelta" DragStarted="RectRightUp_DragStarted" DragCompleted="RectRightUp_DragCompleted"/>
327
-                                        <Thumb x:Name="RectRightUp" Cursor="SizeNESW"  HorizontalAlignment="Left" Height="20"  VerticalAlignment="Top" Width="20" Visibility="Hidden" Canvas.Left="775" Canvas.Top="157" Background="White" BorderBrush="#2D8CF0" BorderThickness="2" DragDelta="RectRightUp_DragDelta" DragStarted="RectRightUp_DragStarted" DragCompleted="RectRightUp_DragCompleted"/>
328
-                                        <Thumb x:Name="RectLeftDown" Cursor="SizeNESW"  HorizontalAlignment="Left" Height="20"  VerticalAlignment="Top" Width="20" Visibility="Hidden" Canvas.Left="314" Canvas.Top="508" Background="White" BorderBrush="#2D8CF0" BorderThickness="2" DragDelta="RectRightUp_DragDelta" DragStarted="RectRightUp_DragStarted" DragCompleted="RectRightUp_DragCompleted"/>
329
-                                        <Thumb x:Name="RectRightDown" Cursor="SizeNWSE"  HorizontalAlignment="Left" Height="20"  VerticalAlignment="Top" Width="20" Visibility="Hidden" Canvas.Left="775" Canvas.Top="508" Background="White" BorderBrush="#2D8CF0" BorderThickness="2" DragDelta="RectRightUp_DragDelta" DragStarted="RectRightUp_DragStarted" DragCompleted="RectRightUp_DragCompleted"/>
330
-                                    </Canvas>
331
-                                </Grid>
332
-                            </Border>
321
+                                        <!--图片表框 -->
322
+                                        <Rectangle x:Name="RectImgBorder" Cursor="SizeAll" Fill="#00000000" HorizontalAlignment="Left" Stroke="#2D8CF0" VerticalAlignment="Top" Width="300" Height="300" Visibility="Hidden" Margin="373,175,0,0" StrokeThickness="4" StrokeDashArray="4 4" SnapsToDevicePixels="True"/>
323
+                                        <Image x:Name="imgCanvas" Height="0" VerticalAlignment="Top" HorizontalAlignment="Left" Stretch="Fill" MouseDown="PicEMap_MouseDown" RenderTransform="{StaticResource Imageview}" MouseLeftButtonDown="imgCanvas_MouseLeftButtonDown" Focusable="True" MouseMove="imgCanvas_MouseMove" MouseUp="imgCanvas_MouseUp"/>
324
+                                        <!--四个点 -->
325
+                                        <Canvas>
326
+                                            <Thumb x:Name="RectLeftUp" Cursor="SizeNWSE"  HorizontalAlignment="Left" Height="20"  VerticalAlignment="Top" Width="20" Visibility="Hidden" Canvas.Left="314" Canvas.Top="157" Background="White" BorderBrush="#2D8CF0" BorderThickness="2"  DragDelta="RectRightUp_DragDelta" DragStarted="RectRightUp_DragStarted" DragCompleted="RectRightUp_DragCompleted"/>
327
+                                            <Thumb x:Name="RectRightUp" Cursor="SizeNESW"  HorizontalAlignment="Left" Height="20"  VerticalAlignment="Top" Width="20" Visibility="Hidden" Canvas.Left="775" Canvas.Top="157" Background="White" BorderBrush="#2D8CF0" BorderThickness="2" DragDelta="RectRightUp_DragDelta" DragStarted="RectRightUp_DragStarted" DragCompleted="RectRightUp_DragCompleted"/>
328
+                                            <Thumb x:Name="RectLeftDown" Cursor="SizeNESW"  HorizontalAlignment="Left" Height="20"  VerticalAlignment="Top" Width="20" Visibility="Hidden" Canvas.Left="314" Canvas.Top="508" Background="White" BorderBrush="#2D8CF0" BorderThickness="2" DragDelta="RectRightUp_DragDelta" DragStarted="RectRightUp_DragStarted" DragCompleted="RectRightUp_DragCompleted"/>
329
+                                            <Thumb x:Name="RectRightDown" Cursor="SizeNWSE"  HorizontalAlignment="Left" Height="20"  VerticalAlignment="Top" Width="20" Visibility="Hidden" Canvas.Left="775" Canvas.Top="508" Background="White" BorderBrush="#2D8CF0" BorderThickness="2" DragDelta="RectRightUp_DragDelta" DragStarted="RectRightUp_DragStarted" DragCompleted="RectRightUp_DragCompleted"/>
330
+                                        </Canvas>
331
+                                    </Grid>
332
+                                </Border>
333
                             </Grid>
333
                             </Grid>
334
                             <Image x:Name="imgDocumentation" Visibility="Visible" Stretch="Fill"/>
334
                             <Image x:Name="imgDocumentation" Visibility="Visible" Stretch="Fill"/>
335
                             <!--<Grid Width="auto" Height="auto" HorizontalAlignment="Center" VerticalAlignment="Center">
335
                             <!--<Grid Width="auto" Height="auto" HorizontalAlignment="Center" VerticalAlignment="Center">
338
                                 </Border>
338
                                 </Border>
339
                             </Grid>-->
339
                             </Grid>-->
340
                             <Image x:Name="imgPPT" Visibility="Visible" VerticalAlignment="Top"/>
340
                             <Image x:Name="imgPPT" Visibility="Visible" VerticalAlignment="Top"/>
341
-                        <!--导入图片-->
342
-                        <!--<Button Cursor="Hand" x:Name="btnOk" Height="50" Width="50" Content="√" FontSize="26" Background="#2E8CF0" Foreground="#FFFFFF" Click="btnOk_Click" Visibility="Collapsed"/>-->
343
-                        <InkCanvas Grid.Row="0" x:Name="blackboard_canvas"  Background="Transparent" Visibility="Collapsed" Grid.ColumnSpan="2"/>
344
-                        <!--摄像头-->
345
-                        <!--<wfi:WindowsFormsHost Grid.Row="0" Grid.Column="1" x:Name="wfhCamera" Height="124" Width="172" HorizontalAlignment="Right" Margin="0,10,30.10,0" VerticalAlignment="Top">
341
+                            <!--导入图片-->
342
+                            <!--<Button Cursor="Hand" x:Name="btnOk" Height="50" Width="50" Content="√" FontSize="26" Background="#2E8CF0" Foreground="#FFFFFF" Click="btnOk_Click" Visibility="Collapsed"/>-->
343
+                            <InkCanvas Grid.Row="0" x:Name="blackboard_canvas"  Background="Transparent" Visibility="Collapsed" Grid.ColumnSpan="2"/>
344
+                            <!--摄像头-->
345
+                            <!--<wfi:WindowsFormsHost Grid.Row="0" Grid.Column="1" x:Name="wfhCamera" Height="124" Width="172" HorizontalAlignment="Right" Margin="0,10,30.10,0" VerticalAlignment="Top">
346
                     <aforge:VideoSourcePlayer x:Name="player" Height="124" Width="172"  />
346
                     <aforge:VideoSourcePlayer x:Name="player" Height="124" Width="172"  />
347
                 </wfi:WindowsFormsHost>-->
347
                 </wfi:WindowsFormsHost>-->
348
                             <!--<Image x:Name="imgLoad"
348
                             <!--<Image x:Name="imgLoad"
438
                             <Button.Template>
438
                             <Button.Template>
439
                                 <ControlTemplate TargetType="{x:Type Button}">
439
                                 <ControlTemplate TargetType="{x:Type Button}">
440
                                     <Border
440
                                     <Border
441
-                                BorderBrush="{TemplateBinding Control.BorderBrush}"
441
+                                BorderBrush="{TemplateBinding BorderBrush}"
442
                                 BorderThickness="1"
442
                                 BorderThickness="1"
443
                                 CornerRadius="2">
443
                                 CornerRadius="2">
444
-                                        <Border.Background>#EBEFF3</Border.Background>
444
+                                        <Border.Background>
445
+                                            <Brush>#EBEFF3</Brush>
446
+                                        </Border.Background>
445
                                         <ContentPresenter
447
                                         <ContentPresenter
446
                                     HorizontalAlignment="Center"
448
                                     HorizontalAlignment="Center"
447
                                     VerticalAlignment="Center"
449
                                     VerticalAlignment="Center"
448
-                                    Content="{TemplateBinding ContentControl.Content}" />
450
+                                    Content="{TemplateBinding Content}" />
449
                                     </Border>
451
                                     </Border>
450
                                 </ControlTemplate>
452
                                 </ControlTemplate>
451
                             </Button.Template>
453
                             </Button.Template>
471
                         <Button.Template>
473
                         <Button.Template>
472
                             <ControlTemplate TargetType="{x:Type Button}">
474
                             <ControlTemplate TargetType="{x:Type Button}">
473
                                 <Border
475
                                 <Border
474
-                                BorderBrush="{TemplateBinding Control.BorderBrush}"
476
+                                BorderBrush="{TemplateBinding BorderBrush}"
475
                                 BorderThickness="1"
477
                                 BorderThickness="1"
476
                                 CornerRadius="2">
478
                                 CornerRadius="2">
477
-                                    <Border.Background>#2D8CF0</Border.Background>
479
+                                    <Border.Background>
480
+                                        <Brush>#2D8CF0</Brush>
481
+                                    </Border.Background>
478
                                     <ContentPresenter
482
                                     <ContentPresenter
479
                                     HorizontalAlignment="Center"
483
                                     HorizontalAlignment="Center"
480
                                     VerticalAlignment="Center"
484
                                     VerticalAlignment="Center"
481
-                                    Content="{TemplateBinding ContentControl.Content}" />
485
+                                    Content="{TemplateBinding Content}" />
482
                                 </Border>
486
                                 </Border>
483
                             </ControlTemplate>
487
                             </ControlTemplate>
484
                         </Button.Template>
488
                         </Button.Template>
553
                     x:Name="btnLastPage"
557
                     x:Name="btnLastPage"
554
                     Width="60" Height="20"
558
                     Width="60" Height="20"
555
                     Click="BtnLastPage_Click">
559
                     Click="BtnLastPage_Click">
556
-                                <Button.Content>
557
-                                    <StackPanel>
558
-                                        <Image Width="16" Height="12" Source=".\Images\class_p1.png" />
559
-                                    </StackPanel>
560
-                                </Button.Content>
560
+                                <StackPanel>
561
+                                    <Image Width="16" Height="12" Source=".\Images\class_p1.png" />
562
+                                </StackPanel>
561
                             </Button>
563
                             </Button>
562
                             <Grid Width="60"  Background="Transparent">
564
                             <Grid Width="60"  Background="Transparent">
563
                                 <Grid.RowDefinitions>
565
                                 <Grid.RowDefinitions>
576
                     x:Name="btnNextPage"  Background="Transparent"
578
                     x:Name="btnNextPage"  Background="Transparent"
577
                     Width="60" Height="20"
579
                     Width="60" Height="20"
578
                     Click="BtnNextPage_Click">
580
                     Click="BtnNextPage_Click">
579
-                                <Button.Content>
580
-                                    <StackPanel>
581
-                                        <Image Width="16" Height="12" Source=".\Images\class_p2.png" />
582
-                                    </StackPanel>
583
-                                </Button.Content>
581
+                                <StackPanel>
582
+                                    <Image Width="16" Height="12" Source=".\Images\class_p2.png" />
583
+                                </StackPanel>
584
                             </Button>
584
                             </Button>
585
                         </StackPanel>
585
                         </StackPanel>
586
                     </Grid>
586
                     </Grid>
645
                     Width="28" Height="20"
645
                     Width="28" Height="20"
646
                     Click="last_button_Click">
646
                     Click="last_button_Click">
647
 
647
 
648
-                            <Button.Content>
649
-                                <StackPanel>
650
-                                    <Image Width="16" Height="12" Source=".\Images\class_p1.png" />
651
-                                </StackPanel>
652
-                            </Button.Content>
648
+                            <StackPanel>
649
+                                <Image Width="16" Height="12" Source=".\Images\class_p1.png" />
650
+                            </StackPanel>
653
                         </Button>
651
                         </Button>
654
                         <Grid Width="60"  Background="Transparent" MouseLeftButtonDown="Window_MouseLeftButtonDown_1">
652
                         <Grid Width="60"  Background="Transparent" MouseLeftButtonDown="Window_MouseLeftButtonDown_1">
655
                             <Grid.RowDefinitions>
653
                             <Grid.RowDefinitions>
668
                     x:Name="next_btn"  Background="Transparent"
666
                     x:Name="next_btn"  Background="Transparent"
669
                     Width="28" Height="20"
667
                     Width="28" Height="20"
670
                     Click="next_btn_Click">
668
                     Click="next_btn_Click">
671
-                            <Button.Content>
672
-                                <StackPanel>
673
-                                    <Image Width="16" Height="12" Source=".\Images\class_p2.png" />
674
-                                </StackPanel>
675
-                            </Button.Content>
669
+                            <StackPanel>
670
+                                <Image Width="16" Height="12" Source=".\Images\class_p2.png" />
671
+                            </StackPanel>
676
                         </Button>
672
                         </Button>
677
                     </StackPanel>
673
                     </StackPanel>
678
                 </Grid>
674
                 </Grid>

+ 4
- 98
XHWK.WKTool/XHMicroLessonSystemWindow.xaml.cs View File

265
             }
265
             }
266
         }
266
         }
267
 
267
 
268
-        /// <summary>
269
-        /// 开始
270
-        /// </summary>
271
-        /// <param name="sender"></param>
272
-        /// <param name="e"></param>
273
-        private void Stack()
274
-        {
275
-            _state = State.Start;
276
-        }
277
-        /// <summary>
278
-        /// 暂停
279
-        /// </summary>
280
-        private void TimeOut()
281
-        {
282
-            _state = State.Pause;
283
-        }
284
-        /// <summary>
285
-        /// 结束
286
-        /// </summary>
287
-        /// <param name="sender"></param>
288
-        /// <param name="e"></param>
289
-        private void End()
290
-        {
291
-            _state = State.End;
292
-        }
293
-        /// <summary>
294
-        /// 时钟回调
295
-        /// </summary>
296
-        /// <param name="sender"></param>
297
-        /// <param name="e"></param>
298
-        private void OnTimer(object sender, EventArgs e)
299
-        {
300
-            switch (_state)
301
-            {
302
-                case State.Start:
303
-                    {
304
-                        _timeSpan += new TimeSpan(0, 0, 0, 1);
305
-                    }
306
-                    break;
307
-
308
-                case State.Pause:
309
-                    {
310
-                    }
311
-                    break;
312
-
313
-                case State.End:
314
-                    {
315
-                        _timeSpan = new TimeSpan();
316
-                        //_timeSpan = new TimeSpan(0, 23, 12, 45, 54);
317
-                    }
318
-                    break;
319
-            }
320
-
321
-            string time = string.Format("{0:D2}:{1:D2}",/* _timeSpan.Hours,*/ _timeSpan.Minutes, _timeSpan.Seconds);
322
-            txbTime.Text = time;
323
-            //txbTime.Text = time;
324
-        }
325
-        /// <summary>
326
-        /// 修改布局
327
-        /// </summary>
328
-        public void SetUpLayout()
329
-        {
330
-            //宽高比1276,1040
331
-            //double AspectRatio = 1276.0 / 1040.0;
332
-            ////System.Drawing.Size des = PrimaryScreen.DESKTOP;
333
-            //System.Drawing.Size workingArea = PrimaryScreen.WorkingArea;
334
-            //this.Height = workingArea.Height;
335
-
336
-        }
337
         #endregion
268
         #endregion
338
 
269
 
339
         #region 事件
270
         #region 事件
347
             DragMove();
278
             DragMove();
348
         }
279
         }
349
 
280
 
350
-
351
         #region 摄像头
281
         #region 摄像头
352
         private System.Timers.Timer times;
282
         private System.Timers.Timer times;
353
         private List<string> RbnOpen;
283
         private List<string> RbnOpen;
2776
         /// </summary>
2706
         /// </summary>
2777
         private void W_ScreenRecordingToolbarWindow_Click_stopRecordingScreen()
2707
         private void W_ScreenRecordingToolbarWindow_Click_stopRecordingScreen()
2778
         {
2708
         {
2709
+            txbTime.Text = "";
2710
+            txbTime.Visibility = Visibility.Hidden;
2779
             txbType.Visibility = Visibility.Visible;
2711
             txbType.Visibility = Visibility.Visible;
2780
             txbType.Text = "保存中";
2712
             txbType.Text = "保存中";
2781
             btnScreenRecording.IsEnabled = false;
2713
             btnScreenRecording.IsEnabled = false;
2928
                     }
2860
                     }
2929
                     #endregion
2861
                     #endregion
2930
 
2862
 
2931
-                    #region 计时器初始化
2932
-
2933
-                    //if (t == null)
2934
-                    //{
2935
-                    //    t = new DispatcherTimer();
2936
-                    //    t.Tick += OnTimer;
2937
-                    //    t.Interval = new TimeSpan(0, 0, 0, 1);
2938
-                    //    t.IsEnabled = true;
2939
-                    //    t.Start();
2940
-                    //}
2941
-                    //t.Interval = new TimeSpan(0, 0, 0, 1);
2942
                     txbTime.Visibility = Visibility.Visible;
2863
                     txbTime.Visibility = Visibility.Visible;
2943
-                    #endregion
2944
 
2864
 
2945
                     VideoInfo = new Model_Video
2865
                     VideoInfo = new Model_Video
2946
                     {
2866
                     {
3326
                     //根据录制时间长度确定是否保存
3246
                     //根据录制时间长度确定是否保存
3327
                     if (SRTime.Hour > 0 || SRTime.Minute > 0 || SRTime.Second > 3)
3247
                     if (SRTime.Hour > 0 || SRTime.Minute > 0 || SRTime.Second > 3)
3328
                     {
3248
                     {
3329
-                        txbType.Visibility = Visibility.Visible;
3330
-                        txbType.Text = "保存中";
3331
                         #region 2秒内不可点击
3249
                         #region 2秒内不可点击
3332
                         new Thread(new ThreadStart(new Action(() =>
3250
                         new Thread(new ThreadStart(new Action(() =>
3333
                         {
3251
                         {
3359
                                 //End();
3277
                                 //End();
3360
                                 txbTime.Text = "";
3278
                                 txbTime.Text = "";
3361
                                 txbTime.Visibility = Visibility.Hidden;
3279
                                 txbTime.Visibility = Visibility.Hidden;
3280
+                                txbType.Visibility = Visibility.Visible;
3281
+                                txbType.Text = "保存中";
3362
                             });
3282
                             });
3363
                             //}))).Start();
3283
                             //}))).Start();
3364
                             //new Thread(new ThreadStart(new Action(() =>
3284
                             //new Thread(new ThreadStart(new Action(() =>
3455
                         timer.Dispose();
3375
                         timer.Dispose();
3456
                         IsFirstR = true;
3376
                         IsFirstR = true;
3457
 
3377
 
3458
-
3459
-
3460
-
3461
                         BtnRecord.IsEnabled = true;
3378
                         BtnRecord.IsEnabled = true;
3462
                         btnStop.IsEnabled = true;
3379
                         btnStop.IsEnabled = true;
3463
                         TxbRecordingWord.Text = "录制";
3380
                         TxbRecordingWord.Text = "录制";
4671
             }
4588
             }
4672
         }
4589
         }
4673
         /// <summary>
4590
         /// <summary>
4674
-        /// 位置确定
4675
-        /// </summary>
4676
-        /// <param name="sender"></param>
4677
-        /// <param name="e"></param>
4678
-        private void BtnOk_Click(object sender, RoutedEventArgs e)
4679
-        {
4680
-            //APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation = true;
4681
-            //btnOk.Visibility = Visibility.Collapsed;
4682
-            //blackboard_canvas.Visibility = Visibility.Visible;
4683
-        }
4684
-        /// <summary>
4685
         /// 引用user32.dll动态链接库(windows api),
4591
         /// 引用user32.dll动态链接库(windows api),
4686
         /// 使用库中定义 API:SetCursorPos
4592
         /// 使用库中定义 API:SetCursorPos
4687
         /// 设置光标位置
4593
         /// 设置光标位置

Loading…
Cancel
Save