Browse Source

zhao:解决冲突

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

+ 8
- 0
Common/Common.csproj View File

@@ -114,6 +114,7 @@
114 114
   </ItemGroup>
115 115
   <ItemGroup>
116 116
     <Compile Include="Model\DownloadInfoModel.cs" />
117
+    <Compile Include="system\BlackboardNew.cs" />
117 118
     <Compile Include="system\CameraHelper.cs" />
118 119
     <Compile Include="system\CLeopardZip.cs" />
119 120
     <Compile Include="system\DataConvertCommon.cs" />
@@ -124,6 +125,7 @@
124 125
     <Compile Include="system\FreeMemoryHelper.cs" />
125 126
     <Compile Include="system\HttpHelper.cs" />
126 127
     <Compile Include="system\ImageHelper.cs" />
128
+    <Compile Include="system\JsonHelper.cs" />
127 129
     <Compile Include="system\LogHelper.cs" />
128 130
     <Compile Include="system\PrimaryScreen.cs" />
129 131
     <Compile Include="Properties\AssemblyInfo.cs" />
@@ -139,5 +141,11 @@
139 141
     </None>
140 142
     <None Include="packages.config" />
141 143
   </ItemGroup>
144
+  <ItemGroup>
145
+    <ProjectReference Include="..\XHWK.Model\XHWK.Model.csproj">
146
+      <Project>{445A4527-849B-4FA9-AA97-8ED1098D211E}</Project>
147
+      <Name>XHWK.Model</Name>
148
+    </ProjectReference>
149
+  </ItemGroup>
142 150
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
143 151
 </Project>

+ 277
- 0
Common/system/BlackboardNew.cs View File

@@ -0,0 +1,277 @@
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.Ink;
9
+using System.Windows.Input;
10
+using System.Windows.Media;
11
+
12
+namespace Common.system
13
+{
14
+    internal enum ZPenType : byte
15
+    {
16
+        Pen = 1,
17
+        Erase = 2
18
+    };
19
+
20
+    internal class ZBBPage
21
+    {
22
+        public List<ZBBPageStep> lines { get; set; }
23
+        public List<ZBBPageStep> lines_histoty { get; set; }
24
+
25
+        public ZBBPage()
26
+        {
27
+            lines = new List<ZBBPageStep>();
28
+            lines_histoty = new List<ZBBPageStep>();
29
+        }
30
+    }
31
+
32
+    internal class ZBBPageStep
33
+    {
34
+        public StrokeCollection lines_curr { get; set; }
35
+        public StrokeCollection lines_add { get; set; }
36
+        public StrokeCollection lines_remove { get; set; }
37
+
38
+        public ZBBPageStep()
39
+        {
40
+            lines_curr = new StrokeCollection();
41
+            lines_add = new StrokeCollection();
42
+            lines_remove = new StrokeCollection();
43
+        }
44
+    }
45
+    public class BlackboardNew
46
+    {
47
+        private InkCanvas m_canvas;
48
+
49
+        //private ZPenType type = ZPenType.Pen;
50
+        private int pagenum = 0;
51
+
52
+        private readonly int erasesize = 64;
53
+        private readonly int pensize = 3;
54
+        private int undoOrRedo = 0; //是否在进行撤销恢复操作
55
+        private Color pencolor;
56
+
57
+        private readonly List<ZBBPage> strokes_page_all = new List<ZBBPage>();
58
+
59
+        // 添加这个变量是因为在用橡皮擦时 一次操作会触发多次StrokesChanged回掉 这里是把多次回掉合并在一起
60
+        private ZBBPageStep step = null;
61
+
62
+        public BlackboardNew(InkCanvas canvas)
63
+        {
64
+            init(canvas, Colors.White);
65
+        }
66
+
67
+        public BlackboardNew(InkCanvas canvas, Color _pencolor)
68
+        {
69
+            init(canvas, _pencolor);
70
+        }
71
+
72
+        private void init(InkCanvas canvas, Color _pencolor)
73
+        {
74
+            m_canvas = canvas;
75
+            pencolor = _pencolor;
76
+            ZBBPage page = new ZBBPage();
77
+            page.lines.Add(new ZBBPageStep());
78
+            strokes_page_all.Add(page);
79
+            if (canvas != null)
80
+            {
81
+                canvas.EditingMode = InkCanvasEditingMode.Ink;
82
+                DrawingAttributes drawingAttributes = new DrawingAttributes();
83
+                canvas.DefaultDrawingAttributes = drawingAttributes;
84
+                drawingAttributes.Width = pensize;
85
+                drawingAttributes.Height = pensize;
86
+                drawingAttributes.Color = pencolor;
87
+                drawingAttributes.FitToCurve = true;
88
+                drawingAttributes.IgnorePressure = false;
89
+                canvas.Strokes.StrokesChanged += Strokes_StrokesChanged;
90
+                canvas.StrokeCollected += Canvas_StrokeCollected;
91
+                canvas.StrokeErasing += Canvas_StrokeErasing;
92
+                canvas.StrokeErased += Canvas_StrokeErased;
93
+                canvas.MouseUp += Canvas_MouseUp;
94
+            }
95
+        }
96
+
97
+        private void Canvas_StrokeErasing(object sender, InkCanvasStrokeErasingEventArgs e)
98
+        {
99
+            undoOrRedo = 0;
100
+        }
101
+
102
+        private void Canvas_StrokeErased(object sender, RoutedEventArgs e)
103
+        {
104
+        }
105
+
106
+        private void Canvas_StrokeCollected(object sender, InkCanvasStrokeCollectedEventArgs e)
107
+        {
108
+        }
109
+
110
+        private void Canvas_MouseUp(object sender, MouseButtonEventArgs e)
111
+        {
112
+            if (step != null)
113
+            {
114
+                ZBBPage page = strokes_page_all[pagenum];
115
+                if (page != null)
116
+                {
117
+                    step.lines_curr.Add(m_canvas.Strokes);
118
+                    page.lines.Add(step);
119
+                    step = null;
120
+                }
121
+            }
122
+        }
123
+
124
+        private void Strokes_StrokesChanged(object sender, StrokeCollectionChangedEventArgs e)
125
+        {
126
+            if (undoOrRedo > 0)
127
+            {
128
+                undoOrRedo -= 1;
129
+                return;
130
+            }
131
+
132
+            if (step == null)
133
+            {
134
+                step = new ZBBPageStep();
135
+            }
136
+
137
+            // 笔模式
138
+            if (e.Added.Count > 0 && e.Removed.Count == 0)
139
+            {
140
+                step.lines_add.Add(e.Added);
141
+            }
142
+            // 橡皮模式 会多次进入回掉
143
+            else if (e.Removed.Count > 0)
144
+            {
145
+                step.lines_add.Add(e.Added);
146
+                for (int i = 0; i < e.Removed.Count; i++)
147
+                {
148
+                    Stroke removeItem = e.Removed[i];
149
+                    if (step.lines_add.Contains(removeItem))
150
+                    {
151
+                        step.lines_add.Remove(removeItem);
152
+                    }
153
+                    else
154
+                    {
155
+                        step.lines_remove.Add(removeItem);
156
+                    }
157
+                }
158
+            }
159
+        }
160
+
161
+        // public方法 笔
162
+        public void change_pen()
163
+        {
164
+            //this.type = ZPenType.Pen;
165
+            DrawingAttributes drawingAttributes = new DrawingAttributes();
166
+            m_canvas.DefaultDrawingAttributes = drawingAttributes;
167
+            drawingAttributes.Color = pencolor;
168
+            drawingAttributes.Width = pensize;
169
+            drawingAttributes.Height = pensize;
170
+            drawingAttributes.FitToCurve = true;
171
+            drawingAttributes.IgnorePressure = false;
172
+            m_canvas.EditingMode = InkCanvasEditingMode.Ink;
173
+        }
174
+
175
+        // 橡皮
176
+        public void change_erase()
177
+        {
178
+            //this.type = ZPenType.Erase;
179
+            m_canvas.EditingMode = InkCanvasEditingMode.EraseByPoint;
180
+            m_canvas.EraserShape = new EllipseStylusShape(erasesize, erasesize, 0);
181
+        }
182
+
183
+        // 撤销
184
+        public void undo()
185
+        {
186
+            ZBBPage page = strokes_page_all[pagenum];
187
+
188
+            if (page != null && m_canvas.Strokes.Count > 0 && page.lines.Count > 1)
189
+            {
190
+                ZBBPageStep last = page.lines.Last();
191
+                page.lines.Remove(last);
192
+                page.lines_histoty.Add(last);
193
+                if (page.lines.Last().lines_curr.Count > 0)
194
+                {
195
+                    undoOrRedo = 2;
196
+                }
197
+                else
198
+                {
199
+                    undoOrRedo = 1;
200
+                }
201
+
202
+                m_canvas.Strokes.Clear();
203
+                m_canvas.Strokes.Add(page.lines.Last().lines_curr);
204
+            }
205
+        }
206
+
207
+        // 恢复
208
+        public void redo()
209
+        {
210
+            ZBBPage page = strokes_page_all[pagenum];
211
+            if (page != null && page.lines_histoty.Count > 0)
212
+            {
213
+                ZBBPageStep line = page.lines_histoty[page.lines_histoty.Count - 1];
214
+
215
+                page.lines.Add(line);
216
+                page.lines_histoty.Remove(line);
217
+                if (page.lines.Last().lines_curr.Count > 0)
218
+                {
219
+                    undoOrRedo = 2;
220
+                }
221
+                else
222
+                {
223
+                    undoOrRedo = 1;
224
+                }
225
+                m_canvas.Strokes.Clear();
226
+                m_canvas.Strokes.Add(page.lines.Last().lines_curr);
227
+            }
228
+        }
229
+
230
+        // 清空
231
+        public void clear()
232
+        {
233
+            ZBBPage page = strokes_page_all[pagenum];
234
+            if (page != null)
235
+            {
236
+                m_canvas.Strokes.Clear();
237
+                page.lines_histoty.Clear();
238
+                page.lines.Clear();
239
+                page.lines.Add(new ZBBPageStep());
240
+            }
241
+        }
242
+
243
+        public void changepage(int mpagenum)
244
+        {
245
+            if (pagenum != mpagenum)
246
+            {
247
+                pagenum = mpagenum;
248
+                if (pagenum >= strokes_page_all.Count)
249
+                {
250
+                    int numadd = pagenum - strokes_page_all.Count + 1;
251
+                    for (int i = 0; i < numadd; i++)
252
+                    {
253
+                        ZBBPage pagetemp = new ZBBPage();
254
+                        pagetemp.lines.Add(new ZBBPageStep());
255
+                        strokes_page_all.Add(pagetemp);
256
+                    }
257
+                }
258
+
259
+                ZBBPage page = strokes_page_all[pagenum];
260
+                if (page != null)
261
+                {
262
+                    if (page.lines.Last().lines_curr.Count > 0)
263
+                    {
264
+                        undoOrRedo += 1;
265
+                    }
266
+                    if (m_canvas.Strokes.Count > 0)
267
+                    {
268
+                        undoOrRedo += 1;
269
+                        m_canvas.Strokes.Clear();
270
+                    }
271
+
272
+                    m_canvas.Strokes.Add(page.lines.Last().lines_curr);
273
+                }
274
+            }
275
+        }
276
+    }
277
+}

