mirror of
https://github.com/kangyu-california/PersistentWindows.git
synced 2025-05-11 04:55:39 +02:00
dump dead window history together with live windows
This commit is contained in:
parent
f6007a4b62
commit
2763659b4c
1 changed files with 23 additions and 5 deletions
|
@ -216,12 +216,30 @@ namespace PersistentWindows.Common
|
||||||
File.WriteAllText(Path.Combine(appDataFolder, snapshotTimeFile), xml2, Encoding.Unicode);
|
File.WriteAllText(Path.Combine(appDataFolder, snapshotTimeFile), xml2, Encoding.Unicode);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void WriteDataDumpCore()
|
private void WriteDataDumpCore(bool dump_dead_window)
|
||||||
{
|
{
|
||||||
DataContractSerializer dcs = new DataContractSerializer(typeof(Dictionary<string, Dictionary<IntPtr, List<ApplicationDisplayMetrics>>>));
|
DataContractSerializer dcs = new DataContractSerializer(typeof(Dictionary<string, Dictionary<IntPtr, List<ApplicationDisplayMetrics>>>));
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
using (XmlWriter xw = XmlWriter.Create(sb))
|
using (XmlWriter xw = XmlWriter.Create(sb))
|
||||||
{
|
{
|
||||||
|
if (dump_dead_window)
|
||||||
|
{
|
||||||
|
var allApps = monitorApplications;
|
||||||
|
foreach (var display_key in deadApps.Keys)
|
||||||
|
{
|
||||||
|
foreach (var hwnd in deadApps[display_key].Keys)
|
||||||
|
{
|
||||||
|
if (!monitorApplications.ContainsKey(display_key))
|
||||||
|
continue;
|
||||||
|
if (monitorApplications[display_key].ContainsKey(hwnd))
|
||||||
|
continue;
|
||||||
|
allApps[display_key][hwnd] = deadApps[display_key][hwnd];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dcs.WriteObject(xw, allApps);
|
||||||
|
}
|
||||||
|
else
|
||||||
dcs.WriteObject(xw, monitorApplications);
|
dcs.WriteObject(xw, monitorApplications);
|
||||||
}
|
}
|
||||||
string xml = sb.ToString();
|
string xml = sb.ToString();
|
||||||
|
@ -229,12 +247,12 @@ namespace PersistentWindows.Common
|
||||||
|
|
||||||
DumpSnapshotTakenTime();
|
DumpSnapshotTakenTime();
|
||||||
}
|
}
|
||||||
public void WriteDataDump()
|
public void WriteDataDump(bool dump_dead_window = true)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (dumpDataWhenExit)
|
if (dumpDataWhenExit)
|
||||||
WriteDataDumpCore();
|
WriteDataDumpCore(dump_dead_window);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -628,7 +646,7 @@ namespace PersistentWindows.Common
|
||||||
|
|
||||||
if (!wasRestoringSnapshot && !wasRestoringFromDB)
|
if (!wasRestoringSnapshot && !wasRestoringFromDB)
|
||||||
{
|
{
|
||||||
WriteDataDump();
|
WriteDataDump(dump_dead_window : false);
|
||||||
|
|
||||||
if (!snapshotTakenTime.ContainsKey(curDisplayKey))
|
if (!snapshotTakenTime.ContainsKey(curDisplayKey))
|
||||||
snapshotTakenTime[curDisplayKey] = new Dictionary<int, DateTime>();
|
snapshotTakenTime[curDisplayKey] = new Dictionary<int, DateTime>();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue