public void Initialize(IList <string> args, bool isDocumentApp) { Console.CancelKeyPress += (sender, e) => Exit(0); NSApplication.Init(); _dispatcher = _dispatcher ?? new Dispatcher(Thread.CurrentThread); Fusion.Application.MainThread = _dispatcher; Fusion.Application.PerFrame = Observable.Interval( TimeSpan.FromSeconds(1.0 / 60.0), new SynchronizationContextScheduler(SynchronizationContext.Current)); var app = new AppDelegate(isDocumentApp); NSApplication.SharedApplication.Delegate = app; //TODO do we really need to retain this object? #pragma warning disable 0219 var documentController = new NSDocumentController(); #pragma warning restore 0219 NSApplication.CheckForIllegalCrossThreadCalls = false; AppDelegate.ThrowOnTerminate = false; Desktop = new MacDialog <object>(); EffectsImplementation.Initialize(_dispatcher); // Make so that the window popups with focus. NSApplication.SharedApplication.ActivateIgnoringOtherApps(true); MacEnvironment.Initialize(new MacEnvironmentImpl()); DraggingImplementation.Initialize(_dispatcher); MenuBuilder.Initialize(_dispatcher); LayeringImplementation.Initialize(_dispatcher); LabelImplementation.Initialize(_dispatcher); SliderImplementation.Initialize(_dispatcher); LineImplementation.Initialize(_dispatcher); CircleImplementation.Initialize(_dispatcher); RectangleImplementation.Initialize(_dispatcher); TextBoxImplementation.Initialize(_dispatcher); CursorsImplementation.Initialize(_dispatcher); ToolTipImplementation.Initialize(_dispatcher); ContextMenuImplementation.Initialize(_dispatcher); DropDownImplementation.Initialize(_dispatcher); ButtonImplementation.Initialize(_dispatcher); ColorPickerImplementation.Initialize(_dispatcher); ScrollingImplementation.Initialize(_dispatcher); LogViewImplementation.Initialize(_dispatcher); Transformation.Initialize(); ImageImplementation.Initialize(_dispatcher); OverlayImplementation.Initialize(_dispatcher); PointerImplementation.Initialize(_dispatcher); KeyboardImplementation.Initialize(_dispatcher); WebViewImplementation.Initialize(_dispatcher); LayoutTrackerImplementation.Initialize(); FileDialogs.Initialize(); // TODO: Fix this!!! Clipping.Initialize((control, clip) => control); // This notification occurs a _lot_, but is the most specific one I was able to find that would // allow us to be notified when the first responder changes consistently NSNotificationCenter.DefaultCenter.AddObserver(new NSString("NSApplicationDidUpdateNotification"), _ => { var keyWindow = NSApplication.SharedApplication.KeyWindow; _firstResponder.OnNext(keyWindow != null ? keyWindow.FirstResponder : null); }); app.Terminates.Subscribe(_ => { if (Terminating != null) { Terminating(); } }); EditMenu = /*CreateFirstResponderMenuItem(name: "Undo", hotkey: HotKey.Create(Fusion.ModifierKeys.Meta, Key.Z), selectorName: "undo:") + CreateFirstResponderMenuItem(name: "Redo", hotkey: HotKey.Create(Fusion.ModifierKeys.Meta | Fusion.ModifierKeys.Shift, Key.Z), selectorName: "redo:") + MenuItem.CreateSeparator() + */CreateFirstResponderMenuItem(name: "Cut", hotkey: HotKey.Create(Fusion.ModifierKeys.Meta, Key.X), selectorName: "cut:") + CreateFirstResponderMenuItem(name: "Copy", hotkey: HotKey.Create(Fusion.ModifierKeys.Meta, Key.C), selectorName: "copy:") + CreateFirstResponderMenuItem(name: "Paste", hotkey: HotKey.Create(Fusion.ModifierKeys.Meta, Key.V), selectorName: "paste:") + CreateFirstResponderMenuItem(name: "Paste and Match Style", hotkey: HotKey.Create(Fusion.ModifierKeys.Meta | Fusion.ModifierKeys.Shift, Key.V), selectorName: "pasteAsPlainText:") + CreateFirstResponderMenuItem(name: "Delete", hotkey: HotKey.Create(Fusion.ModifierKeys.Meta, Key.Backspace), selectorName: "delete:") + CreateFirstResponderMenuItem(name: "Select All", hotkey: HotKey.Create(Fusion.ModifierKeys.Meta, Key.A), selectorName: "selectAll:"); }
public Task <Optional <AbsoluteDirectoryPath> > BrowseForDirectory(AbsoluteDirectoryPath directory) { var dialogs = new FileDialogs(_parent.OrDefault()); return(dialogs.SelectDirectory(new DirectoryDialogOptions("Browse", directory))); }