+ 70
- 0
Common/system/HttpHelper.cs View File

@@ -1,8 +1,10 @@
1 1
 using System;
2 2
 using System.Collections.Generic;
3
+using System.IO;
3 4
 using System.Net;
4 5
 using System.Net.Security;
5 6
 using System.Security.Cryptography.X509Certificates;
7
+using System.Text;
6 8
 using System.Threading;
7 9
 
8 10
 namespace Common.system
@@ -138,5 +140,73 @@ namespace Common.system
138 140
             }
139 141
             return null;
140 142
         }
143
+        /// <summary>
144
+        /// Post Http请求
145
+        /// </summary>
146
+        /// <param name="url">请求地址</param>
147
+        /// <param name="postData">传输数据</param>
148
+        /// <param name="timeout">超时时间</param>
149
+        /// <param name="contentType">媒体格式</param>
150
+        /// <param name="encode">编码</param>
151
+        /// <returns>泛型集合</returns>
152
+        public static T PostAndRespSignle<T>(string url, int timeout = 5000, string postData = "", string contentType = "application/json;", string encode = "UTF-8") where T : class
153
+        {
154
+            if (!string.IsNullOrEmpty(url) && !string.IsNullOrEmpty(encode) && !string.IsNullOrEmpty(contentType) && postData != null)
155
+            {
156
+                // webRequest.Headers.Add("Authorization", "Bearer " + "SportApiAuthData");
157
+                HttpWebResponse webResponse = null;
158
+                Stream responseStream = null;
159
+                Stream requestStream = null;
160
+                StreamReader streamReader = null;
161
+                try
162
+                {
163
+                    string respstr = GetStreamReader(url, responseStream, requestStream, streamReader, webResponse, timeout, encode, postData, contentType);
164
+                    return JsonHelper.JsonToObj<T>(respstr);
165
+                }
166
+                catch (Exception)
167
+                {
168
+                }
169
+                finally
170
+                {
171
+                    if (responseStream != null)
172
+                    {
173
+                        responseStream.Dispose();
174
+                    }
175
+
176
+                    if (webResponse != null)
177
+                    {
178
+                        webResponse.Close();
179
+                    }
180
+
181
+                    if (requestStream != null)
182
+                    {
183
+                        requestStream.Dispose();
184
+                    }
185
+
186
+                    if (streamReader != null)
187
+                    {
188
+                        streamReader.Dispose();
189
+                    }
190
+                }
191
+            }
192
+            return default(T);
193
+        }
194
+        private static string GetStreamReader(string url, Stream responseStream, Stream requestStream, StreamReader streamReader, WebResponse webResponse, int timeout, string encode, string postData, string contentType)
195
+        {
196
+            byte[] data = Encoding.GetEncoding(encode).GetBytes(postData);
197
+            HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
198
+            webRequest.Method = "POST";
199
+            webRequest.ContentType = contentType + ";" + encode;
200
+            webRequest.ContentLength = data.Length;
201
+            webRequest.Timeout = timeout;
202
+            requestStream = webRequest.GetRequestStream();
203
+            requestStream.Write(data, 0, data.Length);
204
+            webResponse = (HttpWebResponse)webRequest.GetResponse();
205
+            responseStream = webResponse.GetResponseStream();
206
+            if (responseStream == null) { return ""; }
207
+            streamReader = new StreamReader(responseStream, Encoding.GetEncoding(encode));
208
+            return streamReader.ReadToEnd();
209
+        }
210
+
141 211
     }
142 212
 }

+ 68
- 0
Common/system/JsonHelper.cs View File

@@ -0,0 +1,68 @@
1
+using Newtonsoft.Json;
2
+using System;
3
+using System.Collections.Generic;
4
+using System.IO;
5
+using System.Linq;
6
+using System.Text;
7
+using System.Threading.Tasks;
8
+
9
+namespace Common.system
10
+{
11
+    public class JsonHelper
12
+    {
13
+        #region Method
14
+
15
+        /// <summary>
16
+        /// 类对像转换成json格式
17
+        /// </summary>
18
+        /// <returns></returns>
19
+        public static string ToJson(object t)
20
+        {
21
+            return JsonConvert.SerializeObject(
22
+                t, Newtonsoft.Json.Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Include }
23
+                );
24
+        }
25
+
26
+        /// <summary>
27
+        /// 类对像转换成json格式
28
+        /// </summary>
29
+        /// <param name="t"></param>
30
+        /// <param name="HasNullIgnore">是否忽略NULL值</param>
31
+        /// <returns></returns>
32
+        public static string ToJson(object t, bool HasNullIgnore)
33
+        {
34
+            if (HasNullIgnore)
35
+            {
36
+                return JsonConvert.SerializeObject(t, Newtonsoft.Json.Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
37
+            }
38
+            else
39
+            {
40
+                return ToJson(t);
41
+            }
42
+        }
43
+
44
+        /// <summary>
45
+        /// json格式转换
46
+        /// </summary>
47
+        /// <typeparam name="T"></typeparam>
48
+        /// <param name="strJson"></param>
49
+        /// <returns></returns>
50
+        public static T JsonToObj<T>(string strJson) where T : class
51
+        {
52
+            if (strJson != null && strJson != "") { return JsonConvert.DeserializeObject<T>(strJson); }
53
+
54
+            return null;
55
+        }
56
+
57
+        internal static List<T> JsonToList<T>(string respstr)
58
+        {
59
+            JsonSerializer serializer = new JsonSerializer();
60
+            StringReader sr = new StringReader(respstr);
61
+            object o = serializer.Deserialize(new JsonTextReader(sr), typeof(List<T>));
62
+            List<T> list = o as List<T>;
63
+            return list;
64
+        }
65
+
66
+        #endregion Method
67
+    }
68
+}

