Browse Source

zhao:修改计时器,解决长时间录屏计时不准

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

+ 37
- 12
XHWK.WKTool/ScreenRecordingToolbarWindow.xaml.cs View File

56
         /// 状态
56
         /// 状态
57
         /// </summary>
57
         /// </summary>
58
         private State _state = State.End;
58
         private State _state = State.End;
59
-        /// <summary>
60
-        /// 计时用
61
-        /// </summary>
62
-        private TimeSpan _timeSpan = new TimeSpan(0, 0, 0, 0, 0);
59
+        
63
         private KeyboardHookCommon k_hook;
60
         private KeyboardHookCommon k_hook;
64
         /// <summary>
61
         /// <summary>
65
         /// 🖊状态 0红色 1蓝色 10红色批注内 11蓝色批注内
62
         /// 🖊状态 0红色 1蓝色 10红色批注内 11蓝色批注内
145
             {
142
             {
146
                 t = new DispatcherTimer();
143
                 t = new DispatcherTimer();
147
                 t.Tick += OnTimer;
144
                 t.Tick += OnTimer;
148
-                t.Interval = new TimeSpan(0, 0, 0, 1);
145
+                t.Interval = new TimeSpan(0, 0, 0,0, 300);
149
                 t.IsEnabled = true;
146
                 t.IsEnabled = true;
150
                 t.Start();
147
                 t.Start();
151
             }
148
             }
152
-            t.Interval = new TimeSpan(0, 0, 0, 1);
149
+            t.Interval = new TimeSpan(0, 0, 0, 0,300);
153
             //Stack();
150
             //Stack();
154
             //ImgRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar25.png"));
151
             //ImgRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar25.png"));
155
             //BtnRecordingScreen_Click(null, null);
152
             //BtnRecordingScreen_Click(null, null);
199
 
196
 
200
         #region 事件
197
         #region 事件
201
         /// <summary>
198
         /// <summary>
199
+        /// 记录上次执行时间
200
+        /// </summary>
201
+        private DateTime Recorddt = DateTime.Now;
202
+        DateTime SRTime = Convert.ToDateTime("2020-01-01 00:00:00");
203
+        /// <summary>
202
         /// 时钟回调
204
         /// 时钟回调
203
         /// </summary>
205
         /// </summary>
204
         /// <param name="sender"></param>
206
         /// <param name="sender"></param>
209
             {
211
             {
210
                 case State.Start:
212
                 case State.Start:
211
                     {
213
                     {
212
-                        _timeSpan += new TimeSpan(0, 0, 0, 1);
214
+                        DateTime dt = DateTime.Now;
215
+                        TimeSpan ts = dt.Subtract(Recorddt);//时间差   
216
+                        double tsmi = ts.TotalMilliseconds;
217
+                        if (tsmi > 500.0)
218
+                        {
219
+                            Recorddt = Recorddt.AddMilliseconds(500);
220
+                            SRTime = SRTime.AddMilliseconds(500);
221
+                        }
213
                     }
222
                     }
214
                     break;
223
                     break;
215
 
224
 
220
 
229
 
221
                 case State.End:
230
                 case State.End:
222
                     {
231
                     {
223
-                        _timeSpan = new TimeSpan();
224
-                        //_timeSpan = new TimeSpan(0, 23, 12, 45, 54);
232
+                        SRTime = Convert.ToDateTime("2020-01-01 00:00:00");
233
+                        //_timeSpan = new TimeSpan();
234
+                        ////_timeSpan = new TimeSpan(0, 23, 12, 45, 54);
225
                     }
235
                     }
226
                     break;
236
                     break;
227
             }
237
             }
228
 
238
 
229
-            string time = string.Format("{0:D2}:{1:D2}",/* _timeSpan.Hours,*/ _timeSpan.Minutes, _timeSpan.Seconds);
239
+            //string time = string.Format("{0:D2}:{1:D2}",/* _timeSpan.Hours,*/ _timeSpan.Minutes, _timeSpan.Seconds);
230
             //char[] times = time.ToCharArray();
240
             //char[] times = time.ToCharArray();
231
-            txbTime.Text = time;
241
+            if (SRTime.Hour > 0)
242
+            {
243
+                //Dispatcher.Invoke(() =>
244
+                //{
245
+                txbTime.Text = SRTime.ToString("HH:mm:ss");
246
+                //});
247
+            }
248
+            else
249
+            {
250
+                //Dispatcher.Invoke(() =>
251
+                //{
252
+                txbTime.Text = SRTime.ToString("mm:ss");
253
+                //});
254
+            }
232
         }
255
         }
256
+
233
         /// <summary>
257
         /// <summary>
234
         /// 开始
258
         /// 开始
235
         /// </summary>
259
         /// </summary>
237
         /// <param name="e"></param>
261
         /// <param name="e"></param>
238
         private void Stack()
262
         private void Stack()
239
         {
263
         {
264
+            Recorddt = DateTime.Now;
240
             _state = State.Start;
265
             _state = State.Start;
241
         }
266
         }
242
         /// <summary>
267
         /// <summary>
556
             {
581
             {
557
                 try
582
                 try
558
                 {
583
                 {
559
-                    if (_timeSpan.Minutes > 0 || _timeSpan.Seconds > 3)
584
+                    if (SRTime.Hour > 0 || SRTime.Minute > 0 || SRTime.Second > 3)
560
                     {
585
                     {
561
                         try
586
                         try
562
                         {
587
                         {

+ 0
- 93
XHWK.WKTool/XHMicroLessonSystemWindow.xaml.cs View File

265
             }
265
             }
266
         }
266
         }
267
 
267
 
268
-        /// <summary>
269
-        /// 开始
270
-        /// </summary>
271
-        /// <param name="sender"></param>
272
-        /// <param name="e"></param>
273
-        private void Stack()
274
-        {
275
-            _state = State.Start;
276
-        }
277
-        /// <summary>
278
-        /// 暂停
279
-        /// </summary>
280
-        private void TimeOut()
281
-        {
282
-            _state = State.Pause;
283
-        }
284
-        /// <summary>
285
-        /// 结束
286
-        /// </summary>
287
-        /// <param name="sender"></param>
288
-        /// <param name="e"></param>
289
-        private void End()
290
-        {
291
-            _state = State.End;
292
-        }
293
-        /// <summary>
294
-        /// 时钟回调
295
-        /// </summary>
296
-        /// <param name="sender"></param>
297
-        /// <param name="e"></param>
298
-        private void OnTimer(object sender, EventArgs e)
299
-        {
300
-            switch (_state)
301
-            {
302
-                case State.Start:
303
-                    {
304
-                        _timeSpan += new TimeSpan(0, 0, 0, 1);
305
-                    }
306
-                    break;
307
-
308
-                case State.Pause:
309
-                    {
310
-                    }
311
-                    break;
312
-
313
-                case State.End:
314
-                    {
315
-                        _timeSpan = new TimeSpan();
316
-                        //_timeSpan = new TimeSpan(0, 23, 12, 45, 54);
317
-                    }
318
-                    break;
319
-            }
320
-
321
-            string time = string.Format("{0:D2}:{1:D2}",/* _timeSpan.Hours,*/ _timeSpan.Minutes, _timeSpan.Seconds);
322
-            txbTime.Text = time;
323
-            //txbTime.Text = time;
324
-        }
325
-        /// <summary>
326
-        /// 修改布局
327
-        /// </summary>
328
-        public void SetUpLayout()
329
-        {
330
-            //宽高比1276,1040
331
-            //double AspectRatio = 1276.0 / 1040.0;
332
-            ////System.Drawing.Size des = PrimaryScreen.DESKTOP;
333
-            //System.Drawing.Size workingArea = PrimaryScreen.WorkingArea;
334
-            //this.Height = workingArea.Height;
335
-
336
-        }
337
         #endregion
268
         #endregion
338
 
269
 
339
         #region 事件
270
         #region 事件
347
             DragMove();
278
             DragMove();
348
         }
279
         }
349
 
280
 
350
-
351
         #region 摄像头
281
         #region 摄像头
352
         private System.Timers.Timer times;
282
         private System.Timers.Timer times;
353
         private List<string> RbnOpen;
283
         private List<string> RbnOpen;
2930
                     }
2860
                     }
2931
                     #endregion
2861
                     #endregion
2932
 
2862
 
2933
-                    #region 计时器初始化
2934
-
2935
-                    //if (t == null)
2936
-                    //{
2937
-                    //    t = new DispatcherTimer();
2938
-                    //    t.Tick += OnTimer;
2939
-                    //    t.Interval = new TimeSpan(0, 0, 0, 1);
2940
-                    //    t.IsEnabled = true;
2941
-                    //    t.Start();
2942
-                    //}
2943
-                    //t.Interval = new TimeSpan(0, 0, 0, 1);
2944
                     txbTime.Visibility = Visibility.Visible;
2863
                     txbTime.Visibility = Visibility.Visible;
2945
-                    #endregion
2946
 
2864
 
2947
                     VideoInfo = new Model_Video
2865
                     VideoInfo = new Model_Video
2948
                     {
2866
                     {
4670
             }
4588
             }
4671
         }
4589
         }
4672
         /// <summary>
4590
         /// <summary>
4673
-        /// 位置确定
4674
-        /// </summary>
4675
-        /// <param name="sender"></param>
4676
-        /// <param name="e"></param>
4677
-        private void BtnOk_Click(object sender, RoutedEventArgs e)
4678
-        {
4679
-            //APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation = true;
4680
-            //btnOk.Visibility = Visibility.Collapsed;
4681
-            //blackboard_canvas.Visibility = Visibility.Visible;
4682
-        }
4683
-        /// <summary>
4684
         /// 引用user32.dll动态链接库(windows api),
4591
         /// 引用user32.dll动态链接库(windows api),
4685
         /// 使用库中定义 API:SetCursorPos
4592
         /// 使用库中定义 API:SetCursorPos
4686
         /// 设置光标位置
4593
         /// 设置光标位置

Loading…
Cancel
Save