瀏覽代碼

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

tags/录制修改前
zhangxueyang 4 年之前
父節點
當前提交
7106b48fe2

+ 108
- 0
Common/system/ImageHelper.cs 查看文件

@@ -4,6 +4,7 @@ using System.Drawing;
4 4
 using System.Drawing.Imaging;
5 5
 using System.IO;
6 6
 using System.Text;
7
+using System.Threading;
7 8
 using System.Windows;
8 9
 using System.Windows.Media;
9 10
 using System.Windows.Media.Imaging;
@@ -370,6 +371,12 @@ namespace Common.system
370 371
                 encoder.Frames.Add(BitmapFrame.Create(bmp));
371 372
                 encoder.Save(fs);
372 373
                 fs.Close();
374
+                new Thread(new ThreadStart(new Action(() =>
375
+                {
376
+                    Bitmap bitmap = CutImageWhitePart(filePathName);
377
+                    FileToolsCommon.DeleteFile(filePathName);
378
+                    bitmap.Save(filePathName);
379
+                }))).Start();
373 380
             }
374 381
             catch (Exception ex)
375 382
             {
@@ -378,5 +385,106 @@ namespace Common.system
378 385
             }
379 386
         }
380 387
         #endregion
388
+
389
+        #region 去掉白边
390
+        /// <summary>
391
+        /// 裁剪图片(去掉白边)
392
+        /// </summary>
393
+        /// <param name="FilePath"></param>
394
+        public static Bitmap CutImageWhitePart(string FilePath)
395
+        {
396
+            Bitmap bmp = new Bitmap(FilePath);
397
+            //上左右下
398
+            int top = 0, left = 0, right = bmp.Width, bottom = bmp.Height;
399
+
400
+            //寻找最上面的标线,从左(0)到右,从上(0)到下
401
+            for (int i = 0; i < bmp.Height; i++)//行
402
+            {
403
+                bool find = false;
404
+                for (int j = 0; j < bmp.Width; j++)//列
405
+                {
406
+                    System.Drawing.Color c = bmp.GetPixel(j, i);
407
+                    if (!IsWhite(c))
408
+                    {
409
+                        top = i;
410
+                        find = true;
411
+                        break;
412
+                    }
413
+                }
414
+                if (find)
415
+                    break;
416
+            }
417
+            //寻找最左边的标线,从上(top位)到下,从左到右
418
+            for (int i = 0; i < bmp.Width; i++)//列
419
+            {
420
+                bool find = false;
421
+                for (int j = top; j < bmp.Height; j++)//行
422
+                {
423
+                    System.Drawing.Color c = bmp.GetPixel(i, j);
424
+                    if (!IsWhite(c))
425
+                    {
426
+                        left = i;
427
+                        find = true;
428
+                        break;
429
+                    }
430
+                }
431
+                if (find)
432
+                    break;
433
+            }
434
+            //寻找最下边标线,从下到上,从左到右
435
+            for (int i = bmp.Height - 1; i >= 0; i--)//行
436
+            {
437
+                bool find = false;
438
+                for (int j = left; j < bmp.Width; j++)//列
439
+                {
440
+                    System.Drawing.Color c = bmp.GetPixel(j, i);
441
+                    if (!IsWhite(c))
442
+                    {
443
+                        bottom = i;
444
+                        find = true;
445
+                        break;
446
+                    }
447
+                }
448
+                if (find)
449
+                    break;
450
+            }
451
+            //寻找最右边的标线,从上到下,从右往左
452
+            for (int i = bmp.Width - 1; i >= 0; i--)//列
453
+            {
454
+                bool find = false;
455
+                for (int j = 0; j <= bottom; j++)//行
456
+                {
457
+                    System.Drawing.Color c = bmp.GetPixel(i, j);
458
+                    if (!IsWhite(c))
459
+                    {
460
+                        right = i;
461
+                        find = true;
462
+                        break;
463
+                    }
464
+                }
465
+                if (find)
466
+                    break;
467
+            }
468
+
469
+            //克隆位图对象的一部分。
470
+            System.Drawing.Rectangle cloneRect = new System.Drawing.Rectangle(left, top, right - left, bottom - top);
471
+            Bitmap cloneBitmap = bmp.Clone(cloneRect, bmp.PixelFormat);
472
+            bmp.Dispose();
473
+            //cloneBitmap.Save(@"d:\123.png", ImageFormat.Png);
474
+            return cloneBitmap;
475
+        }
476
+
477
+        /// <summary>
478
+        /// 判断是否白色和纯透明色(10点的容差)
479
+        /// </summary>
480
+        public static bool IsWhite(System.Drawing.Color c)
481
+        {
482
+            //纯透明也是白色,RGB都为255为纯白
483
+            if (c.A < 10 || (c.R > 245 && c.G > 245 && c.B > 245))
484
+                return true;
485
+
486
+            return false;
487
+        }
488
+        #endregion
381 489
     }
