Browse Source

zhao:优化

tags/录制修改前
耀 4 years ago
parent
commit
61787499cb

+ 55
- 55
Common/system/ImageHelper.cs View File

434
 
434
 
435
                             MemoryStream memoryStream = new MemoryStream();
435
                             MemoryStream memoryStream = new MemoryStream();
436
                             encoder.Save(memoryStream);
436
                             encoder.Save(memoryStream);
437
-                            Bitmap bit = new Bitmap(memoryStream,true);
437
+                            Bitmap bit = new Bitmap(memoryStream, true);
438
                             if (ImgWidth - 2 < bit.Width)
438
                             if (ImgWidth - 2 < bit.Width)
439
+                            {
440
+                                try
439
                                 {
441
                                 {
440
-                                    try
441
-                                    {
442
-                                        Graphics g = Graphics.FromImage(Img);
442
+                                    Graphics g = Graphics.FromImage(Img);
443
                                     g.DrawImage(bit, new Rectangle(0, 0, ImgWidth, ImgHeight), new Rectangle(0, 0, bit.Width, bit.Height), GraphicsUnit.Pixel);
443
                                     g.DrawImage(bit, new Rectangle(0, 0, ImgWidth, ImgHeight), new Rectangle(0, 0, bit.Width, bit.Height), GraphicsUnit.Pixel);
444
-                                        g.Dispose();
445
-                                    }
446
-                                    catch
447
-                                    {
448
-                                        Img = bit;
449
-                                    }
444
+                                    g.Dispose();
450
                                 }
445
                                 }
451
-                                else
446
+                                catch
452
                                 {
447
                                 {
453
                                     Img = bit;
448
                                     Img = bit;
449
+                                }
450
+                            }
451
+                            else
452
+                            {
453
+                                Img = bit;
454
                             }
454
                             }
455
                             Img.Save(filePathName);
455
                             Img.Save(filePathName);
456
                             memoryStream.Dispose();
456
                             memoryStream.Dispose();
638
                 BitmapEncoder encoder = new PngBitmapEncoder();
638
                 BitmapEncoder encoder = new PngBitmapEncoder();
639
                 encoder.Frames.Add(BitmapFrame.Create(bmp));
639
                 encoder.Frames.Add(BitmapFrame.Create(bmp));
640
                 string filePathName = saveModel.filePathName;
640
                 string filePathName = saveModel.filePathName;
641
-            if (ImgWidth > 0)
642
-            {
643
-                Bitmap Img = new Bitmap(ImgWidth, ImgHeight);
644
-                try
641
+                if (ImgWidth > 0)
645
                 {
642
                 {
646
-                    MemoryStream memoryStream = new MemoryStream();
647
-                    encoder.Save(memoryStream);
648
-                    new Thread(new ThreadStart(new Action(() =>
643
+                    Bitmap Img = new Bitmap(ImgWidth, ImgHeight);
644
+                    try
649
                     {
645
                     {
646
+                        MemoryStream memoryStream = new MemoryStream();
647
+                        encoder.Save(memoryStream);
648
+                        new Thread(new ThreadStart(new Action(() =>
649
+                        {
650
                         //System.Drawing.Image img = System.Drawing.Image.FromStream(memoryStream);
650
                         //System.Drawing.Image img = System.Drawing.Image.FromStream(memoryStream);
651
                         Bitmap bit = new Bitmap(memoryStream);
651
                         Bitmap bit = new Bitmap(memoryStream);
652
-                        if (ImgWidth - 2 < bit.Width)
653
-                        {
654
-                            try
652
+                            if (ImgWidth - 2 < bit.Width)
655
                             {
653
                             {
656
-                                Graphics g = Graphics.FromImage(Img);
654
+                                try
655
+                                {
656
+                                    Graphics g = Graphics.FromImage(Img);
657
                                 //g.InterpolationMode = InterpolationMode.HighQualityBicubic;
657
                                 //g.InterpolationMode = InterpolationMode.HighQualityBicubic;
658
                                 g.DrawImage(bit, new Rectangle(0, 0, ImgWidth, ImgHeight), new Rectangle(0, 0, bit.Width, bit.Height), GraphicsUnit.Pixel);
658
                                 g.DrawImage(bit, new Rectangle(0, 0, ImgWidth, ImgHeight), new Rectangle(0, 0, bit.Width, bit.Height), GraphicsUnit.Pixel);
659
-                                g.Dispose();
659
+                                    g.Dispose();
660
+                                }
661
+                                catch
662
+                                {
663
+                                    Img = bit;
664
+                                }
660
                             }
665
                             }
661
-                            catch
666
+                            else
662
                             {
667
                             {
663
                                 Img = bit;
668
                                 Img = bit;
664
                             }
669
                             }
665
-                        }
666
-                        else
667
-                        {
668
-                            Img = bit;
669
-                        }
670
-                        Img.Save(filePathName);
670
+                            Img.Save(filePathName);
671
                         //Bitmap bitmap = CutImageWhitePart(Img);
671
                         //Bitmap bitmap = CutImageWhitePart(Img);
672
                         //FileToolsCommon.DeleteFile(filePathName);
672
                         //FileToolsCommon.DeleteFile(filePathName);
673
                         //bitmap.Save(filePathName);
673
                         //bitmap.Save(filePathName);
674
                         //bitmap.Dispose();
674
                         //bitmap.Dispose();
675
                         memoryStream.Dispose();
675
                         memoryStream.Dispose();
676
-                        Img.Dispose();
677
-                        bit.Dispose();
678
-                    }))).Start();
676
+                            Img.Dispose();
677
+                            bit.Dispose();
678
+                        }))).Start();
679
+                    }
680
+                    catch (Exception ex)
681
+                    {
682
+
683
+                    }
679
                 }
684
                 }
680
-                catch (Exception ex)
685
+                else
681
                 {
686
                 {
687
+                    //SaveImageModel sim = new SaveImageModel();
688
+                    //sim.encoder = new PngBitmapEncoder();
689
+                    //sim.encoder = new PngBitmapEncoder();
690
+                    //BitmapFrame test= encoder.Frames[0];
691
+                    //sim.encoder.Frames.Add(BitmapFrame.Create(test));
692
+                    ////sim.encoder.Frames[0].CopyTo(encoder.Frames[0]);
693
+                    ////sim.encoder.CopyTo(encoder);
694
+                    ////encoder.CopyTo(sim.encoder);
695
+                    //sim.FilePath = filePathName;
696
+                    ////sim.bmp = new RenderTargetBitmap(width, height, PrimaryScreen.DpiX, PrimaryScreen.DpiY, PixelFormats.Pbgra32);
697
+                    ////bmp.CopyTo(sim.bmp);
698
+                    //Thread t1 = new Thread(SaveImage);
699
+                    //t1.Start(sim);
682
 
700
 
701
+                    System.IO.FileStream fs = new System.IO.FileStream(filePathName, System.IO.FileMode.Create);
702
+                    encoder.Save(fs);
703
+                    fs.Close();
683
                 }
704
                 }
684
             }