+ 35
- 0
XHWK.Model/Model_Canvas.cs View File

@@ -0,0 +1,35 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+
7
+namespace XHWK.Model
8
+{
9
+    public class Model_Canvas:NotifyModel
10
+    {
11
+        private string _name;
12
+
13
+        public string Name
14
+        {
15
+            get => _name;
16
+            set { _name = value; OnPropertyChanged("Name"); }
17
+        }
18
+
19
+        private string _Pic;
20
+
21
+        public string Pic
22
+        {
23
+            get => _Pic;
24
+            set { _Pic = value; OnPropertyChanged("Pic"); }
25
+        }
26
+
27
+        private bool _Selected;
28
+
29
+        public bool Selected
30
+        {
31
+            get => _Selected;
32
+            set { _Selected = value; OnPropertyChanged("Selected"); }
33
+        }
34
+    }
35
+}

+ 47
- 0
XHWK.Model/Model_Page.cs View File

@@ -0,0 +1,47 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Collections.ObjectModel;
4
+using System.Linq;
5
+using System.Text;
6
+using System.Threading.Tasks;
7
+
8
+namespace XHWK.Model
9
+{
10
+    public class Model_Page : NotifyModel
11
+    {
12
+        public ObservableCollection<Model_Canvas> menuList { get; set; }
13
+
14
+        /// <summary>
15
+        /// 总页码
16
+        /// </summary>
17
+        private int _pagenum = 1;
18
+
19
+        /// <summary>
20
+        /// 总页码
21
+        /// </summary>
22
+        public int pagenum
23
+        {
24
+            get => _pagenum;
25
+            set { _pagenum = value; OnPropertyChanged("pagenum"); }
26
+        }
27
+
28
+        /// <summary>
29
+        /// 当前页 从1开始
30
+        /// </summary>
31
+        private int _currpage = 1;// 从1开始
32
+
33
+        /// <summary>
34
+        /// 当前页 从1开始
35
+        /// </summary>
36
+        public int currpage
37
+        {
38
+            get => _currpage;
39
+            set { _currpage = value; OnPropertyChanged("currpage"); }
40
+        }
41
+
42
+        public Model_Page() 
43
+        {
44
+            menuList = new ObservableCollection<Model_Canvas>();
45
+        }
46
+    }
47
+}

+ 82
- 6
XHWK.Model/Model_UserInfo.cs View File

@@ -4,17 +4,93 @@ namespace XHWK.Model
4 4
 {
5 5
     public class Model_UserInfo
6 6
     {
7
-        private string _userName;
8
-        private string _name;
9
-        private List<Model_WKData> _wkdata;
10 7
         /// <summary>
11
-        /// 用户
8
+        /// 用户id
12 9
         /// </summary>
13
-        public string UserName { get => _userName; set => _userName = value; }
10
+        private int _userid;
14 11
         /// <summary>
15 12
         /// 姓名
16 13
         /// </summary>
17
-        public string Name { get => _name; set => _name = value; }
14
+        private string _username;
15
+        /// <summary>
16
+        /// 登录名
17
+        /// </summary>
18
+        private string _loginname;
19
+        /// <summary>
20
+        /// 学号
21
+        /// </summary>
22
+        private string _studentno;
23
+        /// <summary>
24
+        /// 联系方式
25
+        /// </summary>
26
+        private string _userphone;
27
+        /// <summary>
28
+        /// 生日
29
+        /// </summary>
30
+        private string _userbirthday;
31
+        /// <summary>
32
+        /// 身份号
33
+        /// </summary>
34
+        private string _cardid;
35
+        /// <summary>
36
+        /// 头像地址
37
+        /// </summary>
38
+        private string _headpic;
39
+        /// <summary>
40
+        /// 用户类型999超级管理员0学校管理员1老师2学生
41
+        /// </summary>
42
+        private string _usertype;
43
+        /// <summary>
44
+        /// 状态
45
+        /// </summary>
46
+        private int _userstate;
47
+        private int _createid;
48
+        private string _createname;
49
+        private string _createtime;
50
+        private string _deleteid;
51
+        private string _deletetime;
52
+        /// <summary>
53
+        /// 当前年份
54
+        /// </summary>
55
+        private int _year;
56
+        /// <summary>
57
+        /// 学校id
58
+        /// </summary>
59
+        private int _schoolid;
60
+        /// <summary>
61
+        /// 学校名称
62
+        /// </summary>
63
+        private string _schoolname;
64
+        /// <summary>
65
+        /// 状态
66
+        /// </summary>
67
+        private int _schoolstate;
68
+        /// <summary>
69
+        /// 学校阶段1小学2初中3高中4大学
70
+        /// </summary>
71
+        private int _schoollevel;
72
+        private List<Model_WKData> _wkdata;
73
+
74
+        public int Userid { get => _userid; set => _userid = value; }
75
+        public string Username { get => _username; set => _username = value; }
76
+        public string Loginname { get => _loginname; set => _loginname = value; }
77
+        public string Studentno { get => _studentno; set => _studentno = value; }
78
+        public string Userphone { get => _userphone; set => _userphone = value; }
79
+        public string Userbirthday { get => _userbirthday; set => _userbirthday = value; }
80
+        public string Cardid { get => _cardid; set => _cardid = value; }
81
+        public string Headpic { get => _headpic; set => _headpic = value; }
82
+        public string Usertype { get => _usertype; set => _usertype = value; }
83
+        public int Userstate { get => _userstate; set => _userstate = value; }
84
+        public int Createid { get => _createid; set => _createid = value; }
85
+        public string Createname { get => _createname; set => _createname = value; }
86
+        public string Createtime { get => _createtime; set => _createtime = value; }
87
+        public string Deleteid { get => _deleteid; set => _deleteid = value; }
88
+        public string Deletetime { get => _deletetime; set => _deletetime = value; }
89
+        public int Year { get => _year; set => _year = value; }
90
+        public int Schoolid { get => _schoolid; set => _schoolid = value; }
91
+        public string Schoolname { get => _schoolname; set => _schoolname = value; }
92
+        public int Schoolstate { get => _schoolstate; set => _schoolstate = value; }
93
+        public int Schoollevel { get => _schoollevel; set => _schoollevel = value; }
18 94
         /// <summary>
19 95
         /// 微课列表信息
20 96
         /// </summary>

+ 0
- 5
XHWK.Model/Model_Video.cs View File

@@ -11,7 +11,6 @@
11 11
         private Enum_WKVidetype _wkType;
12 12
         private string _RSTime;
13 13
         private string _videoSize;
14
-        private string _drawDataPath;
15 14
         /// <summary>
16 15
         /// 视频路径
17 16
         /// </summary>
@@ -36,10 +35,6 @@
36 35
         /// 视频大小
37 36
         /// </summary>
38 37
         public string VideoSize { get => _videoSize; set => _videoSize = value; }
39
-        /// <summary>
40
-        /// 画板数据存储路径
41
-        /// </summary>
42
-        public string DrawDataPath { get => _drawDataPath; set => _drawDataPath = value; }
43 38
     }
44 39
     /// <summary>
45 40
     /// 视频格式类型

+ 5
- 0
XHWK.Model/Model_WKData.cs View File

@@ -8,6 +8,7 @@ namespace XHWK.Model
8 8
         private List<Model_Video> _videoList;
9 9
         private string _wkPath;
10 10
         private string _wkDateTime;
11
+        private string _drawDataPath;
11 12
         /// <summary>
12 13
         /// 微课名
13 14
         /// </summary>
@@ -24,5 +25,9 @@ namespace XHWK.Model
24 25
         /// 微课时间
25 26
         /// </summary>
26 27
         public string WkDateTime { get => _wkDateTime; set => _wkDateTime = value; }
28
+        /// <summary>
29
+        /// 画板数据存储路径
30
+        /// </summary>
31
+        public string DrawDataPath { get => _drawDataPath; set => _drawDataPath = value; }
27 32
     }
28 33
 }

+ 18
- 0
XHWK.Model/NotifyModel.cs View File

@@ -0,0 +1,18 @@
1
+using System.ComponentModel;
2
+
3
+namespace XHWK.Model
4
+{
5
+    public class NotifyModel : INotifyPropertyChanged
6
+    {
7
+        public event PropertyChangedEventHandler PropertyChanged;
8
+
9
+        public void OnPropertyChanged(string propertyName)
10
+        {
11
+            PropertyChangedEventHandler handler = PropertyChanged;
12
+            if (handler != null)
13
+            {
14
+                handler(this, new PropertyChangedEventArgs(propertyName));
15
+            }
16
+        }
17
+    }
18
+}

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

@@ -41,9 +41,12 @@
41 41
     <Reference Include="System.Xml" />
42 42
   </ItemGroup>
43 43
   <ItemGroup>
44
+    <Compile Include="Model_Canvas.cs" />
45
+    <Compile Include="Model_Page.cs" />
44 46
     <Compile Include="Model_UserInfo.cs" />
45 47
     <Compile Include="Model_Video.cs" />
46 48
     <Compile Include="Model_WKData.cs" />
49
+    <Compile Include="NotifyModel.cs" />
47 50
     <Compile Include="Properties\AssemblyInfo.cs" />
48 51
   </ItemGroup>
49 52
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

+ 4
- 0
XHWK.WKTool/App.config View File

@@ -12,5 +12,9 @@
12 12
     <add key="VideoType" value="1" />
13 13
     <!--图片压缩质量-->
14 14
     <add key="ImageCompressionLevel" value="50"/>
15
+    <!--用户名-->
16
+    <add key="userName" value="" />
17
+    <!--记住密码-->
18
+    <add key="isRemind" value="" />
15 19
   </appSettings>
16 20
 </configuration>

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

@@ -14,6 +14,14 @@ namespace XHWK.WKTool
14 14
     {
15 15
         #region 全局变量
16 16
         /// <summary>
17
+        /// 用户信息
18
+        /// </summary>
19
+        public static Model_UserInfo UserInfo=null;
20
+        /// <summary>
21
+        /// 接口返回消息
22
+        /// </summary>
23
+        public static string ServerMsg=string.Empty;
24
+        /// <summary>
17 25
         /// 微课模型
18 26
         /// </summary>
19 27
         public static Model_WKData WKData = null;
@@ -37,6 +45,23 @@ namespace XHWK.WKTool
37 45
         /// 录像工具栏
38 46
         /// </summary>
39 47
         public static ScreenRecordingToolbarWindow W_ScreenRecordingToolbarWindow = null;
48
+        /// <summary>
49
+        /// 登陆
50
+        /// </summary>
51
+        public static LoginWindow W_LoginWindow = null;
52
+        /// <summary>
53
+        /// 登陆状态 false 未登录 true已登陆
54
+        /// </summary>
55
+        public static bool IsLoginType = false;
56
+        public static readonly Model_Page pageData = new Model.Model_Page();
57
+        /// <summary>
58
+        /// 防止图片地址重复
59
+        /// </summary>
60
+        public static long num = 9999;
61
+        /// <summary>
62
+        /// 图片路径
63
+        /// </summary>
64
+        public static string[] Paths = new string[] { };
40 65
         #endregion
41 66
 
42 67
         [STAThread]

+ 44
- 0
XHWK.WKTool/DAL/Interface.cs View File

@@ -0,0 +1,44 @@
1
+using Common.system;
2
+using System;
3
+using System.Collections.Generic;
4
+using System.Linq;
5
+using System.Text;
6
+using System.Threading.Tasks;
7
+using XHWK.Model;
8
+
9
+namespace XHWK.WKTool.DAL
10
+{
11
+    public class Interface
12
+    {
13
+ 
14
+        /// <summary>
15
+        /// 登陆
16
+        /// </summary>
17
+        /// <param name="request"></param>
18
+        /// <returns></returns>
19
+        public int Login(string loginname, string loginpwd)
20
+        {
21
+            string url = "http://schoolapi.xhkjedu.com/user/login";//地址
22
+            Dictionary<string, object> dic = new Dictionary<string, object>
23
+            {
24
+                { "loginname", loginname},
25
+                { "loginpwd", loginpwd}
26
+            };
27
+            string body = JsonHelper.ToJson(dic);
28
+            ResultVo<Model_UserInfo> result = HttpHelper.PostAndRespSignle<ResultVo<Model_UserInfo>>(url, postData: body);
29
+            if (result != null)
30
+            {
31
+                APP.UserInfo = new Model_UserInfo();
32
+                APP.ServerMsg = result.msg;
33
+                APP.UserInfo = result.obj;
34
+                return result.code;
35
+            }
36
+            else
37
+            {
38
+                APP.ServerMsg = "网络异常!";
39
+                APP.UserInfo =new Model_UserInfo();
40
+                return 1;
41
+            }
42
+        }
43
+    }
44
+}

+ 17
- 0
XHWK.WKTool/DAL/ResultVo.cs View File

@@ -0,0 +1,17 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+
7
+namespace XHWK.WKTool.DAL
8
+{
9
+    internal class ResultVo<T>
10
+    {
11
+        public int code { get; set; }
12
+
13
+        public string msg { get; set; }
14
+
15
+        public T obj { get; set; }
16
+    }
17
+}

BIN
XHWK.WKTool/Images/class_p1.png View File


BIN
XHWK.WKTool/Images/class_p2.png View File


BIN
XHWK.WKTool/Images/class_p3.png View File


+ 4
- 17
XHWK.WKTool/LoginWindow.xaml View File

@@ -39,26 +39,13 @@
39 39
                 <TextBlock Text="密码" FontSize="18" Padding="2,15,10,0"/>
40 40
                 <!--输入框-->
41 41
                 <Border Background="#CDD6E0" Width="371" Height="43" CornerRadius="3">
42
-                    <TextBox x:Name="txbPassword" Text="" FontSize="16" Foreground="#333333" Padding="5,12,2,2" Width="369" Height="42" BorderBrush="{x:Null}" BorderThickness="0"/>
42
+                    <PasswordBox x:Name="pobPassword" FontSize="16" Foreground="#333333" PasswordChar="*" Padding="5,12,2,2" Width="369" Height="42" BorderBrush="{x:Null}" BorderThickness="0"/>
43 43
                 </Border>
44 44
             </StackPanel>
45 45
             <StackPanel Grid.Row="3" Orientation="Horizontal" HorizontalAlignment="Left" Margin="20,0,0,0">
46
-                <Button  Cursor="Hand" Grid.Row="3" Height="20" Width="20" Content="√" FontSize="13" >
47
-                    <Button.Template>
48
-                        <ControlTemplate TargetType="{x:Type Button}">
49
-                            <Border
50
-                                BorderBrush="{TemplateBinding Control.BorderBrush}"
51
-                                BorderThickness="1"
52
-                                CornerRadius="2">
53
-                                <Border.Background>#FFFFFFFF</Border.Background>
54
-                                <ContentPresenter
55
-                                    HorizontalAlignment="Center"
56
-                                    VerticalAlignment="Center"
57
-                                    Content="{TemplateBinding ContentControl.Content}" />
58
-                            </Border>
59
-                        </ControlTemplate>
60
-                    </Button.Template>
61
-                </Button>
46
+                <Viewbox Height="23">
47
+                    <CheckBox   x:Name="ckSaveName" Click="CkSaveName_Click"/>
48
+                </Viewbox>
62 49
                 <TextBlock Text="记住账号" FontSize="18" Height="30" Padding="5,3,0,0"/>
63 50
             </StackPanel>
64 51
             

+ 106
- 2
XHWK.WKTool/LoginWindow.xaml.cs View File

@@ -1,4 +1,7 @@
1
-using System.Windows;
1
+using System;
2
+using System.Configuration;
3
+using System.Windows;
4
+using XHWK.WKTool.DAL;
2 5
 
3 6
 namespace XHWK.WKTool
4 7
 {
@@ -7,9 +10,22 @@ namespace XHWK.WKTool
7 10
     /// </summary>
8 11
     public partial class LoginWindow : Window
9 12
     {
13
+        /// <summary>
14
+        /// 调用接口
15
+        /// </summary>
16
+        private readonly Interface @interface = new Interface();
10 17
         public LoginWindow()
11 18
         {
12 19
             InitializeComponent();
20
+            Initialize();
21
+        }
22
+        public void Initialize() 
23
+        {
24
+            if (GetSettingString("isRemind").Equals("True"))
25
+            {
26
+                ckSaveName.IsChecked = true;
27
+                txbAccountNumber.Text = GetSettingString("userName");
28
+            }
13 29
         }
14 30
         /// <summary>
15 31
         /// 关闭事件
@@ -18,7 +34,9 @@ namespace XHWK.WKTool
18 34
         /// <param name="e"></param>
19 35
         private void BtnDown_Click(object sender, RoutedEventArgs e)
20 36
         {
21
-
37
+            txbAccountNumber.Text = string.Empty;
38
+            pobPassword.Password = string.Empty;
39
+            this.Hide();
22 40
         }
23 41
         /// <summary>
24 42
         /// 登陆事件
@@ -27,7 +45,93 @@ namespace XHWK.WKTool
27 45
         /// <param name="e"></param>
28 46
         private void BtnStart_Click(object sender, RoutedEventArgs e)
29 47
         {
48
+            if (string.IsNullOrEmpty(txbAccountNumber.Text))
49
+            {
50
+                MessageBox.Show("账号未输入");
51
+                return;
52
+            }
53
+            if (string.IsNullOrEmpty(pobPassword.Password))
54
+            {
55
+                MessageBox.Show("密码未输入");
56
+                return;
57
+            }
58
+            Login();
59
+        }
60
+        /// <summary>
61
+        /// 登陆
62
+        /// </summary>
63
+        private void Login()
64
+        {
65
+            string accountNumber = string.Empty;
66
+            string password = string.Empty;
67
+            Dispatcher.Invoke(new Action(() =>
68
+            {
69
+                accountNumber = txbAccountNumber.Text.Replace(" ", "").Trim();
70
+                password = pobPassword.Password.Replace(" ", "").Trim();
71
+            }));
72
+            int code = @interface.Login(accountNumber, password);
73
+            if(code==0)
74
+            {
75
+                UpdateSettingString("userName", txbAccountNumber.Text);
76
+                APP.IsLoginType = true;
77
+                txbAccountNumber.Text = string.Empty;
78
+                pobPassword.Password = string.Empty;
79
+                this.Hide();
80
+            }
81
+            else
82
+            {
83
+                MessageBox.Show(APP.ServerMsg);
84
+            }
85
+        }
86
+        /// <summary>
87
+        /// 记住账号
88
+        /// </summary>
89
+        /// <param name="sender"></param>
90
+        /// <param name="e"></param>
91
+        private void CkSaveName_Click(object sender, RoutedEventArgs e)
92
+        {
93
+            if (ckSaveName.IsChecked == false)
94
+            {
95
+                UpdateSettingString("isRemind", ckSaveName.IsChecked.ToString());
96
+            }
97
+            else
98
+            {
99
+                UpdateSettingString("isRemind", ckSaveName.IsChecked.ToString());
100
+            }
101
+        }
102
+        /// <summary>
103
+        /// 读取客户设置
104
+        /// </summary>
105
+        /// <param name="settingName"></param>
106
+        /// <returns></returns>
107
+        public static string GetSettingString(string settingName)
108
+        {
109
+            try
110
+            {
111
+                string settingString = ConfigurationManager.AppSettings[settingName].ToString();
112
+                return settingString;
113
+            }
114
+            catch (Exception)
115
+            {
116
+                return null;
117
+            }
118
+        }
119
+        /// <summary>
120
+        /// 更新设置
121
+        /// </summary>
122
+        /// <param name="settingName"></param>
123
+        /// <param name="valueName"></param>
124
+        public static void UpdateSettingString(string settingName, string valueName)
125
+        {
126
+            Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
30 127
 
128
+            if (ConfigurationManager.AppSettings[settingName] != null)
129
+            {
130
+                config.AppSettings.Settings.Remove(settingName);
131
+            }
132
+            config.AppSettings.Settings.Add(settingName, valueName);
133
+            config.Save(ConfigurationSaveMode.Modified);
134
+            ConfigurationManager.RefreshSection("appSettings");
31 135
         }
32 136
     }
33 137
 }

+ 75
- 13
XHWK.WKTool/XHMicroLessonSystemWindow.xaml View File

@@ -29,7 +29,7 @@
29 29
                     <TextBlock Text="星火微课系统" FontSize="14" Padding="5,0,0,0" Foreground="#FFFFFF"/>
30 30
                 </StackPanel>
31 31
                 <StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Right" Margin="10,10,10,0">
32
-                    <Button Cursor="Hand" x:Name="btnLoginType" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Margin="0,0,10,0">
32
+                    <Button Cursor="Hand" x:Name="btnLoginType" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Margin="0,0,10,0" Click="BtnLoginType_Click">
33 33
                         <StackPanel Orientation="Horizontal">
34 34
                             <Image Source="./Images/microLessonSystem_9.png"/>
35 35
                             <TextBlock x:Name="txbLoginType" Text="未登录" FontSize="14" Padding="5,0,0,0" Foreground="#FFFFFF"/>
@@ -38,9 +38,9 @@
38 38
                     <Button Cursor="Hand" x:Name="btnShrink" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}">