382 490
 }

+ 3
- 3
Common/system/XmlUtilHelper.cs 查看文件

@@ -136,6 +136,9 @@ namespace Common.system
136 136
             return null;
137 137
         }
138 138
 
139
+        #endregion
140
+
141
+        #region 序列化
139 142
         /// <summary>
140 143
         /// 实体类转XML
141 144
         /// </summary>
@@ -153,9 +156,6 @@ namespace Common.system
153 156
                 return sw.ToString();
154 157
             }
155 158
         }
156
-        #endregion
157
-
158
-        #region 序列化
159 159
         /// <summary>
160 160
         /// 序列化
161 161
         /// </summary>

+ 38
- 2
XHWK.WKTool/App.cs 查看文件

@@ -4,6 +4,7 @@ using Common.system;
4 4
 using System;
5 5
 using System.Collections.Generic;
6 6
 using System.Diagnostics;
7
+using System.Security.RightsManagement;
7 8
 using System.Threading;
8 9
 using System.Windows;
9 10
 using System.Windows.Threading;
@@ -28,6 +29,10 @@ namespace XHWK.WKTool
28 29
         /// </summary>
29 30
         public static Model_WKData WKData = null;
30 31
         /// <summary>
32
+        /// 微课视频列表
33
+        /// </summary>
34
+        public static List<Model_Video> VideoList = null;
35
+        /// <summary>
31 36
         /// 主页面
32 37
         /// </summary>
33 38
         public static XHMicroLessonSystemWindow W_XHMicroLessonSystemWindow = null;
@@ -80,14 +85,18 @@ namespace XHWK.WKTool
80 85
         {
81 86
             // 定义Application对象作为整个应用程序入口
82 87
             Application app = new Application();
83
-            WKData = new Model_WKData();
88
+            UserInfo = new Model_UserInfo();
89
+             WKData = new Model_WKData();
90
+            VideoList = new List<Model_Video>();
84 91
             //app.DispatcherUnhandledException += MyApp_DispatcherUnhandledException;
85 92
             CreateAMicroLessonWindow win = new CreateAMicroLessonWindow();
86 93
             app.Run(win);
87 94
             //LogHelper.WriteInfoLog("启动项目");
88 95
             StopSameProcess();
89 96
         }
90
-
97
+        /// <summary>
98
+        /// 结束已运行的程序
99
+        /// </summary>
91 100
         private static void StopSameProcess()
92 101
         {
93 102
             Process current = Process.GetCurrentProcess();
@@ -110,6 +119,11 @@ namespace XHWK.WKTool
110 119
             }
111 120
         }
112 121
 
122
+        /// <summary>
123
+        /// 错误处理
124
+        /// </summary>
125
+        /// <param name="sender"></param>
126
+        /// <param name="e"></param>
113 127
         private void MyApp_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
114 128
         {
115 129
             LogHelper.WriteErrLog("未标示错误:" + e.Exception.Message, e.Exception);
@@ -117,6 +131,28 @@ namespace XHWK.WKTool
117 131
             e.Handled = true;
118 132
         }
119 133
 
134
+        /// <summary>
135
+        /// 保存微课信息
136
+        /// </summary>
137
+        public static void SaveWkData()
138
+        {
139
+            if(UserInfo == null)
140
+            {
141
+                return;
142
+            }
143
+            if (!string.IsNullOrWhiteSpace(APP.UserInfo.Username))
144
+            {
145
+                WKData.VideoList = VideoList;
146
+                //string WkDateXmlStr = XmlUtilHelper.Serializer(typeof(Model_WKData), WKData);
147
+                string WkDateXmlStr = XmlUtilHelper.XmlSerialize(WKData);
148
+                string SavePath = FileToolsCommon.GetFileAbsolutePath("/Data/" + APP.UserInfo.Username + "/");
149
+                FileToolsCommon.CreateDirectory(SavePath);
150
+                
151
+            }
152
+            //if(APP.UserInfo)
153
+            //APP.UserInfo.Wkdata.Add(APP.WKData);
154
+        }
155
+
120 156
         #region 内存处理 -创建人:赵耀 -创建时间:2020年8月12日
121 157
 
122 158
         /// <summary>

+ 1
- 1
XHWK.WKTool/CountdownWindow.xaml 查看文件

@@ -4,7 +4,7 @@
4 4
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5 5
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6 6
         xmlns:local="clr-namespace:XHWK.WKTool"
7
-        xmlns:gifLib="http://wpfanimatedgif.codeplex.com" ContentRendered="Window_ContentRendered"
7
+        xmlns:gifLib="http://wpfanimatedgif.codeplex.com"
8 8
         mc:Ignorable="d"
9 9
         Title="CountdownWindow" Height="450" Width="800"  AllowsTransparency="True"
10 10
     ShowInTaskbar="False"

+ 48
- 139
XHWK.WKTool/CountdownWindow.xaml.cs 查看文件

@@ -12,171 +12,80 @@ namespace XHWK.WKTool
12 12
     /// </summary>
13 13
     public partial class CountdownWindow : Window
14 14
     {
15
-        /// <summary>
16
-        /// 计时用
17
-        /// </summary>
18
-        private TimeSpan _timeSpan = new TimeSpan(0, 0, 0, 0, 0);
19
-        DispatcherTimer timer = null;
20
-        /// <summary>
21
-        /// 状态
22
-        /// </summary>
23
-        private State _state = State.End;
24
-        /// <summary>
25
-        /// 计时器状态
26
-        /// </summary>
27
-        private enum State
28
-        {
29
-            Start,
30
-            Pause,
31
-            End
32
-        }
33
-        public CountdownWindow()
15
+        public CountdownWindow(int changeTime = 650)
34 16
         {
35 17
             InitializeComponent();
18
+            timer = new System.Timers.Timer(changeTime);//设置执行一次(false)还是一直执行(true)
19
+            timer.AutoReset = true;//设置是否执行System.Timers.Timer.Elapsed事件
20
+            timer.Elapsed +=new System.Timers.ElapsedEventHandler(Timer_Elapsed);
36 21
             Initialize();
37 22
         }
38
-        public void Initialize()
23
+        /// <summary>
24
+        /// 计时器
25
+        /// </summary>
26
+        new System.Timers.Timer timer;
27
+        int ImgNum = 3;
28
+        public void Initialize(int changeTime=650)
39 29
         {
40
-            //Thread.Sleep(1200);
41
-            //this.Hide();
42
-            //MediaElement.Position
43
-            //((MediaElement)((object)ImgGif)).Position= TimeSpan.Zero;
44
-            //timer = new DispatcherTimer
45
-            //{
46
-            //    Interval = TimeSpan.FromMilliseconds(2500)
47
-            //};
48
-            //timer.Tick += Timer_Tick;
49
-            //timer.Start();
50
-
51
-
30
+            timer.Interval = changeTime;
31
+            timer.Enabled = true; //启动计时器
32
+            ImgNum = 3;
33
+        }
52 34
 
53
-            if (timer == null)
35
+        private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
36
+        {
37
+            if (ImgNum >= 1)
54 38
             {
55
-                timer = new DispatcherTimer();
56
-                timer.Tick += OnTimer;
57
-                timer.Interval = new TimeSpan(0, 0, 0, 1);
58
-                timer.IsEnabled = true;
59
-                timer.Start();
39
+                loadingImg(ImgNum);
40
+                ImgNum--;
60 41
             }
61
-            timer.Interval = new TimeSpan(0, 0, 0, 1);
62
-            Stack();
63
-
64
-      
65
-                // 开启线程
66
-                Thread tr = new Thread(new ThreadStart(Countdown))
67
-                {
68
-                    IsBackground = true
69
-                };
70
-                tr.Start();
71
-           
72
-        }
73
-        private void Countdown()
74
-        {
75
-            while (_timeSpan.Seconds <= 2)
42
+            else
76 43
             {
77
-              
78
-                if (_timeSpan.Seconds > 1)
44
+                timer.Enabled = false;
45
+                Dispatcher.Invoke(() =>
79 46
                 {
80
-                    Dispatcher.Invoke(
81
-                  DispatcherPriority.Normal,
82
-                  new Action(() => { imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown_1.png")); })
83
-                  );
84
-                 
85
-                }
86
-                else if(_timeSpan.Seconds > 0)
87
-                {
88
-                    Dispatcher.Invoke(
89
-                  DispatcherPriority.Normal,
90
-                  new Action(() => { imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown_2.png")); })
91
-                  );
92
-                    
93
-                }
94
-                Thread.Sleep(888);
47
+                    Hide();
48
+                });
95 49
             }
96
-
97
-
98
-                _state = State.End;
99
-                Dispatcher.Invoke(
100
-                    DispatcherPriority.Normal,
101
-                    new Action(() => { this.Hide(); imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown_3.png"));})
102
-                    );
103
-          
104 50
         }
105 51
         /// <summary>
106
-        /// 结束
52
+        /// 加载图片
107 53
         /// </summary>
108
-        /// <param name="sender"></param>
109
-        /// <param name="e"></param>
110
-        private void End()
54
+        /// <param name="num"></param>
55
+        void loadingImg(int num)
111 56
         {
112
-            _state = State.End;
113
-        }
114
-
115
-        /// <summary>
116
-        /// 时钟回调
117
-        /// </summary>
118
-        /// <param name="sender"></param>
119
-        /// <param name="e"></param>
120
-        private void OnTimer(object sender, EventArgs e)
121
-        {
122
-            switch (_state)
57
+            switch (num)
123 58
             {
124
-                case State.Start:
125
-                    {
126
-                        _timeSpan += new TimeSpan(0, 0, 0, 1);
127
-                    }
59
+                case 1:
60
+                    Dispatcher.Invoke(
61
+                      DispatcherPriority.Send,
62
+                      new Action(() => { 
63
+                          imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown_1.png"));
64
+                      }));
128 65
                     break;
129
-
130
-                case State.Pause:
131
-                    {
132
-                    }
66
+                case 2:
67
+                    Dispatcher.Invoke(
68
+                      DispatcherPriority.Send,
69
+                      new Action(() => {
70
+                          imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown_2.png"));
71
+                      }));
133 72
                     break;
134
-
135
-                case State.End:
136
-                    {
137
-                        _timeSpan = new TimeSpan();
138
-                        //_timeSpan = new TimeSpan(0, 23, 12, 45, 54);
139
-                    }
73
+                case 3:
74
+                    Dispatcher.Invoke(
75
+                      DispatcherPriority.Send,
76
+                      new Action(() => {
77
+                          imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown_3.png"));
78
+                      }));
79
+                    break;
80
+                default:
140 81
                     break;
141 82
             }
142
-
143
-         
144
-        }
145
-        /// <summary>
146
-        /// 开始
147
-        /// </summary>
148
-        /// <param name="sender"></param>
149
-        /// <param name="e"></param>
150
-        private void Stack()
151
-        {
152
-            _state = State.Start;
153
-        }
154
-        private void Timer_Tick(object sender, EventArgs e)
155
-        {
156
-            this.Hide();
157
-            timer.Stop();
158 83
         }
159 84
 
160
-        /// <summary>
161
-        /// 跳转页面
162
-        /// </summary>
163
-        /// <param name="sender"></param>
164
-        /// <param name="e"></param>
165 85
         private void Window_ContentRendered(object sender, EventArgs e)
166 86
         {
167
-            //Thread.Sleep(800);
168
-            //imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown_2.png"));
169
-            //Thread.Sleep(800);
170
-            //imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown_1.png"));
171
-            //Thread.Sleep(300);
172
-            //this.Hide();
173 87
 
174
-            //Initialize();
175 88
         }
176 89
 
177
-        private void Image_MediaEnded(object sender, RoutedEventArgs e)
178
-        {
179
-            ((MediaElement)sender).Position = ((MediaElement)sender).Position.Add(TimeSpan.FromMilliseconds(10000));
180
-        }
181 90
     }
182 91
 }

+ 22
- 2
XHWK.WKTool/ScreenRecordingToolbarWindow.xaml.cs 查看文件

@@ -34,6 +34,10 @@ namespace XHWK.WKTool
34 34
         /// 是否暂停
35 35
         /// </summary>
36 36
         bool IsSuspend = true;
37
+        /// <summary>
38
+        /// 视频信息
39
+        /// </summary>
40
+        Model_Video VideoInfo = null;
37 41
         //声明一个 DrawingAttributes 类型的变量  
38 42
         DrawingAttributes drawingAttributes;
39 43
         #endregion
@@ -78,6 +82,9 @@ namespace XHWK.WKTool
78 82
             {
79 83
                 if (IsFirstRS)
80 84
                 {
85
+                    VideoInfo = new Model_Video();
86
+                    VideoInfo.VideoType = (Enum_VideoType)int.Parse(FileToolsCommon.GetConfigValue("VideoType"));
87
+                    VideoInfo.WkType = Enum_WKVidetype.RecordingScreen;
81 88
                     RecordingPath = APP.WKData.WkPath;
82 89
                     //FileToolsCommon.DeleteDirectory(APP.WKData.WkPath + "temp/");
83 90
                     FileToolsCommon.CreateDirectory(RecordingPath);
@@ -87,7 +94,15 @@ namespace XHWK.WKTool
87 94
                         MessageBoxResult dr = System.Windows.MessageBox.Show("已存在录屏,是否覆盖?", "提示", MessageBoxButton.OKCancel);
88 95
                         if (dr == MessageBoxResult.OK)
89 96
                         {
90
-                            FileToolsCommon.DeleteFile(VideoSavePathName);
97
+                            try
98
+                            {
99
+                                FileToolsCommon.DeleteFile(VideoSavePathName);
100
+                                APP.VideoList.RemoveAll(x => x.VidePath == VideoSavePathName);
101
+                            }
102
+                            catch (Exception ex)
103
+                            {
104
+                                LogHelper.WriteErrLog("【录屏】(BtnRecordingScreen_Click)无法移除视频," + ex.Message, ex);
105
+                            }
91 106
                         }
92 107
                         else
93 108
                         {
@@ -107,7 +122,7 @@ namespace XHWK.WKTool
107 122
                 else
108 123
                 {
109 124
                     APP.W_CountdownWindow.Initialize();
110
-                    APP.W_CountdownWindow.Topmost = true;
125
+                    //APP.W_CountdownWindow.Topmost = true;
111 126
                 }
112 127
                 APP.W_CountdownWindow.Show();
113 128
                 #endregion
@@ -173,7 +188,12 @@ namespace XHWK.WKTool
173 188
                             Thread.Sleep(100);
174 189
                         }
175 190
                         FileToolsCommon.DeleteFile(ThumbnailPathName);
191
+                        VideoInfo.VideoSize = FileToolsCommon.GetFileSizeByMB(VideoSavePathName).ToString() + " MB";
192
+                        VideoInfo.RSTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
193
+                        VideoInfo.VidePath = VideoSavePathName;
194
+                        VideoInfo.ThumbnailPath = ThumbnailPathName;
176 195
                         APP.FFmpeg.GenerateThumbnails(VideoSavePathName, ThumbnailPathName);
196
+                        APP.VideoList.Add(VideoInfo);
177 197
                     }))).Start();
178 198
                 }
179 199
                 catch (Exception ex)

+ 7
- 2
XHWK.WKTool/XHMicroLessonSystemWindow.xaml 查看文件

@@ -123,6 +123,7 @@
123 123
             </Grid>
124 124
             <!--主内容-->
125 125
             <Grid Grid.Row="1" x:Name="GridMain"  Margin="20,0,20,0" Background="#FFFFFF" Height="793.700787401575" Width="1142.51968503937" Visibility="Visible">
126
+                <Label Content="" Grid.Column="0" Height="1" Width="1" Background="#FF0F0F0F" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="1,0,0,0"/>
126 127
                 <Grid>
127 128
                     <Border Grid.Row="1"  CornerRadius="5">
128 129
                         <Grid x:Name="IMG" Margin="0,0,0,0">
@@ -131,8 +132,9 @@
131 132
                                     <ScaleTransform/>
132 133
                                     <TranslateTransform/>
133 134
                                 </TransformGroup>
134
-                            </Grid.Resources>
135
-                            <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Disabled"   Cursor="SizeAll"
135
+                                </Grid.Resources>
136
+                                <Label Content="" Grid.Column="0" HorizontalAlignment="Left" Height="1" VerticalAlignment="Top" Width="1" Background="#FF0F0F0F" Margin="1,0,0,0"/>
137
+                                <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Disabled"   Cursor="SizeAll"
136 138
                   Margin="0,0,0,0" Focusable="False" x:Name="BackFrame">
137 139
                                 <ContentControl  MouseLeftButtonDown="IMG1_MouseLeftButtonDown"   
138 140
                              MouseLeftButtonUp="IMG1_MouseLeftButtonUp"
@@ -194,6 +196,9 @@
194 196
                         </Button.Content>
195 197
                     </Button>
196 198
                 </StackPanel>
199
+
200
+                <Label Content="" Grid.Column="1" Height="1" Width="1" Background="#FF0F0F0F" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,0,21,0"/>
201
+                <Label Content="" Grid.Column="1" Height="1" Width="1" Background="#FF0F0F0F" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,21,0"/>
197 202
             </Grid>
198 203
             <!--设置-->
199 204
             <Grid Grid.Row="1" x:Name="gridSetUp" Margin="20,0,20,0" Background="#FFFFFF" Visibility="Collapsed">

+ 22
- 23
XHWK.WKTool/XHMicroLessonSystemWindow.xaml.cs 查看文件

@@ -37,6 +37,7 @@ namespace XHWK.WKTool
37 37
         private System.Windows.Forms.OpenFileDialog ofd;
38 38
         //声明一个 DrawingAttributes 类型的变量  
39 39
         DrawingAttributes drawingAttributes;
40
+        Model_Video VideoInfo = null;
40 41
         //定义事件
41 42
         public event ChangeTextHandler ChangeTextEvent;
42 43
         //定义委托
@@ -713,6 +714,9 @@ namespace XHWK.WKTool
713 714
             {
714 715
                 if (IsFirstR)//是否第一次录制  初始化录制
715 716
                 {
717
+                    VideoInfo = new Model_Video();
718
+                    VideoInfo.VideoType = (Enum_VideoType)int.Parse(FileToolsCommon.GetConfigValue("VideoType"));
719
+                    VideoInfo.WkType = Enum_WKVidetype.RecordingLessons;
716 720
                     RecordingPath = APP.WKData.WkPath;
717 721
                     ImgPath = APP.WKData.WkPath + "temp/Image/";
718 722
                     AudioPathName = APP.WKData.WkPath + "temp/audio/";
@@ -721,13 +725,22 @@ namespace XHWK.WKTool
721 725
                     FileToolsCommon.CreateDirectory(ImgPath);
722 726
                     FileToolsCommon.CreateDirectory(AudioPathName);
723 727
                     AudioPathName += APP.WKData.WkName + ".MP3";
724
-                    VideoSavePathName = RecordingPath + APP.WKData.WkName + "_录制." + ((Enum_VideoType)int.Parse(FileToolsCommon.GetConfigValue("VideoType"))).ToString();
728
+                    VideoSavePathName = RecordingPath + APP.WKData.WkName + "_录制." + VideoInfo.VideoType.ToString();
729
+                    
725 730
                     if (FileToolsCommon.IsExistFile(VideoSavePathName))
726 731
                     {
727 732
                         MessageBoxResult dr = System.Windows.MessageBox.Show("课程已录制,是否覆盖?", "提示", MessageBoxButton.OKCancel);
728 733
                         if (dr == MessageBoxResult.OK)
729 734
                         {
730
-                            FileToolsCommon.DeleteFile(VideoSavePathName);
735
+                            try
736
+                            {
737
+                                FileToolsCommon.DeleteFile(VideoSavePathName);
738
+                                APP.VideoList.RemoveAll(x => x.VidePath == VideoSavePathName);
739
+                            }
740
+                            catch (Exception ex)
741
+                            {
742
+                                LogHelper.WriteErrLog("【录制】(StartRecord)无法移除视频," + ex.Message, ex);
743
+                            }
731 744
                         }
732 745
                         else
733 746
                         {
@@ -740,25 +753,6 @@ namespace XHWK.WKTool
740 753
                     timer.AutoReset = true;//设置是否执行System.Timers.Timer.Elapsed事件
741 754
                     timer.Elapsed += new System.Timers.ElapsedEventHandler(Timer_Elapsed);
742 755
                     timer.Enabled = true; //启动计时器
743
-                    #region 保存图片
744
-                    //new Thread(new ThreadStart(new Action(() =>
745
-                    //{
746
-                    //    while (true)
747
-                    //    {
748
-                    //        Thread.Sleep(200);
749
-                    //        if (IsStartCount)
750
-                    //        {
751
-                    //            ImgNum++;
752
-                    //            Dispatcher.Invoke(() =>
753
-                    //            {
754
-                    //                lblNumber.Content = ImgNum;
755
-                    //                string FilePathName = ImgPath + ImgNum + ".png";
756
-                    //                ImageHelper.SaveUIToImage(GridMain, FilePathName, (int)GridMain.ActualWidth, (int)GridMain.ActualHeight);
757
-                    //            });
758
-                    //        }
759
-                    //    }
760
-                    //}))).Start();
761
-                    #endregion
762 756
                 }
763 757
                 #region 录像倒计时
764 758
                 if (APP.W_CountdownWindow == null)
@@ -834,7 +828,7 @@ namespace XHWK.WKTool
834 828
                     Dispatcher.Invoke(() =>
835 829
                     {
836 830
                         string FilePathName = ImgPath + RsImgName.Count + ".png";
837
-                        ImageHelper.SaveUIToImage(GridMain, FilePathName, (int)GridMain.ActualWidth, (int)GridMain.ActualHeight);
831
+                        ImageHelper.SaveUIToImage(GridMain, FilePathName, (int)this.ActualWidth, (int)this.ActualHeight);
838 832
                         RsImgName.Add(FilePathName);
839 833
                     });
840 834
                 }
@@ -891,9 +885,14 @@ namespace XHWK.WKTool
891 885
                             Thread.Sleep(100);
892 886
                         }
893 887
                         FileToolsCommon.DeleteFile(ThumbnailPathName);
888
+                        VideoInfo.VideoSize = FileToolsCommon.GetFileSizeByMB(VideoSavePathName).ToString() + " MB";
889
+                        VideoInfo.RSTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
890
+                        VideoInfo.VidePath = VideoSavePathName;
891
+                        VideoInfo.ThumbnailPath = ThumbnailPathName;
894 892
                         APP.FFmpeg.GenerateThumbnails(VideoSavePathName, ThumbnailPathName);
893
+                        APP.VideoList.Add(VideoInfo);
895 894
                     }))).Start();
896
-
895
+                    //List<Model_Video> VideoList
897 896
                 }
898 897
                 catch (Exception ex)
899 898
                 {

Loading…
取消
儲存