Переглянути джерело

zhao:增加统一消息提示框,增加ScreenCapturerRecorder环境检测安装

tags/录制修改前
耀 4 роки тому
джерело
коміт
ec98556317

+ 27
- 0
Common/system/FileToolsCommon.cs Переглянути файл

@@ -935,5 +935,32 @@ namespace Common.system
935 935
         #region 获取媒体文件的播放时长
936 936
 
937 937
         #endregion
938
+
939
+        #region 检测是否安装了某个程序
940
+        /// <summary>  
941
+        /// 确认电脑上是否安装有某个程序 
942
+        /// </summary>  
943
+        /// <param name="softWareName">程序安装后的名称</param>
944
+        /// <returns>true: 有安裝, false:沒有安裝</returns>  
945
+        public static bool CheckSoftWartInstallState(string softWareName)
946
+        {
947
+            Microsoft.Win32.RegistryKey uninstallNode =
948
+                Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", Microsoft.Win32.RegistryKeyPermissionCheck.ReadWriteSubTree, System.Security.AccessControl.RegistryRights.ReadKey);
949
+            foreach (string subKeyName in uninstallNode.GetSubKeyNames())
950
+            {
951
+                Microsoft.Win32.RegistryKey subKey = uninstallNode.OpenSubKey(subKeyName);
952
+                object displayName = subKey.GetValue("DisplayName");
953
+                if (displayName != null)
954
+                {
955
+                    if (displayName.ToString().Contains(softWareName))
956
+                    {
957
+                        return true;
958
+                        // MessageWindow.Show(displayName.ToString());  
959
+                    }
960
+                }
961
+            }
962
+            return false;
963
+        }
964
+        #endregion
938 965
     }
939 966
 }

+ 1
- 1
Common/system/HttpHelper.cs Переглянути файл

@@ -530,7 +530,7 @@ namespace Common.system
530 530
                     jobResult = JObject.Parse(returnValue);
531 531
                     response.Close();
532 532
                     readStream.Close();
533
-                    //MessageBox.Show(returnValue);
533
+                    //MessageWindow.Show(returnValue);
534 534
                     LogHelper.WriteInfoLog("【文件上传】" + returnValue);
535 535
                 }
536 536
                 return jobResult;

+ 91
- 4
XHWK.WKTool/App.cs Переглянути файл

@@ -1,4 +1,5 @@
1 1
 using ComeCapture;
2
+
2 3
 using Common.system;
3 4
 
4 5
 using System;
@@ -24,11 +25,11 @@ namespace XHWK.WKTool
24 25
         /// <summary>
25 26
         /// 用户信息
26 27
         /// </summary>
27
-        public static Model_UserInfo UserInfo=null;
28
+        public static Model_UserInfo UserInfo = null;
28 29
         /// <summary>
29 30
         /// 接口返回消息
30 31
         /// </summary>
31
-        public static string ServerMsg=string.Empty;
32
+        public static string ServerMsg = string.Empty;
32 33
         /// <summary>
33 34
         /// 用户微课列表模型
34 35
         /// </summary>
@@ -75,7 +76,7 @@ namespace XHWK.WKTool
75 76
         /// <summary>
76 77
         /// 数据存放目录
77 78
         /// </summary>
78
-        public static string DataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\XHMicroLesson\\"; 
79
+        public static string DataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\XHMicroLesson\\";
79 80
         #region 点阵笔
80 81
         /// <summary>
81 82
         /// 点阵笔
@@ -238,7 +239,7 @@ namespace XHWK.WKTool
238 239
         private void MyApp_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
239 240
         {
240 241
             LogHelper.WriteErrLog("未标示错误:" + e.Exception.Message, e.Exception);
241
-            MessageBox.Show("程序异常." + Environment.NewLine + e.Exception.Message);
242
+            MessageWindow.Show("程序异常." + Environment.NewLine + e.Exception.Message);
242 243
             e.Handled = true;
243 244
         }
244 245
 
@@ -354,6 +355,92 @@ namespace XHWK.WKTool
354 355
         }
355 356
         #endregion
356 357
 
