public virtual Task ShowModalAsync(Control parent) { var tcs = new TaskCompletionSource <bool>(); session = null; if (parent != null && parent.ParentWindow != null) { var nswindow = parent.ParentWindow.ControlObject as NSWindow; if (nswindow != null) { Control.ParentWindow = nswindow; } } Callback.OnShown(Widget, EventArgs.Empty); Widget.Closed += HandleClosed; if (DisplayMode.HasFlag(DialogDisplayMode.Attached)) { MacModal.BeginSheet(Widget, Control, out session, () => tcs.SetResult(true)); } else { Control.MakeKeyWindow(); Application.Instance.AsyncInvoke(() => { MacModal.Run(Widget, Control, out session); tcs.SetResult(true); }); } return(tcs.Task); }
/// <summary> /// Raises the <see cref="ProcessModalSession"/> event. /// </summary> /// <param name="e">Event arguments</param> protected virtual void OnProcessModalSession(ModalEventArgs e) { if (ProcessModalSession != null) { ProcessModalSession(this, e); } }
public static void RunSheet(Window window, NSWindow theWindow, NSWindow parent, out ModalEventArgs helper) { var app = NSApplication.SharedApplication; app.BeginSheet(theWindow, parent, delegate { NSApplication.SharedApplication.StopModal(); }); var session = app.BeginModalSession(theWindow); helper = new ModalEventArgs(session, window, theWindow, isModal: true, isSheet: true); int result; var etoapp = ApplicationHandler.Instance; // Loop until some result other than continues: do { etoapp.TriggerProcessModalSession(helper); // Run the window modally until there are no events to process: result = (int)app.RunModalSession(session); // Give the main loop some time: NSRunLoop.Current.RunUntil(NSRunLoop.NSDefaultRunLoopMode, NSDate.DistantFuture); } while (result == (int)NSRun.ContinuesResponse || !helper.Stopped); app.EndModalSession(session); /** * theWindow.OrderOut (null); * app.EndSheet (theWindow); * /**/ }
public static void BeginSheet(Window window, NSWindow theWindow, NSWindow parent, out ModalEventArgs helper, Action completed) { NSApplication.SharedApplication.BeginSheet(theWindow, parent); helper = new ModalEventArgs(window, theWindow, isSheet: true); helper.StopAction = e => { NSApplication.SharedApplication.EndSheet(e.NativeWindow); e.NativeWindow.OrderOut(e.NativeWindow); NSApplication.SharedApplication.StopModal(); completed?.Invoke(); }; }
public static void BeginSheet(Window window, NSWindow theWindow, NSWindow parent, out ModalEventArgs helper, Action completed) { var app = NSApplication.SharedApplication; app.BeginSheet(theWindow, parent, delegate { NSApplication.SharedApplication.StopModal(); if (completed != null) { completed(); } }); helper = new ModalEventArgs(IntPtr.Zero, window, theWindow, isSheet: true); }
public virtual void ShowModal() { session = null; Callback.OnShown(Widget, EventArgs.Empty); Widget.Closed += HandleClosed; if (DisplayMode.HasFlag(DialogDisplayMode.Attached) && Control.ParentWindow != null) { MacModal.RunSheet(Widget, Control, out session); } else { Control.MakeKeyWindow(); MacModal.Run(Widget, Control, out session); } }
public virtual void ShowModal() { session = null; Application.Instance.AsyncInvoke(FireOnShown); // fire after dialog is shown Widget.Closed += HandleClosed; if (DisplayMode.HasFlag(DialogDisplayMode.Attached) && Widget.Owner != null) { MacModal.RunSheet(Widget, Control, Widget.Owner.ToNative(), out session); } else { Control.MakeKeyWindow(); MacModal.Run(Widget, Control, out session); } }
public virtual Task ShowModalAsync() { var tcs = new TaskCompletionSource <bool>(); session = null; Widget.Closed += HandleClosed; if (DisplayMode.HasFlag(DialogDisplayMode.Attached) && Widget.Owner != null) { MacModal.BeginSheet(Widget, Control, Widget.Owner.ToNative(), out session, () => tcs.SetResult(true)); } else { Control.MakeKeyWindow(); Application.Instance.AsyncInvoke(() => { Application.Instance.AsyncInvoke(FireOnShown); // fire after dialog is shown MacModal.Run(Widget, Control, out session); tcs.SetResult(true); }); } return(tcs.Task); }
public virtual void ShowModal(Control parent) { session = null; if (parent != null && parent.ParentWindow != null) { var nswindow = parent.ParentWindow.ControlObject as NSWindow; if (nswindow != null) { Control.ParentWindow = nswindow; } } Callback.OnShown(Widget, EventArgs.Empty); Widget.Closed += HandleClosed; if (DisplayMode.HasFlag(DialogDisplayMode.Attached)) { MacModal.RunSheet(Widget, Control, out session); } else { Control.MakeKeyWindow(); MacModal.Run(Widget, Control, out session); } }
internal void TriggerProcessModalSession(ModalEventArgs e) { OnProcessModalSession(e); }
public static void BeginSheet(Window window, NSWindow theWindow, out ModalEventArgs helper, Action completed) { var app = NSApplication.SharedApplication; var parent = theWindow.ParentWindow; app.BeginSheet(theWindow, parent, delegate { NSApplication.SharedApplication.StopModal(); if (completed != null) completed(); }); helper = new ModalEventArgs(IntPtr.Zero, window, theWindow, isSheet: true); }
public static void RunSheet(Window window, NSWindow theWindow, out ModalEventArgs helper) { var app = NSApplication.SharedApplication; var parent = theWindow.ParentWindow; app.BeginSheet(theWindow, parent, delegate { NSApplication.SharedApplication.StopModal(); }); var session = app.BeginModalSession(theWindow); helper = new ModalEventArgs(session, window, theWindow, isModal: true, isSheet: true); int result; var etoapp = ApplicationHandler.Instance; // Loop until some result other than continues: do { etoapp.TriggerProcessModalSession(helper); // Run the window modally until there are no events to process: result = (int)app.RunModalSession(session); // Give the main loop some time: NSRunLoop.Current.RunUntil(NSRunLoop.NSDefaultRunLoopMode, NSDate.DistantFuture); } while (result == (int)NSRun.ContinuesResponse || !helper.Stopped); app.EndModalSession(session); /** theWindow.OrderOut (null); app.EndSheet (theWindow); /**/ }
public static void RunSheet(Window window, NSWindow theWindow, NSWindow parent, out ModalEventArgs helper) { helper = new ModalEventArgs(window, theWindow, isModal: true, isSheet: true); helper.CanRestart = true; helper.RunSheet(parent); }
public static void Run(Window window, NSWindow nativeWindow, out ModalEventArgs helper, bool isSheet = false) { helper = new ModalEventArgs(window, nativeWindow, isModal: true, isSheet: isSheet); helper.CanRestart = true; helper.RunModal(); }