705
             }
685
-            else
686
-            {
687
-                //SaveImageModel sim = new SaveImageModel();
688
-                //sim.encoder = new PngBitmapEncoder();
689
-                //sim.encoder = new PngBitmapEncoder();
690
-                //BitmapFrame test= encoder.Frames[0];
691
-                //sim.encoder.Frames.Add(BitmapFrame.Create(test));
692
-                ////sim.encoder.Frames[0].CopyTo(encoder.Frames[0]);
693
-                ////sim.encoder.CopyTo(encoder);
694
-                ////encoder.CopyTo(sim.encoder);
695
-                //sim.FilePath = filePathName;
696
-                ////sim.bmp = new RenderTargetBitmap(width, height, PrimaryScreen.DpiX, PrimaryScreen.DpiY, PixelFormats.Pbgra32);
697
-                ////bmp.CopyTo(sim.bmp);
698
-                //Thread t1 = new Thread(SaveImage);
699
-                //t1.Start(sim);
700
-
701
-                System.IO.FileStream fs = new System.IO.FileStream(filePathName, System.IO.FileMode.Create);
702
-                encoder.Save(fs);
703
-                fs.Close();
704
-            }
705
-            }
706
             catch (Exception ex)
706
             catch (Exception ex)
707
             {
707
             {
708
 
708
 

+ 4
- 4
XHWK.WKTool/PrintWindow.xaml.cs View File

334
                 }
334
                 }
335
                 #region 添加箭头
335
                 #region 添加箭头
336
                 string Str = "↑";
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
-                
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
341
                 #endregion
342
                 backgroudImg.Save(_saveimg);
342
                 backgroudImg.Save(_saveimg);
343
 
343
 

+ 3
- 3
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
-        
59
+
60
         private KeyboardHookCommon k_hook;
60
         private KeyboardHookCommon k_hook;
61
         /// <summary>
61
         /// <summary>
62
         /// 🖊状态 0红色 1蓝色 10红色批注内 11蓝色批注内
62
         /// 🖊状态 0红色 1蓝色 10红色批注内 11蓝色批注内
142
             {
142
             {
143
                 t = new DispatcherTimer();
143
                 t = new DispatcherTimer();
144
                 t.Tick += OnTimer;
144
                 t.Tick += OnTimer;
145
-                t.Interval = new TimeSpan(0, 0, 0,0, 300);
145
+                t.Interval = new TimeSpan(0, 0, 0, 0, 300);
146
                 t.IsEnabled = true;
146
                 t.IsEnabled = true;
147
                 t.Start();
147
                 t.Start();
148
             }
148
             }
149
-            t.Interval = new TimeSpan(0, 0, 0, 0,300);
149
+            t.Interval = new TimeSpan(0, 0, 0, 0, 300);
150
             //Stack();
150
             //Stack();
151
             //ImgRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar25.png"));
151
             //ImgRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar25.png"));
152
             //BtnRecordingScreen_Click(null, null);
152
             //BtnRecordingScreen_Click(null, null);

+ 2
- 2
XHWK.WKTool/XHMicroLessonSystemWindow.xaml.cs View File

4972
         /// <param name="e"></param>
4972
         /// <param name="e"></param>
4973
         private void txbCurrpage_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
4973
         private void txbCurrpage_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
4974
         {
4974
         {
4975
-            if(e.ClickCount==2)
4975
+            if (e.ClickCount == 2)
4976
             {
4976
             {
4977
                 try
4977
                 try
4978
                 {
4978
                 {
5008
                 MessageWindow.Show("操作有误!请输入有效的页码!");
5008
                 MessageWindow.Show("操作有误!请输入有效的页码!");
5009
                 return;
5009
                 return;
5010
             }
5010
             }
5011
-            if(JumpPage<1)
5011
+            if (JumpPage < 1)
5012
             {
5012
             {
5013
                 JumpPage = 1;
5013
                 JumpPage = 1;
5014
             }
5014
             }

Loading…
Cancel
Save