Browse Source

zhao:修改微课路径位置,增加画板模型及数据存储和读取

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

+ 56
- 0
XHWK.Model/Model_DrawData.cs View File

@@ -0,0 +1,56 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Drawing;
4
+using System.Linq;
5
+using System.Text;
6
+using System.Threading.Tasks;
7
+
8
+namespace XHWK.Model
9
+{
10
+    /// <summary>
11
+    /// 画板模型
12
+    /// </summary>
13
+    public class Model_DrawData
14
+    {
15
+        private int _PageNum;
16
+        private string _pageCode;
17
+        private string _pageImagePath;
18
+        private PointF _ImageLocation;
19
+        private SizeF _ImageSize;
20
+        private string _PenColor;
21
+        private int _PenWigth;
22
+        //private List<PointF> _Handwriting;
23
+        /// <summary>
24
+        /// 页码
25
+        /// </summary>
26
+        public int PageNum { get => _PageNum; set => _PageNum = value; }
27
+        /// <summary>
28
+        /// 页编号
29
+        /// </summary>
30
+        public string PageCode { get => _pageCode; set => _pageCode = value; }
31
+        /// <summary>
32
+        /// 页面图片路径
33
+        /// </summary>
34
+        public string PageImagePath { get => _pageImagePath; set => _pageImagePath = value; }
35
+        /// <summary>
36
+        /// 图片坐标
37
+        /// </summary>
38
+        public PointF ImageLocation { get => _ImageLocation; set => _ImageLocation = value; }
39
+        /// <summary>
40
+        /// 图片大小
41
+        /// </summary>
42
+        public SizeF ImageSize { get => _ImageSize; set => _ImageSize = value; }
43
+        /// <summary>
44
+        /// 笔颜色 十六进制
45
+        /// </summary>
46
+        public string PenColor { get => _PenColor; set => _PenColor = value; }
47
+        /// <summary>
48
+        /// 线宽
49
+        /// </summary>
50
+        public int PenWigth { get => _PenWigth; set => _PenWigth = value; }
51
+        ///// <summary>
52
+        ///// 笔迹 暂无
53
+        ///// </summary>
54
+        //public List<PointF> Handwriting { get => _Handwriting; set => _Handwriting = value; }
55
+    }
56
+}

+ 2
- 0
XHWK.Model/XHWK.Model.csproj View File

@@ -40,6 +40,7 @@
40 40
     <Reference Include="PresentationCore" />
41 41
     <Reference Include="System" />
42 42
     <Reference Include="System.Core" />
43
+    <Reference Include="System.Drawing" />
43 44
     <Reference Include="System.Web" />
44 45
     <Reference Include="System.Xml.Linq" />
45 46
     <Reference Include="System.Data.DataSetExtensions" />
@@ -50,6 +51,7 @@
50 51
   </ItemGroup>
51 52
   <ItemGroup>
52 53
     <Compile Include="Model_Canvas.cs" />
54
+    <Compile Include="Model_DrawData.cs" />
53 55
     <Compile Include="Model_Page.cs" />
54 56
     <Compile Include="Model_Screenshot.cs" />
55 57
     <Compile Include="Model_UserInfo.cs" />

+ 139
- 61
XHWK.WKTool/App.cs View File

@@ -38,35 +38,12 @@ namespace XHWK.WKTool
38 38
         /// 微课视频列表
39 39
         /// </summary>
40 40
         public static List<Model_Video> VideoList = null;
41
-        /// <summary>
42
-        /// 主页面
43
-        /// </summary>
44
-        public static XHMicroLessonSystemWindow W_XHMicroLessonSystemWindow = null;
41
+        public static List<Model_DrawData> PageDrawList = null;
45 42
         /// <summary>
46 43
         /// 录屏工具
47 44
         /// </summary>
48 45
         public static FFMpeg FFmpeg = new FFMpeg();
49 46
         /// <summary>
50
-        /// 开始录像
51
-        /// </summary>
52
-        public static CountdownWindow W_CountdownWindow = null;
53
-        /// <summary>
54
-        /// 录像工具栏
55
-        /// </summary>
56
-        public static ScreenRecordingToolbarWindow W_ScreenRecordingToolbarWindow = null;
57
-        /// <summary>
58
-        /// 登陆
59
-        /// </summary>
60
-        public static LoginWindow W_LoginWindow = null;
61
-        /// <summary>
62
-        /// 截图
63
-        /// </summary>
64
-        public static JieTuWindow W_JieTuWindow = null;
65
-        /// <summary>
66
-        /// 批注
67
-        /// </summary>
68
-        public static PracticeWindow W_PracticeWindow = null;
69
-        /// <summary>
70 47
         /// 登陆状态 false 未登录 true已登陆
71 48
         /// </summary>
72 49
         public static bool IsLoginType = false;
@@ -87,8 +64,8 @@ namespace XHWK.WKTool
87 64
         /// <summary>
88 65
         /// 页码IP
89 66
         /// </summary>
90
-        public static string[] OutPut = new string[] { }; 
91
-
67
+        public static string[] OutPut = new string[] { };
68
+        #region 点阵笔
92 69
         /// <summary>
93 70
         /// 点阵笔
94 71
         /// </summary>
@@ -102,6 +79,37 @@ namespace XHWK.WKTool
102 79
         /// </summary>
103 80
         public static bool PenStatus;
104 81
         #endregion
82
+        #region 页面
83
+        /// <summary>
84
+        /// 主页面
85
+        /// </summary>
86
+        public static XHMicroLessonSystemWindow W_XHMicroLessonSystemWindow = null;
87
+        /// <summary>
88
+        /// 创建微课页面
89
+        /// </summary>
90
+        public static CreateAMicroLessonWindow W_CreateAMicroLessonWindow = null;
91
+        /// <summary>
92
+        /// 开始录像
93
+        /// </summary>
94
+        public static CountdownWindow W_CountdownWindow = null;
95
+        /// <summary>
96
+        /// 录像工具栏
97
+        /// </summary>
98
+        public static ScreenRecordingToolbarWindow W_ScreenRecordingToolbarWindow = null;
99
+        /// <summary>
100
+        /// 登陆
101
+        /// </summary>
102
+        public static LoginWindow W_LoginWindow = null;
103
+        /// <summary>
104
+        /// 截图
105
+        /// </summary>
106
+        public static JieTuWindow W_JieTuWindow = null;
107
+        /// <summary>
108
+        /// 批注
109
+        /// </summary>
110
+        public static PracticeWindow W_PracticeWindow = null;
111
+        #endregion
112
+        #endregion
105 113
 
106 114
         [STAThread]
107 115
         private static void Main()
@@ -113,10 +121,11 @@ namespace XHWK.WKTool
113 121
             WKData = new Model_WKData();
114 122
             VideoList = new List<Model_Video>();
115 123
             //app.DispatcherUnhandledException += MyApp_DispatcherUnhandledException;
116
-            CreateAMicroLessonWindow win = new CreateAMicroLessonWindow();
117
-            app.Run(win);
124
+            W_CreateAMicroLessonWindow = new CreateAMicroLessonWindow();
125
+            app.Run(W_CreateAMicroLessonWindow);
118 126
             //LogHelper.WriteInfoLog("启动项目");
119 127
             StopSameProcess();
128
+            Killffmpeg();
120 129
             LatticeFileHelper.RunPrintConfig();
121 130
         }
122 131
         /// <summary>
@@ -156,63 +165,132 @@ namespace XHWK.WKTool
156 165
             e.Handled = true;
157 166
         }
158 167
 
168
+        #region 数据保存和读取
159 169
         /// <summary>
160 170
         /// 保存微课信息
161 171
         /// </summary>
162 172
         public static void SaveWkData()
163 173
         {
164
-            if(UserInfo == null)
174
+            try
165 175
             {
166
-                return;
176
+                if (UserInfo == null)
177
+                {
178
+                    return;
179
+                }
180
+                if (!string.IsNullOrWhiteSpace(APP.UserInfo.Username))
181
+                {
182
+                    WKData.VideoList = VideoList;
183
+                    if (WKDataList != null)
184
+                    {
185
+                        WKDataList.RemoveAll(x => x.WkName == WKData.WkName);
186
+                    }
187
+                    else
188
+                    {
189
+                        WKDataList = new List<Model_WKData>();
190
+                    }
191
+                    WKDataList.Add(WKData);
192
+                    //string WkDateXmlStr = XmlUtilHelper.Serializer(typeof(Model_WKData), WKData);
193
+                    string WkDateXmlStr = XmlUtilHelper.XmlSerialize(WKDataList);
194
+                    string SavePath = FileToolsCommon.GetFileAbsolutePath("/Data/" + APP.UserInfo.Username + "/");
195
+                    FileToolsCommon.CreateDirectory(SavePath);
196
+                    string SaveName = SavePath + "UserWkDate.d";
197
+                    FileToolsCommon.DeleteFile(SaveName);
198
+                    FileToolsCommon.WriteText(SaveName, WkDateXmlStr);
199
+                }
167 200
             }
168
-            if (!string.IsNullOrWhiteSpace(APP.UserInfo.Username))
201
+            catch (Exception ex)
169 202
             {
170
-                WKData.VideoList = VideoList;
171
-                if (WKDataList != null)
203
+                LogHelper.WriteErrLog("【微课数据保存】(SaveWkData)保存失败:" + ex.Message, ex);
204
+            }
205
+        }
206
+        /// <summary>
207
+        /// 读取微课信息 
208
+        /// </summary>
209
+        public static void ReadWkData()
210
+        {
211
+            try
212
+            {
213
+                if (UserInfo == null)
172 214
                 {
173
-                    WKDataList.RemoveAll(x => x.WkName == WKData.WkName);
215
+                    return;
174 216
                 }
175
-                else
217
+                if (!string.IsNullOrWhiteSpace(APP.UserInfo.Username))
176 218
                 {
177
-                    WKDataList = new List<Model_WKData>();
219
+                    string SavePath = FileToolsCommon.GetFileAbsolutePath("/Data/" + APP.UserInfo.Username + "/");
220
+                    FileToolsCommon.CreateDirectory(SavePath);
221
+                    string SaveName = SavePath + "UserWkDate.d";
222
+                    //文件若存在则读取
223
+                    if (FileToolsCommon.IsExistFile(SaveName))
224
+                    {
225
+                        string WkDateXmlStr = FileToolsCommon.FileToString(SaveName);
226
+                        WKDataList = XmlUtilHelper.DESerializer<List<Model_WKData>>(WkDateXmlStr);
227
+                    }
178 228
                 }
179
-                WKDataList.Add(WKData);
180
-                //string WkDateXmlStr = XmlUtilHelper.Serializer(typeof(Model_WKData), WKData);
181
-                string WkDateXmlStr = XmlUtilHelper.XmlSerialize(WKDataList);
182
-                string SavePath = FileToolsCommon.GetFileAbsolutePath("/Data/" + APP.UserInfo.Username + "/");
183
-                FileToolsCommon.CreateDirectory(SavePath);
184
-                string SaveName = SavePath + "UserWkDate.d";
185
-                FileToolsCommon.DeleteFile(SaveName);
186
-                FileToolsCommon.WriteText(SaveName, WkDateXmlStr);
229
+            }
230
+            catch (Exception ex)
231
+            {
232
+                LogHelper.WriteErrLog("【微课数据读取】(ReadWkData)读取失败:" + ex.Message, ex);
187 233
             }
188 234
         }
189
-
190 235
         /// <summary>
191
-        /// 读取微课信息
236
+        /// 保存画板数据
192 237
         /// </summary>
193
-        public static void ReadWkData()
238
+        public static void SaveDraw()
194 239
         {
195
-            if (UserInfo == null)
240
+            try
196 241
             {
197
-                return;
242
+                if (PageDrawList == null)
243
+                {
244
+                    return;
245
+                }
246
+                if (PageDrawList.Count < 1)
247
+                {
248
+                    return;
249
+                }
250
+                FileToolsCommon.CreateDirectory(WKData.WkPath);
251
+                string SavePath = WKData.WkPath + "PageData.d";
252
+                FileToolsCommon.DeleteFile(SavePath);
253
+                string PageDataXmlStr = XmlUtilHelper.XmlSerialize(PageDrawList);
254
+                FileToolsCommon.WriteText(SavePath, PageDataXmlStr);
198 255
             }
199
-            if (!string.IsNullOrWhiteSpace(APP.UserInfo.Username))
256
+            catch (Exception ex)
200 257
             {
201
-                string SavePath = FileToolsCommon.GetFileAbsolutePath("/Data/" + APP.UserInfo.Username + "/");
202
-                FileToolsCommon.CreateDirectory(SavePath);
203
-                string SaveName = SavePath + "UserWkDate.d";
204
-                if (FileToolsCommon.IsExistFile(SaveName))
258
+                LogHelper.WriteErrLog("【画板数据保存】(SaveDraw)保存失败:" + ex.Message, ex);
259
+            }
260
+        }
261
+        /// <summary>
262
+        /// 读取文件
263
+        /// </summary>
264
+        public static void ReadDrawData()
265
+        {
266
+            try
267
+            {
268
+                PageDrawList = new List<Model_DrawData>();
269
+                FileToolsCommon.CreateDirectory(WKData.WkPath);
270
+                string SavePath = WKData.WkPath + "PageData.d";
271
+                if (FileToolsCommon.IsExistFile(SavePath))
205 272
                 {
206
-                    string WkDateXmlStr=FileToolsCommon.FileToString(SaveName);
207
-                    WKDataList = XmlUtilHelper.DESerializer<List<Model_WKData>>(WkDateXmlStr);
208
-                    if (WKDataList != null)
209
-                    {
210
-                        WKDataList.RemoveAll(x => x.WkName == WKData.WkName);
211
-                    }
273
+                    string PageDataXmlStr = FileToolsCommon.FileToString(SavePath);
274
+                    PageDrawList = XmlUtilHelper.DESerializer<List<Model_DrawData>>(PageDataXmlStr);
212 275
                 }
213 276
             }
277
+            catch (Exception ex)
278
+            {
279
+                LogHelper.WriteErrLog("【画板数据读取】(ReadDraw)读取失败:" + ex.Message, ex);
280
+            }
281
+        }
282
+        #endregion
283
+        /// <summary>
284
+        /// 杀死正在运行的ffmpeg
285
+        /// </summary>
286
+        public static void Killffmpeg()
287
+        {
288
+            Process[] KillProcessArray = Process.GetProcessesByName("ffmpeg");
289
+            foreach (var KillProcess in KillProcessArray)
290
+            {
291
+                KillProcess.Kill();
292
+            }
214 293
         }
215
-
216 294
         #region 内存处理 -创建人:赵耀 -创建时间:2020年8月12日
217 295
 
218 296
         /// <summary>

+ 27
- 15
XHWK.WKTool/CreateAMicroLessonWindow.xaml.cs View File

@@ -34,7 +34,15 @@ namespace XHWK.WKTool
34 34
         /// <param name="e"></param>
35 35
         private void BtnDown_Click(object sender, RoutedEventArgs e)
36 36
         {
37
-            System.Environment.Exit(0);
37
+            MessageBoxResult dr = System.Windows.MessageBox.Show("确定退出系统?", "提示", MessageBoxButton.OKCancel);
38
+            if (dr == MessageBoxResult.OK)
39
+            {
40
+                System.Environment.Exit(0);
41
+            }
42
+            else
43
+            {
44
+                return;
45
+            }
38 46
         }
39 47
         /// <summary>
40 48
         /// 浏览
@@ -76,23 +84,27 @@ namespace XHWK.WKTool
76 84
                 System.Windows.MessageBox.Show("路径不可为空!");
77 85
                 return;
78 86
             }
79
-            //if (!FileToolsCommon.IsLegalPath(txbStoragePath.Text.Trim(), out string ErrMessage))
80
-            //{
81
-            //    System.Windows.MessageBox.Show(ErrMessage);
82
-            //    return;
83
-            //}
84 87
             APP.WKData.WkPath = FileToolsCommon.GetLegalPath(txbStoragePath.Text) + txbExplainName.Text.Trim() + "/";
85
-            if (FileToolsCommon.IsExistDirectory(APP.WKData.WkPath))
88
+            if (APP.UserInfo != null)
86 89
             {
87
-                //微课已存在
88
-                MessageBoxResult dr = System.Windows.MessageBox.Show("讲解已存在是否覆盖?", "提示", MessageBoxButton.OKCancel);
89
-                if (dr == MessageBoxResult.OK)
90
-                {
91
-                    FileToolsCommon.DeleteDirectory(APP.WKData.WkPath);
92
-                }
93
-                else
90
+                if (!string.IsNullOrWhiteSpace(APP.UserInfo.Username))
94 91
                 {
95
-                    return;
92
+                    //判断课程是否存在
93
+                    if (APP.WKDataList.Exists(x => x.WkName == APP.WKData.WkName))
94
+                    {
95
+                        MessageBoxResult dr = System.Windows.MessageBox.Show("此微课已存在是否覆盖?", "提示", MessageBoxButton.OKCancel);
96
+                        if (dr == MessageBoxResult.OK)
97
+                        {
98
+                            FileToolsCommon.DeleteDirectory(APP.WKData.WkPath);
99
+                            FileToolsCommon.CreateDirectory(APP.WKData.WkPath);
100
+                            APP.WKDataList.RemoveAll(x => x.WkName == APP.WKData.WkName);
101
+                        }
102
+                        else
103
+                        {
104
+                            return;
105
+                        }
106
+                    }
107
+                    APP.WKData.WkPath += APP.UserInfo.Username + "/";
96 108
                 }
97 109
             }
98 110
             #endregion

+ 22
- 1
XHWK.WKTool/LoginWindow.xaml.cs View File

@@ -1,4 +1,5 @@
1
-using System;
1
+using Common.system;
2
+using System;
2 3
 using System.Configuration;
3 4
 using System.Windows;
4 5
 using XHWK.WKTool.DAL;
@@ -78,6 +79,26 @@ namespace XHWK.WKTool
78 79
                 pobPassword.Password = string.Empty;
79 80
                 //读取微课数据
80 81
                 APP.ReadWkData();
82
+                APP.ReadDrawData();
83
+                APP.WKData.WkPath += APP.UserInfo.Username + "/";
84
+                //判断微课是否存在,存在则询问
85
+                if (APP.WKDataList != null)
86
+                {
87
+                    if(APP.WKDataList.Exists(x => x.WkName == APP.WKData.WkName))
88
+                    {
89
+                        MessageBoxResult dr = System.Windows.MessageBox.Show("此微课已存在是否覆盖?", "提示", MessageBoxButton.OKCancel);
90
+                        if (dr == MessageBoxResult.OK)
91
+                        {
92
+                            FileToolsCommon.DeleteDirectory(APP.WKData.WkPath);
93
+                            FileToolsCommon.CreateDirectory(APP.WKData.WkPath);
94
+                            APP.WKDataList.RemoveAll(x => x.WkName == APP.WKData.WkName);
95
+                        }
96
+                        else
97
+                        {
98
+                            APP.W_CreateAMicroLessonWindow.Show();
99
+                        }
100
+                    }
101
+                }
81 102
                 this.Hide();
82 103
             }
83 104
             else

+ 30
- 6
XHWK.WKTool/XHMicroLessonSystemWindow.xaml.cs View File

@@ -243,8 +243,34 @@ namespace XHWK.WKTool
243 243
         /// <param name="e"></param>
244 244
         private void BtnDown_Click(object sender, RoutedEventArgs e)
245 245
         {
246
-            APP.SaveWkData();
247
-            System.Environment.Exit(0);
246
+            if (IsFirstR)
247
+            {
248
+                APP.Killffmpeg();
249
+                APP.SaveWkData();
250
+                APP.SaveDraw();
251
+                Thread.Sleep(100);
252
+                System.Environment.Exit(0);
253
+            }
254
+            else
255
+            {
256
+                MessageBoxResult dr = System.Windows.MessageBox.Show("当前正在录制,是否停止录制?", "提示", MessageBoxButton.OKCancel);
257
+                if (dr == MessageBoxResult.OK)
258
+                {
259
+                    APP.SaveWkData();
260
+                    APP.SaveDraw();
261
+                    BtnStop_Click(null, null);
262
+                    while (!IsFirstR)
263
+                    {
264
+                        Thread.Sleep(100);
265
+                    }
266
+                    System.Environment.Exit(0);
267
+
268
+                }
269
+                else
270
+                {
271
+                    return;
272
+                }
273
+            }
248 274
         }
249 275
         /// <summary>
250 276
         /// 设置 保存事件
@@ -324,8 +350,6 @@ namespace XHWK.WKTool
324 350
         /// <param name="e"></param>
325 351
         private void BtnBrowse_Click(object sender, RoutedEventArgs e)
326 352
         {
327
-
328
-
329 353
             System.Diagnostics.Process.Start(APP.WKData.WkPath);
330 354
             //string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
331 355
             //Ofd = new System.Windows.Forms.FolderBrowserDialog();
@@ -730,7 +754,7 @@ namespace XHWK.WKTool
730 754
         /// </summary>
731 755
         bool IsSuspendR = true;
732 756
         /// <summary>
733
-        /// 是否首次录制
757
+        /// 录制是否已停止
734 758
         /// </summary>
735 759
         bool IsFirstR = true;
736 760
         /// <summary>
@@ -914,7 +938,6 @@ namespace XHWK.WKTool
914 938
         {
915 939
             if (!IsFirstR)
916 940
             {
917
-                IsFirstR = true;
918 941
                 IsSuspendR = true;
919 942
                 ImgRecord.Source = new BitmapImage(new Uri("pack://application:,,,/Images/microLessonSystem_14.png"));
920 943
                 TxbRecordingWord.Text = "录制";
@@ -962,6 +985,7 @@ namespace XHWK.WKTool
962 985
                         APP.VideoList.Add(VideoInfo);
963 986
                         //保存数据
964 987
                         APP.SaveWkData();
988
+                        IsFirstR = true;
965 989
                     }))).Start();
966 990
                     //List<Model_Video> VideoList
967 991
                 }

Loading…
Cancel
Save