Przeglądaj źródła

zhao:记录录像信息

tags/录制修改前
耀 4 lat temu
rodzic
commit
15e25f230b

+ 108
- 0
Common/system/ImageHelper.cs Wyświetl plik

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

+ 3
- 3
Common/system/XmlUtilHelper.cs Wyświetl plik

@@ -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>

+ 39
- 2
XHWK.WKTool/App.cs Wyświetl plik

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

+ 1
- 1
XHWK.WKTool/CountdownWindow.xaml Wyświetl plik

@@ -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 Wyświetl plik

@@ -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(); })
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 Wyświetl plik

@@ -31,6 +31,10 @@ namespace XHWK.WKTool
31 31
         /// 是否暂停
32 32
         /// </summary>
33 33
         bool IsSuspend = true;
34
+        /// <summary>
35
+        /// 视频信息
36
+        /// </summary>
37
+        Model_Video VideoInfo = null;
34 38
         #endregion
35 39
 
36 40
         #region 初始化
@@ -63,6 +67,9 @@ namespace XHWK.WKTool
63 67
             {
64 68
                 if(IsFirstRS)
65 69
                 {
70
+                    VideoInfo = new Model_Video();
71
+                    VideoInfo.VideoType = (Enum_VideoType)int.Parse(FileToolsCommon.GetConfigValue("VideoType"));
72
+                    VideoInfo.WkType = Enum_WKVidetype.RecordingScreen;
66 73
                     RecordingPath = APP.WKData.WkPath;
67 74
                     //FileToolsCommon.DeleteDirectory(APP.WKData.WkPath + "temp/");
68 75
                     FileToolsCommon.CreateDirectory(RecordingPath);
@@ -72,7 +79,15 @@ namespace XHWK.WKTool
72 79
                         MessageBoxResult dr = System.Windows.MessageBox.Show("已存在录屏,是否覆盖?", "提示", MessageBoxButton.OKCancel);
73 80
                         if (dr == MessageBoxResult.OK)
74 81
                         {
75
-                            FileToolsCommon.DeleteFile(VideoSavePathName);
82
+                            try
83
+                            {
84
+                                FileToolsCommon.DeleteFile(VideoSavePathName);
85
+                                APP.VideoList.RemoveAll(x => x.VidePath == VideoSavePathName);
86
+                            }
87
+                            catch (Exception ex)
88
+                            {
89
+                                LogHelper.WriteErrLog("【录屏】(BtnRecordingScreen_Click)无法移除视频," + ex.Message, ex);
90
+                            }
76 91
                         }
77 92
                         else
78 93
                         {
@@ -92,7 +107,7 @@ namespace XHWK.WKTool
92 107
                 else
93 108
                 {
94 109
                     APP.W_CountdownWindow.Initialize();
95
-                    APP.W_CountdownWindow.Topmost = true;
110
+                    //APP.W_CountdownWindow.Topmost = true;
96 111
                 }
97 112
                 APP.W_CountdownWindow.Show();
98 113
                 #endregion
@@ -158,7 +173,12 @@ namespace XHWK.WKTool
158 173
                             Thread.Sleep(100);
159 174
                         }
160 175
                         FileToolsCommon.DeleteFile(ThumbnailPathName);
176
+                        VideoInfo.VideoSize = FileToolsCommon.GetFileSizeByMB(VideoSavePathName).ToString() + " MB";
177
+                        VideoInfo.RSTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
178
+                        VideoInfo.VidePath = VideoSavePathName;
179
+                        VideoInfo.ThumbnailPath = ThumbnailPathName;
161 180
                         APP.FFmpeg.GenerateThumbnails(VideoSavePathName, ThumbnailPathName);
181
+                        APP.VideoList.Add(VideoInfo);
162 182
                     }))).Start();
163 183
                 }
164 184
                 catch (Exception ex)

+ 12
- 3
XHWK.WKTool/XHMicroLessonSystemWindow.xaml Wyświetl plik

@@ -122,7 +122,7 @@
122 122
                 </StackPanel>
123 123
             </Grid>
124 124
             <!--主内容-->
125
-            <Grid Grid.Row="1" x:Name="GridMain"  Margin="20,0,20,0" Background="#FFFFFF" Height="793.700787401575" Width="1142.51968503937" Visibility="Collapsed">
125
+            <Grid Grid.Row="1" x:Name="GridMain"  Margin="20,0,20,0" Background="#FFFFFF" Height="793.700787401575" Width="1142.51968503937" Visibility="Visible">
126 126
                 <Grid.Resources>
