瀏覽代碼

zhao:修改存储

tags/录制修改前
耀 4 年之前
父節點
當前提交
082c81a014
共有 3 個檔案被更改,包括 165 行新增152 行删除
  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 查看文件

@@ -235,86 +235,88 @@ namespace Common.system
235 235
         /// <param name="VideoHeight">视频高度</param>
236 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 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 322
         /// <summary>
@@ -338,11 +340,11 @@ namespace Common.system
338 340
             string FilePath = (string)FilePathobj;
339 341
             string Path = FileToolsCommon.GetDirectoryName(FilePath);
340 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 348
             myProcess = new Process();
347 349
             LogPath = CreateffmpegLog();
348 350
             this.myProcess.StartInfo.FileName = FileToolsCommon.GetFileAbsolutePath(@"/ffmpeg/bin/ffmpeg.exe");   //ffmpeg.exe的绝对路径
@@ -381,7 +383,9 @@ namespace Common.system
381 383
             #endregion
382 384
             myProcess = null;
383 385
             if (Extension.ToUpper() == ".MP3")
386
+            {
384 387
                 FileToolsCommon.DeleteDirectory(Path + "temp/");
388
+            }
385 389
             else
386 390
                 FileToolsCommon.DeleteDirectory(Path + "temprs/");
387 391
         }

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

@@ -289,6 +289,8 @@ namespace XHWK.WKTool
289 289
                     if (WKDataList.Exists(x => x.WkPath == WkPath))
290 290
                     {
291 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 查看文件

@@ -188,7 +188,7 @@ namespace XHWK.WKTool
188 188
                         if (I > 10010)
189 189
                         {
190 190
                             long time = Timestamp();
191
-                        string imgPath= FileToolsCommon.GetFileAbsolutePath("Temp/imgplayer");
191
+                            string imgPath = FileToolsCommon.GetFileAbsolutePath("Temp/imgplayer");
192 192
                             //string FilePathName = ImgPath + RsImgName.Count + ".png";
193 193
                             string path = CameraHelper.CaptureImage(imgPath, time.ToString());
194 194
                             if (!string.IsNullOrWhiteSpace(path))
@@ -335,7 +335,7 @@ namespace XHWK.WKTool
335 335
                     TxbRecordScreenWord.Text = "录屏";
336 336
                 });
337 337
             }))).Start();
338
-           
338
+
339 339
         }
340 340
 
341 341
         /// <summary>
@@ -350,7 +350,7 @@ namespace XHWK.WKTool
350 350
                 Login();
351 351
                 return;
352 352
             }
353
-            if(APP.fileDirectoryWindow==null)
353
+            if (APP.fileDirectoryWindow == null)
354 354
             {
355 355
                 APP.fileDirectoryWindow = new FileDirectoryWindow();
356 356
                 //APP.fileDirectoryWindow.Topmost = true;
@@ -715,7 +715,7 @@ namespace XHWK.WKTool
715 715
             {
716 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 720
                         APP.pageData.pagenum += 1;
721 721
                         APP.pageData.currpage = APP.pageData.pagenum;
@@ -928,21 +928,21 @@ namespace XHWK.WKTool
928 928
                             string paths = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
929 929
                             string[] page = ConvertWordToImage(filepath, paths, "", 0, 0, null, 0).ToArray();
930 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 937
                                     APP.PageDrawList[i].PageNum = i + 1;
938 938
                                     APP.PageDrawList[i].ImgDocumentation = true;
939 939
                                 }
940 940
                                 else
941 941
                                 {
942
-                                  
942
+
943 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 946
                                     model_DrawData.PageNum = i + 1;
947 947
                                     model_DrawData.ImgDocumentation = true;
948 948
                                     APP.PageDrawList.Add(model_DrawData);
@@ -953,12 +953,12 @@ namespace XHWK.WKTool
953 953
                                 APP.SaveDraw();
954 954
                                 num++;
955 955
                             }
956
-                            if(num>0)
956
+                            if (num > 0)
957 957
                             {
958 958
                                 APP.pageData.currpage = APP.pageData.pagenum + 1;
959 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 963
                                 imgDocumentation.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));//给当前页面展示图片
964 964
                                 imgCanvas.Source = null;
@@ -1039,7 +1039,7 @@ namespace XHWK.WKTool
1039 1039
         /// <param name="e"></param>
1040 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 1044
                 blackboard_canvas.Visibility = Visibility.Visible;
1045 1045
             }
@@ -1306,7 +1306,7 @@ namespace XHWK.WKTool
1306 1306
                 ImgSetUpTwo.Visibility = Visibility.Collapsed;
1307 1307
                 btnSetUp.IsEnabled = true;
1308 1308
 
1309
-                btnLoginType.IsEnabled = true; 
1309
+                btnLoginType.IsEnabled = true;
1310 1310
                 #endregion
1311 1311
 
1312 1312
                 IsSuspendR = true;
@@ -1326,9 +1326,17 @@ namespace XHWK.WKTool
1326 1326
                 #endregion
1327 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 1336
                     APP.FFmpeg.StopFFmpeg(AudioPathName);