358
+        #region 检测安装Screen Capturer Recorder
359
+        /// <summary>
360
+        /// 检测是否安装了Screen Capturer Recorder
361
+        /// </summary>
362
+        /// <returns></returns>
363
+        public static bool CheckScreenCapturerRecorder()
364
+        {
365
+            if (FileToolsCommon.CheckSoftWartInstallState("Screen Capturer Recorder"))
366
+            {
367
+                //已经安装
368
+                return true;
369
+            }
370
+            else
371
+            {
372
+                return false;
373
+            }
374
+        }
375
+        /// <summary>
376
+        /// 安装Screen Capturer Recorder
377
+        /// </summary>
378
+        /// <returns></returns>
379
+        public static bool InstallScreenCapturerRecorder()
380
+        {
381
+            Process InstallProcess = new Process();
382
+            string StandardError = "";
383
+            string StandardOutput = "";
384
+            try
385
+            {
386
+                InstallProcess.StartInfo.FileName = FileToolsCommon.GetFileAbsolutePath(@"/ffmpeg/bin/Setup Screen Capturer Recorder v0.12.10.exe");   //绝对路径
387
+                InstallProcess.StartInfo.UseShellExecute = false;           //不使用操作系统外壳程序启动
388
+                InstallProcess.StartInfo.RedirectStandardError = true;      //重定向标准错误输出
389
+                InstallProcess.StartInfo.RedirectStandardOutput = true;
390
+                InstallProcess.StartInfo.CreateNoWindow = true;             //不显示程序窗口
391
+                InstallProcess.StartInfo.RedirectStandardInput = true;      //用于模拟该进程控制台的输入
392
+                                                                            //外部程序(这里是FFMPEG)输出流时候产生的事件,这里是把流的处理过程转移到下面的方法中,详细请查阅MSDN
393
+                InstallProcess.ErrorDataReceived += new DataReceivedEventHandler(InstallProcess_ErrorDataReceived);
394
+                InstallProcess.Start();                 //启动线程
395
+                InstallProcess.WaitForExit();           //阻塞等待进程结束
396
+                StandardError = InstallProcess.StandardError.ReadToEnd();
397
+                StandardOutput = InstallProcess.StandardOutput.ReadToEnd();
398
+                int ExitCode = InstallProcess.ExitCode;
399
+                InstallProcess.Close();                 //关闭进程
400
+                InstallProcess.Dispose();               //释放资源
401
+                if (ExitCode == 0) //非0则为安装失败 1为取消安装
402
+                {
403
+                    return true;
404
+                }
405
+                else
406
+                {
407
+                    MessageBoxResult br = MessageWindow.Show("不安装环境将无法使用微课录制系统,是否重新安装?", "安装", MessageBoxButton.OKCancel);
408
+                    if (br == MessageBoxResult.OK)
409
+                    {
410
+                        return InstallScreenCapturerRecorder();
411
+                    }
412
+                    else
413
+                    {
414
+                        return false;
415
+                    }
416
+                }
417
+            }
418
+            catch (Exception ex)
419
+            {
420
+                LogHelper.WriteErrLog("【ScreenCapturerRecorder安装】(installScreenCapturerRecorder)安装失败:" + ex.Message, ex);
421
+                if (string.IsNullOrWhiteSpace(StandardError))
422
+                {
423
+                    LogHelper.WriteErrLog("【ScreenCapturerRecorder安装】(installScreenCapturerRecorder)安装失败:" + StandardError, null);
424
+                }
425
+                if (string.IsNullOrWhiteSpace(StandardOutput))
426
+                {
427
+                    LogHelper.WriteErrLog("【ScreenCapturerRecorder安装】(installScreenCapturerRecorder)安装返回信息:" + StandardOutput, null);
428
+                }
429
+                return false;
430
+            }
431
+        }
432
+        /// <summary>
433
+        /// 安装失败信息
434
+        /// </summary>
435
+        /// <param name="sender"></param>
436
+        /// <param name="e"></param>
437
+        private static void InstallProcess_ErrorDataReceived(object sender, DataReceivedEventArgs e)
438
+        {
439
+            LogHelper.WriteErrLog("【ScreenCapturerRecorder安装】(installScreenCapturerRecorder)安装失败:" + e.Data, null);
440
+            //MessageWindow.Show(e.Data);
441
+        }
442
+
443
+        #endregion
357 444
         #region 内存处理 -创建人:赵耀 -创建时间:2020年8月12日
358 445
 
359 446
         /// <summary>

+ 1
- 1
XHWK.WKTool/AppUpdateWin.xaml.cs Переглянути файл

@@ -108,7 +108,7 @@ namespace XHWK.WKTool
108 108
 
109 109
         public void downloadError(int position, string msg)
110 110
         {
111
-            MessageBox.Show(msg);
111
+            MessageWindow.Show(msg);
112 112
         }
113 113
     }
114 114
 }

+ 1
- 1
XHWK.WKTool/CountdownWindow.xaml Переглянути файл

@@ -21,7 +21,7 @@
21 21
         <Image x:Name="imgLoding"
22 22
                     Width="600"
23 23
                     Height="600"
24
-                    Source=".\Images\countdown_3.png" />
24
+                    Source=".\Images\countdown3_1.png" />
25 25
         <Label x:Name="lblShortcut" Content="开始/暂停:Ctrl+F5     停止:Ctrl+S" Height="77" Margin="0,750,0,0" Width="682" Foreground="#FF5B5151" FontSize="36" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/>
26 26
     </Grid>
27 27
 </Window>

+ 10
- 4
XHWK.WKTool/CreateAMicroLessonWindow.xaml.cs Переглянути файл

@@ -1,6 +1,7 @@
1 1
 using Common.system;
2 2
 
3 3
 using System;
4
+using System.Diagnostics;
4 5
 using System.Threading;
5 6
 using System.Windows;
6 7
 using System.Windows.Forms;
@@ -26,6 +27,11 @@ namespace XHWK.WKTool
26 27
         public CreateAMicroLessonWindow()
27 28
         {
28 29
             InitializeComponent();
30
+            if (!APP.CheckScreenCapturerRecorder())
31
+            {
32
+                MessageWindow.Show("首次运行需安装环境,请在确定后依次点击“OK-Next>-Next>Install”完成安装!");
33
+                APP.InstallScreenCapturerRecorder();
34
+            }
29 35
             txbStoragePath.Text = FileToolsCommon.GetConfigValue("VideoSavePath");
30 36
         }
31 37
 
@@ -37,7 +43,7 @@ namespace XHWK.WKTool
37 43
         /// <param name="e"></param>
38 44
         private void BtnDown_Click(object sender, RoutedEventArgs e)
39 45
         {
40
-            MessageBoxResult dr = System.Windows.MessageBox.Show("确定退出系统?", "提示", MessageBoxButton.OKCancel);
46
+            MessageBoxResult dr = MessageWindow.Show("确定退出系统?", "提示", MessageBoxButton.OKCancel);
41 47
             if (dr == MessageBoxResult.OK)
42 48
             {
43 49
                 System.Environment.Exit(0);
@@ -79,12 +85,12 @@ namespace XHWK.WKTool
79 85
             #region 合法性判断
80 86
             if (string.IsNullOrWhiteSpace(txbExplainName.Text.Trim()))
81 87
             {
82
-                System.Windows.MessageBox.Show("讲解名称不可为空!");
88
+                MessageWindow.Show("讲解名称不可为空!");
83 89
                 return;
84 90
             }
85 91
             if (string.IsNullOrWhiteSpace(txbStoragePath.Text.Trim()))
86 92
             {
87
-                System.Windows.MessageBox.Show("路径不可为空!");
93
+                MessageWindow.Show("路径不可为空!");
88 94
                 return;
89 95
             }
90 96
             #endregion
@@ -109,7 +115,7 @@ namespace XHWK.WKTool
109 115
             //{
110 116
             //    if (APP.WKDataList.Exists(x => x.WkName == APP.WKData.WkName))
111 117
             //    {
112
-            //        MessageBoxResult dr = System.Windows.MessageBox.Show("此微课已存在是否覆盖?", "提示", MessageBoxButton.OKCancel);
118
+            //        MessageBoxResult dr = MessageWindow.Show("此微课已存在是否覆盖?", "提示", MessageBoxButton.OKCancel);
113 119
             //        if (dr == MessageBoxResult.OK)
114 120
             //        {
115 121
             //            FileToolsCommon.DeleteDirectory(APP.WKData.WkPath);

+ 38
- 18
XHWK.WKTool/FileDirectoryWindow.xaml.cs Переглянути файл

@@ -6,6 +6,8 @@ using System;
6 6
 using System.Collections.Generic;
7 7
 using System.Collections.ObjectModel;
8 8
 using System.Diagnostics;
9
+using System.Security.AccessControl;
10
+using System.Text;
9 11
 using System.Windows;
10 12
 using System.Windows.Controls;
11 13
 using System.Windows.Input;
@@ -200,11 +202,11 @@ namespace XHWK.WKTool
200 202
 
201 203
                         DataContext = pageData;
202 204
 
203
-                        MessageBox.Show("视频上传成功!");
205
+                        MessageWindow.Show("视频上传成功!");
204 206
                     }
205 207
                     else
206 208
                     {
207
-                        MessageBox.Show(ErrMessage);
209
+                        MessageWindow.Show(ErrMessage);
208 210
                     }
209 211
 
210 212
 
@@ -250,7 +252,7 @@ namespace XHWK.WKTool
250 252
                             }
251 253
                             catch (Exception ex)
252 254
                             {
253
-                                MessageBox.Show("无法删除视频!" + ex.Message);
255
+                                MessageWindow.Show("无法删除视频!" + ex.Message);
254 256
                                 return;
255 257
                             }
256 258
                         }
@@ -283,7 +285,7 @@ namespace XHWK.WKTool
283 285
                     catch (Exception ex)
284 286
                     {
285 287
                         LogHelper.WriteErrLog("FileDirectoryWindow【BtnPlay_Click】" + ex.Message, ex);
286
-                        MessageBox.Show(ex.Message);
288
+                        MessageWindow.Show(ex.Message);
287 289
                         return;
288 290
                     }
289 291
                 }
@@ -379,7 +381,7 @@ namespace XHWK.WKTool
379 381
             //        }
380 382
             //        catch (Exception ex)
381 383
             //        {
382
-            //            MessageBox.Show("无法修改视频名称!" + ex.Message);
384
+            //            MessageWindow.Show("无法修改视频名称!" + ex.Message);
383 385
             //            return;
384 386
             //        }
385 387
             //    }
@@ -403,7 +405,7 @@ namespace XHWK.WKTool
403 405
             //                    string tempPath = pageData.menuList[Subscript].FilePath + pageData.menuList[Subscript].VideoName + "." + pageData.menuList[Subscript].VideoType;
