Browse Source

Implemented Active*ContentChanged events.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0wpf@3322 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 17 years ago
parent
commit
606cb75ed5
  1. 2
      src/AddIns/BackendBindings/FSharp/FSharpBinding/Project/FSharpBinding.fsproj
  2. 6
      src/AddIns/DisplayBindings/FormsDesigner/Project/Src/FormKeyHandler.cs
  3. 4
      src/AddIns/Misc/PInvokeAddIn/Project/Src/InsertPInvokeSignaturesCommand.cs
  4. 11
      src/Main/Base/Project/Src/Gui/AbstractPadContent.cs
  5. 8
      src/Main/Base/Project/Src/Gui/IWorkbenchLayout.cs
  6. 4
      src/Main/Base/Project/Src/Gui/Workbench/DefaultWorkbench.cs
  7. 11
      src/Main/Base/Project/Src/Gui/Workbench/Layouts/AvalonDockLayout.cs
  8. 86
      src/Main/Base/Project/Src/Gui/Workbench/WpfWorkbench.cs

2
src/AddIns/BackendBindings/FSharp/FSharpBinding/Project/FSharpBinding.fsproj

@ -28,7 +28,7 @@
<HintPath>..\..\RequiredLibraries\FSharp.Build.Tasks.dll</HintPath> <HintPath>..\..\RequiredLibraries\FSharp.Build.Tasks.dll</HintPath>
</Reference> </Reference>
<Reference Include="log4net"> <Reference Include="log4net">
<HintPath>..\..\..\..\..\..\..\3.0\SharpDevelop\src\Libraries\log4net\log4net.dll</HintPath> <HintPath>..\..\..\..\..\Libraries\log4net\log4net.dll</HintPath>
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
<Reference Include="Microsoft.Build.Engine, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <Reference Include="Microsoft.Build.Engine, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">

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

@ -70,11 +70,7 @@ namespace ICSharpCode.FormsDesigner
return false; return false;
} }
if (WorkbenchSingleton.Workbench.ActiveWorkbenchWindow == null) { FormsDesignerViewContent formDesigner = WorkbenchSingleton.Workbench.ActiveContent as FormsDesignerViewContent;
return false;
}
FormsDesignerViewContent formDesigner = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ActiveViewContent as FormsDesignerViewContent;
if (formDesigner == null || formDesigner.Host == null) { if (formDesigner == null || formDesigner.Host == null) {
return false; return false;

4
src/AddIns/Misc/PInvokeAddIn/Project/Src/InsertPInvokeSignaturesCommand.cs

@ -16,7 +16,7 @@ namespace ICSharpCode.PInvokeAddIn
/// insert one or more of them into the code. /// insert one or more of them into the code.
/// </summary> /// </summary>
public class InsertPInvokeSignaturesCommand : AbstractMenuCommand public class InsertPInvokeSignaturesCommand : AbstractMenuCommand
{ {
/// <summary> /// <summary>
/// Starts the command. /// Starts the command.
/// </summary> /// </summary>
@ -24,7 +24,7 @@ namespace ICSharpCode.PInvokeAddIn
{ {
// Show PInvoke dialog. // Show PInvoke dialog.
using(InsertPInvokeSignaturesForm form = new InsertPInvokeSignaturesForm()) { using(InsertPInvokeSignaturesForm form = new InsertPInvokeSignaturesForm()) {
form.ShowDialog(WorkbenchSingleton.MainWin32Window); form.ShowDialog(WorkbenchSingleton.MainWin32Window);
} }
} }
} }

11
src/Main/Base/Project/Src/Gui/AbstractPadContent.cs

@ -23,5 +23,16 @@ namespace ICSharpCode.SharpDevelop.Gui
public virtual void Dispose() public virtual void Dispose()
{ {
} }
protected bool IsVisible {
get {
if (WorkbenchSingleton.Workbench == null || WorkbenchSingleton.Workbench.WorkbenchLayout == null)
return false;
PadDescriptor d = WorkbenchSingleton.Workbench.GetPad(GetType());
if (d == null)
return false;
return WorkbenchSingleton.Workbench.WorkbenchLayout.IsVisible(d);
}
}
} }
} }

8
src/Main/Base/Project/Src/Gui/IWorkbenchLayout.cs

@ -32,6 +32,8 @@ namespace ICSharpCode.SharpDevelop.Gui
get; get;
} }
event EventHandler ActiveContentChanged;
/// <summary> /// <summary>
/// Attaches this layout manager to a workbench object. /// Attaches this layout manager to a workbench object.
/// </summary> /// </summary>
@ -82,11 +84,5 @@ namespace ICSharpCode.SharpDevelop.Gui
void LoadConfiguration(); void LoadConfiguration();
void StoreConfiguration(); void StoreConfiguration();
/// <summary>
/// Is called, when the workbench window which the user has into
/// the foreground (e.g. editable) changed to a new one.
/// </summary>
event EventHandler ActiveWorkbenchWindowChanged;
} }
} }

4
src/Main/Base/Project/Src/Gui/Workbench/DefaultWorkbench.cs

@ -94,12 +94,12 @@ namespace ICSharpCode.SharpDevelop.Gui
} }
set { set {
if (layout != null) { if (layout != null) {
layout.ActiveWorkbenchWindowChanged -= OnActiveWindowChanged; layout.ActiveContentChanged -= OnActiveWindowChanged;
layout.Detach(); layout.Detach();
} }
value.Attach(this); value.Attach(this);
layout = value; layout = value;
layout.ActiveWorkbenchWindowChanged += OnActiveWindowChanged; layout.ActiveContentChanged += OnActiveWindowChanged;
OnActiveWindowChanged(null, null); OnActiveWindowChanged(null, null);
} }
} }

