mirror of
https://github.com/kangyu-california/PersistentWindows.git
synced 2025-05-11 04:55:39 +02:00
1. Fixing some logging stuff
2. Fixing freeze lock at startup 3. More diagnostics
This commit is contained in:
parent
bca5ea398c
commit
90885bf9ba
3 changed files with 20 additions and 9 deletions
|
@ -19,15 +19,15 @@ namespace Ninjacrab.PersistentWindows.WpfShell.Diagnostics
|
|||
config.AddTarget("file", fileTarget);
|
||||
|
||||
// Step 3. Set target properties
|
||||
consoleTarget.Layout = @"${date:format=HH\\:MM\\:ss} ${logger} ${message}";
|
||||
consoleTarget.Layout = @"${date:format=HH\\:mm\\:ss} ${logger} ${message}";
|
||||
fileTarget.FileName = "${basedir}/PersistentWindows.Log";
|
||||
fileTarget.Layout = "${message}";
|
||||
fileTarget.Layout = "${date:format=HH\\:mm\\:ss} ${logger} ${message}";
|
||||
|
||||
// Step 4. Define rules
|
||||
var rule1 = new LoggingRule("*", LogLevel.Trace, consoleTarget);
|
||||
config.LoggingRules.Add(rule1);
|
||||
|
||||
var rule2 = new LoggingRule("*", LogLevel.Debug, fileTarget);
|
||||
var rule2 = new LoggingRule("*", LogLevel.Trace, fileTarget);
|
||||
config.LoggingRules.Add(rule2);
|
||||
|
||||
// Step 5. Activate the configuration
|
||||
|
|
|
@ -22,5 +22,10 @@ namespace Ninjacrab.PersistentWindows.WpfShell.Models
|
|||
&& this.WindowPlacement.NormalPosition.Width == other.WindowPlacement.NormalPosition.Width
|
||||
&& this.WindowPlacement.NormalPosition.Height == other.WindowPlacement.NormalPosition.Height;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0}.{1} {2}", ProcessId, HWnd.ToInt64(), ApplicationName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,12 +19,19 @@ namespace Ninjacrab.PersistentWindows.WpfShell
|
|||
|
||||
public void Start()
|
||||
{
|
||||
lastMetrics = DesktopDisplayMetrics.AcquireMetrics();
|
||||
CaptureApplicationsOnCurrentDisplays();
|
||||
|
||||
var thread = new Thread(InternalRun);
|
||||
thread.IsBackground = true;
|
||||
thread.Name = "PersistentWindowProcessor.InternalRun()";
|
||||
thread.Start();
|
||||
|
||||
SystemEvents.DisplaySettingsChanged += (s, e) => BeginRestoreApplicationsOnCurrentDisplays();
|
||||
SystemEvents.DisplaySettingsChanged += (s, e) =>
|
||||
{
|
||||
Log.Info("Display settings changed");
|
||||
BeginRestoreApplicationsOnCurrentDisplays();
|
||||
};
|
||||
SystemEvents.PowerModeChanged += (s, e) =>
|
||||
{
|
||||
switch (e.Mode)
|
||||
|
@ -40,11 +47,9 @@ namespace Ninjacrab.PersistentWindows.WpfShell
|
|||
break;
|
||||
}
|
||||
};
|
||||
CaptureApplicationsOnCurrentDisplays();
|
||||
lastMetrics = DesktopDisplayMetrics.AcquireMetrics();
|
||||
}
|
||||
|
||||
private readonly Dictionary<string, Dictionary<string, ApplicationDisplayMetrics>> monitorApplications = new Dictionary<string, Dictionary<string, ApplicationDisplayMetrics>>();
|
||||
private readonly Dictionary<string, SortedDictionary<string, ApplicationDisplayMetrics>> monitorApplications = new Dictionary<string, SortedDictionary<string, ApplicationDisplayMetrics>>();
|
||||
private readonly object displayChangeLock = new object();
|
||||
|
||||
private void InternalRun()
|
||||
|
@ -83,7 +88,7 @@ namespace Ninjacrab.PersistentWindows.WpfShell
|
|||
|
||||
if (!monitorApplications.ContainsKey(displayKey))
|
||||
{
|
||||
monitorApplications.Add(displayKey, new Dictionary<string, ApplicationDisplayMetrics>());
|
||||
monitorApplications.Add(displayKey, new SortedDictionary<string, ApplicationDisplayMetrics>());
|
||||
}
|
||||
|
||||
List<string> changeLog = new List<string>();
|
||||
|
@ -116,7 +121,7 @@ namespace Ninjacrab.PersistentWindows.WpfShell
|
|||
if (addToChangeLog)
|
||||
{
|
||||
changeLog.Add(string.Format("Capturing {0} at [{1}x{2}] size [{3}x{4}]",
|
||||
applicationDisplayMetric.ApplicationName,
|
||||
applicationDisplayMetric,
|
||||
applicationDisplayMetric.WindowPlacement.NormalPosition.Left,
|
||||
applicationDisplayMetric.WindowPlacement.NormalPosition.Top,
|
||||
applicationDisplayMetric.WindowPlacement.NormalPosition.Width,
|
||||
|
@ -127,6 +132,7 @@ namespace Ninjacrab.PersistentWindows.WpfShell
|
|||
|
||||
if (changeLog.Count > 0)
|
||||
{
|
||||
changeLog.Sort();
|
||||
Log.Info("Capturing applications for {0}", displayKey);
|
||||
Log.Trace(string.Join(Environment.NewLine, changeLog));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue