Browse Source

WpfWorkbench: Fixed window bound restore code

- When closing a minimized SharpDevelop instance, save the previous state (before minimizing)
 - Use RestoreBounds so that window size is saved even when maximized
 - Validate the bounds being restored (avoid placing SharpDevelop on deactivated monitor)
4.0
Daniel Grunwald 15 years ago
parent
commit
1230d8a392
  1. 2
      src/Main/Base/Project/Src/Gui/FormLocationHelper.cs
  2. 33
      src/Main/Base/Project/Src/Gui/Workbench/WpfWorkbench.cs

2
src/Main/Base/Project/Src/Gui/FormLocationHelper.cs

@ -60,7 +60,7 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -60,7 +60,7 @@ namespace ICSharpCode.SharpDevelop.Gui
};
}
static Rect Validate(Rect bounds)
public static Rect Validate(Rect bounds)
{
// Check if form is outside the screen and get it back if necessary.
// This is important when the user uses multiple screens, a window stores its location

33
src/Main/Base/Project/Src/Gui/Workbench/WpfWorkbench.cs

@ -529,25 +529,36 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -529,25 +529,36 @@ namespace ICSharpCode.SharpDevelop.Gui
}
#endregion
System.Windows.WindowState lastNonMinimizedWindowState = System.Windows.WindowState.Normal;
Rect restoreBoundsBeforeClosing;
protected override void OnStateChanged(EventArgs e)
{
base.OnStateChanged(e);
if (this.WindowState != System.Windows.WindowState.Minimized)
lastNonMinimizedWindowState = this.WindowState;
}
public Properties CreateMemento()
{
Properties prop = new Properties();
prop.Set("WindowState", this.WindowState);
if (this.WindowState == System.Windows.WindowState.Normal) {
prop.Set("Left", this.Left);
prop.Set("Top", this.Top);
prop.Set("Width", this.Width);
prop.Set("Height", this.Height);
prop.Set("WindowState", lastNonMinimizedWindowState);
var bounds = this.RestoreBounds;
if (bounds.IsEmpty) bounds = restoreBoundsBeforeClosing;
if (!bounds.IsEmpty) {
prop.Set("Bounds", bounds);
}
return prop;
}
public void SetMemento(Properties memento)
{
this.Left = memento.Get("Left", 10.0);
this.Top = memento.Get("Top", 10.0);
this.Width = memento.Get("Width", 600.0);
this.Height = memento.Get("Height", 400.0);
Rect bounds = memento.Get("Bounds", new Rect(10, 10, 750, 550));
bounds = FormLocationHelper.Validate(bounds);
this.Left = bounds.Left;
this.Top = bounds.Top;
this.Width = bounds.Width;
this.Height = bounds.Height;
this.WindowState = memento.Get("WindowState", System.Windows.WindowState.Maximized);
}
@ -574,6 +585,8 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -574,6 +585,8 @@ namespace ICSharpCode.SharpDevelop.Gui
Project.ProjectService.CloseSolution();
ParserService.StopParserThread();
restoreBoundsBeforeClosing = this.RestoreBounds;
this.WorkbenchLayout = null;
foreach (PadDescriptor padDescriptor in this.PadContentCollection) {

Loading…
Cancel
Save