127 127
                     <TransformGroup x:Key="ImageTransformResource">
128 128
                         <ScaleTransform />
@@ -133,6 +133,8 @@
133 133
                     <ColumnDefinition Width="79*" />
134 134
                     <ColumnDefinition Width="1063*"/>
135 135
                 </Grid.ColumnDefinitions>
136
+
137
+                <Label Content="" Grid.Column="0" HorizontalAlignment="Left" Height="1" VerticalAlignment="Top" Width="1" Background="#FF0F0F0F" Margin="1,0,0,0"/>
136 138
                 <Rectangle Grid.Column="0" x:Name="MasterImage"
137 139
 MouseLeftButtonDown="MasterImage_MouseLeftButtonDown"
138 140
 MouseLeftButtonUp="MasterImage_MouseLeftButtonUp"
@@ -148,7 +150,11 @@ MouseWheel="MasterImage_MouseWheel" Grid.ColumnSpan="2" Margin="0,0,0.4,-0.299">
148 150
                 </Rectangle>
149 151
 
150 152
                 <!--<Image Grid.Row="0" x:Name="imgCanvas" Height="760"/>-->
151
-                <InkCanvas Grid.Row="0" x:Name="blackboard_canvas" Background="Transparent" Visibility="Visible" Grid.ColumnSpan="2" Margin="0,0,0.4,-0.299"/>
153
+                <InkCanvas Grid.Row="0" x:Name="blackboard_canvas" Background="Transparent" Visibility="Visible" Grid.ColumnSpan="2">
154
+
155
+                </InkCanvas>
156
+
157
+                <Label Content="" Grid.Column="0" Height="1" Width="1" Background="#FF0F0F0F" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="1,0,0,0"/>
152 158
                 <!--摄像头-->
153 159
                 <wfi:WindowsFormsHost Grid.Row="0" Grid.Column="1" x:Name="wfhCamera" Height="124" Width="172" HorizontalAlignment="Right" Margin="0,10,10.4,0" VerticalAlignment="Top">
154 160
                     <aforge:VideoSourcePlayer x:Name="player" Height="124" Width="172"  />
@@ -209,9 +215,12 @@ MouseWheel="MasterImage_MouseWheel" Grid.ColumnSpan="2" Margin="0,0,0.4,-0.299">
209 215
                         </Button.Content>
210 216
                     </Button>
211 217
                 </StackPanel>
218
+
219
+                <Label Content="" Grid.Column="1" Height="1" Width="1" Background="#FF0F0F0F" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,0,21,0"/>
220
+                <Label Content="" Grid.Column="1" Height="1" Width="1" Background="#FF0F0F0F" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,21,0"/>
212 221
             </Grid>
213 222
             <!--设置-->
214
-            <Grid Grid.Row="1" x:Name="gridSetUp" Margin="20,0,20,0" Background="#FFFFFF" Visibility="Visible">
223
+            <Grid Grid.Row="1" x:Name="gridSetUp" Margin="20,0,20,0" Background="#FFFFFF" Visibility="Collapsed">
215 224
                 <Grid.RowDefinitions>
216 225
                     <RowDefinition Height="120"/>
217 226
                     <RowDefinition Height="90"/>

+ 24
- 23
XHWK.WKTool/XHMicroLessonSystemWindow.xaml.cs Wyświetl plik

@@ -53,6 +53,8 @@ namespace XHWK.WKTool
53 53
         private System.Windows.Forms.OpenFileDialog ofd;
54 54
         //声明一个 DrawingAttributes 类型的变量  
55 55
         DrawingAttributes drawingAttributes;
56
+
57
+        Model_Video VideoInfo = null;
56 58
         #endregion
57 59
 
58 60
         #region 初始化
@@ -536,6 +538,7 @@ namespace XHWK.WKTool
536 538
                 }
537 539
             }
538 540
         }
541
+
539 542
         #region 录制窗口
540 543
         #region 变量
541 544
         /// <summary>
