Skip to content
This repository has been archived by the owner on Oct 16, 2020. It is now read-only.

Commit

Permalink
Add interface to allow replacing WinFormsMessageService with a custom…
Browse files Browse the repository at this point in the history
… implementation when hosting SharpDevelop.
  • Loading branch information
dgrunwald committed Aug 28, 2010
1 parent 6e8012e commit 53f51a2
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
12 changes: 7 additions & 5 deletions src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs
Expand Up @@ -57,7 +57,7 @@ public static class WorkbenchSingleton
}
}

public static IStatusBarService StatusBar {
public static IStatusBarService StatusBar {
get {
return workbench != null ? workbench.StatusBar : null;
}
Expand All @@ -77,10 +77,12 @@ public static void InitializeWorkbench(IWorkbench workbench, IWorkbenchLayout la
Project.CustomToolsService.Initialize();
Project.BuildModifiedProjectsOnlyService.Initialize();

var messageService = (WinFormsMessageService)Core.Services.ServiceManager.Instance.MessageService;
messageService.DialogOwner = workbench.MainWin32Window;
Debug.Assert(messageService.DialogOwner != null);
messageService.DialogSynchronizeInvoke = workbench.SynchronizingObject;
var messageService = Core.Services.ServiceManager.Instance.MessageService as IDialogMessageService;
if (messageService != null) {
messageService.DialogOwner = workbench.MainWin32Window;
Debug.Assert(messageService.DialogOwner != null);
messageService.DialogSynchronizeInvoke = workbench.SynchronizingObject;
}

workbench.Initialize();
workbench.SetMemento(PropertyService.Get(workbenchMemento, new Properties()));
Expand Down
Expand Up @@ -59,6 +59,7 @@
<Compile Include="Menu\MenuSeparator.cs" />
<Compile Include="Menu\MenuService.cs" />
<Compile Include="MessageService\CustomDialog.cs" />
<Compile Include="MessageService\IDialogMessageService.cs" />
<Compile Include="MessageService\InputBox.cs" />
<Compile Include="MessageService\SaveErrorChooseDialog.cs" />
<Compile Include="MessageService\SaveErrorInformDialog.cs" />
Expand Down
@@ -0,0 +1,24 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <author name="Daniel Grunwald"/>
// <version>$Revision$</version>
// </file>

using System;
using System.ComponentModel;
using System.Windows.Forms;

using ICSharpCode.Core.Services;

namespace ICSharpCode.Core.WinForms
{
/// <summary>
/// Message service that sets an owner for dialog boxes.
/// </summary>
public interface IDialogMessageService : IMessageService
{
IWin32Window DialogOwner { set; get; }
ISynchronizeInvoke DialogSynchronizeInvoke { set; get; }
}
}
Expand Up @@ -18,7 +18,7 @@ namespace ICSharpCode.Core.WinForms
/// All text displayed using the MessageService is passed to the
/// <see cref="StringParser"/> to replace ${res} markers.
/// </summary>
public class WinFormsMessageService : IMessageService
public class WinFormsMessageService : IDialogMessageService
{
/// <summary>
/// Gets/Sets the form used as owner for shown message boxes.
Expand Down

0 comments on commit 53f51a2

Please sign in to comment.