39 39
                         <Image Source="./Images/microLessonSystem_19.png"/>
40 40
                     </Button>
41
-                    <!--<Button Cursor="Hand" x:Name="btnEnlarge" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Margin="8,0,8,0">
41
+                    <Button Cursor="Hand" x:Name="btnEnlarge" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Margin="8,0,8,0">
42 42
                         <Image Source="./Images/microLessonSystem_8.png"/>
43
-                    </Button>-->
43
+                    </Button>
44 44
                     <Button Cursor="Hand" x:Name="btnDown" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Click="BtnDown_Click">
45 45
                         <Image Source="./Images/microLessonSystem_10.png"/>
46 46
                     </Button>
@@ -54,28 +54,28 @@
54 54
                             <TextBlock Text="录屏" FontSize="14" Foreground="#FFFFFF" HorizontalAlignment="Center"/>
55 55
                         </StackPanel>
56 56
                     </Button>
57
-                    <Button Cursor="Hand" x:Name="btnScreenshot" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Margin="30,0,30,0">
57
+                    <Button Cursor="Hand" x:Name="btnScreenshot" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Margin="30,0,30,0" Click="BtnScreenshot_Click">
58 58
                         <StackPanel Orientation="Vertical">
59 59
                             <Image x:Name="ImgScreenshot" Source="./Images/microLessonSystem_12.png"/>
60 60
                             <Image x:Name="ImgScreenshotTwo" Source="./Images/microLessonSystem_11.png" Visibility="Collapsed"/>
61 61
                             <TextBlock Text="截图" FontSize="14" Foreground="#FFFFFF" HorizontalAlignment="Center"/>
62 62
                         </StackPanel>
63 63
                     </Button>
64
-                    <Button Cursor="Hand" x:Name="btnImport" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}">
64
+                    <Button Cursor="Hand" x:Name="btnImport" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Click="BtnImport_Click">
65 65
                         <StackPanel Orientation="Vertical">
66 66
                             <Image x:Name="ImgImport" Source="./Images/microLessonSystem_6.png"/>
67 67
                             <Image x:Name="ImgImportTwo" Source="./Images/microLessonSystem_7.png" Visibility="Collapsed"/>
68 68
                             <TextBlock Text="导入" FontSize="14" Foreground="#FFFFFF" HorizontalAlignment="Center"/>
69 69
                         </StackPanel>
70 70
                     </Button>
71
-                    <Button Cursor="Hand" x:Name="btnRecord" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Margin="60,0,30,0">
71
+                    <Button Cursor="Hand" x:Name="btnRecord" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Margin="60,0,30,0" Click="BtnRecord_Click">
72 72
                         <StackPanel Orientation="Vertical">
73 73
                             <Image x:Name="ImgRecord" Source="./Images/microLessonSystem_14.png"/>
74 74
                             <Image x:Name="ImgRecordTwo" Source="./Images/microLessonSystem_13.png" Visibility="Collapsed"/>
75 75
                             <TextBlock Text="录制" FontSize="14" Foreground="#FFFFFF" HorizontalAlignment="Center"/>
76 76
                         </StackPanel>
77 77
                     </Button>
78
-                    <Button Cursor="Hand" x:Name="btnStop" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}">
78
+                    <Button Cursor="Hand" x:Name="btnStop" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Click="BtnStop_Click">
79 79
                         <StackPanel Orientation="Vertical">
