Kaynağa Gözat

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

tags/录制修改前
耀 4 yıl önce
ebeveyn
işleme
8d078f3d06

+ 37
- 12
XHWK.WKTool/ScreenRecordingToolbarWindow.xaml.cs Dosyayı Görüntüle

@@ -56,10 +56,7 @@ namespace XHWK.WKTool
56 56
         /// 状态
57 57
         /// </summary>
58 58
         private State _state = State.End;
59
-        /// <summary>
60
-        /// 计时用
61
-        /// </summary>
62
-        private TimeSpan _timeSpan = new TimeSpan(0, 0, 0, 0, 0);
59
+        
63 60
         private KeyboardHookCommon k_hook;
64 61
         /// <summary>
65 62
         /// 🖊状态 0红色 1蓝色 10红色批注内 11蓝色批注内
@@ -145,11 +142,11 @@ namespace XHWK.WKTool
145 142
             {
146 143
                 t = new DispatcherTimer();
147 144
                 t.Tick += OnTimer;
148
-                t.Interval = new TimeSpan(0, 0, 0, 1);
145
+                t.Interval = new TimeSpan(0, 0, 0,0, 300);
149 146
                 t.IsEnabled = true;
150 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 150
             //Stack();
154 151
             //ImgRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar25.png"));
155 152
             //BtnRecordingScreen_Click(null, null);
@@ -199,6 +196,11 @@ namespace XHWK.WKTool
199 196
 
200 197
         #region 事件
201 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 205
         /// </summary>
204 206
         /// <param name="sender"></param>
@@ -209,7 +211,14 @@ namespace XHWK.WKTool
209 211
             {
210 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 223
                     break;
215 224
 
@@ -220,16 +229,31 @@ namespace XHWK.WKTool
220 229
 
221 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 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 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 257
         /// <summary>
234 258
         /// 开始
235 259
         /// </summary>
@@ -237,6 +261,7 @@ namespace XHWK.WKTool
237 261
         /// <param name="e"></param>
238 262
         private void Stack()
239 263
         {
264
+            Recorddt = DateTime.Now;
240 265
             _state = State.Start;
241 266
         }
242 267
         /// <summary>
@@ -556,7 +581,7 @@ namespace XHWK.WKTool
556 581
             {
557 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 586
                         try
562 587
                         {

+ 0
- 93
XHWK.WKTool/XHMicroLessonSystemWindow.xaml.cs Dosyayı Görüntüle

@@ -265,75 +265,6 @@ namespace XHWK.WKTool
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 268
         #endregion
338 269
 
339 270
         #region 事件
@@ -347,7 +278,6 @@ namespace XHWK.WKTool
347 278
             DragMove();
348 279
         }
349 280
 
350
-
351 281
         #region 摄像头
352 282
         private System.Timers.Timer times;
353 283
         private List<string> RbnOpen;
@@ -2930,19 +2860,7 @@ namespace XHWK.WKTool
2930 2860
                     }
2931 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 2863
                     txbTime.Visibility = Visibility.Visible;
2945
-                    #endregion
2946 2864
 
2947 2865
                     VideoInfo = new Model_Video
2948 2866
                     {
@@ -4670,17 +4588,6 @@ namespace XHWK.WKTool
4670 4588
             }
4671 4589
         }
4672 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 4591
         /// 引用user32.dll动态链接库(windows api),
4685 4592
         /// 使用库中定义 API:SetCursorPos
4686 4593
         /// 设置光标位置

Loading…
İptal
Kaydet