mirror of
https://github.com/kangyu-california/PersistentWindows.git
synced 2025-05-12 05:25:37 +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);
|
config.AddTarget("file", fileTarget);
|
||||||
|
|
||||||
// Step 3. Set target properties
|
// 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.FileName = "${basedir}/PersistentWindows.Log";
|
||||||
fileTarget.Layout = "${message}";
|
fileTarget.Layout = "${date:format=HH\\:mm\\:ss} ${logger} ${message}";
|
||||||
|
|
||||||
// Step 4. Define rules
|
// Step 4. Define rules
|
||||||
var rule1 = new LoggingRule("*", LogLevel.Trace, consoleTarget);
|
var rule1 = new LoggingRule("*", LogLevel.Trace, consoleTarget);
|
||||||
config.LoggingRules.Add(rule1);
|
config.LoggingRules.Add(rule1);
|
||||||
|
|
||||||
var rule2 = new LoggingRule("*", LogLevel.Debug, fileTarget);
|
var rule2 = new LoggingRule("*", LogLevel.Trace, fileTarget);
|
||||||
config.LoggingRules.Add(rule2);
|
config.LoggingRules.Add(rule2);
|
||||||
|
|
||||||
// Step 5. Activate the configuration
|
// 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.Width == other.WindowPlacement.NormalPosition.Width
|
||||||
&& this.WindowPlacement.NormalPosition.Height == other.WindowPlacement.NormalPosition.Height;
|
&& 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()
|
public void Start()
|
||||||
{
|
{
|
||||||
|
lastMetrics = DesktopDisplayMetrics.AcquireMetrics();
|
||||||
|
CaptureApplicationsOnCurrentDisplays();
|
||||||
|
|
||||||
var thread = new Thread(InternalRun);
|
var thread = new Thread(InternalRun);
|
||||||
thread.IsBackground = true;
|
thread.IsBackground = true;
|
||||||
thread.Name = "PersistentWindowProcessor.InternalRun()";
|
thread.Name = "PersistentWindowProcessor.InternalRun()";
|
||||||
thread.Start();
|
thread.Start();
|
||||||
|
|
||||||
SystemEvents.DisplaySettingsChanged += (s, e) => BeginRestoreApplicationsOnCurrentDisplays();
|
SystemEvents.DisplaySettingsChanged += (s, e) =>
|
||||||
|
{
|
||||||
|
Log.Info("Display settings changed");
|
||||||
|
BeginRestoreApplicationsOnCurrentDisplays();
|
||||||
|
};
|
||||||
SystemEvents.PowerModeChanged += (s, e) =>
|
SystemEvents.PowerModeChanged += (s, e) =>
|
||||||
{
|
{
|
||||||
switch (e.Mode)
|
switch (e.Mode)
|
||||||
|
@ -40,11 +47,9 @@ namespace Ninjacrab.PersistentWindows.WpfShell
|
||||||
break;
|
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 readonly object displayChangeLock = new object();
|
||||||
|
|
||||||
private void InternalRun()
|
private void InternalRun()
|
||||||
|
@ -83,7 +88,7 @@ namespace Ninjacrab.PersistentWindows.WpfShell
|
||||||
|
|
||||||
if (!monitorApplications.ContainsKey(displayKey))
|
if (!monitorApplications.ContainsKey(displayKey))
|
||||||
{
|
{
|
||||||
monitorApplications.Add(displayKey, new Dictionary<string, ApplicationDisplayMetrics>());
|
monitorApplications.Add(displayKey, new SortedDictionary<string, ApplicationDisplayMetrics>());
|
||||||
}
|
}
|
||||||
|
|
||||||
List<string> changeLog = new List<string>();
|
List<string> changeLog = new List<string>();
|
||||||
|
@ -116,7 +121,7 @@ namespace Ninjacrab.PersistentWindows.WpfShell
|
||||||
if (addToChangeLog)
|
if (addToChangeLog)
|
||||||
{
|
{
|
||||||
changeLog.Add(string.Format("Capturing {0} at [{1}x{2}] size [{3}x{4}]",
|
changeLog.Add(string.Format("Capturing {0} at [{1}x{2}] size [{3}x{4}]",
|
||||||
applicationDisplayMetric.ApplicationName,
|
applicationDisplayMetric,
|
||||||
applicationDisplayMetric.WindowPlacement.NormalPosition.Left,
|
applicationDisplayMetric.WindowPlacement.NormalPosition.Left,
|
||||||
applicationDisplayMetric.WindowPlacement.NormalPosition.Top,
|
applicationDisplayMetric.WindowPlacement.NormalPosition.Top,
|
||||||
applicationDisplayMetric.WindowPlacement.NormalPosition.Width,
|
applicationDisplayMetric.WindowPlacement.NormalPosition.Width,
|
||||||
|
@ -127,6 +132,7 @@ namespace Ninjacrab.PersistentWindows.WpfShell
|
||||||
|
|
||||||
if (changeLog.Count > 0)
|
if (changeLog.Count > 0)
|
||||||
{
|
{
|
||||||
|
changeLog.Sort();
|
||||||
Log.Info("Capturing applications for {0}", displayKey);
|
Log.Info("Capturing applications for {0}", displayKey);
|
||||||
Log.Trace(string.Join(Environment.NewLine, changeLog));
|
Log.Trace(string.Join(Environment.NewLine, changeLog));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue