Browse Source

zhao:优化

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

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

@@ -434,23 +434,23 @@ namespace Common.system
434 434
 
435 435
                             MemoryStream memoryStream = new MemoryStream();
436 436
                             encoder.Save(memoryStream);
437
-                            Bitmap bit = new Bitmap(memoryStream,true);
437
+                            Bitmap bit = new Bitmap(memoryStream, true);
438 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 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 448
                                     Img = bit;
449
+                                }
450
+                            }
451
+                            else
452
+                            {
453
+                                Img = bit;
454 454
                             }
455 455
                             Img.Save(filePathName);
456 456
                             memoryStream.Dispose();
@@ -638,71 +638,71 @@ namespace Common.system
638 638
                 BitmapEncoder encoder = new PngBitmapEncoder();
639 639
                 encoder.Frames.Add(BitmapFrame.Create(bmp));
640 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 650
                         //System.Drawing.Image img = System.Drawing.Image.FromStream(memoryStream);
651 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 657
                                 //g.InterpolationMode = InterpolationMode.HighQualityBicubic;
658 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 668
                                 Img = bit;
664 669
                             }
665
-                        }
666
-                        else
667
-                        {
668
-                            Img = bit;
669
-                        }
670
-                        Img.Save(filePathName);
670
+                            Img.Save(filePathName);
671 671
                         //Bitmap bitmap = CutImageWhitePart(Img);
672 672
                         //FileToolsCommon.DeleteFile(filePathName);
673 673
                         //bitmap.Save(filePathName);
674 674
                         //bitmap.Dispose();
675 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 706
             catch (Exception ex)
707 707
             {
708 708
 

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

@@ -334,10 +334,10 @@ namespace XHWK.WKTool
334 334
                 }
335 335
                 #region 添加箭头
336 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 341
                 #endregion
342 342
                 backgroudImg.Save(_saveimg);
343 343
 

+ 3
- 3
XHWK.WKTool/ScreenRecordingToolbarWindow.xaml.cs View File

@@ -56,7 +56,7 @@ namespace XHWK.WKTool
56 56
         /// 状态
57 57
         /// </summary>
58 58
         private State _state = State.End;
59
-        
59
+
60 60
         private KeyboardHookCommon k_hook;
61 61
         /// <summary>
62 62
         /// 🖊状态 0红色 1蓝色 10红色批注内 11蓝色批注内
@@ -142,11 +142,11 @@ namespace XHWK.WKTool
142 142
             {
143 143
                 t = new DispatcherTimer();
144 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 146
                 t.IsEnabled = true;
147 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 150
             //Stack();
151 151
             //ImgRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar25.png"));
152 152
             //BtnRecordingScreen_Click(null, null);

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

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

Loading…
Cancel
Save