|
@@ -2191,9 +2191,9 @@ namespace XHWK.WKTool
|
2191
|
2191
|
#endregion
|
2192
|
2192
|
IsFirstR = false;
|
2193
|
2193
|
RsImgName = new List<string>();
|
2194
|
|
- ///启动截图
|
2195
|
|
- timer = new System.Threading.Timer(new TimerCallback(Timer_Elapsed), null, 0, 200);
|
2196
|
2194
|
SRTime = Convert.ToDateTime("2020-01-01 00:00:00");
|
|
2195
|
+ ///启动截图
|
|
2196
|
+ timer = new System.Threading.Timer(new TimerCallback(Timer_Elapsed), null, 0, 20);
|
2197
|
2197
|
//{
|
2198
|
2198
|
// AutoReset = true//设置是否执行System.Timers.Timer.Elapsed事件
|
2199
|
2199
|
//};//设置执行一次(false)还是一直执行(true)
|
|
@@ -2233,6 +2233,7 @@ namespace XHWK.WKTool
|
2233
|
2233
|
Thread.Sleep(1000);
|
2234
|
2234
|
Dispatcher.Invoke(() =>
|
2235
|
2235
|
{
|
|
2236
|
+ Recorddt = DateTime.Now;
|
2236
|
2237
|
IsStartCount = true;
|
2237
|
2238
|
//Stack();
|
2238
|
2239
|
//timer.Start();
|
|
@@ -2288,38 +2289,70 @@ namespace XHWK.WKTool
|
2288
|
2289
|
}
|
2289
|
2290
|
}
|
2290
|
2291
|
/// <summary>
|
2291
|
|
- /// 录制保存图片
|
|
2292
|
+ /// 记录上次截图时间
|
|
2293
|
+ /// </summary>
|
|
2294
|
+ DateTime Recorddt = DateTime.Now;
|
|
2295
|
+ /// <summary>
|
|
2296
|
+ /// 录制保存图片计时器
|
2292
|
2297
|
/// </summary>
|
2293
|
2298
|
/// <param name="sender"></param>
|
2294
|
2299
|
private void Timer_Elapsed(object sender)
|
2295
|
2300
|
{
|
2296
|
2301
|
if (IsStartCount)
|
2297
|
2302
|
{
|
2298
|
|
- try
|
|
2303
|
+ DateTime dt = DateTime.Now;
|
|
2304
|
+ TimeSpan ts = dt.Subtract(Recorddt);//时间差
|
|
2305
|
+ double tsmi = ts.TotalMilliseconds;
|
|
2306
|
+ if (tsmi > 200.0)
|
2299
|
2307
|
{
|
2300
|
|
- Dispatcher.Invoke(() =>
|
|
2308
|
+ Recorddt = Recorddt.AddMilliseconds(200);
|
|
2309
|
+ Thread thread = new Thread(RecordSaveImage);
|
|
2310
|
+ //开启线程
|
|
2311
|
+ thread.Start();
|
|
2312
|
+ }
|
|
2313
|
+ }
|
|
2314
|
+ }
|
|
2315
|
+ /// <summary>
|
|
2316
|
+ /// 录制保存图片
|
|
2317
|
+ /// </summary>
|
|
2318
|
+ void RecordSaveImage()
|
|
2319
|
+ {
|
|
2320
|
+ try
|
|
2321
|
+ {
|
|
2322
|
+ Dispatcher.Invoke(() =>
|
|
2323
|
+ {
|
|
2324
|
+ if (IsStartCount)
|
2301
|
2325
|
{
|
2302
|
2326
|
string FilePathName = ImgPath + RsImgName.Count + ".png";
|
2303
|
2327
|
RsImgName.Add(FilePathName);
|
2304
|
|
- ImageHelper.SaveUIToImage(GridMain, FilePathName, (int)ActualWidth, (int)ActualHeight);
|
2305
|
|
- SRTime=SRTime.AddMilliseconds(200);
|
|
2328
|
+ ImageHelper.SaveUIToImage(GridMain, FilePathName, (int)(ActualWidth * (PrimaryScreen.DpiX / 96f)), (int)(ActualHeight * (PrimaryScreen.DpiY / 96f)));
|
|
2329
|
+ SRTime = SRTime.AddMilliseconds(200);
|
|
2330
|
+ if (txbTime.Visibility == Visibility.Hidden)
|
|
2331
|
+ {
|
|
2332
|
+ txbTime.Visibility = Visibility.Visible;
|
|
2333
|
+ }
|
2306
|
2334
|
if (SRTime.Hour > 0)
|
2307
|
2335
|
{
|
|
2336
|
+ //Dispatcher.Invoke(() =>
|
|
2337
|
+ //{
|
2308
|
2338
|
txbTime.Text = SRTime.ToString("HH:mm:ss");
|
|
2339
|
+ //});
|
2309
|
2340
|
}
|
2310
|
2341
|
else
|
2311
|
2342
|
{
|
|
2343
|
+ //Dispatcher.Invoke(() =>
|
|
2344
|
+ //{
|
2312
|
2345
|
txbTime.Text = SRTime.ToString("mm:ss");
|
|
2346
|
+ //});
|
2313
|
2347
|
}
|
2314
|
|
- });
|
2315
|
|
- }
|
2316
|
|
- catch (Exception ex)
|
2317
|
|
- {
|
2318
|
|
- LogHelper.WriteErrLog("【录制】(Timer_Elapsed)生成图片错误:" + ex.Message, ex);
|
2319
|
|
- }
|
|
2348
|
+ }
|
|
2349
|
+ });
|
|
2350
|
+ }
|
|
2351
|
+ catch (Exception ex)
|
|
2352
|
+ {
|
|
2353
|
+ LogHelper.WriteErrLog("【录制】(Timer_Elapsed)生成图片错误:" + ex.Message, ex);
|
2320
|
2354
|
}
|
2321
|
2355
|
}
|
2322
|
|
-
|
2323
|
2356
|
/// <summary>
|
2324
|
2357
|
/// 停止录制并生成录制文件
|
2325
|
2358
|
/// </summary>
|
|
@@ -2412,6 +2445,7 @@ namespace XHWK.WKTool
|
2412
|
2445
|
APP.FFmpeg.StopFFmpeg(AudioPathName);
|
2413
|
2446
|
new Thread(new ThreadStart(new Action(() =>
|
2414
|
2447
|
{
|
|
2448
|
+ IsStartCount = false;
|
2415
|
2449
|
//停止截图
|
2416
|
2450
|
while (APP.FFmpeg.myProcess != null)
|
2417
|
2451
|
{
|
|
@@ -2419,7 +2453,6 @@ namespace XHWK.WKTool
|
2419
|
2453
|
}
|
2420
|
2454
|
Dispatcher.Invoke(() =>
|
2421
|
2455
|
{
|
2422
|
|
- IsStartCount = false;
|
2423
|
2456
|
timer.Change(-1, 0);
|
2424
|
2457
|
timer.Dispose();
|
2425
|
2458
|
//End();
|
|
@@ -4059,5 +4092,11 @@ namespace XHWK.WKTool
|
4059
|
4092
|
{
|
4060
|
4093
|
Thread.Sleep(2000);
|
4061
|
4094
|
}
|
|
4095
|
+
|
|
4096
|
+ private void Button_Click_2(object sender, RoutedEventArgs e)
|
|
4097
|
+ {
|
|
4098
|
+
|
|
4099
|
+ MessageWindow.Show("A:"+ActualWidth*(PrimaryScreen.DpiX / 96f)+"x" +ActualHeight * (PrimaryScreen.DpiY / 96f) + " wh:"+Width+"x"+Height);
|
|
4100
|
+ }
|
4062
|
4101
|
}
|
4063
|
4102
|
}
|