Browse Source

Fixed bug that caused WinFormsMessageService.DialogOwner to be initialized to null instead of the actual main window.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5240 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Daniel Grunwald 16 years ago
parent
commit
3f49d60757
  1. 15
      src/Main/Base/Project/Src/Gui/Workbench/WpfWorkbench.cs
  2. 1
      src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs
  3. 26
      src/Main/Base/Project/Src/Util/ExtensionMethods.cs

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

@ -27,7 +27,7 @@ namespace ICSharpCode.SharpDevelop.Gui
/// <summary> /// <summary>
/// Workbench implementation using WPF and AvalonDock. /// Workbench implementation using WPF and AvalonDock.
/// </summary> /// </summary>
sealed partial class WpfWorkbench : Window, IWorkbench sealed partial class WpfWorkbench : Window, IWorkbench, System.Windows.Forms.IWin32Window
{ {
const string mainMenuPath = "/SharpDevelop/Workbench/MainMenu"; const string mainMenuPath = "/SharpDevelop/Workbench/MainMenu";
const string viewContentPath = "/SharpDevelop/Workbench/Pads"; const string viewContentPath = "/SharpDevelop/Workbench/Pads";
@ -53,10 +53,20 @@ namespace ICSharpCode.SharpDevelop.Gui
} }
} }
public System.Windows.Forms.IWin32Window MainWin32Window { get; private set; } public System.Windows.Forms.IWin32Window MainWin32Window { get { return this; } }
public ISynchronizeInvoke SynchronizingObject { get; private set; } public ISynchronizeInvoke SynchronizingObject { get; private set; }
public Window MainWindow { get { return this; } } public Window MainWindow { get { return this; } }
IntPtr System.Windows.Forms.IWin32Window.Handle {
get {
var wnd = System.Windows.PresentationSource.FromVisual(this) as System.Windows.Interop.IWin32Window;
if (wnd != null)
return wnd.Handle;
else
return IntPtr.Zero;
}
}
List<PadDescriptor> padDescriptorCollection = new List<PadDescriptor>(); List<PadDescriptor> padDescriptorCollection = new List<PadDescriptor>();
ToolBar[] toolBars; ToolBar[] toolBars;
@ -70,7 +80,6 @@ namespace ICSharpCode.SharpDevelop.Gui
protected override void OnSourceInitialized(EventArgs e) protected override void OnSourceInitialized(EventArgs e)
{ {
this.MainWin32Window = this.GetWin32Window();
base.OnSourceInitialized(e); base.OnSourceInitialized(e);
HwndSource.FromHwnd(this.MainWin32Window.Handle).AddHook(SingleInstanceHelper.WndProc); HwndSource.FromHwnd(this.MainWin32Window.Handle).AddHook(SingleInstanceHelper.WndProc);
} }

1
src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs

@ -86,6 +86,7 @@ namespace ICSharpCode.SharpDevelop.Gui
var messageService = (WinFormsMessageService)Core.Services.ServiceManager.Instance.MessageService; var messageService = (WinFormsMessageService)Core.Services.ServiceManager.Instance.MessageService;
messageService.DialogOwner = workbench.MainWin32Window; messageService.DialogOwner = workbench.MainWin32Window;
Debug.Assert(messageService.DialogOwner != null);
messageService.DialogSynchronizeInvoke = workbench.SynchronizingObject; messageService.DialogSynchronizeInvoke = workbench.SynchronizingObject;
workbench.Initialize(); workbench.Initialize();

26
src/Main/Base/Project/Src/Util/ExtensionMethods.cs

@ -134,32 +134,6 @@ namespace ICSharpCode.SharpDevelop
return result; return result;
} }
/// <summary>
/// Gets the IWin32Window associated with a WPF window.
/// </summary>
public static WinForms.IWin32Window GetWin32Window(this System.Windows.Window window)
{
var wnd = System.Windows.PresentationSource.FromVisual(window) as System.Windows.Interop.IWin32Window;
if (wnd != null)
return new Win32WindowAdapter(wnd);
else
return null;
}
sealed class Win32WindowAdapter : WinForms.IWin32Window
{
readonly System.Windows.Interop.IWin32Window window;
public Win32WindowAdapter(System.Windows.Interop.IWin32Window window)
{
this.window = window;
}
public IntPtr Handle {
get { return window.Handle; }
}
}
/// <summary> /// <summary>
/// Sets the Content property of the specified ControlControl to the specified content. /// Sets the Content property of the specified ControlControl to the specified content.
/// If the content is a Windows-Forms control, it is wrapped in a WindowsFormsHost. /// If the content is a Windows-Forms control, it is wrapped in a WindowsFormsHost.

Loading…
Cancel
Save