1330 1337
                     new Thread(new ThreadStart(new Action(() =>
1331 1338
                     {
1339
+                        //停止截图
1332 1340
                         while (APP.FFmpeg.myProcess != null)
1333 1341
                         {
1334 1342
                             Thread.Sleep(100);
@@ -1338,23 +1346,22 @@ namespace XHWK.WKTool
1338 1346
                             IsStartCount = false;
1339 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 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 1365
                         while (!FileToolsCommon.IsExistFile(VideoSavePathName))
1359 1366
                         {
1360 1367
                             Thread.Sleep(100);
@@ -1402,36 +1409,36 @@ namespace XHWK.WKTool
1402 1409
         /// <param name="e"></param>
1403 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 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 1443
             ImgScreenshot.Visibility = Visibility.Visible;
1437 1444
             ImgScreenshotTwo.Visibility = Visibility.Collapsed;
@@ -1450,7 +1457,7 @@ namespace XHWK.WKTool
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 1461
                 //iTextSharp.text.Rectangle page = new iTextSharp.text.Rectangle(iTextSharp.text.PageSize.A4., 250f);//cs
1455 1462
                 ////设置纸张横向
1456 1463
                 //document.SetPageSize(iTextSharp.text.PageSize.A4.Rotate());
@@ -1473,7 +1480,7 @@ namespace XHWK.WKTool
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 1485
                         image = iTextSharp.text.Image.GetInstance(APP.PageDrawList[i].PageImagePath);
1479 1486
                     }
@@ -1488,7 +1495,7 @@ namespace XHWK.WKTool
1488 1495
 
1489 1496
                         string msg = string.Empty;
1490 1497
                         bool isImg = MergerImg(APP.PageDrawList[i].PageImagePath, filePathOutPut, rectangleF, out msg);
1491
-                        if(isImg)
1498
+                        if (isImg)
1492 1499
                         {
1493 1500
                             image = iTextSharp.text.Image.GetInstance(filePathOutPut);
1494 1501
                         }
@@ -1498,7 +1505,7 @@ namespace XHWK.WKTool
1498 1505
                         }
1499 1506
                     }
1500 1507
 
1501
-                   
1508
+
1502 1509
 
1503 1510
 
1504 1511
                     if (image.Height > iTextSharp.text.PageSize.A4.Height - 25)
@@ -1526,7 +1533,7 @@ namespace XHWK.WKTool
1526 1533
             }
1527 1534
 
1528 1535
 
1529
-         
1536
+
1530 1537
 
1531 1538
 
1532 1539
 
@@ -1697,7 +1704,7 @@ namespace XHWK.WKTool
1697 1704
                     }
1698 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 1709
                             imgCanvas.Source = null;
1703 1710
                             imgDocumentation.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));
@@ -1751,45 +1758,45 @@ namespace XHWK.WKTool
1751 1758
         /// <param name="_rectangle">图片位置</param>
1752 1759
         /// <param name="errmsg">错误消息</param>
1753 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 1763
             errmsg = null;
1757 1764
             try
1758 1765
             {
1759 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 1770
                 Graphics g = Graphics.FromImage(backgroudImg);
1764 1771
                 //清除画布,背景设置为白色
1765 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 1777
                     g.DrawImage(bitmap, _rectangle);
1771 1778
                 }
1772 1779
 
1773 1780
 
1774 1781
                 backgroudImg.Save(_saveimg);
1775
-               
1782
+
1776 1783
                 g.Dispose();
1777 1784
                 backgroudImg.Dispose();
1778
-                if(bitmap!=null)
1785
+                if (bitmap != null)
1779 1786
                 {
1780 1787
                     bitmap.Dispose();
1781 1788
                 }
1782
-              
1789
+
1783 1790
                 GC.Collect();
1784 1791
                 return true;
1785 1792
             }
1786 1793
             catch (Exception ex)
1787 1794
             {
1788 1795
                 errmsg = ex.Message;
1789
-                LogHelper.WriteErrLog("【截图合成】(MergerImg)图片合成失败:" + ex.Message,ex);
1796
+                LogHelper.WriteErrLog("【截图合成】(MergerImg)图片合成失败:" + ex.Message, ex);
1790 1797
                 return false;
1791 1798
             }
1792
-        
1799
+
1793 1800
         }
1794 1801
         /// <summary>
1795 1802
         /// 将Word文档转换为图片的方法(该方法基于第三方DLL),你可以像这样调用该方法: ConvertPDF2Image("F:\\PdfFile.doc", "F:\\",
@@ -2388,7 +2395,7 @@ namespace XHWK.WKTool
2388 2395
         /// <param name="e"></param>
2389 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 2400
                 this.WindowState = WindowState.Normal;
2394 2401
             }
@@ -2402,7 +2409,7 @@ namespace XHWK.WKTool
2402 2409
         /// </summary>
2403 2410
         /// <param name="sender"></param>
2404 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 2414
             //APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation = true;
2408 2415
             //btnOk.Visibility = Visibility.Collapsed;

Loading…
取消
儲存