@@ -610,6 +613,9 @@ namespace XHWK.WKTool
610 613
             {
611 614
                 if (IsFirstR)//是否第一次录制  初始化录制
612 615
                 {
616
+                    VideoInfo = new Model_Video();
617
+                    VideoInfo.VideoType = (Enum_VideoType)int.Parse(FileToolsCommon.GetConfigValue("VideoType"));
618
+                    VideoInfo.WkType = Enum_WKVidetype.RecordingLessons;
613 619
                     RecordingPath = APP.WKData.WkPath;
614 620
                     ImgPath = APP.WKData.WkPath + "temp/Image/";
615 621
                     AudioPathName = APP.WKData.WkPath + "temp/audio/";
@@ -618,13 +624,22 @@ namespace XHWK.WKTool
618 624
                     FileToolsCommon.CreateDirectory(ImgPath);
619 625
                     FileToolsCommon.CreateDirectory(AudioPathName);
620 626
                     AudioPathName += APP.WKData.WkName + ".MP3";
621
-                    VideoSavePathName = RecordingPath + APP.WKData.WkName + "_录制." + ((Enum_VideoType)int.Parse(FileToolsCommon.GetConfigValue("VideoType"))).ToString();
627
+                    VideoSavePathName = RecordingPath + APP.WKData.WkName + "_录制." + VideoInfo.VideoType.ToString();
628
+                    
622 629
                     if (FileToolsCommon.IsExistFile(VideoSavePathName))
623 630
                     {
624 631
                         MessageBoxResult dr = System.Windows.MessageBox.Show("课程已录制,是否覆盖?", "提示", MessageBoxButton.OKCancel);
625 632
                         if (dr == MessageBoxResult.OK)
626 633
                         {
627
-                            FileToolsCommon.DeleteFile(VideoSavePathName);
634
+                            try
635
+                            {
636
+                                FileToolsCommon.DeleteFile(VideoSavePathName);
637
+                                APP.VideoList.RemoveAll(x => x.VidePath == VideoSavePathName);
638
+                            }
639
+                            catch (Exception ex)
640
+                            {
641
+                                LogHelper.WriteErrLog("【录制】(StartRecord)无法移除视频," + ex.Message, ex);
642
+                            }
628 643
                         }
629 644
                         else
630 645
                         {
@@ -637,25 +652,6 @@ namespace XHWK.WKTool
637 652
                     timer.AutoReset = true;//设置是否执行System.Timers.Timer.Elapsed事件
638 653
                     timer.Elapsed += new System.Timers.ElapsedEventHandler(Timer_Elapsed);
639 654
                     timer.Enabled = true; //启动计时器
640
-                    #region 保存图片
641
-                    //new Thread(new ThreadStart(new Action(() =>
642
-                    //{
643
-                    //    while (true)
644
-                    //    {
645
-                    //        Thread.Sleep(200);
646
-                    //        if (IsStartCount)
647
-                    //        {
648
-                    //            ImgNum++;
649
-                    //            Dispatcher.Invoke(() =>
650
-                    //            {
651
-                    //                lblNumber.Content = ImgNum;
652
-                    //                string FilePathName = ImgPath + ImgNum + ".png";
653
-                    //                ImageHelper.SaveUIToImage(GridMain, FilePathName, (int)GridMain.ActualWidth, (int)GridMain.ActualHeight);
654
-                    //            });
655
-                    //        }
656
-                    //    }
657
-                    //}))).Start();
658
-                    #endregion
659 655
                 }
660 656
                 #region 录像倒计时
661 657
                 if (APP.W_CountdownWindow == null)
@@ -731,7 +727,7 @@ namespace XHWK.WKTool
731 727
                     Dispatcher.Invoke(() =>
732 728
                     {
733 729
                         string FilePathName = ImgPath + RsImgName.Count + ".png";
734
-                        ImageHelper.SaveUIToImage(GridMain, FilePathName, (int)GridMain.ActualWidth, (int)GridMain.ActualHeight);
730
+                        ImageHelper.SaveUIToImage(GridMain, FilePathName, (int)this.ActualWidth, (int)this.ActualHeight);
735 731
                         RsImgName.Add(FilePathName);
736 732
                     });
737 733
                 }
@@ -788,9 +784,14 @@ namespace XHWK.WKTool
788 784
                             Thread.Sleep(100);
789 785
                         }
790 786
                         FileToolsCommon.DeleteFile(ThumbnailPathName);
787
+                        VideoInfo.VideoSize = FileToolsCommon.GetFileSizeByMB(VideoSavePathName).ToString() + " MB";
788
+                        VideoInfo.RSTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
789
+                        VideoInfo.VidePath = VideoSavePathName;
790
+                        VideoInfo.ThumbnailPath = ThumbnailPathName;
791 791
                         APP.FFmpeg.GenerateThumbnails(VideoSavePathName, ThumbnailPathName);
792
+                        APP.VideoList.Add(VideoInfo);
792 793
                     }))).Start();
793
-
794
+                    //List<Model_Video> VideoList
794 795
                 }
795 796
                 catch (Exception ex)
796 797
                 {

Ładowanie…
Anuluj
Zapisz