Browse Source

zhao:修改存储

tags/录制修改前
耀 4 years ago
parent
commit
082c81a014
3 changed files with 165 additions and 152 deletions
  1. 84
    80
      Common/system/FFMpeg.cs
  2. 2
    0
      XHWK.WKTool/App.cs
  3. 79
    72
      XHWK.WKTool/XHMicroLessonSystemWindow.xaml.cs

+ 84
- 80
Common/system/FFMpeg.cs View File

235
         /// <param name="VideoHeight">视频高度</param>
235
         /// <param name="VideoHeight">视频高度</param>
236
         public void SynthesisVideo(string ImageListPath, string Mp3Path, string VideoSavePath, int Frequency, int VideoWidth, int VideoHeight)
236
         public void SynthesisVideo(string ImageListPath, string Mp3Path, string VideoSavePath, int Frequency, int VideoWidth, int VideoHeight)
237
         {
237
         {
238
-            new Thread(new ThreadStart(new Action(() =>
238
+            //new Thread(new ThreadStart(new Action(() =>
239
+            //{
240
+
241
+            //}))).Start();
242
+            while (myProcess != null)
243
+            {
244
+                Thread.Sleep(100);
245
+            }
246
+            string Extension = FileToolsCommon.GetIOExtension(VideoSavePath);//扩展名
247
+            Process[] KillProcessArray = Process.GetProcessesByName("ffmpeg");
248
+            //Debug.WriteLine(KillProcessArray.Length.ToString());
249
+            foreach (var KillProcess in KillProcessArray)
250
+            {
251
+                KillProcess.Kill();
252
+            }
253
+            myProcess = new Process();
254
+            LogPath = CreateffmpegLog();
255
+            this.myProcess.StartInfo.FileName = FileToolsCommon.GetFileAbsolutePath(@"/ffmpeg/bin/ffmpeg.exe");   //ffmpeg.exe的绝对路径
256
+            switch (Extension.ToUpper())
257
+            {
258
+                case "MP4":
259
+                    myProcess.StartInfo.Arguments = @"-y -r " + Frequency + " -i " +
260
+                        ImageListPath + @"%d.png -i " +
261
+                        Mp3Path + @" -s " + VideoWidth + "x" + VideoHeight + " -vcodec mpeg4 " +
262
+                        VideoSavePath;
263
+                    break;
264
+                case "AVI":
265
+                    myProcess.StartInfo.Arguments = @"-y -r " + Frequency + " -i " +
266
+                        ImageListPath + @"%d.png -i " +
267
+                        Mp3Path + @" -s " + VideoWidth + "x" + VideoHeight + " -f AVI " +
268
+                        VideoSavePath;
269
+                    break;
270
+                case "FLV":
271
+                    myProcess.StartInfo.Arguments = @"-y -r " + Frequency + " -i " +
272
+                        ImageListPath + @"%d.png -i " +
273
+                        Mp3Path + @" -s " + VideoWidth + "x" + VideoHeight + " -f FLV " +
274
+                        VideoSavePath;
275
+                    break;
276
+                default:
277
+                    myProcess.StartInfo.Arguments = @"-y -r " + Frequency + " -i " +
278
+                        ImageListPath + @"%d.png -i " +
279
+                        Mp3Path + @" -s " + VideoWidth + "x" + VideoHeight + " -vcodec mpeg4 " +
280
+                        VideoSavePath;
281
+                    break;
282
+            }
283
+            myProcess.StartInfo.UseShellExecute = false;           //不使用操作系统外壳程序启动
284
+            myProcess.StartInfo.RedirectStandardError = true;      //重定向标准错误输出
285
+            myProcess.StartInfo.CreateNoWindow = true;             //不显示程序窗口
286
+            myProcess.StartInfo.RedirectStandardInput = true;      //用于模拟该进程控制台的输入
287
+                                                                   //外部程序(这里是FFMPEG)输出流时候产生的事件,这里是把流的处理过程转移到下面的方法中,详细请查阅MSDN
288
+            myProcess.ErrorDataReceived += new DataReceivedEventHandler(Output);
289
+            myProcess.Start();                 //启动线程
290
+            myProcess.BeginErrorReadLine();    //开始异步读取
291
+            myProcess.WaitForExit();           //阻塞等待进程结束
292
+            myProcess.Close();                 //关闭进程
293
+            myProcess.Dispose();               //释放资源
294
+            #region 进程是否已经释放
295
+            bool IsRunning = true;
296
+            while (IsRunning)
239
             {
297
             {
240
-                Thread.Sleep(500);
241
-                while (myProcess != null)
298
+                IsRunning = false;
299
+                Process[] ProcessArray = Process.GetProcessesByName("ffmpeg");
300
+                foreach (var KillProcess in ProcessArray)
242
                 {
301
                 {
302
+                    IsRunning = true;
243
                     Thread.Sleep(100);
303
                     Thread.Sleep(100);
244
                 }
304
                 }
245
-                string Extension = FileToolsCommon.GetIOExtension(VideoSavePath);//扩展名
246
-                Process[] KillProcessArray = Process.GetProcessesByName("ffmpeg");
247
-                //Debug.WriteLine(KillProcessArray.Length.ToString());
248
-                foreach (var KillProcess in KillProcessArray)
249
-                {
250
-                    KillProcess.Kill();
251
-                }
252
-                myProcess = new Process();
253
-                LogPath = CreateffmpegLog();
254
-                this.myProcess.StartInfo.FileName = FileToolsCommon.GetFileAbsolutePath(@"/ffmpeg/bin/ffmpeg.exe");   //ffmpeg.exe的绝对路径
255
-                switch (Extension.ToUpper())
256
-                {
257
-                    case "MP4":
258
-                        myProcess.StartInfo.Arguments = @"-y -r " + Frequency + " -i " +
259
-                            ImageListPath + @"%d.png -i " +
260
-                            Mp3Path + @" -s " + VideoWidth + "x" + VideoHeight + " -vcodec mpeg4 " +
261
-                            VideoSavePath;
262
-                        break;
263
-                    case "AVI":
264
-                        myProcess.StartInfo.Arguments = @"-y -r " + Frequency + " -i " +
265
-                            ImageListPath + @"%d.png -i " +
266
-                            Mp3Path + @" -s " + VideoWidth + "x" + VideoHeight + " -f AVI " +
267
-                            VideoSavePath;
268
-                        break;
269
-                    case "FLV":
270
-                        myProcess.StartInfo.Arguments = @"-y -r " + Frequency + " -i " +
271
-                            ImageListPath + @"%d.png -i " +
272
-                            Mp3Path + @" -s " + VideoWidth + "x" + VideoHeight + " -f FLV " +
273
-                            VideoSavePath;
274
-                        break;
275
-                    default:
276
-                        myProcess.StartInfo.Arguments = @"-y -r " + Frequency + " -i " +
277
-                            ImageListPath + @"%d.png -i " +
278
-                            Mp3Path + @" -s " + VideoWidth + "x" + VideoHeight + " -vcodec mpeg4 " +
279
-                            VideoSavePath;
280
-                        break;
281
-                }
282
-                myProcess.StartInfo.UseShellExecute = false;           //不使用操作系统外壳程序启动
283
-                myProcess.StartInfo.RedirectStandardError = true;      //重定向标准错误输出
284
-                myProcess.StartInfo.CreateNoWindow = true;             //不显示程序窗口
285
-                myProcess.StartInfo.RedirectStandardInput = true;      //用于模拟该进程控制台的输入
286
-                                                                       //外部程序(这里是FFMPEG)输出流时候产生的事件,这里是把流的处理过程转移到下面的方法中,详细请查阅MSDN
287
-                myProcess.ErrorDataReceived += new DataReceivedEventHandler(Output);
288
-                myProcess.Start();                 //启动线程
289
-                myProcess.BeginErrorReadLine();    //开始异步读取
290
-                myProcess.WaitForExit();           //阻塞等待进程结束
291
-                myProcess.Close();                 //关闭进程
292
-                myProcess.Dispose();               //释放资源
293
-                #region 进程是否已经释放
294
-                bool IsRunning = true;
295
-                while (IsRunning)
296
-                {
297
-                    IsRunning = false;
298
-                    Process[] ProcessArray = Process.GetProcessesByName("ffmpeg");
299
-                    foreach (var KillProcess in ProcessArray)
300
-                    {
301
-                        IsRunning = true;
302
-                        Thread.Sleep(100);
303
-                    }
304
-                }
305
-                #endregion
306
-                myProcess = null;
307
-                //生成视频后删除图片和音频保存列表
308
-                //FileToolsCommon.DeleteDirectory(ImageListPath);
309
-                //FileToolsCommon.DeleteDirectory(FileToolsCommon.GetDirectoryName(Mp3Path));
310
-                FileToolsCommon.DeleteDirectory(FileToolsCommon.GetDirectoryName(VideoSavePath) + "temp");
305
+            }
306
+            #endregion
307
+            myProcess = null;
308
+            //生成视频后删除图片和音频保存列表
309
+            //FileToolsCommon.DeleteDirectory(ImageListPath);
310
+            //FileToolsCommon.DeleteDirectory(FileToolsCommon.GetDirectoryName(Mp3Path));
311
 
311
 
312
-                //Dispatcher.Invoke(() =>
313
-                //{
314
-                //});
315
-                //// 允许不同线程间的调用
316
-                //Control.CheckForIllegalCrossThreadCalls = false;
317
-            }))).Start();
312
+            Thread.Sleep(100);
313
+            FileToolsCommon.DeleteDirectory(FileToolsCommon.GetDirectoryName(VideoSavePath) + "temp");
314
+
315
+            //Dispatcher.Invoke(() =>
316
+            //{
317
+            //});
318
+            //// 允许不同线程间的调用
319
+            //Control.CheckForIllegalCrossThreadCalls = false;
318
         }
320
         }