80 80
                             <Image x:Name="ImgStop" Source="./Images/microLessonSystem_21.png"/>
81 81
                             <Image x:Name="ImgStopTwo" Source="./Images/microLessonSystem_20.png" Visibility="Collapsed"/>
@@ -84,17 +84,17 @@
84 84
                     </Button>
85 85
                 </StackPanel>
86 86
                 <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right" Margin="10,10,10,0">
87
-                    <Button Cursor="Hand" x:Name="btnAdd" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}">
87
+                    <Button Cursor="Hand" x:Name="btnAdd" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Click="BtnAdd_Click">
88 88
                         <StackPanel Orientation="Vertical">
89 89
                             <Image x:Name="ImgAdd" Source="./Images/microLessonSystem_25.png"/>
90 90
                             <Image x:Name="ImgAddTwo" Source="./Images/microLessonSystem_24.png" Visibility="Collapsed"/>
91 91
                             <TextBlock Text="增加" FontSize="14" Foreground="#FFFFFF" HorizontalAlignment="Center"/>
92 92
                         </StackPanel>
93 93
                     </Button>
94
-                    <Button Cursor="Hand" x:Name="btnPrint" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Margin="30,0,30,0">
94
+                    <Button Cursor="Hand" x:Name="btnPrint" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Margin="30,0,30,0" Click="BtnPrint_Click">
95 95
                         <StackPanel Orientation="Vertical">
96
-                            <Image x:Name="ImgPrint" Source="./Images/microLessonSystem_4.png"/>
97
-                            <Image x:Name="ImgPrintTwo" Source="./Images/microLessonSystem_5.png" Visibility="Collapsed"/>
96
+                            <Image x:Name="ImgPrint" Source="./Images/microLessonSystem_4.png" Visibility="Collapsed"/>
97
+                            <Image x:Name="ImgPrintTwo" Source="./Images/microLessonSystem_5.png" Visibility="Visible"/>
98 98
                             <TextBlock Text="打印" FontSize="14" Foreground="#FFFFFF" HorizontalAlignment="Center"/>
99 99
                         </StackPanel>
100 100
                     </Button>
@@ -105,7 +105,7 @@
105 105
                             <TextBlock Text="上传" FontSize="14" Foreground="#FFFFFF" HorizontalAlignment="Center"/>
106 106
                         </StackPanel>
107 107
                     </Button>
108
-                    <Button Cursor="Hand" x:Name="btnMyMine" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Margin="30,0,30,0">
108
+                    <Button Cursor="Hand" x:Name="btnMyMine" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Margin="30,0,30,0" Click="BtnMyMine_Click">
109 109
                         <StackPanel Orientation="Vertical">
110 110
                             <Image x:Name="ImgMyMine" Source="./Images/microLessonSystem_1.png"/>
111 111
                             <Image x:Name="ImgMyMineTwo" Source="./Images/microLessonSystem_22.png" Visibility="Collapsed"/>
@@ -123,11 +123,73 @@
123 123
             </Grid>
124 124
             <!--主内容-->
125 125
             <Grid Grid.Row="1" x:Name="gridMain"  Margin="20,0,20,0" Background="#FFFFFF" Height="793.700787401575" Width="1142.51968503937" Visibility="Visible">
126
-                <InkCanvas x:Name="blackboard_canvas" Background="#FFFFFF" />
126
+                <Grid.RowDefinitions>
127
+                    <RowDefinition Height="auto"/>
128
+                </Grid.RowDefinitions>
129
+                
130
+                <Image Grid.Row="0" x:Name="imgCanvas" Height="760"/>
131
+                <InkCanvas Grid.Row="0" x:Name="blackboard_canvas" Background="Transparent" Visibility="Visible"/>
132
+                
127 133
                 <!--摄像头-->
128 134
                 <wfi:WindowsFormsHost Grid.Row="0" Grid.Column="0" x:Name="wfhCamera" Height="124" Width="172" HorizontalAlignment="Right" Margin="10,10,10,10" VerticalAlignment="Top">
129 135
                     <aforge:VideoSourcePlayer x:Name="player" Height="124" Width="172"  />
130 136
                 </wfi:WindowsFormsHost>
137
+                <StackPanel Grid.Row="0" Orientation="Horizontal" Background="#FFFFFF" Width="240" HorizontalAlignment="Right"
138
+            Height="58" Margin="0,700,50,0">
139
+                    <Button Cursor="Hand" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}"
140
+                    x:Name="last_button"
141
+                    Width="60"
142
+                    Click="last_button_Click">
143
+                        <Button.Content>
144
+                            <StackPanel>
145
+                                <Image Width="16" Source=".\Images\class_p1.png" />
146
+                                <TextBlock Margin="0,8,0,0" Text="上一页" />
147
+                            </StackPanel>
148
+                        </Button.Content>
149
+                    </Button>
150
+                    <Grid Width="60">
151
+                        <Grid.RowDefinitions>
152
+                            <RowDefinition Height="311*"/>
153
+                            <RowDefinition Height="483*"/>
154
+                        </Grid.RowDefinitions>
155
+                        <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,-25,0,0" Grid.Row="1" >
156
+
157
+                            <StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
158
+                                <TextBlock x:Name="txbCurrpage" Text="{Binding currpage}" TextAlignment="Center" FontSize="15"/>
159
+                                <TextBlock Text="/" TextAlignment="Center" FontSize="15"/>
160
+                                <TextBlock Text="{Binding pagenum}" TextAlignment="Center" FontSize="15"/>
161
+                            </StackPanel>
162
+
163
+                            <TextBlock
164
+                            Margin="0,8,0,0"
165
+                            HorizontalAlignment="Center"
166
+                            Text="页码" />
167
+                        </StackPanel>
168
+                    </Grid>
169
+                    <Button Cursor="Hand" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}"
170
+                    x:Name="next_btn"
171
+                    Width="60"
172
+                    Click="next_btn_Click">
173
+                        <Button.Content>
174
+                            <StackPanel>
175
+                                <Image Width="16" Source=".\Images\class_p2.png" />
176
+                                <TextBlock Margin="0,8,0,0" Text="下一页" />
177
+                            </StackPanel>
178
+                        </Button.Content>
179
+                    </Button>
180
+
181
+                    <Button Cursor="Hand" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}"
182
+                    x:Name="add_button"
183
+                    Width="60"
184
+                    Click="add_button_Click">
185
+                        <Button.Content>
186
+                            <StackPanel>
187
+                                <Image Width="16" Source=".\Images\class_p3.png" />
188
+                                <TextBlock Margin="0,4,0,0" Text="添加" />
189
+                            </StackPanel>
190
+                        </Button.Content>
191
+                    </Button>
192
+                </StackPanel>
131 193
             </Grid>
132 194
             <!--设置-->
133 195
             <Grid Grid.Row="1" x:Name="gridSetUp" Margin="20,0,20,0" Background="#FFFFFF" Visibility="Collapsed">

+ 341
- 1
XHWK.WKTool/XHMicroLessonSystemWindow.xaml.cs View File

@@ -1,11 +1,18 @@
1
-using Common.system;
1
+using Aspose.Words;
2
+using Aspose.Words.Saving;
3
+using Common.system;
2 4
 
3 5
 using System;
6
+using System.Collections.Generic;
7
+using System.Drawing.Imaging;
8
+using System.IO;
9
+using System.Threading;
4 10
 using System.Windows;
5 11
 using System.Windows.Forms;
6 12
 using System.Windows.Ink;
7 13
 using System.Windows.Input;
8 14
 using System.Windows.Media;
15
+using System.Windows.Media.Imaging;
9 16
 
10 17
 namespace XHWK.WKTool
