Browse Source

zhao:增加增加暂停功能,多视频录制合并

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

+ 138
- 45
Common/system/FFMpeg.cs View File

@@ -4,6 +4,8 @@ using System.Diagnostics;
4 4
 using System.IO;
5 5
 using System.Linq;
6 6
 using System.Text;
7
+using System.Threading;
8
+
7 9
 using VisioForge.Shared.NAudio.CoreAudioApi;
8 10
 using VisioForge.Shared.NAudio.Wave;
9 11
 
@@ -11,6 +13,8 @@ namespace Common.system
11 13
 {
12 14
     /// <summary>
13 15
     /// ffmpeg帮助类
16
+    /// 创建人:赵耀
17
+    /// 创建时间::2020年8月22日
14 18
     /// 需要安装\ffmpeg\bin\Setup Screen Capturer Recorder v0.12.10.exe
15 19
     /// 本地调试需要配置环境变量 将ffmpeg.exe位置配置到环境变量的path中
16 20
     /// </summary>
@@ -24,10 +28,14 @@ namespace Common.system
24 28
         /// <summary>
25 29
         /// 录制屏幕
26 30
         /// </summary>
27
-        /// <param name="PathName">文件存储路径</param>
28
-        /// <param name="VideoType">视频类型</param>
29
-        public void StartRecordingVideo(string PathName, string VideoType)
31
+        /// <param name="FilePath">文件存储路径</param>
32
+        public void StartRecordingVideo(string FilePath)
30 33
         {
34
+            //路径
35
+            string Path = FileToolsCommon.GetDirectoryName(FilePath) + @"\";
36
+            string Extension = FileToolsCommon.GetIOExtension(FilePath);//扩展名
37
+            //文件保存路径
38
+            string PathName = GetFilePathName(FilePath);
31 39
             Process[] KillProcessArray = Process.GetProcessesByName("ffmpeg");
32 40
             Debug.WriteLine(KillProcessArray.Length.ToString());
33 41
             foreach (var KillProcess in KillProcessArray)
@@ -38,7 +46,7 @@ namespace Common.system
38 46
             LogPath = CreateffmpegLog();
39 47
             string MicrophoneName = GetMicrophone();
40 48
             myProcess.StartInfo.FileName = FileToolsCommon.GetFileAbsolutePath(@"/ffmpeg/bin/ffmpeg.exe");   //ffmpeg.exe的绝对路径
41
-            switch (VideoType.ToUpper())
49
+            switch (Extension.ToUpper())
42 50
             {
43 51
                 case "MP4":
44 52
                     if (string.IsNullOrWhiteSpace(MicrophoneName))
@@ -55,12 +63,12 @@ namespace Common.system
55 63
                 case "FLV":
56 64
                     if (string.IsNullOrWhiteSpace(MicrophoneName))
57 65
                     {
58
-                        myProcess.StartInfo.Arguments = "-f dshow -i video=\"screen-capture-recorder\" -f dshow -i audio=\"virtual-audio-capturer\" -vcodec libx264 -acodec libmp3lame -r 15 -crf 22 -f "+ VideoType.ToLower() + " " + PathName;  //ffmpeg的参数
66
+                        myProcess.StartInfo.Arguments = "-f dshow -i video=\"screen-capture-recorder\" -f dshow -i audio=\"virtual-audio-capturer\" -vcodec libx264 -acodec libmp3lame -r 15 -crf 22 -f " + Extension.ToLower() + " " + PathName;  //ffmpeg的参数
59 67
                     }
60 68
                     else
61 69
                     {
62 70
                         myProcess.StartInfo.Arguments = "-f dshow -i audio=\"virtual-audio-capturer\" -f dshow -i audio=\"" +
63
-                            MicrophoneName + "\" -filter_complex amix=inputs=2:duration=first:dropout_transition=2 -f dshow -i video=\"screen-capture-recorder\" -pix_fmt yuv420p -vcodec h264 -preset:v ultrafast -tune:v zerolatency -acodec aac -ar 44100 -ac 2 -f " + VideoType.ToLower() + " " + PathName;  //ffmpeg的参数
71
+                            MicrophoneName + "\" -filter_complex amix=inputs=2:duration=first:dropout_transition=2 -f dshow -i video=\"screen-capture-recorder\" -pix_fmt yuv420p -vcodec h264 -preset:v ultrafast -tune:v zerolatency -acodec aac -ar 44100 -ac 2 -f " + Extension.ToLower() + " " + PathName;  //ffmpeg的参数
64 72
                     }
65 73
                     break;
66 74
                 default:
@@ -120,11 +128,10 @@ namespace Common.system
120 128
         }
121 129
 
122 130
         /// <summary>
123
-        /// 停录制
131
+        /// 停录制
124 132
         /// </summary>
125
-        public void StopFFmpeg()
133
+        public void SuspendFFmpeg()
126 134
         {
127
-            //Thread.Sleep(3000);
128 135
             if (myProcess == null)
129 136
                 return;
130 137
             myProcess.StandardInput.WriteLine("q");//在这个进程的控制台中模拟输入q,用于暂停录制
@@ -135,7 +142,25 @@ namespace Common.system
135 142
         }
136 143
 
137 144
         /// <summary>
138
-        /// 合成视频
145
+        /// 停止录制并合成文件
146
+        /// </summary>
147
+        /// <param name="FilePath">文件存储路径 必须与开始时的路径完全一致</param>
148
+        public void StopFFmpeg(string FilePath)
149
+        {
150
+            //文件完整路径
151
+            if (myProcess == null)
152
+                return;
153
+            myProcess.StandardInput.WriteLine("q");//在这个进程的控制台中模拟输入q,用于暂停录制
154
+            myProcess.Close();//关闭进程
155
+            myProcess.Dispose();//释放资源
156
+            myProcess = null;
157
+            Thread t1 = new Thread(MergeVideoOrAudio);
158
+            t1.Start(FilePath);
159
+            //文件合成
160
+        }
161
+
162
+        /// <summary>
163
+        /// 图片音频合成视频
139 164
         /// </summary>
140 165
         /// <param name="ImageListPath">图片列表位置 命名为1.png 2.png</param>
141 166
         /// <param name="Mp3Path">MP3音频位置</param>
@@ -143,9 +168,76 @@ namespace Common.system
143 168
         /// <param name="Frequency">每秒帧率</param>
144 169
         /// <param name="VideoWidth">视频宽度</param>
145 170
         /// <param name="VideoHeight">视频高度</param>
146
-        /// <param name="VideoType">视频类型  MP4 FLV AVI</param>
147
-        private void SynthesisVideo(string ImageListPath, string Mp3Path, string VideoSavePath, int Frequency, int VideoWidth, int VideoHeight, string VideoType)
171
+        private void SynthesisVideo(string ImageListPath, string Mp3Path, string VideoSavePath, int Frequency, int VideoWidth, int VideoHeight)
172
+        {
173
+            Thread thread = new Thread(delegate ()
174
+            {
175
+                //// 允许不同线程间的调用
176
+                //Control.CheckForIllegalCrossThreadCalls = false;
177
+                Thread.Sleep(500);
178
+                string Extension = FileToolsCommon.GetIOExtension(VideoSavePath);//扩展名
179
+                Process[] KillProcessArray = Process.GetProcessesByName("ffmpeg");
180
+                Debug.WriteLine(KillProcessArray.Length.ToString());
181
+                foreach (var KillProcess in KillProcessArray)
182
+                {
183
+                    KillProcess.Kill();
184
+                }
185
+                myProcess = new Process();
186
+                LogPath = CreateffmpegLog();
187
+                this.myProcess.StartInfo.FileName = FileToolsCommon.GetFileAbsolutePath(@"/ffmpeg/bin/ffmpeg.exe");   //ffmpeg.exe的绝对路径
188
+                switch (Extension.ToUpper())
189
+                {
190
+                    case "MP4":
191
+                        myProcess.StartInfo.Arguments = @"-y -r " + Frequency + " -i " +
192
+                            ImageListPath + @"%d.png -i " +
193
+                            Mp3Path + @" -s " + VideoWidth + "x" + VideoHeight + " -vcodec mpeg4 " +
194
+                            VideoSavePath;
195
+                        break;
196
+                    case "AVI":
197
+                        myProcess.StartInfo.Arguments = @"-y -r " + Frequency + " -i " +
198
+                            ImageListPath + @"%d.png -i " +
199
+                            Mp3Path + @" -s " + VideoWidth + "x" + VideoHeight + " -f AVI " +
200
+                            VideoSavePath;
201
+                        break;
202
+                    case "FLV":
203
+                        myProcess.StartInfo.Arguments = @"-y -r " + Frequency + " -i " +
204
+                            ImageListPath + @"%d.png -i " +
205
+                            Mp3Path + @" -s " + VideoWidth + "x" + VideoHeight + " -f FLV " +
206
+                            VideoSavePath;
207
+                        break;
208
+                    default:
209
+                        myProcess.StartInfo.Arguments = @"-y -r " + Frequency + " -i " +
210
+                            ImageListPath + @"%d.png -i " +
211
+                            Mp3Path + @" -s " + VideoWidth + "x" + VideoHeight + " -vcodec mpeg4 " +
212
+                            VideoSavePath;
213
+                        break;
214
+                }
215
+                myProcess.StartInfo.UseShellExecute = false;           //不使用操作系统外壳程序启动
216
+                myProcess.StartInfo.RedirectStandardError = true;      //重定向标准错误输出
217
+                myProcess.StartInfo.CreateNoWindow = true;             //不显示程序窗口
218
+                myProcess.StartInfo.RedirectStandardInput = true;      //用于模拟该进程控制台的输入
219
+                                                                       //外部程序(这里是FFMPEG)输出流时候产生的事件,这里是把流的处理过程转移到下面的方法中,详细请查阅MSDN
220
+                myProcess.ErrorDataReceived += new DataReceivedEventHandler(Output);
221
+                myProcess.Start();                 //启动线程
222
+                myProcess.BeginErrorReadLine();    //开始异步读取
223
+                myProcess.WaitForExit();           //阻塞等待进程结束
224
+                myProcess.Close();                 //关闭进程
225
+                myProcess.Dispose();               //释放资源
226
+                                                   //生成视频后删除图片保存列表
227
+                FileToolsCommon.DeleteDirectory(ImageListPath);
228
+            });
229
+        }
230
+
231
+        /// <summary>
232
+        /// 视频音频合成
233
+        /// </summary>
234
+        /// <param name="FilePath">存储路径</param>
235
+        void MergeVideoOrAudio(object FilePathobj)
148 236
         {
237
+            Thread.Sleep(500);
238
+            //路径
239
+            string FilePath = (string)FilePathobj;
240
+            string Path = FileToolsCommon.GetDirectoryName(FilePath) + @"\";
149 241
             Process[] KillProcessArray = Process.GetProcessesByName("ffmpeg");
150 242
             Debug.WriteLine(KillProcessArray.Length.ToString());
151 243
             foreach (var KillProcess in KillProcessArray)
@@ -153,35 +245,9 @@ namespace Common.system
153 245
                 KillProcess.Kill();
154 246
             }
155 247
             myProcess = new Process();
156
-            LogPath=CreateffmpegLog();
248
+            LogPath = CreateffmpegLog();
157 249
             this.myProcess.StartInfo.FileName = FileToolsCommon.GetFileAbsolutePath(@"/ffmpeg/bin/ffmpeg.exe");   //ffmpeg.exe的绝对路径
158
-            switch (VideoType.ToUpper())
159
-            {
160
-                case "MP4":
161
-                    myProcess.StartInfo.Arguments = @"-y -r " + Frequency + " -i " +
162
-                        ImageListPath + @"%d.png -i " +
163
-                        Mp3Path + @" -s " + VideoWidth + "x" + VideoHeight + " -vcodec mpeg4 " +
164
-                        VideoSavePath;
165
-                    break;
166
-                case "AVI":
167
-                    myProcess.StartInfo.Arguments = @"-y -r " + Frequency + " -i " +
168
-                        ImageListPath + @"%d.png -i " +
169
-                        Mp3Path + @" -s " + VideoWidth + "x" + VideoHeight + " -f AVI " +
170
-                        VideoSavePath;
171
-                    break;
172
-                case "FLV":
173
-                    myProcess.StartInfo.Arguments = @"-y -r " + Frequency + " -i " +
174
-                        ImageListPath + @"%d.png -i " +
175
-                        Mp3Path + @" -s " + VideoWidth + "x" + VideoHeight + " -f FLV " +
176
-                        VideoSavePath;
177
-                    break;
178
-                default:
179
-                    myProcess.StartInfo.Arguments = @"-y -r " + Frequency + " -i " +
180
-                        ImageListPath + @"%d.png -i " +
181
-                        Mp3Path + @" -s " + VideoWidth + "x" + VideoHeight + " -vcodec mpeg4 " +
182
-                        VideoSavePath;
183
-                    break;
184
-            }
250
+            myProcess.StartInfo.Arguments = "-f concat  -safe 0 -i " + Path + "temp/filelist.d -c copy " + FilePath;
185 251
             myProcess.StartInfo.UseShellExecute = false;           //不使用操作系统外壳程序启动
186 252
             myProcess.StartInfo.RedirectStandardError = true;      //重定向标准错误输出
187 253
             myProcess.StartInfo.CreateNoWindow = true;             //不显示程序窗口
@@ -193,17 +259,44 @@ namespace Common.system
193 259
             myProcess.WaitForExit();           //阻塞等待进程结束
194 260
             myProcess.Close();                 //关闭进程
195 261
             myProcess.Dispose();               //释放资源
196
-            //生成视频后删除图片保存列表
197
-            FileToolsCommon.DeleteDirectory(ImageListPath);
198
-            
199 262
         }
200
-        
263
+
264
+        /// <summary>
265
+        /// 获取文件完整路径
266
+        /// </summary>
267
+        /// <param name="FilePath">文件路径</param>
268
+        /// <returns></returns>
269
+        string GetFilePathName(string FilePath)
270
+        {
271
+            //路径
272
+            string Path = FileToolsCommon.GetDirectoryName(FilePath) + @"\";
273
+            //Path.GetFileName(FilePath);//获取文件名
274
+            string Extension = FileToolsCommon.GetIOExtension(FilePath);//扩展名
275
+            string tempFilePath = Path + "temp/";
276
+            //创建临时目录
277
+            FileToolsCommon.CreateDirectory(tempFilePath);
278
+            //创建记录文件
279
+            if (!FileToolsCommon.IsExistFile(tempFilePath + "filelist.d"))
280
+            {
281
+                FileToolsCommon.CreateFile(tempFilePath + "filelist.d");
282
+            }
283
+            int num = 1;
284
+            string CompleteFilePath = tempFilePath + num + Extension;
285
+            while (FileToolsCommon.IsExistFile(CompleteFilePath))
286
+            {
287
+                num++;
288
+                CompleteFilePath = tempFilePath + num + Extension;
289
+            }
290
+            FileToolsCommon.AppendText(tempFilePath + "filelist.d", "file ./" + num + Extension + "\r\n");
291
+            return CompleteFilePath;
292
+        }
293
+
201 294
         /// <summary>
202 295
         /// 生成缩略图
203 296
         /// </summary>
204 297
         /// <param name="VideoPath">视频地址</param>
205 298
         /// <param name="ImagePath">图片地址</param>
206
-        void GenerateThumbnails(string VideoPath,string ImagePath)
299
+        void GenerateThumbnails(string VideoPath, string ImagePath)
207 300
         {
208 301
             Process[] KillProcessArray = Process.GetProcessesByName("ffmpeg");
209 302
             Debug.WriteLine(KillProcessArray.Length.ToString());

+ 43
- 5
Common/system/FileToolsCommon.cs View File

@@ -20,7 +20,7 @@ namespace Common.system
20 20
         /// </summary>
21 21
         /// <param name="Path">相对路径</param>
22 22
         /// <returns></returns>
23
-        public static string GetFileAbsolutePath(string Path="")
23
+        public static string GetFileAbsolutePath(string Path = "")
24 24
         {
25 25
             try
26 26
             {
@@ -155,9 +155,9 @@ namespace Common.system
155 155
                     Directory.CreateDirectory(directoryPath);
156 156
                 }
157 157
             }
158
-            catch (Exception)
158
+            catch (Exception ex)
159 159
             {
160
-                throw  new ApplicationException("请使用管理员权限运行!");
160
+                throw new ApplicationException(ex.Message); //"请使用管理员权限运行!"
161 161
             }
162 162
         }
163 163
         #endregion
@@ -284,7 +284,7 @@ namespace Common.system
284 284
         /// 获取指定目录中所有文件列表  
285 285
         /// </summary>  
286 286
         /// <param name="directoryPath">指定目录的绝对路径</param>          
287
-        public static FileInfo[] GetFileInfos(string directoryPath,string files=null)
287
+        public static FileInfo[] GetFileInfos(string directoryPath, string files = null)
288 288
         {
289 289
             //如果目录不存在,则抛出异常  
290 290
             if (!IsExistDirectory(directoryPath))
@@ -515,7 +515,7 @@ namespace Common.system
515 515
         public static string FileToString(string filePath)
516 516
         {
517 517
             //return FileToString(filePath, Encoding.Default); 
518
-            return FileToString(filePath, Encoding.UTF8); 
518
+            return FileToString(filePath, Encoding.UTF8);
519 519
         }
520 520
         /// <summary>  
521 521
         /// 将文件读取到字符串中  
@@ -554,6 +554,14 @@ namespace Common.system
554 554
             FileInfo fi = new FileInfo(filePath);
555 555
             return fi.Name;
556 556
         }
557
+        /// <summary>  
558
+        /// 使用IO从文件的绝对路径中获取文件名( 包含扩展名 )  
559
+        /// </summary>  
560
+        /// <param name="filePath">文件的绝对路径</param>          
561
+        public static string GetIOFileName(string filePath)
562
+        {
563
+            return Path.GetFileName(filePath);
564
+        }
557 565
         #endregion
558 566
 
559 567
         #region 从文件的绝对路径中获取文件名( 不包含扩展名 )
@@ -567,6 +575,14 @@ namespace Common.system
567 575
             FileInfo fi = new FileInfo(filePath);
568 576
             return fi.Name.Split('.')[0];
569 577
         }
578
+        /// <summary>  
579
+        /// 使用IO从文件的绝对路径中获取文件名( 不包含扩展名 )  
580
+        /// </summary>  
581
+        /// <param name="filePath">文件的绝对路径</param>          
582
+        public static string GetIOFileNameNoExtension(string filePath)
583
+        {
584
+            return System.IO.Path.GetFileNameWithoutExtension(filePath);
585
+        }
570 586
         #endregion
571 587
 
572 588
         #region 从文件的绝对路径中获取扩展名
@@ -580,6 +596,28 @@ namespace Common.system
580 596
             FileInfo fi = new FileInfo(filePath);
581 597
             return fi.Extension;
582 598
         }
599
+        /// <summary>  
600
+        /// 使用IO从文件的绝对路径中获取扩展名 
601
+        /// </summary>  
602
+        /// <param name="filePath">文件的绝对路径</param>          
603
+        public static string GetIOExtension(string filePath)
604
+        {
605
+            string Extension = System.IO.Path.GetExtension(filePath);
606
+            return Extension;
607
+        }
608
+
609
+        #endregion
610
+
611
+        #region 从文件的绝对路径中获取路径名
612
+        /// <summary>  
613
+        /// 从文件的绝对路径中获取扩展名  
614
+        /// </summary>  
615
+        /// <param name="filePath">文件的绝对路径</param>          
616
+        public static string GetDirectoryName(string filePath)
617
+        {
618
+            string DirectoryName = (System.IO.Path.GetDirectoryName(filePath) + "\\").Replace("\\", "/");
619
+            return DirectoryName;
620
+        }
583 621
         #endregion
584 622
 
585 623
         #region 清空指定目录

+ 13
- 0
XHWK.WKTool/App.cs View File

@@ -14,6 +14,19 @@ namespace XHWK.WKTool
14 14
 {
15 15
     public partial class APP : Application
16 16
     {
17
+        /// <summary>
18
+        /// 主页面
19
+        /// </summary>
20
+        public static XHMicroLessonSystemWindow W_XHMicroLessonSystemWindow = null;
21
+        /// <summary>
22
+        /// 开始录像
23
+        /// </summary>
24
+        public static CountdownWindow W_CountdownWindow = null;
25
+        /// <summary>
26
+        /// 录像工具栏
27
+        /// </summary>
28
+        public static ScreenRecordingToolbarWindow W_ScreenRecordingToolbarWindow = null;
29
+
17 30
         [STAThread]
18 31
         private static void Main()
19 32
         {

+ 1
- 1
XHWK.WKTool/CountdownWindow.xaml View File

@@ -14,7 +14,7 @@
14 14
         <SolidColorBrush Opacity="0.96" Color="#292C2E" />
15 15
     </Window.Background>
16 16
     <Grid>
17
-        <Image
17
+        <Image x:Name="ImgGif"
18 18
                     Width="600"
19 19
                     Height="600"
20 20
                     gifLib:ImageBehavior.AnimatedSource=".\Images\countdown.gif" MediaElement.MediaEnded="Image_MediaEnded"/>

+ 20
- 14
XHWK.WKTool/CountdownWindow.xaml.cs View File

@@ -1,4 +1,6 @@
1
-using System;
1
+using AForge.Imaging;
2
+using Common.system;
3
+using System;
2 4
 using System.Collections.Generic;
3 5
 using System.Linq;
4 6
 using System.Text;
@@ -12,6 +14,7 @@ using System.Windows.Input;
12 14
 using System.Windows.Media;
13 15
 using System.Windows.Media.Imaging;
14 16
 using System.Windows.Shapes;
17
+using System.Windows.Threading;
15 18
 
16 19
 namespace XHWK.WKTool
17 20
 {
@@ -20,16 +23,30 @@ namespace XHWK.WKTool
20 23
     /// </summary>
21 24
     public partial class CountdownWindow : Window
22 25
     {
26
+        DispatcherTimer timer = null;
23 27
         public CountdownWindow()
24 28
         {
25 29
             InitializeComponent();
26
-            
30
+            Initialize();
27 31
         }
28 32
         public void Initialize()
29 33
         {
30 34
             //Thread.Sleep(1200);
31 35
             //this.Hide();
36
+            //MediaElement.Position
37
+            //((MediaElement)((object)ImgGif)).Position= TimeSpan.Zero;
38
+            timer = new DispatcherTimer();
39
+            timer.Interval = TimeSpan.FromMilliseconds(2500);
40
+            timer.Tick += Timer_Tick;
41
+            timer.Start();
32 42
         }
43
+
44
+        private void Timer_Tick(object sender, EventArgs e)
45
+        {
46
+            this.Hide();
47
+            timer.Stop();
48
+        }
49
+
33 50
         /// <summary>
34 51
         /// 跳转页面
35 52
         /// </summary>
@@ -37,18 +54,6 @@ namespace XHWK.WKTool
37 54
         /// <param name="e"></param>
38 55
         private void Window_ContentRendered(object sender, EventArgs e)
39 56
         {
40
-            ScreenRecordingToolbarWindow win = new ScreenRecordingToolbarWindow();
41
-            win.Topmost = true;
42
-            win.Show();
43
-            //显示在右下角
44
-            double xpos = this.Left + this.Width - win.Width-10;
45
-            double ypos = this.Top + this.Height - win.Height - 60;
46
-
47
-
48
-            win.Left = xpos;
49
-            win.Top = ypos;
50
-            this.Hide();
51
-
52 57
             //Thread.Sleep(800);
53 58
             ////imgLoding.Source= new BitmapImage(new Uri("pack://application:,,/Images/countdown_2.png"));
54 59
             ////Thread.Sleep(300);
@@ -61,6 +66,7 @@ namespace XHWK.WKTool
61 66
 
62 67
         private void Image_MediaEnded(object sender, RoutedEventArgs e)
63 68
         {
69
+            System.Windows.Controls.Image img = (System.Windows.Controls.Image)sender;
64 70
             ((MediaElement)sender).Position = ((MediaElement)sender).Position.Add(TimeSpan.FromMilliseconds(10000));
65 71
         }
66 72
     }

+ 7
- 4
XHWK.WKTool/CreateAMicroLessonWindow.xaml.cs View File

@@ -73,10 +73,13 @@ namespace XHWK.WKTool
73 73
         /// <param name="e"></param>
74 74
         private void btnStart_Click(object sender, RoutedEventArgs e)
75 75
         {
76
-            XHMicroLessonSystemWindow win = new XHMicroLessonSystemWindow();
77
-            //win.Topmost = true;
78
-            win.ShowDialog();
79
-            this.Close();
76
+            if (APP.W_XHMicroLessonSystemWindow == null)
77
+            {
78
+                APP.W_XHMicroLessonSystemWindow = new XHMicroLessonSystemWindow();
79
+                //APP.W_XHMicroLessonSystemWindow .Topmost = true;
80
+            }
81
+            APP.W_XHMicroLessonSystemWindow.Show();
82
+            this.Hide();
80 83
         }
81 84
         /// <summary>
82 85
         /// 窗体移动

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

@@ -8,7 +8,7 @@
8 8
         Title="ScreenRecordingToolbarWindow" Height="450" Width="300" AllowsTransparency="True" 
9 9
     ShowInTaskbar="False"
10 10
     WindowStartupLocation="CenterOwner"
11
-    WindowStyle="None">
11
+    WindowStyle="None" Margin="0" Left="0" Top="0">
12 12
     <Window.Background>
13 13
         <SolidColorBrush Opacity="0" Color="#292C2E" />
14 14
     </Window.Background>
@@ -74,9 +74,9 @@
74 74
             <TextBlock Grid.Row="1" Text="01:35" FontSize="23" Foreground="#FFFFFF" Margin="30,50,0,0"/>
75 75
             <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,15,0">
76 76
                 <Button Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Margin="0,0,15,0">
77
-                    <Image Source="./Images/Toobar25.png"/>
77
+                    <Image Source="Images/microLessonSystem_23.png"/>
78 78
                 </Button>
79
-                <Button Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Margin="0,0,15,0">
79
+                <Button x:Name="BtnStopRecordingScreen" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Margin="0,0,15,0" Click="BtnStopRecordingScreen_Click">
80 80
                     <Image Source="./Images/Toobar14.png"/>
81 81
                 </Button>
82 82
                 <Button x:Name="btnBrush" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Margin="0,0,10,0" Click="BtnBrush_Click">

+ 28
- 2
XHWK.WKTool/ScreenRecordingToolbarWindow.xaml.cs View File

@@ -1,4 +1,5 @@
1
-using System;
1
+using Common.system;
2
+using System;
2 3
 using System.Collections.Generic;
3 4
 using System.Linq;
4 5
 using System.Text;
@@ -23,6 +24,10 @@ namespace XHWK.WKTool
23 24
         {
24 25
             InitializeComponent();
25 26
         }
27
+        public void Initialize()
28
+        {
29
+            BtnToolbarDown_Click(null, null);
30
+        }
26 31
         /// <summary>
27 32
         /// 画笔工具栏关闭事件
28 33
         /// </summary>
@@ -39,7 +44,14 @@ namespace XHWK.WKTool
39 44
         /// <param name="e"></param>
40 45
         private void BtnBrush_Click(object sender, RoutedEventArgs e)
41 46
         {
42
-            gridToolbar.Visibility = Visibility.Visible;
47
+            if (gridToolbar.Visibility == Visibility.Visible)
48
+            {
49
+                gridToolbar.Visibility = Visibility.Hidden;
50
+            }
51
+            else
52
+            {
53
+                gridToolbar.Visibility = Visibility.Visible;
54
+            }
43 55
         }
44 56
         /// <summary>
45 57
         /// 画笔粗细事件
@@ -61,5 +73,19 @@ namespace XHWK.WKTool
61 73
             gridColour.Visibility = Visibility.Visible;
62 74
             gridThickness.Visibility = Visibility.Collapsed;
63 75
         }
76
+        /// <summary>
77
+        /// 停止录像
78
+        /// </summary>
79
+        /// <param name="sender"></param>
80
+        /// <param name="e"></param>
81
+        private void BtnStopRecordingScreen_Click(object sender, RoutedEventArgs e)
82
+        {
83
+            if(APP.W_XHMicroLessonSystemWindow==null)
84
+            {
85
+                APP.W_XHMicroLessonSystemWindow = new XHMicroLessonSystemWindow();
86
+            }
87
+            APP.W_XHMicroLessonSystemWindow.Show();
88
+            Hide();
89
+        }
64 90
     }
65 91
 }

+ 29
- 5
XHWK.WKTool/XHMicroLessonSystemWindow.xaml.cs View File

@@ -21,7 +21,7 @@ namespace XHWK.WKTool
21 21
     /// </summary>
22 22
     public partial class XHMicroLessonSystemWindow : Window
23 23
     {
24
-        #region 字段
24
+        #region 初始值
25 25
         /// <summary>
26 26
         /// 文件目录窗口
27 27
         /// </summary>
@@ -97,10 +97,34 @@ namespace XHWK.WKTool
97 97
         /// <param name="e"></param>
98 98
         private void BtnScreenRecording_Click(object sender, RoutedEventArgs e)
99 99
         {
100
-            CountdownWindow win = new CountdownWindow();
101
-            win.Topmost = true;
102
-            win.Show();
103
-            this.Close();
100
+            if (APP.W_CountdownWindow == null)
101
+            {
102
+                APP.W_CountdownWindow = new CountdownWindow();
103
+                //APP.W_CountdownWindow.Topmost = true;
104
+            }
105
+            else
106
+            {
107
+                APP.W_CountdownWindow.Initialize();
108
+                APP.W_CountdownWindow.Topmost = true;
109
+            }
110
+            APP.W_CountdownWindow.Show();
111
+
112
+            if (APP.W_ScreenRecordingToolbarWindow == null)
113
+            {
114
+                APP.W_ScreenRecordingToolbarWindow = new ScreenRecordingToolbarWindow();
115
+                APP.W_ScreenRecordingToolbarWindow.Topmost = true;
116
+                APP.W_ScreenRecordingToolbarWindow.Initialize();
117
+
118
+            }
119
+            else
120
+            {
121
+                APP.W_ScreenRecordingToolbarWindow.Initialize();
122
+            }
123
+            //显示在右下角
124
+            //APP.W_ScreenRecordingToolbarWindow.Left= PrimaryScreen.DESKTOP.Width - APP.W_ScreenRecordingToolbarWindow.Width - 10;
125
+            //APP.W_ScreenRecordingToolbarWindow.Top= PrimaryScreen.DESKTOP.Height - APP.W_ScreenRecordingToolbarWindow.Height - 60;
126
+            this.Hide();
127
+            Hide();
104 128
         }
105 129
         /// <summary>
106 130
         /// 上传事件

+ 1
- 0
XHWK.WKTool/XHWK.WKTool.csproj View File

@@ -58,6 +58,7 @@
58 58
     </Reference>
59 59
     <Reference Include="System" />
60 60
     <Reference Include="System.Data" />
61
+    <Reference Include="System.Drawing" />
61 62
     <Reference Include="System.Windows.Forms" />
62 63
     <Reference Include="System.Xml" />
63 64
     <Reference Include="Microsoft.CSharp" />

Loading…
Cancel
Save