2
using System.ComponentModel;
3
using System.Collections.Generic;
5
using System.Windows.Forms;
7
using CustomControls.OS;
9
namespace MonoDevelop.Platform
11
class WinFormsRoot : Form
13
// From OpenFileDialogEx.cs
14
private SetWindowPosFlags UFLAGSHIDE =
15
SetWindowPosFlags.SWP_NOACTIVATE |
16
SetWindowPosFlags.SWP_NOOWNERZORDER |
17
SetWindowPosFlags.SWP_NOMOVE |
18
SetWindowPosFlags.SWP_NOSIZE |
19
SetWindowPosFlags.SWP_HIDEWINDOW;
21
IDisposable nativeDialogWindow;
22
bool watchForActivate;
27
this.StartPosition = FormStartPosition.Manual;
28
this.Location = new Point(-32000, -32000);
29
this.ShowInTaskbar = false;
30
this.Icon = MonoDevelopIcon; // Icon is inherited to FileDialog objects
32
Win32.SetWindowPos(Handle, IntPtr.Zero, 0, 0, 0, 0, UFLAGSHIDE);
33
watchForActivate = true;
36
public static readonly Icon MonoDevelopIcon = LoadMonoDevelopIcon ();
38
static Icon LoadMonoDevelopIcon ()
40
// IconSize.Dnd seems to be the best match for Form.Icon
41
var pixbuf = MonoDevelop.Ide.ImageService.GetPixbuf ("md-monodevelop", Gtk.IconSize.Dnd);
42
return new Icon (new System.IO.MemoryStream (pixbuf.SaveToBuffer ("ico")));
45
protected override void OnClosing (CancelEventArgs args)
47
base.OnClosing (args);
48
if (nativeDialogWindow != null)
49
nativeDialogWindow.Dispose ();
52
protected override void WndProc(ref Message m)
54
if (m.Msg == (int)Msg.WM_ACTIVATE && watchForActivate) {
55
watchForActivate = false;
56
nativeDialogWindow = new NativeDialogWindow (m.LParam);
62
// The CommonDialog's Form Handle
63
class NativeDialogWindow : NativeWindow, IDisposable
67
public NativeDialogWindow (IntPtr handle)
70
AssignHandle (handle);
73
public void Dispose ()
78
protected override void WndProc (ref Message m)
80
/* Disable the handling of the pending events of the
81
* MD's UI thread, as we are running them in a separated thread now,
82
* but leave them here since we may need them when/if the MD's Main
83
* method is marked with the STAThread attribute.
85
case (int) Msg.WM_ENTERIDLE:
86
case (int) Msg.WM_WINDOWPOSCHANGED:
87
MonoDevelop.Ide.DispatchService.RunPendingEvents ();
102
public void Run(EventHandler action)
104
this.action = action;
105
Application.Idle += WinFormsIdle;
107
Application.Idle -= WinFormsIdle;
110
void WinFormsIdle(object sender, EventArgs e)
118
MonoDevelop.Ide.DispatchService.RunPendingEvents();