コード例 #1
0
ファイル: ViewController.cs プロジェクト: cheetodust/VRC-Mac
        nint OpenPanel(bool chooseFiles, bool chooseDirectories, out string dir)
        {
            nint res       = 1;
            var  openPanel = new NSOpenPanel
            {
                CanChooseFiles       = chooseFiles,
                CanChooseDirectories = chooseDirectories,
            };
            NSWindow window = new NSWindow {
            };

            openPanel.BeginSheet(window, result =>
            {
                window.EndSheet(window);
                res = result;
            });
            if (res == 1)
            {
                dir = openPanel.DirectoryUrl.Path;
            }
            else
            {
                dir = "";
            }
            return(res);
        }
コード例 #2
0
ファイル: GuiUtils.cs プロジェクト: whitevirus/Eddie
        public static void SelectPath(NSWindow window, NSTextField field)
        {
            NSOpenPanel openPanel = new NSOpenPanel();

            openPanel.CanChooseFiles          = false;
            openPanel.CanChooseDirectories    = true;
            openPanel.AllowsMultipleSelection = false;
            openPanel.ResolvesAliases         = true;
            openPanel.BeginSheet(window, (i) =>
            {
                try
                {
                    if (openPanel.Url != null)
                    {
                        string path = openPanel.Url.Path;

                        if (!string.IsNullOrEmpty(path))
                        {
                            field.StringValue = path;
                        }
                    }
                }
                finally
                {
                    openPanel.Dispose();
                }
            });
        }
コード例 #3
0
        partial void LoadDataClicked(NSButton sender)
        {
            var panel = new NSOpenPanel
            {
                CanChooseFiles          = false,
                CanChooseDirectories    = true,
                AllowsMultipleSelection = true
            };

            panel.BeginSheet(View.Window, (result) =>
            {
                if (result == 0 || panel.Url == null)
                {
                    return;                                   // 0: pressed `Cancel`
                }
                var dataSource = new LoadedDataOutlineDataSource(
                    new RootDirectory(
                        panel.Url.Path,
                        FileManager
                        )
                    );
                var outlineViewDelegate = new LoadedDataOutlineDelegate(dataSource);

                LoadedDataOutlineView.DataSource = dataSource;
                LoadedDataOutlineView.Delegate   = outlineViewDelegate;
                ProcessDataButton.Enabled        = true;
            });
        }
コード例 #4
0
        partial void btnBrowseData_Clicked(MonoMac.Foundation.NSObject sender)
        {
            NSOpenPanel openPanel = NSOpenPanel.OpenPanel;

            openPanel.CanChooseDirectories = true;
            openPanel.CanChooseFiles       = false;
            openPanel.BeginSheet(Window, ((int result) => {
                if (result == (int)NSPanelButtonType.Ok)
                {
                    txtData.Cell.Title = openPanel.Url.Path;
                }
            }));
        }
コード例 #5
0
        public void OpenFile(NSMenuItem menuItem)
        {
            if (backgroundWorker.IsBusy)
            {
                var alert = new NSAlert()
                {
                    InformativeText = "Please wait until the current process is finished and try again.",
                    MessageText     = NSBundle.MainBundle.ObjectForInfoDictionary("CFBundleExecutable").ToString(),
                };
                alert.RunModal();
                return;
            }

            NSOpenPanel openPanel = NSOpenPanel.OpenPanel;

            openPanel.CanChooseFiles          = true;
            openPanel.CanChooseDirectories    = false;
            openPanel.AllowsMultipleSelection = true;
            openPanel.AllowedFileTypes        = new string[] { "xci", "nsp", "nro" };
            openPanel.DirectoryUrl            = new NSUrl(!String.IsNullOrEmpty(Common.Settings.Default.InitialDirectory) && Directory.Exists(Common.Settings.Default.InitialDirectory) ? Common.Settings.Default.InitialDirectory : Environment.GetFolderPath(Environment.SpecialFolder.UserProfile));
            openPanel.Title = "Open NX Game Files";

            Process.log?.WriteLine("\nOpen File");

            openPanel.BeginSheet(Window, (nint result) =>
            {
                if (result == (int)NSModalResponse.OK)
                {
                    tableViewDataSource.Titles.Clear();
                    tableView.ReloadData();

                    Common.Settings.Default.InitialDirectory = Path.GetDirectoryName(openPanel.Urls.First().Path);
                    Common.Settings.Default.Save();

                    title.StringValue    = String.Format("Opening files");
                    message.StringValue  = "";
                    progress.DoubleValue = 0;

                    Window.BeginSheet(sheet, ProgressComplete);

                    List <string> filenames = openPanel.Urls.Select((arg) => arg.Path).ToList();
                    filenames.Sort();

                    Process.log?.WriteLine("{0} files selected", filenames.Count);

                    title.StringValue = String.Format("Opening {0} files", filenames.Count);

                    backgroundWorker.RunWorkerAsync(filenames);
                }
            });
        }
コード例 #6
0
 partial void openProject(NSObject sender)
 {
     if (CheckSave())
     {
         NSOpenPanel panel = NSOpenPanel.OpenPanel;
         panel.AllowedFileTypes = new string[] { @"header_hero" };
         panel.BeginSheet(mainWindowController.Window, (result) => {
             if (result == (int)NSPanelButtonType.Ok)
             {
                 Open(panel.Url.Path);
             }
         });
     }
 }
コード例 #7
0
        partial void ShowOpenPanel(Foundation.NSObject sender)
        {
            NSOpenPanel panel = NSOpenPanel.OpenPanel;

            panel.AllowedFileTypes = NSImage.ImageFileTypes;
            panel.BeginSheet(stretchView.Window, (result) => {
                if (result == 1)
                {
                    StretchImage image = new StretchImage(panel.Url);
                    stretchView.Image  = image;
                }
                panel = null;
            });
        }
コード例 #8
0
        partial void btnBrowseIpBin_Clicked(MonoMac.Foundation.NSObject sender)
        {
            NSOpenPanel openPanel = NSOpenPanel.OpenPanel;

            openPanel.CanChooseFiles       = true;
            openPanel.CanChooseDirectories = false;
            openPanel.AllowedFileTypes     = new [] { "bin" };
            openPanel.AllowsOtherFileTypes = false;
            openPanel.BeginSheet(Window, ((int result) => {
                if (result == (int)NSPanelButtonType.Ok)
                {
                    txtIpBin.Cell.Title = openPanel.Url.Path;
                }
            }));
        }
コード例 #9
0
        partial void ChangeWatchPath(NSObject sender)
        {
            var openPanel = new NSOpenPanel {
                CanChooseDirectories = true,
                CanChooseFiles       = false
            };

            openPanel.BeginSheet(Window, result => {
                if (result == 1)
                {
                    WatchPathTextField.StringValue = openPanel.DirectoryUrl.Path;
                    OnWatchPathChanged(null, null);
                }
            });
        }
コード例 #10
0
        void ChangeFolder(Foundation.NSObject sender)
        {
            var panel = new NSOpenPanel
            {
                CanChooseDirectories = true,
                CanCreateDirectories = true,
                CanChooseFiles       = false,
                DirectoryUrl         = new NSUrl(directoryField.StringValue, true)
            };

            panel.BeginSheet(this.View.Window, (nint hi) =>
            {
                if (hi == (int)NSModalResponse.OK)
                {
                    var newURL = panel.Url;
                    directoryField.StringValue = newURL.Path;
                }
            });
        }
コード例 #11
0
        partial void btnAdd_Clicked(MonoMac.Foundation.NSObject sender)
        {
            NSOpenPanel openPanel = NSOpenPanel.OpenPanel;

            openPanel.CanChooseFiles          = true;
            openPanel.CanChooseDirectories    = false;
            openPanel.AllowedFileTypes        = new [] { "raw" };
            openPanel.AllowsOtherFileTypes    = false;
            openPanel.AllowsMultipleSelection = true;
            openPanel.BeginSheet(Window, ((int result) => {
                if (result == (int)NSPanelButtonType.Ok)
                {
                    foreach (NSUrl url in openPanel.Urls)
                    {
                        _tracks.Rows.Add(new CddaItem(url.Path));
                    }
                    tblCdda.ReloadData();
                }
            }));
        }
コード例 #12
0
        public static void SelectFile(NSWindow window, NSTextField field)
        {
            NSOpenPanel openPanel = new NSOpenPanel();

            openPanel.BeginSheet(window, (i) => {
                try {
                    if (openPanel.Url != null)
                    {
                        string path = openPanel.Url.Path;

                        if (!string.IsNullOrEmpty(path))
                        {
                            field.StringValue = path;
                        }
                    }
                } finally {
                    openPanel.Dispose();
                }
            });
        }
コード例 #13
0
        //public NSImage ToNSImage(BitmapImage img)
        //{
        //	System.IO.MemoryStream s = new System.IO.MemoryStream();
        //	img.Save(s, ImageFileType.Png);
        //	byte[] b = s.ToArray();
        //	CGDataProvider dp = new CGDataProvider(b, 0, (int)s.Length);
        //	s.Flush();
        //	s.Close();
        //	CGImage img2 = CGImage.FromPNG(dp, null, false, CGColorRenderingIntent.Default);
        //	return new NSImage(img2, new CGSize (img2.Width, img2.Height));
        //}

        public async Task <IImageWrapper> OpenDialogSelectImage(IWindowWrapper selectedWindow)
        {
            var panel = new NSOpenPanel();

            panel.AllowedFileTypes = new[] { "png" };
            panel.Prompt           = "Select a image";
            IImageWrapper rtrn = null;

            processingCompletion = new TaskCompletionSource <object>();

            panel.BeginSheet(selectedWindow.NativeObject as NSWindow, result =>
            {
                if (result == 1 && panel.Url != null)
                {
                    rtrn = new MacImageWrapper(new NSImage(panel.Url.Path));// Xwt.Drawing.Image.FromFile(panel.Url.Path);
                }
                processingCompletion.TrySetResult(null);
            });
            await processingCompletion.Task;

            return(rtrn);
        }
コード例 #14
0
        public void OpenSDCard(NSMenuItem menuItem)
        {
            if (Process.keyset?.SdSeed?.All(b => b == 0) ?? true)
            {
                string error = "sd_seed is missing from Console Keys";
                Process.log?.WriteLine(error);

                var alert = new NSAlert()
                {
                    InformativeText = String.Format("{0}.\nOpen SD Card will not be available.", error),
                    MessageText     = NSBundle.MainBundle.ObjectForInfoDictionary("CFBundleExecutable").ToString(),
                };
                alert.RunModal();
                return;
            }

            if ((Process.keyset?.SdCardKekSource?.All(b => b == 0) ?? true) || (Process.keyset?.SdCardKeySources?[1]?.All(b => b == 0) ?? true))
            {
                Process.log?.WriteLine("Keyfile missing required keys");
                Process.log?.WriteLine(" - {0} ({1}exists)", "sd_card_kek_source", (bool)Process.keyset?.SdCardKekSource?.Any(b => b != 0) ? "" : "not ");
                Process.log?.WriteLine(" - {0} ({1}exists)", "sd_card_nca_key_source", (bool)Process.keyset?.SdCardKeySources?[1]?.Any(b => b != 0) ? "" : "not ");

                var alert = new NSAlert()
                {
                    InformativeText = "sd_card_kek_source and sd_card_nca_key_source are missing from Keyfile.\nOpen SD Card will not be available.",
                    MessageText     = NSBundle.MainBundle.ObjectForInfoDictionary("CFBundleExecutable").ToString(),
                };
                alert.RunModal();
                return;
            }

            if (backgroundWorker.IsBusy)
            {
                var alert = new NSAlert()
                {
                    InformativeText = "Please wait until the current process is finished and try again.",
                    MessageText     = NSBundle.MainBundle.ObjectForInfoDictionary("CFBundleExecutable").ToString(),
                };
                alert.RunModal();
                return;
            }

            NSOpenPanel openPanel = NSOpenPanel.OpenPanel;

            openPanel.CanChooseFiles       = false;
            openPanel.CanChooseDirectories = true;
            openPanel.DirectoryUrl         = new NSUrl(!String.IsNullOrEmpty(Common.Settings.Default.SDCardDirectory) && Directory.Exists(Common.Settings.Default.SDCardDirectory) ? Common.Settings.Default.SDCardDirectory : Environment.GetFolderPath(Environment.SpecialFolder.UserProfile));
            openPanel.Title = "Open SD Card";

            Process.log?.WriteLine("\nOpen SD Card");

            openPanel.BeginSheet(Window, (nint result) =>
            {
                if (result == (int)NSModalResponse.OK)
                {
                    tableViewDataSource.Titles.Clear();
                    tableView.ReloadData();

                    Common.Settings.Default.SDCardDirectory = openPanel.Urls.First().Path;
                    Common.Settings.Default.Save();

                    title.StringValue    = String.Format("Opening SD card on {0}", openPanel.Urls.First().Path);
                    message.StringValue  = "";
                    progress.DoubleValue = 0;

                    Process.log?.WriteLine("SD card selected");

                    Window.BeginSheet(sheet, ProgressComplete);

                    backgroundWorker.RunWorkerAsync(openPanel.Urls.First().Path);
                }
            });
        }
