mirror of
https://github.com/kangyu-california/PersistentWindows.git
synced 2025-05-11 04:55:39 +02:00
refactor UndoCapture(DateTime)
This commit is contained in:
parent
b13bcf0b58
commit
eade031052
1 changed files with 20 additions and 15 deletions
|
@ -719,21 +719,8 @@ namespace PersistentWindows.Common
|
|||
string displayKey = GetDisplayKey();
|
||||
Log.Event("Display settings changed {0}", displayKey);
|
||||
|
||||
// undo disqualified capture time
|
||||
if (snapshotTakenTime.ContainsKey(curDisplayKey) && snapshotTakenTime[curDisplayKey].ContainsKey(MaxSnapshots))
|
||||
{
|
||||
var lastCaptureTime = snapshotTakenTime[curDisplayKey][MaxSnapshots];
|
||||
var diff = lastDisplayChangeTime - lastCaptureTime;
|
||||
if (diff.TotalMilliseconds < CaptureLatency)
|
||||
{
|
||||
if (snapshotTakenTime[curDisplayKey].ContainsKey(MaxSnapshots + 1))
|
||||
{
|
||||
snapshotTakenTime[curDisplayKey][MaxSnapshots] = snapshotTakenTime[curDisplayKey][MaxSnapshots + 1];
|
||||
Log.Error("undo capture of {0} at {1}", curDisplayKey, lastCaptureTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// rewind disqualified capture time
|
||||
UndoCapture(lastDisplayChangeTime);
|
||||
|
||||
{
|
||||
EndDisplaySession();
|
||||
|
@ -2499,6 +2486,24 @@ namespace PersistentWindows.Common
|
|||
return null;
|
||||
}
|
||||
|
||||
private void UndoCapture(DateTime ref_time)
|
||||
{
|
||||
// rewind disqualified capture time
|
||||
if (snapshotTakenTime.ContainsKey(curDisplayKey) && snapshotTakenTime[curDisplayKey].ContainsKey(MaxSnapshots))
|
||||
{
|
||||
var lastCaptureTime = snapshotTakenTime[curDisplayKey][MaxSnapshots];
|
||||
var diff = ref_time - lastCaptureTime;
|
||||
if (diff.TotalMilliseconds < CaptureLatency)
|
||||
{
|
||||
if (snapshotTakenTime[curDisplayKey].ContainsKey(MaxSnapshots + 1))
|
||||
{
|
||||
snapshotTakenTime[curDisplayKey][MaxSnapshots] = snapshotTakenTime[curDisplayKey][MaxSnapshots + 1];
|
||||
Log.Error("undo capture of {0} at {1}", curDisplayKey, lastCaptureTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CaptureApplicationsOnCurrentDisplays(string displayKey, bool saveToDB = false, bool immediateCapture = false)
|
||||
{
|
||||
User32.SetThreadDpiAwarenessContextSafe(User32.DPI_AWARENESS_CONTEXT_UNAWARE);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue