コード例 #1
0
 public override void Dispose()
 {
     if (ofdlg != null)
     {
         ofdlg.Dispose();
     }
     if (sfdlg != null)
     {
         sfdlg.Dispose();
     }
 }
コード例 #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
            }));
        }
コード例 #3
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
            }));
        }
コード例 #4
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);
        }
コード例 #5
0
        private bool MacOpenFile()
        {
            NSOpenPanel nsOpenPanel = new NSOpenPanel();

            nsOpenPanel.Title = this.Title;
            switch (this.FileChooserAction)
            {
            case FileAction.Open:
                nsOpenPanel.CanChooseFiles       = true;
                nsOpenPanel.CanChooseDirectories = false;
                if (this.AllowedFileTypes != null)
                {
                    nsOpenPanel.AllowedFileTypes = this.AllowedFileTypes;
                    break;
                }
                break;

            case FileAction.Save:
                NSSavePanel savePanel = NSSavePanel.SavePanel;
                savePanel.AllowedFileTypes     = this.AllowedFileTypes;
                savePanel.CanCreateDirectories = true;
                savePanel.DirectoryUrl         = new NSUrl(this.InitialDirectory);
                // ISSUE: reference to a compiler-generated method
                if (savePanel.RunModal() == 1)
                {
                    this.Path = savePanel.Url.Path;
                    savePanel.Dispose();
                    return(true);
                }
                savePanel.Dispose();
                return(false);

            case FileAction.SelectFolder:
                nsOpenPanel.CanChooseDirectories = true;
                nsOpenPanel.CanChooseFiles       = false;
                break;

            case FileAction.SelectFiles:
                nsOpenPanel.CanChooseDirectories = true;
                nsOpenPanel.CanChooseFiles       = true;
                break;
            }
            nsOpenPanel.CanCreateDirectories    = false;
            nsOpenPanel.AllowsMultipleSelection = this.AllowMultipleSelect;
            nsOpenPanel.DirectoryUrl            = new NSUrl(this.InitialDirectory);
            // ISSUE: reference to a compiler-generated method
            if (nsOpenPanel.RunModal() == 1)
            {
                int      length   = nsOpenPanel.Urls.Length;
                string[] strArray = new string[length];
                for (int index = 0; index < length; ++index)
                {
                    strArray[index] = nsOpenPanel.Urls[index].Path.ToString();
                }
                this.Paths = strArray;
                this.Path  = this.Paths[0];
                nsOpenPanel.Dispose();
                return(true);
            }
            nsOpenPanel.Dispose();
            return(false);
        }