using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading;
-#if NET_2_0
using System.Text;
-#endif
using System.Windows.Forms.VisualStyles;
namespace System.Windows.Forms
private static readonly ArrayList message_filters = new ArrayList();
private static readonly FormCollection forms = new FormCollection ();
-#if NET_2_0
private static bool use_wait_cursor;
private static ToolStrip keyboard_capture;
-#endif
private static VisualStyleState visual_style_state = VisualStyleState.ClientAndNonClientAreasEnabled;
static bool visual_styles_enabled;
browser_embedded = false;
}
-#if NET_2_0
static Application ()
{
// Attempt to load UIA support for winforms
// UIA support requires .NET 2.0
InitializeUIAutomation ();
}
-#endif
#region Private Methods
-#if NET_2_0
-
private static void InitializeUIAutomation ()
{
// Initialize the UIAutomationWinforms Global class,
Console.Error.WriteLine ("Error setting up UIA: " + ex);
}
}
-#endif
internal static void CloseForms (Thread thread)
{
}
}
-#if NET_2_0
public static bool UseWaitCursor {
get {
return use_wait_cursor;
}
}
}
-#endif
-
-#if NET_2_0
- public
-#else
- internal
-#endif
- static bool RenderWithVisualStyles {
+
+ public static bool RenderWithVisualStyles {
get {
if (VisualStyleInformation.IsSupportedByOS) {
if (!VisualStyleInformation.IsEnabledByUser)
}
}
-#if NET_2_0
- public
-#else
- internal
-#endif
- static VisualStyleState VisualStyleState {
+ public static VisualStyleState VisualStyleState {
get { return Application.visual_style_state; }
set { Application.visual_style_state = value; }
}
XplatUI.EnableThemes ();
}
-#if NET_2_0
[EditorBrowsable (EditorBrowsableState.Advanced)]
- public
-#else
- internal
-#endif
- static bool FilterMessage (ref Message message)
+ public static bool FilterMessage (ref Message message)
{
lock (message_filters) {
for (int i = 0; i < message_filters.Count; i++) {
return false;
}
-#if NET_2_0
//
// If true, it uses GDI+, performance reasons were quoted
//
Application.Exit ();
Process.Start (procInfo);
}
-#endif
public static void Exit ()
{
-#if NET_2_0
Exit (new CancelEventArgs ());
-#else
- XplatUI.PostQuitMessage (0);
- CloseForms (null);
-#endif
}
-#if NET_2_0
[EditorBrowsable (EditorBrowsableState.Advanced)]
public static void Exit (CancelEventArgs e)
{
XplatUI.PostQuitMessage (0);
}
-#endif
public static void ExitThread()
{
Run (new ApplicationContext (mainForm));
}
-#if NET_2_0
internal static void FirePreRun ()
{
EventHandler handler = PreRun;
if (handler != null)
handler (null, EventArgs.Empty);
}
-#endif
public static void Run (ApplicationContext context)
{
-#if NET_2_0
// If a sync context hasn't been created by now, create
// a default one
if (SynchronizationContext.Current == null)
SynchronizationContext.SetSynchronizationContext (new SynchronizationContext ());
-#endif
RunLoop (false, context);
-#if NET_2_0
// Reset the sync context back to the default
if (SynchronizationContext.Current is WindowsFormsSynchronizationContext)
WindowsFormsSynchronizationContext.Uninstall ();
-#endif
}
private static void DisableFormsForModalLoop (Queue toplevels, ApplicationContext context)
Control c;
c = Control.FromHandle(msg.hwnd);
-#if NET_2_0
// If we have a control with keyboard capture (usually a *Strip)
// give it the message, and then drop the message
if (keyboard_capture != null) {
break;
}
}
-#endif
if (((c != null) && c.PreProcessControlMessageInternal (ref m) != PreProcessControlState.MessageProcessed) ||
(c == null)) {
goto default;
}
break;
-#if NET_2_0
+
case Msg.WM_LBUTTONDOWN:
case Msg.WM_MBUTTONDOWN:
case Msg.WM_RBUTTONDOWN:
}
goto default;
-#endif
+
case Msg.WM_QUIT:
quit = true; // make sure we exit
break;
break;
}
- // Handle exit, Form might have received WM_CLOSE and set 'closing' in response
+ // If our Form doesn't have a handle anymore, it means it was destroyed and we need to *wait* for WM_QUIT.
+ if ((context.MainForm != null) && (!context.MainForm.IsHandleCreated))
+ continue;
+
+ // Handle exit, Form might have received WM_CLOSE and set 'closing' in response.
if ((context.MainForm != null) && (context.MainForm.closing || (Modal && !context.MainForm.Visible))) {
if (!Modal) {
XplatUI.PostQuitMessage (0);
public static event EventHandler ThreadExit;
public static event ThreadExceptionEventHandler ThreadException;
-#if NET_2_0
// These are used externally by the UIA framework
internal static event EventHandler FormAdded;
internal static event EventHandler PreRun;
+#pragma warning disable 0067
+ [MonoTODO]
[EditorBrowsable (EditorBrowsableState.Advanced)]
public static event EventHandler EnterThreadModal;
+ [MonoTODO]
[EditorBrowsable (EditorBrowsableState.Advanced)]
public static event EventHandler LeaveThreadModal;
-#endif
+#pragma warning restore 0067
#endregion // Events
#region Public Delegates
-#if NET_2_0
[EditorBrowsable (EditorBrowsableState.Advanced)]
public delegate bool MessageLoopCallback ();
-#endif
#endregion
#region Internal Properties
-#if NET_2_0
internal static ToolStrip KeyboardCapture {
get { return keyboard_capture; }
set { keyboard_capture = value; }
}
-#endif
internal static bool VisualStylesEnabled {
get { return visual_styles_enabled; }
{
lock (forms)
forms.Add (f);
-#if NET_2_0
// Signal that a Form has been added to this
// Application. Used by UIA to detect new Forms that
// need a11y support. This event may be fired even if
// account for that when handling this signal.
if (FormAdded != null)
FormAdded (f, null);
-#endif
}
internal static void RemoveForm (Form f)
forms.Remove (f);
}
-#if NET_2_0
private static bool ControlOnToolStrip (Control c)
{
Control p = c.Parent;
return false;
}
-#endif
// Takes a starting path, appends company name, product name, and
// product version. If the directory doesn't exist, create it