319
 
321
 
320
         /// <summary>
322
         /// <summary>
338
             string FilePath = (string)FilePathobj;
340
             string FilePath = (string)FilePathobj;
339
             string Path = FileToolsCommon.GetDirectoryName(FilePath);
341
             string Path = FileToolsCommon.GetDirectoryName(FilePath);
340
             string Extension = FileToolsCommon.GetIOExtension(FilePath);//扩展名
342
             string Extension = FileToolsCommon.GetIOExtension(FilePath);//扩展名
341
-            Process[] KillProcessArray = Process.GetProcessesByName("ffmpeg");
342
-            foreach (var KillProcess in KillProcessArray)
343
-            {
344
-                KillProcess.Kill();
345
-            }
343
+            //Process[] KillProcessArray = Process.GetProcessesByName("ffmpeg");
344
+            //foreach (var KillProcess in KillProcessArray)
345
+            //{
346
+            //    KillProcess.Kill();
347
+            //}
346
             myProcess = new Process();
348
             myProcess = new Process();
347
             LogPath = CreateffmpegLog();
349
             LogPath = CreateffmpegLog();
348
             this.myProcess.StartInfo.FileName = FileToolsCommon.GetFileAbsolutePath(@"/ffmpeg/bin/ffmpeg.exe");   //ffmpeg.exe的绝对路径
350
             this.myProcess.StartInfo.FileName = FileToolsCommon.GetFileAbsolutePath(@"/ffmpeg/bin/ffmpeg.exe");   //ffmpeg.exe的绝对路径
381
             #endregion
383
             #endregion
382
             myProcess = null;
384
             myProcess = null;
383
             if (Extension.ToUpper() == ".MP3")
385
             if (Extension.ToUpper() == ".MP3")
386
+            {
384
                 FileToolsCommon.DeleteDirectory(Path + "temp/");
387
                 FileToolsCommon.DeleteDirectory(Path + "temp/");
388
+            }
385
             else
389
             else
386
                 FileToolsCommon.DeleteDirectory(Path + "temprs/");
390
                 FileToolsCommon.DeleteDirectory(Path + "temprs/");
387
         }
391
         }

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

289
                     if (WKDataList.Exists(x => x.WkPath == WkPath))
289
                     if (WKDataList.Exists(x => x.WkPath == WkPath))
290
                     {
290
                     {
291
                         WKData = WKDataList.Find(x => x.WkPath == WkPath);
291
                         WKData = WKDataList.Find(x => x.WkPath == WkPath);
292
+                        VideoList = new List<Model_Video>();
293
+                        VideoList = WKData.VideoList;
292
                     }
294
                     }
293
                 }
295
                 }
294
             }
296
             }

+ 79
- 72
XHWK.WKTool/XHMicroLessonSystemWindow.xaml.cs View File

188
                         if (I > 10010)
188
                         if (I > 10010)
189
                         {
189
                         {
190
                             long time = Timestamp();
190
                             long time = Timestamp();
191
-                        string imgPath= FileToolsCommon.GetFileAbsolutePath("Temp/imgplayer");
191
+                            string imgPath = FileToolsCommon.GetFileAbsolutePath("Temp/imgplayer");
192
                             //string FilePathName = ImgPath + RsImgName.Count + ".png";
192
                             //string FilePathName = ImgPath + RsImgName.Count + ".png";
193
                             string path = CameraHelper.CaptureImage(imgPath, time.ToString());
193
                             string path = CameraHelper.CaptureImage(imgPath, time.ToString());
194
                             if (!string.IsNullOrWhiteSpace(path))
194
                             if (!string.IsNullOrWhiteSpace(path))
335
                     TxbRecordScreenWord.Text = "录屏";
335
                     TxbRecordScreenWord.Text = "录屏";
336
                 });
336
                 });
337
             }))).Start();
337
             }))).Start();
338
-           
338
+
339
         }
339
         }
340
 
340
 
341
         /// <summary>
341
         /// <summary>
350
                 Login();
350
                 Login();
351
                 return;
351
                 return;
352
             }
352
             }
353
-            if(APP.fileDirectoryWindow==null)
353
+            if (APP.fileDirectoryWindow == null)
354
             {
354
             {
355
                 APP.fileDirectoryWindow = new FileDirectoryWindow();
355
                 APP.fileDirectoryWindow = new FileDirectoryWindow();
356
                 //APP.fileDirectoryWindow.Topmost = true;
356
                 //APP.fileDirectoryWindow.Topmost = true;
715
             {
715
             {
716
                 if (!string.IsNullOrWhiteSpace(APP.ImgPath) && File.Exists(APP.ImgPath))
716
                 if (!string.IsNullOrWhiteSpace(APP.ImgPath) && File.Exists(APP.ImgPath))
717
                 {
717
                 {
718
-                    if(APP.pageData.currpage==0)
718
+                    if (APP.pageData.currpage == 0)
719
                     {
719
                     {
720
                         APP.pageData.pagenum += 1;
720
                         APP.pageData.pagenum += 1;
721
                         APP.pageData.currpage = APP.pageData.pagenum;
721
                         APP.pageData.currpage = APP.pageData.pagenum;
928
                             string paths = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
928
                             string paths = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
929
                             string[] page = ConvertWordToImage(filepath, paths, "", 0, 0, null, 0).ToArray();
929
                             string[] page = ConvertWordToImage(filepath, paths, "", 0, 0, null, 0).ToArray();
930
                             int num = 0;
930
                             int num = 0;
931
-                            for (int i = 0+ APP.pageData.pagenum; i < page.Length+ APP.pageData.pagenum; i++)//给画板模型加图片路径
931
+                            for (int i = 0 + APP.pageData.pagenum; i < page.Length + APP.pageData.pagenum; i++)//给画板模型加图片路径
932
                             {
932
                             {
933
-                                if (APP.PageDrawList!=null&&APP.PageDrawList.Count > i)
933
+                                if (APP.PageDrawList != null && APP.PageDrawList.Count > i)
934
                                 {
934
                                 {
935
-                                    APP.PageDrawList[i].PageImagePath = page[i- APP.pageData.pagenum]; //zxycs
936
-                                    APP.PageDrawList[i].PdfImagePath = page[i- APP.pageData.pagenum];
935
+                                    APP.PageDrawList[i].PageImagePath = page[i - APP.pageData.pagenum]; //zxycs
936
+                                    APP.PageDrawList[i].PdfImagePath = page[i - APP.pageData.pagenum];
937
                                     APP.PageDrawList[i].PageNum = i + 1;
937
                                     APP.PageDrawList[i].PageNum = i + 1;
938
                                     APP.PageDrawList[i].ImgDocumentation = true;
938
                                     APP.PageDrawList[i].ImgDocumentation = true;
939
                                 }
939
                                 }
940
                                 else
940
                                 else
941
                                 {
941
                                 {
942
-                                  
942
+
943
                                     Model_DrawData model_DrawData = new Model_DrawData();
943
                                     Model_DrawData model_DrawData = new Model_DrawData();
944
-                                    model_DrawData.PageImagePath = page[i- APP.pageData.pagenum];
945
-                                    model_DrawData.PdfImagePath = page[i- APP.pageData.pagenum];
944
+                                    model_DrawData.PageImagePath = page[i - APP.pageData.pagenum];
945
+                                    model_DrawData.PdfImagePath = page[i - APP.pageData.pagenum];
946
                                     model_DrawData.PageNum = i + 1;
946
                                     model_DrawData.PageNum = i + 1;
947
                                     model_DrawData.ImgDocumentation = true;
947
                                     model_DrawData.ImgDocumentation = true;
948
                                     APP.PageDrawList.Add(model_DrawData);
948
                                     APP.PageDrawList.Add(model_DrawData);
953
                                 APP.SaveDraw();
953
                                 APP.SaveDraw();
954
                                 num++;
954
                                 num++;
955
                             }
955
                             }
956
-                            if(num>0)
956
+                            if (num > 0)
957
                             {
957
                             {
958
                                 APP.pageData.currpage = APP.pageData.pagenum + 1;
958
                                 APP.pageData.currpage = APP.pageData.pagenum + 1;
959
                                 APP.pageData.pagenum += num;
959
                                 APP.pageData.pagenum += num;
960
                             }
960
                             }
961
-                            if (APP.pageData.currpage>0 && APP.pageData.currpage < APP.PageDrawList.Count)
961
+                            if (APP.pageData.currpage > 0 && APP.pageData.currpage < APP.PageDrawList.Count)
962
                             {
962
                             {
963
                                 imgDocumentation.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));//给当前页面展示图片
963
                                 imgDocumentation.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));//给当前页面展示图片
964
                                 imgCanvas.Source = null;
964
                                 imgCanvas.Source = null;
1039
         /// <param name="e"></param>
1039
         /// <param name="e"></param>
1040
         private void BtnRecord_Click(object sender, RoutedEventArgs e)
1040
         private void BtnRecord_Click(object sender, RoutedEventArgs e)
1041
         {
1041
         {
1042
-            if(APP.pageData.currpage > 0)
1042
+            if (APP.pageData.currpage > 0)
1043
             {
1043
             {
1044
                 blackboard_canvas.Visibility = Visibility.Visible;
1044
                 blackboard_canvas.Visibility = Visibility.Visible;
1045
             }
1045
             }
1306
                 ImgSetUpTwo.Visibility = Visibility.Collapsed;
1306
                 ImgSetUpTwo.Visibility = Visibility.Collapsed;
1307
                 btnSetUp.IsEnabled = true;
1307
                 btnSetUp.IsEnabled = true;
1308
 
1308
 
1309
-                btnLoginType.IsEnabled = true; 
1309
+                btnLoginType.IsEnabled = true;
1310
                 #endregion
1310
                 #endregion
1311
 
1311
 
1312
                 IsSuspendR = true;
1312
                 IsSuspendR = true;
1326
                 #endregion
1326
                 #endregion
1327
                 try
1327
                 try
1328
                 {
1328
                 {
1329
+                    //缩略图
1330
+                    string ThumbnailPath = FileToolsCommon.GetDirectoryName(VideoSavePathName) + "ThumbnailPath/";
1331
+                    FileToolsCommon.CreateDirectory(ThumbnailPath);
1332
+                    //缩略图存储位置
1333
+                    string ThumbnailPathName = ThumbnailPath + FileToolsCommon.GetIOFileNameNoExtension(VideoSavePathName) + ".JPG";
1334
+                    int gridActWidth = (int)GridMain.ActualWidth;
1335
+                    int gridActHeight = (int)GridMain.ActualHeight;
1329
                     APP.FFmpeg.StopFFmpeg(AudioPathName);
1336
                     APP.FFmpeg.StopFFmpeg(AudioPathName);
1330
                     new Thread(new ThreadStart(new Action(() =>
1337
                     new Thread(new ThreadStart(new Action(() =>
1331
                     {
1338
                     {
1339
+                        //停止截图
1332
                         while (APP.FFmpeg.myProcess != null)
1340
                         while (APP.FFmpeg.myProcess != null)
1333
                         {
1341
                         {
1334
                             Thread.Sleep(100);
1342
                             Thread.Sleep(100);
1338
                             IsStartCount = false;
1346
                             IsStartCount = false;
1339
                             timer.Stop();
1347
                             timer.Stop();
1340
                         });
1348
                         });
1341
-                    }))).Start();
1342
-
1343
-                    new Thread(new ThreadStart(new Action(() =>
1344
-                    {
1345
-                        while (APP.FFmpeg.myProcess != null)
1349
+                    //}))).Start();
1350
+                    //new Thread(new ThreadStart(new Action(() =>
1351
+                    //{
1352
+                        //判断音频是否存在 判断音频临时文件夹是否存在
1353
+                        if (!FileToolsCommon.IsExistFile(AudioPathName))
1346
                         {
1354
                         {
1347
                             Thread.Sleep(100);
1355
                             Thread.Sleep(100);
1348
                         }
1356
                         }
1349
-                    }))).Start();
1350
-                    APP.FFmpeg.SynthesisVideo(ImgPath, AudioPathName, VideoSavePathName, 5, (int)GridMain.Width, (int)GridMain.Height);
1351
-                    //生成缩略图
1352
-                    string ThumbnailPath = FileToolsCommon.GetDirectoryName(VideoSavePathName) + "ThumbnailPath/";
1353
-                    FileToolsCommon.CreateDirectory(ThumbnailPath);
1354
-                    //缩略图存储位置
1355
-                    string ThumbnailPathName = ThumbnailPath + FileToolsCommon.GetIOFileNameNoExtension(VideoSavePathName) + ".JPG";
1356
-                    new Thread(new ThreadStart(new Action(() =>
1357
-                    {
1357
+                        if (FileToolsCommon.IsExistDirectory(FileToolsCommon.GetDirectoryName(AudioPathName) + "temp/"))
1358
+                        {
1359
+                            Thread.Sleep(100);
1360
+                        }
1361
+                        APP.FFmpeg.SynthesisVideo(ImgPath, AudioPathName, VideoSavePathName, 5, gridActWidth, gridActHeight);
1362
+                    //}))).Start();
1363
+                    //new Thread(new ThreadStart(new Action(() =>
1364
+                    //{
1358
                         while (!FileToolsCommon.IsExistFile(VideoSavePathName))
1365
                         while (!FileToolsCommon.IsExistFile(VideoSavePathName))
1359
                         {
1366
                         {
1360
                             Thread.Sleep(100);
1367
                             Thread.Sleep(100);
1402
         /// <param name="e"></param>
1409
         /// <param name="e"></param>
1403
         private void BtnAdd_Click(object sender, RoutedEventArgs e)
1410
         private void BtnAdd_Click(object sender, RoutedEventArgs e)
1404
         {
1411
         {
1405
-      //      RectangleF rectangleF = new RectangleF();
1406
-      //      rectangleF.Width = (float)APP.PageDrawList[0].ImageSizes.CenterX;
1407
-      //      rectangleF.Height = (float)APP.PageDrawList[0].ImageSizes.CenterY;
1408
-      //      rectangleF.X= (float)APP.PageDrawList[0].ImageLocation.X;
1409
-      //      rectangleF.Y = (float)APP.PageDrawList[0].ImageLocation.Y;
1412
+            //      RectangleF rectangleF = new RectangleF();
1413
+            //      rectangleF.Width = (float)APP.PageDrawList[0].ImageSizes.CenterX;
1414
+            //      rectangleF.Height = (float)APP.PageDrawList[0].ImageSizes.CenterY;
1415
+            //      rectangleF.X= (float)APP.PageDrawList[0].ImageLocation.X;
1416
+            //      rectangleF.Y = (float)APP.PageDrawList[0].ImageLocation.Y;
1410
 
1417
 
1411
-      //      //CESHI 
1412
-      //bool isImg=    MergerImg(APP.PageDrawList[0].PageImagePath, @"G:\102H.jpg", rectangleF, out string errmsg);
1418
+            //      //CESHI 
1419
+            //bool isImg=    MergerImg(APP.PageDrawList[0].PageImagePath, @"G:\102H.jpg", rectangleF, out string errmsg);
1413
 
1420
 
1414
 
1421
 
1415
 
1422
 
1416
-                if (APP.pageData.currpage>0)
1417
-                {
1418
-                    APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation = true;
1419
-                }
1420
-                if(IsStartCount&& blackboard_canvas.Visibility == Visibility.Collapsed)
1421
-                {
1422
-                    blackboard_canvas.Visibility = Visibility.Visible;
1423
-                }
1424
-                APP.pageData.pagenum += 1;
1425
-                APP.pageData.currpage = APP.pageData.pagenum;
1426
-                myblackboard.changepage(APP.pageData.currpage - 1);
1427
-                ///清空页面图片UI
1428
-                imgCanvas.Source = null;
1423
+            if (APP.pageData.currpage > 0)
1424
+            {
1425
+                APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation = true;
1426
+            }
1427
+            if (IsStartCount && blackboard_canvas.Visibility == Visibility.Collapsed)
1428
+            {
1429
+                blackboard_canvas.Visibility = Visibility.Visible;
1430
+            }
1431
+            APP.pageData.pagenum += 1;
1432
+            APP.pageData.currpage = APP.pageData.pagenum;
1433
+            myblackboard.changepage(APP.pageData.currpage - 1);
1434
+            ///清空页面图片UI
1435
+            imgCanvas.Source = null;
1429
             imgDocumentation.Source = null;
1436
             imgDocumentation.Source = null;
1430
-                ///画板模型增加一页
1431
-                Model_DrawData model_DrawData = new Model_DrawData();
1432
-                model_DrawData.PageNum = APP.pageData.currpage;
1433
-                APP.PageDrawList.Add(model_DrawData);
1434
-                APP.SaveDraw();
1437
+            ///画板模型增加一页
1438
+            Model_DrawData model_DrawData = new Model_DrawData();
1439
+            model_DrawData.PageNum = APP.pageData.currpage;
1440
+            APP.PageDrawList.Add(model_DrawData);
1441
+            APP.SaveDraw();
1435
             ///截图可用
1442
             ///截图可用
1436
             ImgScreenshot.Visibility = Visibility.Visible;
1443
             ImgScreenshot.Visibility = Visibility.Visible;
1437
             ImgScreenshotTwo.Visibility = Visibility.Collapsed;
1444
             ImgScreenshotTwo.Visibility = Visibility.Collapsed;
1450
 
1457
 
1451
 
1458
 
1452
 
1459
 
1453
-                    iTextSharp.text.Document document = new iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 25, 25, 25, 25);
1460
+                iTextSharp.text.Document document = new iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 25, 25, 25, 25);
1454
                 //iTextSharp.text.Rectangle page = new iTextSharp.text.Rectangle(iTextSharp.text.PageSize.A4., 250f);//cs
1461
                 //iTextSharp.text.Rectangle page = new iTextSharp.text.Rectangle(iTextSharp.text.PageSize.A4., 250f);//cs
1455
                 ////设置纸张横向
1462
                 ////设置纸张横向
1456
                 //document.SetPageSize(iTextSharp.text.PageSize.A4.Rotate());
1463
                 //document.SetPageSize(iTextSharp.text.PageSize.A4.Rotate());
1473
                     {
1480
                     {
1474
 
1481
 
1475
                     }
1482
                     }
1476
-                    else if(APP.PageDrawList[i].ImgDocumentation==true)
1483
+                    else if (APP.PageDrawList[i].ImgDocumentation == true)
1477
                     {
1484
                     {
1478
                         image = iTextSharp.text.Image.GetInstance(APP.PageDrawList[i].PageImagePath);
1485
                         image = iTextSharp.text.Image.GetInstance(APP.PageDrawList[i].PageImagePath);
1479
                     }
1486
                     }
1488
 
1495
 
1489
                         string msg = string.Empty;
1496
                         string msg = string.Empty;
1490
                         bool isImg = MergerImg(APP.PageDrawList[i].PageImagePath, filePathOutPut, rectangleF, out msg);
1497
                         bool isImg = MergerImg(APP.PageDrawList[i].PageImagePath, filePathOutPut, rectangleF, out msg);
1491
-                        if(isImg)
1498
+                        if (isImg)
1492
                         {
1499
                         {
1493
                             image = iTextSharp.text.Image.GetInstance(filePathOutPut);
1500
                             image = iTextSharp.text.Image.GetInstance(filePathOutPut);
1494
                         }
1501
                         }
1498
                         }
1505
                         }
1499
                     }
1506
                     }
1500
 
1507
 
1501
-                   
1508
+
1502
 
1509
 
1503
 
1510
 
1504
                     if (image.Height > iTextSharp.text.PageSize.A4.Height - 25)
1511
                     if (image.Height > iTextSharp.text.PageSize.A4.Height - 25)
1526
             }
1533
             }
1527
 
1534
 
1528
 
1535
 
1529
-         
1536
+
1530
 
1537
 
1531
 
1538
 
1532
 
1539
 
1697
                     }
1704
                     }
1698
                     if (!string.IsNullOrWhiteSpace(txbCurrpage.Text) && APP.pageData.currpage <= APP.PageDrawList.Count && !string.IsNullOrWhiteSpace(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath))
1705
                     if (!string.IsNullOrWhiteSpace(txbCurrpage.Text) && APP.pageData.currpage <= APP.PageDrawList.Count && !string.IsNullOrWhiteSpace(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath))
1699
                     {
1706
                     {
1700
-                        if(APP.PageDrawList[APP.pageData.currpage - 1].ImgDocumentation)
1707
+                        if (APP.PageDrawList[APP.pageData.currpage - 1].ImgDocumentation)
1701
                         {
1708
                         {
1702
                             imgCanvas.Source = null;
1709
                             imgCanvas.Source = null;
1703
                             imgDocumentation.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));
1710
                             imgDocumentation.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));
1751
         /// <param name="_rectangle">图片位置</param>
1758
         /// <param name="_rectangle">图片位置</param>
1752
         /// <param name="errmsg">错误消息</param>
1759
         /// <param name="errmsg">错误消息</param>
1753
         /// <returns></returns>
1760
         /// <returns></returns>
1754
-        private bool MergerImg(string _path,string _saveimg,RectangleF _rectangle, out string errmsg)
1761
+        private bool MergerImg(string _path, string _saveimg, RectangleF _rectangle, out string errmsg)
1755
         {
1762
         {
1756
             errmsg = null;
1763
             errmsg = null;
1757
             try
1764
             try
1758
             {
1765
             {
1759
                 Bitmap bitmap = null;
1766
                 Bitmap bitmap = null;
1760
 
1767
 
1761
-                 //创建要显示的图片对象,根据参数的个数设置宽度
1762
-                 Bitmap backgroudImg = new Bitmap((int)gridM.ActualWidth, (int)gridM.ActualHeight);
1768
+                //创建要显示的图片对象,根据参数的个数设置宽度
1769
+                Bitmap backgroudImg = new Bitmap((int)gridM.ActualWidth, (int)gridM.ActualHeight);
1763
                 Graphics g = Graphics.FromImage(backgroudImg);
1770
                 Graphics g = Graphics.FromImage(backgroudImg);
1764
                 //清除画布,背景设置为白色
1771
                 //清除画布,背景设置为白色
1765
                 g.Clear(System.Drawing.Color.White);
1772
                 g.Clear(System.Drawing.Color.White);
1766
 
1773
 
1767
-                if(!string.IsNullOrWhiteSpace(_path))
1774
+                if (!string.IsNullOrWhiteSpace(_path))
1768
                 {
1775
                 {
1769
-                     bitmap = ImageHelper.ReadBitmapFile(_path);
1776
+                    bitmap = ImageHelper.ReadBitmapFile(_path);
1770
                     g.DrawImage(bitmap, _rectangle);
1777
                     g.DrawImage(bitmap, _rectangle);
1771
                 }
1778
                 }
1772
 
1779
 
1773
 
1780
 
1774
                 backgroudImg.Save(_saveimg);
1781
                 backgroudImg.Save(_saveimg);
1775
-               
1782
+
1776
                 g.Dispose();
1783
                 g.Dispose();
1777
                 backgroudImg.Dispose();
1784
                 backgroudImg.Dispose();
1778
-                if(bitmap!=null)
1785
+                if (bitmap != null)
1779
                 {
1786
                 {
1780
                     bitmap.Dispose();
1787
                     bitmap.Dispose();
1781
                 }
1788
                 }
1782
-              
1789
+
1783
                 GC.Collect();
1790
                 GC.Collect();
1784
                 return true;
1791
                 return true;
1785
             }
1792
             }
1786
             catch (Exception ex)
1793
             catch (Exception ex)
1787
             {
1794
             {
1788
                 errmsg = ex.Message;
1795
                 errmsg = ex.Message;
1789
-                LogHelper.WriteErrLog("【截图合成】(MergerImg)图片合成失败:" + ex.Message,ex);
1796
+                LogHelper.WriteErrLog("【截图合成】(MergerImg)图片合成失败:" + ex.Message, ex);
1790
                 return false;
1797
                 return false;
1791
             }
1798
             }
1792
-        
1799
+
1793
         }
1800
         }
1794
         /// <summary>
1801
         /// <summary>
1795
         /// 将Word文档转换为图片的方法(该方法基于第三方DLL),你可以像这样调用该方法: ConvertPDF2Image("F:\\PdfFile.doc", "F:\\",
1802
         /// 将Word文档转换为图片的方法(该方法基于第三方DLL),你可以像这样调用该方法: ConvertPDF2Image("F:\\PdfFile.doc", "F:\\",
2388
         /// <param name="e"></param>
2395
         /// <param name="e"></param>
2389
         private void BtnShrink_Click(object sender, RoutedEventArgs e)
2396
         private void BtnShrink_Click(object sender, RoutedEventArgs e)
2390
         {
2397
         {
2391
-            if(this.WindowState == WindowState.Minimized)
2398
+            if (this.WindowState == WindowState.Minimized)
2392
             {
2399
             {
2393
                 this.WindowState = WindowState.Normal;
2400
                 this.WindowState = WindowState.Normal;
2394
             }
2401
             }
2402
         /// </summary>
2409
         /// </summary>
2403
         /// <param name="sender"></param>
2410
         /// <param name="sender"></param>
2404
         /// <param name="e"></param>
2411
         /// <param name="e"></param>
2405
-        private void BtnOk_Click(object sender, RoutedEventArgs e) 
2412
+        private void BtnOk_Click(object sender, RoutedEventArgs e)
2406
         {
2413
         {
2407
             //APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation = true;
2414
             //APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation = true;
2408
             //btnOk.Visibility = Visibility.Collapsed;
2415
             //btnOk.Visibility = Visibility.Collapsed;

Loading…
Cancel
Save