404 406
             //                    if (FileToolsCommon.IsExistFile(tempPath))
405 407
             //                    {
406
-            //                        MessageBox.Show("文件名已存在!");
408
+            //                        MessageWindow.Show("文件名已存在!");
407 409
             //                        return;
408 410
             //                    }
409 411
             //                    foreach (Model_WKData wKData in APP.WKDataList)
@@ -422,7 +424,7 @@ namespace XHWK.WKTool
422 424
             //                            }
423 425
             //                            catch (Exception ex)
424 426
             //                            {
425
-            //                                MessageBox.Show("无法删除视频!" + ex.Message);
427
+            //                                MessageWindow.Show("无法删除视频!" + ex.Message);
426 428
             //                                return;
427 429
             //                            }
428 430
             //                        }
@@ -432,25 +434,43 @@ namespace XHWK.WKTool
432 434
             //            }
433 435
             //            catch (Exception ex)
434 436
             //            {
435
-            //                MessageBox.Show("无法修改视频名称!" + ex.Message);
437
+            //                MessageWindow.Show("无法修改视频名称!" + ex.Message);
436 438
             //                return;
437 439
             //            }
438 440
             //        }
439 441
             //        MouseNumber++;
440 442
             //    }
441 443
         }
442
-    }
444
+        /// <summary>
445
+        /// 修改文件名
446
+        /// </summary>
447
+        /// <param name="Guid">唯一编号</param>
448
+        /// <param name="NewName">新文件名带后缀 不带路径</param>
449
+        /// <param name="Errmessage">错误信息</param>
450
+        /// <returns></returns>
451
+        bool ModifyPathName(string FileGuid, string NewName, out string Errmessage)
452
+        {
453
+            Errmessage = "";
454
+            Model_Video model_Video = APP.VideoList.Find(x => x.FileGuid == FileGuid);
455
+            string filePathName = model_Video.VideoPath;
456
+            string filePath = FileToolsCommon.GetDirectoryName(filePathName);
457
+            string newFilePathName = filePath + NewName;
458
+            if (FileToolsCommon.IsExistFile(newFilePathName))
459
+            {
460
+                Errmessage = "文件已存在,请重新修改文件名!";
461
+                return false;
462
+            }
463
+            else
464
+            {
465
+                FileToolsCommon.Copy(filePathName, newFilePathName);
466
+                model_Video.VideoPath = newFilePathName;
467
+                APP.SaveWkData();
468
+                return true;
469
+            }
470
+        }
443 471
 
444
-    ///// <summary>
445
-    ///// 修改文件名
446
-    ///// </summary>
447
-    ///// <param name="Guid">唯一编号</param>
448
-    ///// <param name="NewName">文件名带后缀 不带路径</param>
449
-    ///// <returns></returns>
450
-    //bool ModifyPathName(string Guid,string NewName)
451
-    //{
472
+    }
452 473
 
453
-    //}
454 474
     public class FileDirectoryData : NotifyModel
455 475
     {
456 476
         public ObservableCollection<FileDirectoryModel> menuList { get; set; }

+ 1
- 1
XHWK.WKTool/JieTuWindow.xaml.cs Переглянути файл

@@ -427,7 +427,7 @@ namespace ComeCapture
427 427
             }
428 428
             catch (Exception ex)
429 429
             {
430
-                MessageBox.Show(ex.Message);
430
+                MessageWindow.Show(ex.Message);
431 431
             }
432 432
             if (_IsCapture)
433 433
             {

+ 4
- 4
XHWK.WKTool/LoginWindow.xaml.cs Переглянути файл

@@ -60,12 +60,12 @@ namespace XHWK.WKTool
60 60
         {
61 61
             if (string.IsNullOrEmpty(txbAccountNumber.Text))
62 62
             {
63
-                MessageBox.Show("账号未输入");
63
+                MessageWindow.Show("账号未输入");
64 64
                 return;
65 65
             }
66 66
             if (string.IsNullOrEmpty(pobPassword.Password))
67 67
             {
68
-                MessageBox.Show("密码未输入");
68
+                MessageWindow.Show("密码未输入");
69 69
                 return;
70 70
             }
71 71
             APP.myloading.Show();
@@ -112,7 +112,7 @@ namespace XHWK.WKTool
112 112
                 //{
113 113
                 //    if(APP.WKDataList.Exists(x => x.WkName == APP.WKData.WkName))
114 114
                 //    {
115
-                //        MessageBoxResult dr = System.Windows.MessageBox.Show("此微课已存在是否覆盖?", "提示", MessageBoxButton.OKCancel);
115
+                //        MessageBoxResult dr = MessageWindow.Show("此微课已存在是否覆盖?", "提示", MessageBoxButton.OKCancel);
116 116
                 //        if (dr == MessageBoxResult.OK)
117 117
                 //        {
118 118
                 //            FileToolsCommon.DeleteDirectory(APP.WKData.WkPath);
@@ -133,7 +133,7 @@ namespace XHWK.WKTool
133 133
             else
134 134
             {
135 135
                 APP.myloading.Hide();
136
-                MessageBox.Show(APP.ServerMsg);
136
+                MessageWindow.Show(APP.ServerMsg);
137 137
             }
138 138
         }
139 139
         /// <summary>

+ 36
- 0
XHWK.WKTool/MessageWindow.xaml Переглянути файл

@@ -0,0 +1,36 @@
1
+<Window x:Class="XHWK.WKTool.MessageWindow"
2
+        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3
+        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4
+        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5
+        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6
+        xmlns:local="clr-namespace:XHWK.WKTool"
7
+        mc:Ignorable="d" 
8
+        Title="星火微课" WindowStartupLocation="CenterScreen"
9
+    WindowStyle="None" AllowsTransparency="True"    WindowState="Normal"
10
+    ShowInTaskbar="False" Topmost="True" ResizeMode="NoResize" d:DesignHeight="250" Width="600" Height="220" BorderThickness="5,5,5,5" MouseMove="Window_MouseMove">
11
+    <Window.Effect>
12
+        <DropShadowEffect BlurRadius="8" Color="#FF060606" Direction="80" ShadowDepth="0"/>
13
+    </Window.Effect>
14
+    <Grid>
15
+        <Grid.RowDefinitions>
16
+            <RowDefinition Height="50"/>
17
+            <RowDefinition Height="100*"/>
18
+            <RowDefinition Height="70"/>
19
+        </Grid.RowDefinitions>
20
+        <Grid Grid.Row="0">
21
+            <Label x:Name="lblTitle" Content="提示" HorizontalAlignment="Left" Margin="14,20,0,0" VerticalAlignment="Top" Foreground="#FF333333" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" FontSize="17" FontWeight="Bold"/>
22
+        </Grid>
23
+        <Grid Grid.Row="1">
24
+            <TextBlock x:Name="tbkContent" Margin="20,5,20,0" TextWrapping="Wrap" VerticalAlignment="Center" FontSize="15" Foreground="#FF919191" Grid.Row="1" HorizontalAlignment="Center" Text=""/>
25
+        </Grid>
26
+        <Grid Grid.Row="2" Margin="0,0,0,0">
27
+            <Border x:Name="borOk" Background="#EE3A52" CornerRadius="6" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,30,20">
28
+                <Button x:Name="BtnOK" Width="104" Height="42" Content="确定" FontSize="18"  Background="#00000000"  BorderBrush="{x:Null}" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Foreground="White"  Cursor="Hand" Click="BtnOK_Click"/>
29
+            </Border>
30
+            <Border x:Name="borCancel" Background="#E5E5E5" CornerRadius="6"  HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,150,20">
31
+                <Button x:Name="BtnCancel" Width="104" Height="42" Content="取消" FontSize="18" Background="#00000000" BorderBrush="{x:Null}"  Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}"  Cursor="Hand" Click="BtnCancel_Click"/>
32
+            </Border>
33
+        </Grid>
34
+
35
+    </Grid>
36
+</Window>

+ 158
- 0
XHWK.WKTool/MessageWindow.xaml.cs Переглянути файл

@@ -0,0 +1,158 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+using System.Windows;
7
+using System.Windows.Controls;
8
+using System.Windows.Data;
9
+using System.Windows.Documents;
10
+using System.Windows.Input;
11
+using System.Windows.Media;
12
+using System.Windows.Media.Imaging;
13
+using System.Windows.Shapes;
14
+
15
+namespace XHWK.WKTool
16
+{
17
+    /// <summary>
18
+    /// MessageWindow.xaml 的交互逻辑
19
+    /// </summary>
20
+    public partial class MessageWindow : Window
21
+    {
22
+        /// <summary>
23
+        /// 提示框
24
+        /// </summary>
25
+        /// <param name="MessageType">取消按钮  1不显示2显示</param>
26
+        /// <param name="Title">标题</param>
27
+        /// <param name="content">消息内容</param>
28
+        public MessageWindow(int MessageType,string Title,string Content)
29
+        {
30
+            InitializeComponent();
31
+            switch (MessageType)
32
+            {
33
+                case 1:
34
+                    borCancel.Visibility = Visibility.Hidden;
35
+                    break;
36
+                case 2:
37
+                    borCancel.Visibility = Visibility.Visible;
38
+                    break;
39
+                default:
40
+                    break;
41
+            }
42
+            lblTitle.Content = Title;
43
+            if (string.IsNullOrWhiteSpace(Content))
44
+            {
45
+                if(Content.Length>143)
46
+                {
47
+                    Content = Content.Substring(0, 140) + "...";
48
+                }
49
+                tbkContent.Text = Content;
50
+            }
51
+            else
52
+            {
53
+                tbkContent.Text = "错误!";
54
+            }
55
+        }
56
+        /// <summary>
57
+        /// 取消
58
+        /// </summary>
59
+        /// <param name="sender"></param>
60
+        /// <param name="e"></param>
61
+        private void BtnCancel_Click(object sender, RoutedEventArgs e)
62
+        {
63
+            DialogResult = false;
64
+        }
65
+        /// <summary>
66
+        /// 确定
67
+        /// </summary>
68
+        /// <param name="sender"></param>
69
+        /// <param name="e"></param>
70
+        private void BtnOK_Click(object sender, RoutedEventArgs e)
71
+        {
72
+            DialogResult = true;
73
+        }
74
+        /// <summary>
75
+        /// 消息提示框
76
+        /// </summary>
77
+        /// <param name="Message">消息</param>
78
+        /// <returns></returns>
79
+        public static MessageBoxResult Show(string Message)
80
+        {
81
+            string Title = "消息提示";
82
+            return Show(Message, Title);
83
+        }
84
+        /// <summary>
85
+        /// 消息提示框
86
+        /// </summary>
87
+        /// <param name="Message">消息</param>
88
+        /// <returns></returns>
89
+        public static MessageBoxResult Show(string Message,string Title)
90
+        {
91
+            MessageWindow message = new MessageWindow(1, Title, Message);
92
+            message.ShowDialog();
93
+            return MessageBoxResult.Cancel;
94
+        }
95
+        /// <summary>
96
+        /// 消息提示框
97
+        /// </summary>
98
+        /// <param name="Title">标题</param>
99
+        /// <param name="Message">消息</param>
100
+        /// <returns></returns>
101
+        public static MessageBoxResult Show(string Message,string Title, MessageBoxButton messageBox)
102
+        {
103
+            if (string.IsNullOrWhiteSpace(Title))
104
+            {
105
+                Title = "消息提示";
106
+            }
107
+            MessageWindow message = new MessageWindow(2,Title,Message);
108
+            bool? res= message.ShowDialog();
109
+            if ((bool)res)
110
+            {
111
+                if (messageBox == MessageBoxButton.OKCancel)
112
+                {
113
+                    return MessageBoxResult.OK;
114
+                }
115
+                else
116
+                {
117
+                    return MessageBoxResult.Yes;
118
+                }
119
+            }
120
+            else
121
+            {
122
+                if (messageBox == MessageBoxButton.OKCancel)
123
+                {
124
+                    return MessageBoxResult.Cancel;
125
+                }
126
+                else
127
+                {
128
+                    return MessageBoxResult.No;
129
+                }
130
+            }
131
+        }
132
+        private static MessageBoxResult Win32ToMessageBoxResult(int value)
133
+        {
134
+            switch (value)
135
+            {
136
+                case 1:
137
+                    return MessageBoxResult.OK;
138
+                case 2:
139
+                    return MessageBoxResult.Cancel;
140
+                case 6:
141
+                    return MessageBoxResult.Yes;
142
+                case 7:
143
+                    return MessageBoxResult.No;
144
+                default:
145
+                    return MessageBoxResult.No;
146
+            }
147
+        }
148
+
149
+        private void Window_MouseMove(object sender, MouseEventArgs e)
150
+        {
151
+            if (e.LeftButton == MouseButtonState.Pressed)
152
+            {
153
+                //this.DragMove();              
154
+                this.DragMove();
155
+            }
156
+        }
157
+    }
158
+}

+ 5
- 7
XHWK.WKTool/PrintWindow.xaml.cs Переглянути файл

@@ -66,8 +66,8 @@ namespace XHWK.WKTool
66 66
         {
67 67
             if(string.IsNullOrWhiteSpace(cmbClass.Text))
68 68
             {
69
-                //MessageBox.Show("打印机不能为空!");
70
-                System.Windows.Forms.MessageBox.Show("打印机不能为空!", "", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly);
69
+                //MessageWindow.Show("打印机不能为空!");
70
+                MessageWindow.Show("打印机不能为空!", "", MessageBoxButton.OKCancel);
71 71
                 return;
72 72
             }
73 73
             string imgPath = FileToolsCommon.GetFileAbsolutePath("temp");
@@ -106,18 +106,16 @@ namespace XHWK.WKTool
106 106
                 }
107 107
                 if(printResult==0)// 0为成功
108 108
                 {
109
-                    //MessageBox.Show("打印成功!");
110
-                    System.Windows.Forms.MessageBox.Show("打印成功", "", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly);
109
+                    MessageWindow.Show("打印成功", "", MessageBoxButton.OKCancel);
111 110
                 }
112 111
                 else
113 112
                 {
114
-                    System.Windows.Forms.MessageBox.Show(standardError, "", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly);
115
-                    //MessageBox.Show(standardError);
113
+                    MessageWindow.Show(standardError, "", MessageBoxButton.OKCancel);
116 114
                 }
117 115
             }
118 116
             else
119 117
             {
120
-                System.Windows.Forms.MessageBox.Show(msg, "", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly);
118
+                MessageWindow.Show(msg, "", MessageBoxButton.OKCancel);
121 119
             }
122 120
         }
123 121
         /// <summary>

+ 2
- 2
XHWK.WKTool/ScreenRecordingToolbarWindow.xaml.cs Переглянути файл

@@ -256,7 +256,7 @@ namespace XHWK.WKTool
256 256
                 }
257 257
                 catch (Exception ex)
258 258
                 {
259
-                    System.Windows.MessageBox.Show(ex.Message);
259
+                    MessageWindow.Show(ex.Message);
260 260
                 }
261 261
             }
262 262
             else
@@ -286,7 +286,7 @@ namespace XHWK.WKTool
286 286
                 }
287 287
                 catch (Exception ex)
288 288
                 {
289
-                    System.Windows.MessageBox.Show(ex.Message);
289
+                    MessageWindow.Show(ex.Message);
290 290
                 }
291 291
             }
292 292
         }

+ 26
- 14
XHWK.WKTool/XHMicroLessonSystemWindow.xaml.cs Переглянути файл

@@ -361,11 +361,17 @@ namespace XHWK.WKTool
361 361
         /// <param name="e"></param>
362 362
         private void BtnScreenRecording_Click(object sender, RoutedEventArgs e)
363 363
         {
364
+            if (!APP.CheckScreenCapturerRecorder())
365
+            {
366
+                MessageWindow.Show("使用此功能需安装环境,请在确定后依次点击“OK-Next>-Next>Install”完成安装!");
367
+                APP.InstallScreenCapturerRecorder();
368
+                return;
369
+            }
364 370
             #region 限制只允许录制一个录屏  废弃
365 371
             //string RecordScreenPathName = APP.WKData.WkPath + APP.WKData.WkName + "_录屏." + ((Enum_VideoType)int.Parse(FileToolsCommon.GetConfigValue("VideoType"))).ToString();
366 372
             //if (FileToolsCommon.IsExistFile(RecordScreenPathName))
367 373
             //{
368
-            //    MessageBoxResult dr = System.Windows.MessageBox.Show("已存在录屏,是否覆盖?", "提示", MessageBoxButton.OKCancel);
374
+            //    MessageBoxResult dr = MessageWindow.Show("已存在录屏,是否覆盖?", "提示", MessageBoxButton.OKCancel);
369 375
             //    if (dr == MessageBoxResult.OK)
370 376
             //    {
371 377
             //        try
@@ -469,9 +475,9 @@ namespace XHWK.WKTool
469 475
             }
470 476
             else
471 477
             {
472
-                System.Windows.MessageBox.Show("当前正在录制,请先停止录制。");
478
+                MessageWindow.Show("当前正在录制,请先停止录制。");
473 479
                 return;
474
-                //MessageBoxResult dr = System.Windows.MessageBox.Show("当前正在录制,是否停止录制?", "提示", MessageBoxButton.OKCancel);
480
+                //MessageBoxResult dr = MessageWindow.Show("当前正在录制,是否停止录制?", "提示", MessageBoxButton.OKCancel);
475 481
                 //if (dr == MessageBoxResult.OK)
476 482
                 //{
477 483
                 //    APP.SaveWkData();
@@ -499,7 +505,7 @@ namespace XHWK.WKTool
499 505
             #region 合法性判断
500 506
             //if (string.IsNullOrWhiteSpace(txbStoragePath.Text.Trim()))
501 507
             //{
502
-            //    System.Windows.MessageBox.Show("路径不可为空!");
508
+            //    MessageWindow.Show("路径不可为空!");
503 509
             //    return;
504 510
             //}
505 511
             //string temp = FileToolsCommon.GetLegalPath(txbStoragePath.Text) + APP.WKData.WkName.Trim() + "/";
@@ -509,7 +515,7 @@ namespace XHWK.WKTool
509 515
             //    if (FileToolsCommon.IsExistDirectory(APP.WKData.WkPath))
510 516
             //    {
511 517
             //        //微课已存在
512
-            //        MessageBoxResult dr = System.Windows.MessageBox.Show("讲解已存在是否覆盖?", "提示", MessageBoxButton.OKCancel);
518
+            //        MessageBoxResult dr = MessageWindow.Show("讲解已存在是否覆盖?", "提示", MessageBoxButton.OKCancel);
513 519
             //        if (dr == MessageBoxResult.OK)
514 520
             //        {
515 521
             //            FileToolsCommon.DeleteDirectory(APP.WKData.WkPath);
@@ -1175,13 +1181,19 @@ namespace XHWK.WKTool
1175 1181
         /// <param name="e"></param>
1176 1182
         private void BtnRecord_Click(object sender, RoutedEventArgs e)
1177 1183
         {
1184
+            if (!APP.CheckScreenCapturerRecorder())
1185
+            {
1186
+                MessageWindow.Show("使用此功能需安装环境,请在确定后依次点击“OK-Next>-Next>Install”完成安装!");
1187
+                APP.InstallScreenCapturerRecorder();
1188
+                return;
1189
+            }
1178 1190
             if (APP.pageData.currpage > 0)
1179 1191
             {
1180 1192
                 blackboard_canvas.Visibility = Visibility.Visible;
1181 1193
             }
1182 1194
             else
1183 1195
             {
1184
-                System.Windows.MessageBox.Show("请先导入文档或截图!");
1196
+                MessageWindow.Show("请先导入文档或截图!");
1185 1197
                 return;
1186 1198
             }
1187 1199
 
@@ -1250,7 +1262,7 @@ namespace XHWK.WKTool
1250 1262
                     #region 设置录屏唯一  废弃
1251 1263
                     //if (FileToolsCommon.IsExistFile(VideoSavePathName))
1252 1264
                     //{
1253
-                    //    MessageBoxResult dr = System.Windows.MessageBox.Show("课程已录制,是否覆盖?", "提示", MessageBoxButton.OKCancel);
1265
+                    //    MessageBoxResult dr = MessageWindow.Show("课程已录制,是否覆盖?", "提示", MessageBoxButton.OKCancel);
1254 1266
                     //    if (dr == MessageBoxResult.OK)
1255 1267
                     //    {
1256 1268
                     //        try
@@ -1360,7 +1372,7 @@ namespace XHWK.WKTool
1360 1372
                 }
1361 1373
                 catch (Exception ex)
1362 1374
                 {
1363
-                    System.Windows.MessageBox.Show(ex.Message);
1375
+                    MessageWindow.Show(ex.Message);
1364 1376
                 }
1365 1377
             }
