Ejemplo n.º 1
0
        public static void SaveCurrentSetFilePanel()
        {
            NSSavePanel savePanel = new NSSavePanel ();
            savePanel.Begin (((int result) => {
                try {
                    if (savePanel.Url != null) {
                        var urlString = savePanel.Url.Path;

                        if (!string.IsNullOrEmpty (urlString)) {
                            m_at.SaveCurrentSet (System.IO.Path.GetFileName (urlString),
                                System.IO.Path.GetDirectoryName (urlString));
                        } // string not null
                    } // url not null
                } finally {
                    savePanel.Dispose ();
                } // finally
            }));
        }
Ejemplo n.º 2
0
        public static void SaveCurrentSetFilePanel()
        {
            NSSavePanel savePanel = new NSSavePanel();

            savePanel.Begin(((int result) => {
                try {
                    if (savePanel.Url != null)
                    {
                        var urlString = savePanel.Url.Path;

                        if (!string.IsNullOrEmpty(urlString))
                        {
                            m_at.SaveCurrentSet(System.IO.Path.GetFileName(urlString),
                                                System.IO.Path.GetDirectoryName(urlString));
                        }                 // string not null
                    }                     // url not null
                } finally {
                    savePanel.Dispose();
                }                 // finally
            }));
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        internal static async Task <IStorageFile> PickSaveAsFileAsync(string defaultFileExtension = null, IDictionary <string, IList <string> > fileTypeChoices = null)
        {
            return(await MainThread.InvokeOnMainThread(async() =>
            {
                var tcs = new TaskCompletionSource <IStorageFile>();
                var panel = new NSSavePanel
                {
                    Title = "Save As ...",
                    CanCreateDirectories = true,
                };
                if (!string.IsNullOrWhiteSpace(defaultFileExtension))
                {
                    panel.AllowedContentTypes = new UniformTypeIdentifiers.UTType[]
                    {
                        //UTType.CreatePreferredIdentifier(UTType.TagClassFilenameExtension, defaultFileExtension, null)
                        UniformTypeIdentifiers.UTType.CreateFromExtension(defaultFileExtension)
                    }
                }
                ;

                panel.Begin(button =>
                {
                    if (button == (int)NSPanelButtonType.Ok)
                    {
                        if (panel.Url != null && panel.Url.IsFileUrl)
                        {
                            var result = new StorageFile(panel.Url, true);
                            tcs.SetResult(result);
                            return;
                        }
                    }
                    tcs.SetResult(null);
                });

                return await tcs.Task;
            }));
        }