コード例 #15
0
ファイル: MainWindow.cs プロジェクト: luicil/MacRAR
        private void procBtn(int state = 1)
        {
            if (state == 4)
            {
                string[]    filetypes = { "rar" };
                NSOpenPanel dlg       = NSOpenPanel.OpenPanel;
                dlg.Title                   = "Selecione";
                dlg.CanChooseFiles          = true;
                dlg.CanChooseDirectories    = false;
                dlg.AllowedFileTypes        = filetypes;
                dlg.AllowsMultipleSelection = false;
                dlg.ResolvesAliases         = true;
                dlg.ReleasedWhenClosed      = true;
                dlg.BeginSheet(this, (i) => {
                    try
                    {
                        if (dlg.Url != null)
                        {
                            var urlString = dlg.Url.Path;
                            if (!string.IsNullOrEmpty(urlString))
                            {
                                //NSDate DateLoop = new NSDate ();
                                //DateLoop = DateLoop.AddSeconds (0.1);
                                //NSRunLoop.Current.RunUntil(DateLoop );

                                NSThread.Start(() => {
                                    clsRAR orar = new clsRAR();
                                    rarFile     = orar.OpenRAR(urlString, this, this.tbv_Arquivos);
                                    orar        = null;
                                });
                            }
                        }
                    }
                    finally
                    {
                        dlg.Dispose();
                        dlg = null;
                    }
                });
            }
            else
            {
                NSIndexSet nSelRows = this.tbv_Arquivos.SelectedRows;
                if (nSelRows.Count > 0)
                {
                    nuint[] nRows = nSelRows.ToArray();
                    if (nRows.Length > 0)
                    {
                        ViewArquivosDataSource datasource = (ViewArquivosDataSource)this.tbv_Arquivos.DataSource;
                        clsViewArquivos        cvarqs     = new clsViewArquivos();
                        string aState = string.Empty;
                        foreach (nint lRow in nRows)
                        {
                            switch (state)
                            {
                            case 1:
                                aState = "1";
                                break;

                            case 2:
                                aState = cvarqs.GetTagsArquivo(datasource, (int)lRow, 1);
                                break;

                            case 3:
                                NSOpenPanel dlg = NSOpenPanel.OpenPanel;
                                dlg.Title                   = "Salvar em";
                                dlg.CanChooseFiles          = false;
                                dlg.CanChooseDirectories    = true;
                                dlg.AllowsMultipleSelection = false;
                                dlg.ResolvesAliases         = true;
                                dlg.ReleasedWhenClosed      = true;
                                dlg.BeginSheet(this, (i) => {
                                    try {
                                        string urlString = dlg.Url.Path;
                                        if (!string.IsNullOrEmpty(urlString))
                                        {
                                            nSelRows = this.tbv_Arquivos.SelectedRows;
                                            NSThread.Start(() => {
                                                clsRAR exRAR = new clsRAR();
                                                exRAR.ExtractRAR(this, this.tbv_Arquivos, nSelRows, rarFile, urlString);
                                                exRAR = null;
                                            });
                                        }
                                    } finally {
                                        dlg.Dispose();
                                        dlg = null;
                                    }
                                    this.tbv_Arquivos.ReloadData();
                                });
                                break;

                            case 5:

                                break;
                            }
                            if (state != 3)
                            {
                                cvarqs.SetTagsArquivo(datasource, (int)lRow, aState);
                                cvarqs     = null;
                                datasource = null;
                                this.tbv_Arquivos.ReloadData();
                            }
                        }
                    }
                }
                else
                {
                    string mText = string.Empty;
                    string iText = string.Empty;
                    switch (state)
                    {
                    case 1:
                        mText = "Remover Arquivo(s)";
                        iText = "Selecione ao menos um aquivo para Remover !";
                        break;

                    case 2:
                        mText = "Desfazer Ação";
                        iText = "Selecione ao menos um arquivo para\r\n Desfazer a Ação !";
                        break;

                    case 3:
                        mText = "Extrair Arquivos";
                        iText = "Selecione ao menos um arquivo para Extrair !";
                        break;
                    }

                    NSAlert alert = new NSAlert()
                    {
                        AlertStyle      = NSAlertStyle.Warning,
                        InformativeText = iText,
                        MessageText     = mText,
                    };
                    alert.RunSheetModal(this);
                }
            }
        }
コード例 #16
0
		partial void ChangeWatchPath (NSObject sender)
		{
			var openPanel = new NSOpenPanel {
				CanChooseDirectories = true,
				CanChooseFiles = false
			};

			openPanel.BeginSheet (Window, result => {
				if (result == 1) {
					WatchPathTextField.StringValue = openPanel.DirectoryUrl.Path;
					OnWatchPathChanged (null, null);
				}
			});
		}