Browse Source

代码优化

master
张剑 1 year ago
parent
commit
8227fa021d
3 changed files with 12 additions and 42 deletions
  1. 1
    1
      XHWK.WKTool/DAL/DalUpload.cs
  2. 3
    2
      XHWK.WKTool/MainWindow.xaml
  3. 8
    39
      XHWK.WKTool/MainWindow.xaml.cs

+ 1
- 1
XHWK.WKTool/DAL/DalUpload.cs View File

135
         /// </returns>
135
         /// </returns>
136
         public bool UploadVideo(string videoGuid, out string errMessage)
136
         public bool UploadVideo(string videoGuid, out string errMessage)
137
         {
137
         {
138
-            errMessage = "";
138
+            errMessage = "上传视频失败";
139
             try
139
             try
140
             {
140
             {
141
                 ModelVideo videoInfo = null;
141
                 ModelVideo videoInfo = null;

+ 3
- 2
XHWK.WKTool/MainWindow.xaml View File

1500
                         <Label
1500
                         <Label
1501
                             x:Name="LblVideoMess"
1501
                             x:Name="LblVideoMess"
1502
                             Grid.Row="0"
1502
                             Grid.Row="0"
1503
-                            Margin="0,0,0,100"
1503
+                            Margin="0,0,0,0"
1504
                             HorizontalAlignment="Center"
1504
                             HorizontalAlignment="Center"
1505
                             VerticalAlignment="Center"
1505
                             VerticalAlignment="Center"
1506
-                            Content="暂无微课录制信息,请录制并等待保存完成后重试!"
1506
+                            Content="暂无微课录制"
1507
                             FontSize="20"
1507
                             FontSize="20"
1508
+                            Foreground="#999"
1508
                             Visibility="Hidden" />
1509
                             Visibility="Hidden" />
1509
                         <Button
1510
                         <Button
1510
                             x:Name="BtnVideoUpPage"
1511
                             x:Name="BtnVideoUpPage"

+ 8
- 39
XHWK.WKTool/MainWindow.xaml.cs View File

15
 using System.Diagnostics;
15
 using System.Diagnostics;
16
 using System.Drawing;
16
 using System.Drawing;
17
 using System.IO;
17
 using System.IO;
18
-using System.Linq;
19
 using System.Threading;
18
 using System.Threading;
20
 using System.Threading.Tasks;
19
 using System.Threading.Tasks;
21
 using System.Windows;
20
 using System.Windows;
351
             if (App.IsLoginType)
350
             if (App.IsLoginType)
352
             {
351
             {
353
                 string headpicPath = FileToolsCommon.GetFileAbsolutePath("/Data/" + App.UserInfo.Username + ".png");
352
                 string headpicPath = FileToolsCommon.GetFileAbsolutePath("/Data/" + App.UserInfo.Username + ".png");
354
-                if (FileToolsCommon.IsExistFile(headpicPath))
355
-                {
356
-                    ImgHead.ImageSource = new BitmapImage(new Uri(headpicPath));
357
-                }
358
-                else
359
-                {
360
-                    ImgHead.ImageSource = new BitmapImage(new Uri("pack://application:,,,/BlackImages/HM_HeadImg.png"));
361
-                }
353
+                ImgHead.ImageSource = FileToolsCommon.IsExistFile(headpicPath) ? new BitmapImage(new Uri(headpicPath)) : new BitmapImage(new Uri("pack://application:,,,/BlackImages/HM_HeadImg.png"));
362
                 TxbLoginType.Text = App.UserInfo.Username;
354
                 TxbLoginType.Text = App.UserInfo.Username;
363
                 ImgHeadImgN.Visibility = Visibility.Collapsed;
355
                 ImgHeadImgN.Visibility = Visibility.Collapsed;
364
                 ImgHeadImg.Visibility = Visibility.Visible;
356
                 ImgHeadImg.Visibility = Visibility.Visible;
1968
                 }
1960
                 }
1969
                 else if (!string.IsNullOrEmpty(childName))
1961
                 else if (!string.IsNullOrEmpty(childName))
1970
                 {
1962
                 {
1971
-                    FrameworkElement frameworkElement = child as FrameworkElement;
1972
                     // 如果控件名称符合参数条件
1963
                     // 如果控件名称符合参数条件
1973
-                    if (frameworkElement != null && frameworkElement.Name == childName)
1964
+                    if (child is FrameworkElement frameworkElement && frameworkElement.Name == childName)
1974
                     {
1965
                     {
1975
                         list.Add((T)child);
1966
                         list.Add((T)child);
1976
                     }
1967
                     }
2857
                     () =>
2848
                     () =>
2858
                     {
2849
                     {
2859
                         _srTime = _srTime.AddMilliseconds(200);
2850
                         _srTime = _srTime.AddMilliseconds(200);
2860
-                        if (_srTime.Hour > 0)
2861
-                        {
2862
-                            TxbTime.Text = _srTime.ToString("HH:mm:ss");
2863
-                        }
2864
-                        else
2865
-                        {
2866
-                            TxbTime.Text = _srTime.ToString("mm:ss");
2867
-                        }
2851
+                        TxbTime.Text = _srTime.ToString(_srTime.Hour > 0 ? "HH:mm:ss" : "mm:ss");
2868
                     }
2852
                     }
2869
                 );
2853
                 );
2870
                 ThreadPool.QueueUserWorkItem(
2854
                 ThreadPool.QueueUserWorkItem(
3495
         {
3479
         {
3496
             _wit = wit;
3480
             _wit = wit;
3497
             _hei = hei;
3481
             _hei = hei;
3498
-            if (!string.IsNullOrWhiteSpace(imgPath))
3499
-            {
3500
-                ImgPri.Source = new BitmapImage(new Uri(imgPath));
3501
-            }
3502
-            else
3503
-            {
3504
-                ImgPri.Source = null;
3505
-            }
3482
+            ImgPri.Source = !string.IsNullOrWhiteSpace(imgPath) ? new BitmapImage(new Uri(imgPath)) : null;
3506
             GridPrintMask.Visibility = Visibility.Collapsed;
3483
             GridPrintMask.Visibility = Visibility.Collapsed;
3507
         }
3484
         }
3508
 
3485
 
3626
                     // ignored
3603
                     // ignored
3627
                 }
3604
                 }
3628
                 _document.Open();
3605
                 _document.Open();
3629
-                iTextSharp.text.Image image;
3630
                 for (int i = 0; i < App.PageDrawList.Count; i++)
3606
                 for (int i = 0; i < App.PageDrawList.Count; i++)
3631
                 {
3607
                 {
3632
                     long ii = Timestamp();
3608
                     long ii = Timestamp();
3645
                         filePathOutPut,
3621
                         filePathOutPut,
3646
                         rectangleFs
3622
                         rectangleFs
3647
                     );
3623
                     );
3648
-                    image = iTextSharp.text.Image.GetInstance(filePathOutPut);
3624
+                    iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(filePathOutPut);
3649
                     if (string.IsNullOrEmpty(App.PageDrawList[i].PageImagePath)) //没有图片
3625
                     if (string.IsNullOrEmpty(App.PageDrawList[i].PageImagePath)) //没有图片
3650
                     { }
3626
                     { }
3651
                     else if (App.PageDrawList[i].ImgDocumentation && !App.PageDrawList[i].Type.Equals("ppt"))
3627
                     else if (App.PageDrawList[i].ImgDocumentation && !App.PageDrawList[i].Type.Equals("ppt"))
3678
                             filePathOutPut,
3654
                             filePathOutPut,
3679
                             rectangleF
3655
                             rectangleF
3680
                         );
3656
                         );
3681
-                        if (isImg)
3682
-                        {
3683
-                            image = iTextSharp.text.Image.GetInstance(filePathOutPut);
3684
-                        }
3685
-                        else
3686
-                        {
3687
-                            image = iTextSharp.text.Image.GetInstance(App.PageDrawList[i].PageImagePath);
3688
-                        }
3657
+                        image = iTextSharp.text.Image.GetInstance(isImg ? filePathOutPut : App.PageDrawList[i].PageImagePath);
3689
                     }
3658
                     }
3690
                     if (image.Height > iTextSharp.text.PageSize.A4.Height)
3659
                     if (image.Height > iTextSharp.text.PageSize.A4.Height)
3691
                     {
3660
                     {
3732
                     try
3701
                     try
3733
                     {
3702
                     {
3734
                         // 腾千里会根据原PDF的页数生成多个PDF文件
3703
                         // 腾千里会根据原PDF的页数生成多个PDF文件
3735
-                        for (int i = 0; i < strs.Count(); i++)
3704
+                        for (int i = 0; i < strs.Length; i++)
3736
                         {
3705
                         {
3737
                             _timesPrint.Stop();
3706
                             _timesPrint.Stop();
3738
-                            _printMsg = "正在打印第" + (i + 1) + "/" + strs.Count() + "页中";
3707
+                            _printMsg = "正在打印第" + (i + 1) + "/" + strs.Length + "页中";
3739
                             _msgnum = 0;
3708
                             _msgnum = 0;
3740
                             _num = 0;
3709
                             _num = 0;
3741
                             _timesPrint.Interval = 100;
3710
                             _timesPrint.Interval = 100;

Loading…
Cancel
Save