11
src/Main/Base/Project/Src/Gui/Workbench/Layouts/AvalonDockLayout.cs

@ -38,9 +38,18 @@ namespace ICSharpCode.SharpDevelop.Gui
public AvalonDockLayout() public AvalonDockLayout()
{ {
dockingManager.Content = documentPane; dockingManager.Content = documentPane;
dockingManager.PropertyChanged += dockingManager_PropertyChanged;
} }
public event EventHandler ActiveWorkbenchWindowChanged; void dockingManager_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (e.PropertyName == "ActiveContent") {
if (ActiveContentChanged != null)
ActiveContentChanged(this, e);
}
}
public event EventHandler ActiveContentChanged;
public IWorkbenchWindow ActiveWorkbenchWindow { public IWorkbenchWindow ActiveWorkbenchWindow {
get { get {

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

@ -9,6 +9,7 @@ using ICSharpCode.Core.Presentation;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Linq;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using ICSharpCode.Core; using ICSharpCode.Core;
@ -28,7 +29,7 @@ namespace ICSharpCode.SharpDevelop.Gui
public event EventHandler ActiveContentChanged; public event EventHandler ActiveContentChanged;
public event ViewContentEventHandler ViewOpened; public event ViewContentEventHandler ViewOpened;
protected void OnViewOpened(ViewContentEventArgs e) void OnViewOpened(ViewContentEventArgs e)
{ {
if (ViewOpened != null) { if (ViewOpened != null) {
ViewOpened(this, e); ViewOpened(this, e);
@ -87,7 +88,8 @@ namespace ICSharpCode.SharpDevelop.Gui
public IList<IWorkbenchWindow> WorkbenchWindowCollection { public IList<IWorkbenchWindow> WorkbenchWindowCollection {
get { get {
return new IWorkbenchWindow[0]; return viewContentCollection.Select(vc => vc.WorkbenchWindow)
.Distinct().ToList().AsReadOnly();
} }
} }
@ -97,21 +99,85 @@ namespace ICSharpCode.SharpDevelop.Gui
} }
} }
IWorkbenchWindow activeWorkbenchWindow;
public IWorkbenchWindow ActiveWorkbenchWindow { public IWorkbenchWindow ActiveWorkbenchWindow {
get { get {
return null; return activeWorkbenchWindow;
}
private set {
if (activeWorkbenchWindow != value) {
if (activeWorkbenchWindow != null) {
activeWorkbenchWindow.ActiveViewContentChanged -= WorkbenchWindowActiveViewContentChanged;
}
activeWorkbenchWindow = value;
if (value != null) {
value.ActiveViewContentChanged += WorkbenchWindowActiveViewContentChanged;
}
if (ActiveWorkbenchWindowChanged != null) {
ActiveWorkbenchWindowChanged(this, EventArgs.Empty);
}
WorkbenchWindowActiveViewContentChanged(null, null);
}
}
}
void WorkbenchWindowActiveViewContentChanged(object sender, EventArgs e)
{
if (workbenchLayout != null) {
// update ActiveViewContent
IWorkbenchWindow window = this.ActiveWorkbenchWindow;
if (window != null)
this.ActiveViewContent = window.ActiveViewContent;
else
this.ActiveViewContent = null;
// update ActiveContent
this.ActiveContent = workbenchLayout.ActiveContent;
} }
} }
void OnActiveWindowChanged(object sender, EventArgs e)
{
if (workbenchLayout != null) {
this.ActiveContent = workbenchLayout.ActiveContent;
this.ActiveWorkbenchWindow = workbenchLayout.ActiveWorkbenchWindow;
} else {
this.ActiveContent = null;
this.ActiveWorkbenchWindow = null;
}
}
IViewContent activeViewContent;
public IViewContent ActiveViewContent { public IViewContent ActiveViewContent {
get { get { return activeViewContent; }
return null; private set {
if (activeViewContent != value) {
activeViewContent = value;
if (ActiveViewContentChanged != null) {
ActiveViewContentChanged(this, EventArgs.Empty);
}
}
} }
} }
object activeContent;
public object ActiveContent { public object ActiveContent {
get { get { return activeContent; }
return null; private set {
if (activeContent != value) {
activeContent = value;
if (ActiveContentChanged != null) {
ActiveContentChanged(this, EventArgs.Empty);
}
}
} }
} }
@ -123,15 +189,15 @@ namespace ICSharpCode.SharpDevelop.Gui
} }
set { set {
if (workbenchLayout != null) { if (workbenchLayout != null) {
//workbenchLayout.ActiveWorkbenchWindowChanged -= OnActiveWindowChanged; workbenchLayout.ActiveContentChanged -= OnActiveWindowChanged;
workbenchLayout.Detach(); workbenchLayout.Detach();
} }
if (value != null) { if (value != null) {
value.Attach(this); value.Attach(this);
value.ActiveContentChanged += OnActiveWindowChanged;
} }
workbenchLayout = value; workbenchLayout = value;
//workbenchLayout.ActiveWorkbenchWindowChanged += OnActiveWindowChanged; OnActiveWindowChanged(null, null);
//OnActiveWindowChanged(null, null);
} }
} }

Loading…
Cancel
Save