Browse Source

SD2-693 - ToolstripContainer designer loading problem. Applied Christian Hornung's patch that adds a Deselecting event handler for the IBaseViewContent interface, which is called before the view has been deselected, allowing the forms designer to read the correct ToolStripPanelVisible properties before the designed form is hidden.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.0@1172 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Matt Ward 20 years ago
parent
commit
af3c2e2d76
  1. 6
      src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerViewContent.cs
  2. 4
      src/Main/Base/Project/Src/Gui/AbstractBaseViewContent.cs
  3. 6
      src/Main/Base/Project/Src/Gui/IBaseViewContent.cs
  4. 46
      src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceWindow.cs

6
src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerViewContent.cs

@ -347,17 +347,17 @@ namespace ICSharpCode.FormsDesigner
{ {
disposing = true; disposing = true;
if (IsFormsDesignerVisible) { if (IsFormsDesignerVisible) {
Deselected(); Deselecting();
} }
base.Dispose(); base.Dispose();
} }
public override void Deselected() public override void Deselecting()
{ {
// can happen if form designer is disposed and then deselected // can happen if form designer is disposed and then deselected
if (!IsFormsDesignerVisible) if (!IsFormsDesignerVisible)
return; return;
LoggingService.Info("Deselected form designer, unloading..." + viewContent.TitleName); LoggingService.Info("Deselecting form designer, unloading..." + viewContent.TitleName);
PropertyPad.PropertyValueChanged -= PropertyValueChanged; PropertyPad.PropertyValueChanged -= PropertyValueChanged;
propertyContainer.Clear(); propertyContainer.Clear();
IsFormsDesignerVisible = false; IsFormsDesignerVisible = false;

4
src/Main/Base/Project/Src/Gui/AbstractBaseViewContent.cs

@ -55,6 +55,10 @@ namespace ICSharpCode.SharpDevelop.Gui
public virtual void Deselected() public virtual void Deselected()
{ {
} }
public virtual void Deselecting()
{
}
public virtual void RedrawContent() public virtual void RedrawContent()
{ {

6
src/Main/Base/Project/Src/Gui/IBaseViewContent.cs

@ -50,6 +50,12 @@ namespace ICSharpCode.SharpDevelop.Gui
/// tab. NOT when the windows is selected. /// tab. NOT when the windows is selected.
/// </summary> /// </summary>
void Selected(); void Selected();
/// <summary>
/// Is called just before the view content is deselected inside the window
/// tab before the other window is selected. NOT when the windows is deselected.
/// </summary>
void Deselecting();
/// <summary> /// <summary>
/// Is called when the view content is deselected inside the window /// Is called when the view content is deselected inside the window

46
src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceWindow.cs

@ -136,7 +136,9 @@ namespace ICSharpCode.SharpDevelop.Gui
viewTabControl = new TabControl(); viewTabControl = new TabControl();
viewTabControl.Alignment = TabAlignment.Bottom; viewTabControl.Alignment = TabAlignment.Bottom;
viewTabControl.Dock = DockStyle.Fill; viewTabControl.Dock = DockStyle.Fill;
viewTabControl.SelectedIndexChanged += new EventHandler(viewTabControlIndexChanged); viewTabControl.Selected += viewTabControlSelected;
viewTabControl.Deselecting += viewTabControlDeselecting;
viewTabControl.Deselected += viewTabControlDeselected;
} }
internal void InitControls() internal void InitControls()
@ -200,11 +202,6 @@ namespace ICSharpCode.SharpDevelop.Gui
WorkbenchSingleton.SafeThreadAsyncCall(new MethodInvoker(this.RefreshSecondaryViewContents)); WorkbenchSingleton.SafeThreadAsyncCall(new MethodInvoker(this.RefreshSecondaryViewContents));
} }
void LeaveTabPage(object sender, EventArgs e)
{
OnWindowDeselected(EventArgs.Empty);
}
public IViewContent ViewContent { public IViewContent ViewContent {
get { get {
return content; return content;
@ -260,6 +257,9 @@ namespace ICSharpCode.SharpDevelop.Gui
if (viewTabControl != null) { if (viewTabControl != null) {
foreach (TabPage page in viewTabControl.TabPages) { foreach (TabPage page in viewTabControl.TabPages) {
if (viewTabControl.SelectedTab == page && page.Tag is IBaseViewContent) {
((IBaseViewContent)page.Tag).Deselecting();
}
page.Controls.Clear(); page.Controls.Clear();
if (viewTabControl.SelectedTab == page && page.Tag is IBaseViewContent) { if (viewTabControl.SelectedTab == page && page.Tag is IBaseViewContent) {
((IBaseViewContent)page.Tag).Deselected(); ((IBaseViewContent)page.Tag).Deselected();
@ -319,28 +319,40 @@ namespace ICSharpCode.SharpDevelop.Gui
return content.SecondaryViewContents[index - 1]; return content.SecondaryViewContents[index - 1];
} }
int oldIndex = 0; void viewTabControlSelected(object sender, TabControlEventArgs e)
void viewTabControlIndexChanged(object sender, EventArgs e)
{ {
if (oldIndex >= 0) { if (e.Action == TabControlAction.Selected && e.TabPageIndex >= 0) {
IBaseViewContent secondaryViewContent = GetSubViewContent(oldIndex); IBaseViewContent secondaryViewContent = GetSubViewContent(e.TabPageIndex);
if (secondaryViewContent != null) { if (secondaryViewContent != null) {
secondaryViewContent.Deselected(); secondaryViewContent.Deselected();
}
}
if (viewTabControl.SelectedIndex >= 0) {
IBaseViewContent secondaryViewContent = GetSubViewContent(viewTabControl.SelectedIndex);
if (secondaryViewContent != null) {
secondaryViewContent.SwitchedTo(); secondaryViewContent.SwitchedTo();
secondaryViewContent.Selected(); secondaryViewContent.Selected();
} }
} }
oldIndex = viewTabControl.SelectedIndex;
WorkbenchSingleton.Workbench.WorkbenchLayout.OnActiveWorkbenchWindowChanged(EventArgs.Empty); WorkbenchSingleton.Workbench.WorkbenchLayout.OnActiveWorkbenchWindowChanged(EventArgs.Empty);
ActiveViewContent.Control.Focus(); ActiveViewContent.Control.Focus();
} }
void viewTabControlDeselecting(object sender, TabControlCancelEventArgs e)
{
if (e.Action == TabControlAction.Deselecting && e.TabPageIndex >= 0) {
IBaseViewContent secondaryViewContent = GetSubViewContent(e.TabPageIndex);
if (secondaryViewContent != null) {
secondaryViewContent.Deselecting();
}
}
}
void viewTabControlDeselected(object sender, TabControlEventArgs e)
{
if (e.Action == TabControlAction.Deselected && e.TabPageIndex >= 0) {
IBaseViewContent secondaryViewContent = GetSubViewContent(e.TabPageIndex);
if (secondaryViewContent != null) {
secondaryViewContent.Deselected();
}
}
}
public virtual void RedrawContent() public virtual void RedrawContent()
{ {
if (viewTabControl != null) { if (viewTabControl != null) {

Loading…
Cancel
Save