11 18
 {
@@ -21,6 +28,9 @@ namespace XHWK.WKTool
21 28
         //private CountdownWindow FileDirectoryWindows = null;  
22 29
         private FolderBrowserDialog Ofd;
23 30
         private DialogResult Result;
31
+        public readonly BlackboardNew myblackboard;
32
+        private System.Windows.Forms.DialogResult result;
33
+        private System.Windows.Forms.OpenFileDialog ofd;
24 34
         #endregion
25 35
 
26 36
         #region 初始化
@@ -30,6 +40,10 @@ namespace XHWK.WKTool
30 40
         public XHMicroLessonSystemWindow()
31 41
         {
32 42
             InitializeComponent();
43
+            myblackboard = new BlackboardNew(blackboard_canvas);
44
+            APP.pageData.pagenum = 1;
45
+            APP.pageData.currpage = 1;
46
+            DataContext = APP.pageData;
33 47
             Initialize();
34 48
         }
35 49
         /// <summary>
@@ -43,6 +57,10 @@ namespace XHWK.WKTool
43 57
             //InkCanvas 通过 DefaultDrawingAttributes 属性来获取墨迹的各种设置,该属性的类型为 DrawingAttributes 型  
44 58
             blackboard_canvas.DefaultDrawingAttributes = drawingAttributes;
45 59
             drawingAttributes.FitToCurve = true;
60
+
61
+            wfhCamera.Visibility = Visibility.Hidden;
62
+
63
+         
46 64
         }
47 65
         #endregion
48 66
 
@@ -96,6 +114,11 @@ namespace XHWK.WKTool
96 114
         /// <param name="e"></param>
97 115
         private void BtnScreenRecording_Click(object sender, RoutedEventArgs e)
98 116
         {
117
+            if(APP.IsLoginType==false)
118
+            {
119
+                Login();
120
+                return;
121
+            }
99 122
             if (APP.W_CountdownWindow == null)
100 123
             {
101 124
                 APP.W_CountdownWindow = new CountdownWindow();
@@ -134,6 +157,11 @@ namespace XHWK.WKTool
134 157
         /// <param name="e"></param>
135 158
         private void BtnUpload_Click(object sender, RoutedEventArgs e)
136 159
         {
160
+            if (APP.IsLoginType == false)
161
+            {
162
+                Login();
163
+                return;
164
+            }
137 165
             FileDirectoryWindow fileDirectoryWindow = new FileDirectoryWindow();
138 166
             fileDirectoryWindow.Show();
139 167
         }
@@ -282,5 +310,317 @@ namespace XHWK.WKTool
282 310
             drawingAttributes.Width = 5;
283 311
             drawingAttributes.Height = 5;
284 312
         }
313
+        /// <summary>
314
+        /// 登陆
315
+        /// </summary>
316
+        /// <param name="sender"></param>
317
+        /// <param name="e"></param>
318
+        private void BtnLoginType_Click(object sender, RoutedEventArgs e)
319
+        {
320
+            Login();
321
+        }
322
+        /// <summary>
323
+        /// 登陆
324
+        /// </summary>
325
+        private void Login()
326
+        {
327
+            if (APP.W_LoginWindow == null)
328
+            {
329
+                APP.W_LoginWindow = new LoginWindow();
330
+
331
+            }
332
+            else
333
+            {
334
+                APP.W_LoginWindow.Initialize();
335
+            }
336
+            APP.W_LoginWindow.ShowDialog();
337
+            if (APP.IsLoginType)
338
+            {
339
+                txbLoginType.Text = APP.UserInfo.Username;
340
+            }
341
+            else
342
+            {
343
+                txbLoginType.Text = "未登录";
344
+            }
345
+        }
346
+        /// <summary>
347
+        /// 截图事件
348
+        /// </summary>
349
+        /// <param name="sender"></param>
350
+        /// <param name="e"></param>
351
+        private void BtnScreenshot_Click(object sender, RoutedEventArgs e)
352
+        {
353
+            if (APP.IsLoginType == false)
354
+            {
355
+                Login();
356
+                return;
357
+            }
358
+        }
359
+        /// <summary>
360
+        /// 导入
361
+        /// </summary>
362
+        /// <param name="sender"></param>
363
+        /// <param name="e"></param>
364
+        private void BtnImport_Click(object sender, RoutedEventArgs e)
365
+        {
366
+            if (APP.IsLoginType == false)
367
+            {
368
+                Login();
369
+                return;
370
+            }
371
+            try
372
+            {
373
+                string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
374
+                ofd = new System.Windows.Forms.OpenFileDialog
375
+                {
376
+                    Filter = "文档|*.docx;*.doc",
377
+                    InitialDirectory = desktopPath,
378
+                    Multiselect = false,
379
+                    AddExtension = true,
380
+                    DereferenceLinks = true
381
+                };
382
+
383
+                new Thread(
384
+                    o =>
385
+                    {
386
+                        Thread.Sleep(400);
387
+                        Dispatcher.Invoke(new Action(() =>
388
+                        {
389
+                            openDialog();
390
+                        }
391
+                            ));
392
+                    })
393
+                {
394
+                    IsBackground = true
395
+                }.Start();
396
+            }
397
+            catch (Exception ex)
398
+            {
399
+                LogHelper.WriteErrLog("【导入(BtnImport_Click)" + ex.Message, ex);
400
+            }
401
+        }
402
+        private void openDialog()
403
+        {
404
+            result = ofd.ShowDialog();
405
+            if (result == System.Windows.Forms.DialogResult.OK)
406
+            {
407
+                if (ofd.FileName != "")
408
+                {
409
+                    string filepath = ofd.FileName;
410
+                    string path = AppDomain.CurrentDomain.BaseDirectory+ "Temp\\";
411
+                    APP.Paths = ConvertWordToImage(filepath, path, "", 0, 0, null, 0).ToArray();
412
+                    if(!string.IsNullOrWhiteSpace(txbCurrpage.Text)&& Convert.ToInt32(txbCurrpage.Text)< APP.Paths.Length)
413
+                    {
414
+                        imgCanvas.Source = new BitmapImage(new Uri(APP.Paths[Convert.ToInt32(txbCurrpage.Text) - 1]));
415
+                    }
416
+                    else
417
+                    {
418
+                        imgCanvas.Source = null;
419
+                    }
420
+                    
421
+                }
422
+            }
423
+        }
424
+        /// <summary>
425
+        /// 录制窗口内容
426
+        /// </summary>
427
+        /// <param name="sender"></param>
428
+        /// <param name="e"></param>
429
+        private void BtnRecord_Click(object sender, RoutedEventArgs e)
430
+        {
431
+            if (APP.IsLoginType == false)
432
+            {
433
+                Login();
434
+                return;
435
+            }
436
+        }
437
+        /// <summary>
438
+        /// 停止录制窗口内容
439
+        /// </summary>
440
+        /// <param name="sender"></param>
441
+        /// <param name="e"></param>
442
+        private void BtnStop_Click(object sender, RoutedEventArgs e)
443
+        {
444
+            if (APP.IsLoginType == false)
445
+            {
446
+                Login();
447
+                return;
448
+            }
449
+        }
450
+        /// <summary>
451
+        /// 增加
452
+        /// </summary>
453
+        /// <param name="sender"></param>
454
+        /// <param name="e"></param>
455
+        private void BtnAdd_Click(object sender, RoutedEventArgs e)
456
+        {
457
+            if (APP.IsLoginType == false)
458
+            {
459
+                Login();
460
+                return;
461
+            }
462
+        }
463
+        /// <summary>
464
+        /// 打印
465
+        /// </summary>
466
+        /// <param name="sender"></param>
467
+        /// <param name="e"></param>
468
+        private void BtnPrint_Click(object sender, RoutedEventArgs e)
469
+        {
470
+
471
+        }
472
+        /// <summary>
473
+        /// 我的
474
+        /// </summary>
475
+        /// <param name="sender"></param>
476
+        /// <param name="e"></param>
477
+        private void BtnMyMine_Click(object sender, RoutedEventArgs e)
478
+        {
479
+            if (APP.IsLoginType == false)
480
+            {
481
+                Login();
482
+                return;
483
+            }
484
+        }
485
+        /// <summary>
486
+        /// 上一页
487
+        /// </summary>
488
+        /// <param name="sender"></param>
489
+        /// <param name="e"></param>
490
+        private void last_button_Click(object sender, RoutedEventArgs e)
491
+        {
492
+            if (APP.pageData.currpage > 1)
493
+            {
494
+                APP.pageData.currpage -= 1;
495
+                myblackboard.changepage(APP.pageData.currpage - 1);
496
+                if(APP.Paths.Length>0)
497
+                {
498
+                    if (!string.IsNullOrWhiteSpace(txbCurrpage.Text) && Convert.ToInt32(txbCurrpage.Text) < APP.Paths.Length&& Convert.ToInt32(txbCurrpage.Text)>1)
499
+                    {
500
+                        imgCanvas.Source = new BitmapImage(new Uri(APP.Paths[Convert.ToInt32(txbCurrpage.Text) - 2]));
501
+                    }
502
+                    else
503
+                    {
504
+                        imgCanvas.Source = null;
505
+                    }
506
+                }
507
+            }
508
+            
509
+        }
510
+        /// <summary>
511
+        /// 下一页
512
+        /// </summary>
513
+        /// <param name="sender"></param>
514
+        /// <param name="e"></param>
515
+        private void next_btn_Click(object sender, RoutedEventArgs e)
516
+        {
517
+            if (APP.pageData.currpage < APP.pageData.pagenum)
518
+            {
519
+                APP.pageData.currpage += 1;
520
+                myblackboard.changepage(APP.pageData.currpage - 1);
521
+                if (APP.Paths.Length > 0)
522
+                {
523
+                    if (!string.IsNullOrWhiteSpace(txbCurrpage.Text) && Convert.ToInt32(txbCurrpage.Text)+1 < APP.Paths.Length)
524
+                    {
525
+                        imgCanvas.Source = new BitmapImage(new Uri(APP.Paths[Convert.ToInt32(txbCurrpage.Text) ]));
526
+                    }
527
+                    else
528
+                    {
529
+                        imgCanvas.Source = null;
530
+                    }
531
+                }
532
+            }
533
+        }
534
+        /// <summary>
535
+        /// 添加
536
+        /// </summary>
537
+        /// <param name="sender"></param>
538
+        /// <param name="e"></param>
539
+        private void add_button_Click(object sender, RoutedEventArgs e)
540
+        {
541
+            APP.pageData.pagenum += 1;
542
+            APP.pageData.currpage = APP.pageData.pagenum;
543
+            myblackboard.changepage(APP.pageData.currpage - 1);
544
+        }
545
+        /// <summary>
546
+        /// 将Word文档转换为图片的方法(该方法基于第三方DLL),你可以像这样调用该方法: ConvertPDF2Image("F:\\PdfFile.doc", "F:\\",
547
+        /// "ImageFile", 1, 20, ImageFormat.Png, 256);
548
+        /// </summary>
549
+        /// <param name="pdfInputPath">Word文件路径</param>
550
+        /// <param name="imageOutputPath">图片输出路径,如果为空,默认值为Word所在路径</param>
551
+        /// <param name="imageName">图片的名字,不需要带扩展名,如果为空,默认值为Word的名称</param>
552
+        /// <param name="startPageNum">从PDF文档的第几页开始转换,如果为0,默认值为1</param>
553
+        /// <param name="endPageNum">从PDF文档的第几页开始停止转换,如果为0,默认值为Word总页数</param>
554
+        /// <param name="imageFormat">设置所需图片格式,如果为null,默认格式为PNG</param>
555
+        /// <param name="resolution">设置图片的像素,数字越大越清晰,如果为0,默认值为128,建议最大值不要超过1024</param>
556
+        public List<string> ConvertWordToImage(string wordInputPath, string imageOutputPath,
557
+            string imageName, int startPageNum, int endPageNum, ImageFormat imageFormat, float resolution)
558
+        {
559
+            // 返回的图片绝对路径集合
560
+            List<string> images = new List<string>();
561
+            try
562
+            {
563
+                // open word file
564
+                Aspose.Words.Document doc = new Aspose.Words.Document(wordInputPath);
565
+                // validate parameter
566
+                if (doc == null) { throw new Exception("Word文件无效或者Word文件被加密!"); }
567
+                if (imageOutputPath.Trim().Length == 0) { imageOutputPath = Path.GetDirectoryName(wordInputPath); }
568
+                if (!Directory.Exists(imageOutputPath)) { Directory.CreateDirectory(imageOutputPath); }
569
+                if (imageName.Trim().Length == 0) { imageName = Path.GetFileNameWithoutExtension(wordInputPath); }
570
+                if (startPageNum <= 0) { startPageNum = 1; }
571
+                if (endPageNum > doc.PageCount || endPageNum <= 0) { endPageNum = doc.PageCount; }
572
+                if (startPageNum > endPageNum) { int tempPageNum = startPageNum; startPageNum = endPageNum; endPageNum = startPageNum; }
573
+                if (imageFormat == null) { imageFormat = ImageFormat.Png; }
574
+                if (resolution <= 0) { resolution = 128; }
575
+
576
+                ImageSaveOptions imageSaveOptions = new ImageSaveOptions(GetSaveFormat(imageFormat))
577
+                {
578
+                    Resolution = resolution
579
+                };
580
+
581
+                // start to convert each page
582
+                for (int i = startPageNum; i <= endPageNum; i++)
583
+                {
584
+                    imageSaveOptions.PageIndex = i - 1;
585
+                    doc.Save(Path.Combine(imageOutputPath, imageName) + "_" + APP.num.ToString() + "." + imageFormat.ToString(), imageSaveOptions);
586
+                    images.Add(Path.Combine(imageOutputPath, imageName) + "_" + APP.num.ToString() + "." + imageFormat.ToString());
587
+                    APP.num++;
588
+                }
589
+                imageSaveOptions = null;
590
+                doc = null;
591
+            }
592
+            catch (Exception ex)
593
+            {
594
+                System.Windows.MessageBox.Show("文档已打开,请关闭后重试!");
595
+                LogHelper.WriteErrLog("【课堂考试(ExamWindow)】错误日志:" + ex.Message, ex);
596
+            }
597
+            return images;
598
+        }
599
+        private static SaveFormat GetSaveFormat(ImageFormat imageFormat)
600
+        {
601
+            SaveFormat sf;// = SaveFormat.Unknown;
602
+            if (imageFormat.Equals(ImageFormat.Png))
603
+            {
604
+                sf = SaveFormat.Png;
605
+            }
606
+            else if (imageFormat.Equals(ImageFormat.Jpeg))
607
+            {
608
+                sf = SaveFormat.Jpeg;
609
+            }
610
+            else if (imageFormat.Equals(ImageFormat.Tiff))
611
+            {
612
+                sf = SaveFormat.Tiff;
613
+            }
614
+            else if (imageFormat.Equals(ImageFormat.Bmp))
615
+            {
616
+                sf = SaveFormat.Bmp;
617
+            }
618
+            else
619
+            {
620
+                sf = SaveFormat.Unknown;
621
+            }
622
+
623
+            return sf;
624
+        }
285 625
     }
286 626
 }

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

@@ -53,10 +53,14 @@
53 53
     <Reference Include="AForge.Video.DirectShow, Version=2.2.5.0, Culture=neutral, PublicKeyToken=61ea4348d43881b7, processorArchitecture=MSIL">
54 54
       <HintPath>..\packages\AForge.Video.DirectShow.2.2.5\lib\AForge.Video.DirectShow.dll</HintPath>
55 55
     </Reference>
56
+    <Reference Include="Aspose.Words">
57
+      <HintPath>..\dl\Aspose.Words.dll</HintPath>
58
+    </Reference>
56 59
     <Reference Include="log4net">
57 60
       <HintPath>..\Common\dlls\log4net.dll</HintPath>
58 61
     </Reference>
59 62
     <Reference Include="System" />
63
+    <Reference Include="System.Configuration" />
60 64
     <Reference Include="System.Data" />
61 65
     <Reference Include="System.Drawing" />
62 66
     <Reference Include="System.Windows.Forms" />
@@ -81,6 +85,8 @@
81 85
     <Compile Include="CountdownWindow.xaml.cs">
82 86
       <DependentUpon>CountdownWindow.xaml</DependentUpon>
83 87
     </Compile>
88
+    <Compile Include="DAL\Interface.cs" />
89
+    <Compile Include="DAL\ResultVo.cs" />
84 90
     <Compile Include="FileDirectoryWindow.xaml.cs">
85 91
       <DependentUpon>FileDirectoryWindow.xaml</DependentUpon>
86 92
     </Compile>
@@ -236,5 +242,10 @@
236 242
     <Resource Include="Images\Toobar8.png" />
237 243
     <Resource Include="Images\Toobar9.png" />
238 244
   </ItemGroup>
245
+  <ItemGroup>
246
+    <Resource Include="Images\class_p1.png" />
247
+    <Resource Include="Images\class_p2.png" />
248
+    <Resource Include="Images\class_p3.png" />
249
+  </ItemGroup>
239 250
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
240 251
 </Project>

BIN
dl/Aspose.Words.dll View File


BIN
dl/Clear.Framework.dll View File


Loading…
Cancel
Save