1366 1378
             else
@@ -1402,7 +1414,7 @@ namespace XHWK.WKTool
1402 1414
                 }
1403 1415
                 catch (Exception ex)
1404 1416
                 {
1405
-                    System.Windows.MessageBox.Show(ex.Message);
1417
+                    MessageWindow.Show(ex.Message);
1406 1418
                 }
1407 1419
             }
1408 1420
         }
@@ -1570,7 +1582,7 @@ namespace XHWK.WKTool
1570 1582
                 }
1571 1583
                 catch (Exception ex)
1572 1584
                 {
1573
-                    System.Windows.MessageBox.Show(ex.Message);
1585
+                    MessageWindow.Show(ex.Message);
1574 1586
                 }
1575 1587
             }
1576 1588
         }
@@ -1986,7 +1998,7 @@ namespace XHWK.WKTool
1986 1998
             }
1987 1999
             catch (Exception ex)
1988 2000
             {
1989
-                System.Windows.MessageBox.Show("文档已打开,请关闭后重试!");
2001
+                MessageWindow.Show("文档已打开,请关闭后重试!");
1990 2002
                 LogHelper.WriteErrLog("【课堂考试(ExamWindow)】错误日志:" + ex.Message, ex);
1991 2003
             }
1992 2004
             return images;
@@ -2209,7 +2221,7 @@ namespace XHWK.WKTool
2209 2221
             //判断是否成功
2210 2222
             if (ER != ERROR_CODE.ERROR_OK)
2211 2223
             {
2212
-                System.Windows.MessageBox.Show("初始化失败,授权过期,返回值:" + ER.ToString());
2224
+                MessageWindow.Show("初始化失败,授权过期,返回值:" + ER.ToString());
2213 2225
             }
2214 2226
         }
2215 2227
 
@@ -2402,7 +2414,7 @@ namespace XHWK.WKTool
2402 2414
             }
2403 2415
             else
2404 2416
             {
2405
-                //System.Windows.MessageBox.Show("电池电量:" + capacity.ToString());
2417
+                //System.Windows.MessageWindow.Show("电池电量:" + capacity.ToString());
2406 2418
             }
2407 2419
         }
2408 2420
 
@@ -2422,7 +2434,7 @@ namespace XHWK.WKTool
2422 2434
             }
2423 2435
             else
2424 2436
             {
2425
-                //System.Windows.MessageBox.Show("存储:" + fillLevel.ToString());
2437
+                //System.Windows.MessageWindow.Show("存储:" + fillLevel.ToString());
2426 2438
             }
2427 2439
         }
2428 2440
 

+ 7
- 0
XHWK.WKTool/XHWK.WKTool.csproj Переглянути файл

@@ -141,6 +141,9 @@
141 141
     <Compile Include="LoginWindow.xaml.cs">
142 142
       <DependentUpon>LoginWindow.xaml</DependentUpon>
143 143
     </Compile>
144
+    <Compile Include="MessageWindow.xaml.cs">
145
+      <DependentUpon>MessageWindow.xaml</DependentUpon>
146
+    </Compile>
144 147
     <Compile Include="Models\AppModel.cs" />
145 148
     <Compile Include="Models\Direction.cs" />
146 149
     <Compile Include="Models\EntityBase.cs" />
@@ -188,6 +191,10 @@
188 191
       <SubType>Designer</SubType>
189 192
       <Generator>MSBuild:Compile</Generator>
190 193
     </Page>
194
+    <Page Include="MessageWindow.xaml">
195
+      <SubType>Designer</SubType>
196
+      <Generator>MSBuild:Compile</Generator>
197
+    </Page>
191 198
     <Page Include="PracticeWindow.xaml">
192 199
       <SubType>Designer</SubType>
193 200
       <Generator>MSBuild:Compile</Generator>

Завантаження…
Відмінити
Зберегти