Example #1
0
        Task <string[]> RunPanel(NSSavePanel panel, IWindowImpl parent)
        {
            var keyWindow = MonoMacPlatform.App.KeyWindow;
            var tcs       = new TaskCompletionSource <string[]>();

            void OnComplete(int result)
            {
                if (result == 0)
                {
                    tcs.SetResult(null);
                }
                else
                {
                    if (panel is NSOpenPanel openPanel)
                    {
                        tcs.SetResult(openPanel.Urls.Select(url => url.AbsoluteString).ToArray());
                    }
                    else
                    {
                        tcs.SetResult(new[] { panel.Url.AbsoluteString });
                    }
                }
                panel.OrderOut(panel);
                keyWindow?.MakeKeyAndOrderFront(keyWindow);
                MonoMacPlatform.App.ActivateIgnoringOtherApps(true);
                panel.Dispose();
            }

            if (parent != null)
            {
                var window = (WindowImpl)parent;
                panel.BeginSheet(window.Window, OnComplete);
            }
            else
            {
                panel.Begin(OnComplete);
            }
            return(tcs.Task);
        }