示例#1
0
        private void OnFinished(object?sender, LogDownloadFinishedEventArgs e)
        {
            Dispatcher.UIThread.Post(async() =>
            {
                _progressText.Text = Loc.Resolve("coredump_dl_progress_finished");

                OpenFolderDialog dlg = new OpenFolderDialog()
                {
                    Title = Loc.Resolve("coredump_dl_save_dialog_title")
                };
                string?path = await dlg.ShowAsync(MainWindow.Instance);

                if (string.IsNullOrEmpty(path))
                {
                    return;
                }

                e.CoreDumpPaths.ForEach(x => CopyFile(x, path));
                e.TraceDumpPaths.ForEach(x => CopyFile(x, path));

                await new MessageBox()
                {
                    Title       = Loc.Resolve("coredump_dl_save_success_title"),
                    Description = string.Format(Loc.Resolve("coredump_dl_save_success"), e.CoreDumpPaths.Count + e.TraceDumpPaths.Count, path)
                }.ShowDialog(MainWindow.Instance);
            });
        }
示例#2
0
        private async void BrowseButton_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new OpenFolderDialog();
            var result = await dialog.ShowAsync((Window)this.GetVisualRoot());

            this.PathText.Text = result;
        }
示例#3
0
        void Brouse(object sender, EventArgs e)
        {
            if (Environment.OSVersion.Version.Major >= 6)
            {
                OpenFolderDialog dialog = new OpenFolderDialog();

                if (System.IO.Directory.Exists(DirPath))
                {
                    dialog.InitialFolder = DirPath;
                }

                if (dialog.ShowDialog(this) == DialogResult.OK)
                {
                    DirPath = dialog.Folder;
                }
            }
            else
            {
                FolderBrowserDialog dialog = new FolderBrowserDialog()
                {
                    Description = "検索対象のフォルダを選択してください。",
                };
                if (System.IO.Directory.Exists(DirPath))
                {
                    dialog.SelectedPath = DirPath;
                }

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    DirPath = dialog.SelectedPath;
                }
            }
        }
示例#4
0
        public static async Task <string> FindSteamGamePath(Window win, int appid, string gameName)
        {
            string path = null;

            if (ReadRegistrySafe("Software\\Valve\\Steam", "SteamPath") != null)
            {
                string appsPath = Path.Combine((string)ReadRegistrySafe("Software\\Valve\\Steam", "SteamPath"), "steamapps");

                if (File.Exists(Path.Combine(appsPath, $"appmanifest_{appid}.acf")))
                {
                    return(Path.Combine(Path.Combine(appsPath, "common"), gameName));
                }

                path = SearchAllInstallations(Path.Combine(appsPath, "libraryfolders.vdf"), appid, gameName);
            }

            if (path == null)
            {
                await MessageBoxUtil.ShowDialog(win, "Game location", "Couldn't find installation automatically. Please pick the location manually.");

                OpenFolderDialog ofd    = new OpenFolderDialog();
                string           folder = await ofd.ShowAsync(win);

                if (folder != null && folder != "")
                {
                    path = folder;
                }
            }

            return(path);
        }
示例#5
0
        public AssetTypeValueField GetBaseField(AssetContainer cont)
        {
            var item     = cont.Item;
            var fileInst = cont.FileInstance;

            if (item.TypeID == 0x72)
            {
                var tt = fileInst.file.typeTree;
                //check if typetree data exists already
                if (!tt.hasTypeTree || AssetHelper.FindTypeTreeTypeByScriptIndex(tt, item.MonoID) == null)
                {
                    var filePath    = Path.GetDirectoryName(fileInst.parentBundle != null ? fileInst.parentBundle.path : fileInst.path);
                    var managedPath = Path.Combine(filePath ?? Environment.CurrentDirectory, "Managed");
                    if (!Directory.Exists(managedPath))
                    {
                        var ofd = new OpenFolderDialog
                        {
                            Title = @"Select a folder for assemblies"
                        };
                        if (ofd.ShowDialog() != DialogResult.OK)
                        {
                            return(cont.TypeInstance?.GetBaseField());
                        }

                        managedPath = ofd.Folder;
                    }
                    var monoField = GetMonoBaseField(cont, managedPath);
                    if (monoField != null)
                    {
                        return(monoField);
                    }
                }
            }
            return(cont.TypeInstance?.GetBaseField());
        }
示例#6
0
        private void Browse_Click(object sender, EventArgs e)
        {
            var ofd = new OpenFolderDialog();

            if (sender == _sourceButton)
            {
                ofd.Title        = "Select source directory";
                ofd.SelectedPath = _sourceTextBox.Text;
            }
            else if (sender == _destinationButton)
            {
                ofd.Title        = "Select destination directory";
                ofd.SelectedPath = _destinationTextBox.Text;
            }

            if (!ofd.Show(this))
            {
                return;
            }

            if (sender == _sourceButton)
            {
                _sourceTextBox.Text = ofd.SelectedPath;
            }
            else if (sender == _destinationButton)
            {
                _destinationTextBox.Text = ofd.SelectedPath;
            }
        }
        public BrowseableUriEntry()
        {
            InitializeComponent();

            this.FindControl <Button>("BrowseButton").Command = ReactiveCommand.Create(async() =>
            {
                if (IsDirEntry)
                {
                    var dialog = new OpenFolderDialog();
                    var res    = await dialog.ShowAsync((Window)this.GetVisualRoot());

                    if (res != null)
                    {
                        Text = res;
                    }
                }
                else
                {
                    var dialog = new OpenFileDialog();
                    var res    = await dialog.ShowAsync((Window)this.GetVisualRoot());

                    if (res != null)
                    {
                        Text = res[0];
                    }
                }
            });

            _textBox = this.FindControl <TextBox>("TextBox");
            _label   = this.FindControl <TextBlock>("Label");
        }
示例#8
0
        public async Task <bool> BatchImport(Window win, AssetWorkspace workspace, List <AssetContainer> selection)
        {
            OpenFolderDialog ofd = new OpenFolderDialog();

            ofd.Title = "Select import directory";

            string dir = await ofd.ShowAsync(win);

            if (dir != null && dir != string.Empty)
            {
                ImportBatch            dialog     = new ImportBatch(workspace, selection, dir, ".png");
                List <ImportBatchInfo> batchInfos = await dialog.ShowDialog <List <ImportBatchInfo> >(win);

                foreach (ImportBatchInfo batchInfo in batchInfos)
                {
                    AssetContainer cont = batchInfo.cont;

                    AssetTypeValueField baseField = workspace.GetBaseField(cont);

                    string file = batchInfo.importFile;

                    byte[] byteData = File.ReadAllBytes(file);
                    baseField.Get("m_Script").GetValue().Set(byteData);

                    byte[] savedAsset = baseField.WriteToByteArray();

                    var replacer = new AssetsReplacerFromMemory(
                        0, cont.PathId, (int)cont.ClassId, cont.MonoId, savedAsset);

                    workspace.AddReplacer(cont.FileInstance, replacer, new MemoryStream(savedAsset));
                }
                return(true);
            }
            return(false);
        }
        private async void FindPathButton_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
        {
            var dialog = new OpenFolderDialog();
            var path   = await dialog.ShowAsync(this);

            PathTextBox.Text = path;
        }
        private void btExportCSV_Click(object sender, EventArgs e)
        {
            var ofd = new OpenFolderDialog();

            if (ofd.ShowDialog(this) == DialogResult.OK)
            {
                //получаем список анкет в выбранной папке
                var anketas = Directory.GetFiles(ofd.Folder, "*.a").Select(path => SaverLoader.Load <Anketa>(path)).ToList();
                if (anketas.Count == 0)
                {
                    MessageBox.Show("В этой папке не найдены анкеты");
                    return;
                }

                //запрашиваем имя выходного csv файла
                var sfd = new SaveFileDialog()
                {
                    Filter = "CSV|*.csv"
                };
                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    //экспортируем
                    new Export().ExportToCSV(anketas, sfd.FileName);
                    MessageBox.Show("Экспортировано " + anketas.Count + " анкет");
                }
            }
        }
示例#11
0
        public async Task <Photo[]> ReadAllFromDir(PhotoLoadType loadType = PhotoLoadType.Miniature, bool isRecursive = false)
        {
            var dig = new OpenFolderDialog()
            {
                //TODO: Multi language support
                Title = "Chose directory image files"
            };
            var multipleFiles = await _reader.ReadAllFromDir(dig, isRecursive);

            var photoList = new List <Photo>();

            foreach (var(path, stream) in multipleFiles)
            {
                try
                {
                    var imageBrush          = ReadImageBrushFromFile(stream, loadType);
                    var metaDataDirectories = ImageMetadataReader.ReadMetadata(path);
                    var photo = new Photo
                    {
                        ImageBrush          = imageBrush,
                        Attribute           = Attribute.NotProcessed,
                        MetaDataDirectories = metaDataDirectories
                    };
                    photoList.Add(photo);
                }
                catch (Exception e)
                {
                    //TODO: translate to rus
                    Console.WriteLine($"ERROR: image from {path} is skipped!\nDetails: {e}");
                }
            }
            return(photoList.ToArray());
        }
示例#12
0
        public void doOpenDialog(string filter, string callback)
        {
            ObjectCreator oc = new ObjectCreator("OpenFolderDialog");

            oc["Title"]         = "Select Export Folder";
            oc["Filters"]       = filter;
            oc["DefaultFile"]   = new ObjectCreator.StringNoQuote("$currentFile");
            oc["ChangePath"]    = false;
            oc["MustExist"]     = true;
            oc["MultipleFiles"] = false;

            OpenFolderDialog dlg = oc.Create();

            if (Util.filePath(sGlobal["$currentFile"]) != "")
            {
                dlg["DefaultPath"] = Util.filePath(sGlobal["$currentFile"]);
            }
            else
            {
                dlg["DefaultPath"] = Util.getMainDotCsDir();
            }

            if (dlg.Execute())
            {
                Util.eval(callback + "(\"" + dlg["FileName"] + "\");");
            }

            dlg.delete();
        }
示例#13
0
        /// <summary>
        /// Event handler. Opens the select folder dialog
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected async void OpenFileButtonOnClick(object sender, RoutedEventArgs e)
        {
            var btn = sender as Button;

            if (btn is null)
            {
                return;
            }

            var dialog = new OpenFolderDialog();

            var result = await dialog.ShowAsync((Window)Parent);

            var vm = GetViewModel();

            if (result is not null && result.Any())
            {
                if (btn.Name == nameof(StartViewModel.DatasetPath))
                {
                    vm.DatasetPath = result;
                }
                else if (btn.Name == nameof(StartViewModel.OutputPath))
                {
                    vm.OutputPath = result;
                }
            }
        }
示例#14
0
        public async void ImportButtonClick(object sender, RoutedEventArgs args)
        {
            var dialog = new OpenFolderDialog();

            var result = await dialog.ShowAsync(this);

            if (string.IsNullOrEmpty(result))
            {
                return;
            }

            await MessageBox.Show(this, "Waitting for Decompress", "Decompress", MessageBox.MessageBoxButtons.None,
                                  () =>
            {
                var decompressDirectory = FileUtil.CreateDecompressDirectory(new DirectoryInfo(result));

                FileUtil.Decompress(decompressDirectory);

                Dispatcher.UIThread.InvokeAsync(() =>
                {
                    if (viewModel != null)
                    {
                        viewModel.LogFilePath = decompressDirectory.FullName;
                    }
                });
            });
        }
示例#15
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void openFileSystemToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (worker.IsBusy)
            {
                return;
            }

            fileSystemToolStripMenuItem.Enabled      = false;
            iSOToolStripMenuItem.Enabled             = true;
            saveAsToolStripMenuItem.Enabled          = true;
            saveToolStripMenuItem.Enabled            = true;
            closeFileSystemToolStripMenuItem.Enabled = true;

            using (OpenFolderDialog d = new OpenFolderDialog())
            {
                if (d.ShowDialog() == DialogResult.OK)
                {
                    if (openedPath == d.SelectedPath)
                    {
                        MessageBox.Show("File System is already opened", "Open ISO", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    else
                    {
                        if (Core.MEX.InitFromFileSystem(d.SelectedPath))
                        {
                            FileSystemLoaded(d.SelectedPath);
                        }
                    }
                }
            }
        }
示例#16
0
        protected virtual void InitializeCommands()
        {
            OpenEmulatorFolderCommand = new RelayCommand(p =>
            {
                OpenFolderDialog openFolderDialog = new OpenFolderDialog();

                if (openFolderDialog.ShowDialog() == true)
                {
                    SetSelectedPath(openFolderDialog.SelectedPath);
                }
            });

            OpenFolderCommand = new RelayCommand(p =>
            {
                try
                {
                    var path = Path.GetFullPath(SelectedPath);
                    Process.Start(path);
                }
                catch
                {
                    Process.Start(Environment.CurrentDirectory);
                }
            });

            OpenMTPFolderCommand = new RelayCommand(p =>
            {
                var mtp = mTPManager.Open(SelectedPath);
                if (mtp.Result == true)
                {
                    SetSelectedPath(mtp.SelectedPath);
                }
            });
        }
示例#17
0
        public GccProfilesSettingsViewModel() : base("GCC Profiles")
        {
            SaveCommand = ReactiveCommand.Create(() =>
            {
                if (!string.IsNullOrEmpty(InstanceName))
                {
                    if (!_settings.Profiles.ContainsKey(InstanceName))
                    {
                        _settings.Profiles[InstanceName] = new CustomGCCToolchainProfile();

                        Profiles.Add(InstanceName);
                    }

                    var profile = _settings.Profiles[InstanceName];

                    _settings.Save();
                }
            });

            BrowseCommand = ReactiveCommand.Create(async() =>
            {
                var fbd = new OpenFolderDialog();

                var result = await fbd.ShowAsync();

                if (!string.IsNullOrEmpty(result))
                {
                    BasePath = result;

                    Save();
                }
            });
        }
示例#18
0
        public async Task <string> ShowFolderDialogAsync(OpenFolderDialog dialog, IWindowImpl parent)
        {
            var res = await ShowDialog(dialog.Title, ((WindowBaseImpl)parent)?.GtkWidget,
                                       GtkFileChooserAction.SelectFolder, false, dialog.InitialDirectory);

            return(res?.FirstOrDefault());
        }
示例#19
0
        public Task <string> ShowFolderDialogAsync(OpenFolderDialog dialog, IWindowImpl parent)
        {
            var tcs = new TaskCompletionSource <string>();
            var dlg = new global::Gtk.FileChooserDialog(dialog.Title, ((WindowImplBase)parent)?.Widget.Toplevel as Window,
                                                        FileChooserAction.SelectFolder,
                                                        "Cancel", ResponseType.Cancel,
                                                        "Select Folder", ResponseType.Accept)
            {
            };

            dlg.Modal = true;

            dlg.Response += (_, args) =>
            {
                if (args.ResponseId == ResponseType.Accept)
                {
                    tcs.TrySetResult(dlg.Filename);
                }

                dlg.Hide();
                dlg.Dispose();
            };

            dlg.Close += delegate
            {
                tcs.TrySetResult(null);
                dlg.Dispose();
            };
            dlg.Show();
            return(tcs.Task);
        }
示例#20
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void fileSystemToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (worker.IsBusy || !Core.MEX.Initialized)
            {
                return;
            }

            rebuildPath = null;

            using (var d = new OpenFolderDialog())
            {
                d.Title = "Choose output folder";

                if (d.ShowDialog() == DialogResult.OK)
                {
                    rebuildPath = d.SelectedPath;
                }
                else
                {
                    return;
                }
            }

            BeginSaving(ForceMode.FileSystem);
        }
示例#21
0
 /// <summary>
 /// show folder dialog as an asynchronous operation.
 /// </summary>
 /// <param name="dialog">The dialog.</param>
 /// <param name="parent">The parent.</param>
 /// <returns>System.String.</returns>
 public async Task <string> ShowFolderDialogAsync(OpenFolderDialog dialog, IWindowImpl parent)
 {
     return((await ShowAsync(dialog, parent, new ManagedFileDialogOptions()
     {
         AllowDirectorySelection = true
     }))?.FirstOrDefault());
 }
示例#22
0
        public async Task <bool> BatchExport(Window win, AssetWorkspace workspace, List <AssetContainer> selection)
        {
            OpenFolderDialog ofd = new OpenFolderDialog();

            ofd.Title = "Select export directory";

            string dir = await ofd.ShowAsync(win);

            if (dir != null && dir != string.Empty)
            {
                foreach (AssetContainer cont in selection)
                {
                    AssetTypeValueField baseField = workspace.GetBaseField(cont);

                    string name     = baseField.Get("m_Name").GetValue().AsString();
                    byte[] byteData = baseField.Get("m_Script").GetValue().AsStringBytes();

                    string file = Path.Combine(dir, $"{name}-{Path.GetFileName(cont.FileInstance.path)}-{cont.PathId}.txt");

                    File.WriteAllBytes(file, byteData);
                }
                return(true);
            }
            return(false);
        }
示例#23
0
        private void BatchExportRaw(List <AssetContainer> selectedAssets)
        {
            var fd = new OpenFolderDialog
            {
                Title = "Select a folder for the raw assets"
            };

            if (fd.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }
            foreach (var cont in selectedAssets)
            {
                var item = cont.Item;
                var name = item.Name;
                if (string.IsNullOrEmpty(name))
                {
                    name = "Unnamed asset";
                }

                var fileName = $"{name}-{Workspace.LoadedFiles[item.FileID].name}-{item.PathID}-{item.Type}.dat";
                var path     = Path.Combine(fd.Folder, fileName);
                Exporter.ExportRawAsset(path, item);
            }
        }
 private void ButtonBrowseFolder_Click(object sender, EventArgs e)
 {
     if (OpenFolderDialog.ShowDialog(this) == DialogResult.OK)
     {
         TextFolder.Text = OpenFolderDialog.SelectedPath;
     }
 }
示例#25
0
        public async Task OpenFolderEvent()
        {
            var folderDialog = new OpenFolderDialog();
            var result       = await folderDialog.ShowAsync(MainWindow.Instance);

            if (result != null)
            {
                folderDialog.Directory = result;
                var folderNode = NodeFactory.FromDirectory(result, "*.po");
                var dirModel   = new DirectoryRootModel()
                {
                    RootNode = folderNode,
                    Name     = folderNode.Path,
                    Tags     = folderNode.Tags["DirectoryInfo"],
                };

                foreach (var node in folderNode.Children)
                {
                    dirModel.Nodes.Add(new DirectoryNodeModel
                    {
                        Name = node.Name,
                        Node = node,
                    });
                }

                Directories.Add(dirModel);
            }
        }
示例#26
0
        private async Task DownloadFilesHandlerAsync()
        {
            if (Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
            {
                var dialog = new OpenFolderDialog();

                var results = await dialog.ShowAsync(desktop.MainWindow);

                foreach (var attachment in _message.Attachments)
                {
                    var fileName = attachment.ContentDisposition?.FileName ?? attachment.ContentType.Name;
                    var combined = Path.Combine(results, fileName);

                    using var stream = File.Create(combined);
                    if (attachment is MessagePart rfc822)
                    {
                        rfc822.Message.WriteTo(stream);
                    }
                    else
                    {
                        var part = (MimePart)attachment;

                        part.Content.DecodeTo(stream);
                    }
                }
            }

            await Task.CompletedTask;
        }
示例#27
0
        public Task <string> ShowFolderDialogAsync(OpenFolderDialog dialog, IWindowImpl parent)
        {
            return(Task.Factory.StartNew(() =>
            {
                string result = string.Empty;

                var hWnd = parent?.Handle?.Handle ?? IntPtr.Zero;
                var frm = (IFileDialog)(new UnmanagedMethods.FileOpenDialogRCW());
                uint options;
                frm.GetOptions(out options);
                options |= (uint)(UnmanagedMethods.FOS.FOS_PICKFOLDERS | UnmanagedMethods.FOS.FOS_FORCEFILESYSTEM | UnmanagedMethods.FOS.FOS_NOVALIDATE | UnmanagedMethods.FOS.FOS_NOTESTFILECREATE | UnmanagedMethods.FOS.FOS_DONTADDTORECENT);
                frm.SetOptions(options);

                if (dialog.InitialDirectory != null)
                {
                    IShellItem directoryShellItem;
                    var riid = new Guid("43826D1E-E718-42EE-BC55-A1E261C37BFE"); //IShellItem
                    if (UnmanagedMethods.SHCreateItemFromParsingName(dialog.InitialDirectory, IntPtr.Zero, ref riid, out directoryShellItem) == (uint)UnmanagedMethods.HRESULT.S_OK)
                    {
                        frm.SetFolder(directoryShellItem);
                    }
                }

                if (dialog.DefaultDirectory != null)
                {
                    IShellItem directoryShellItem;
                    var riid = new Guid("43826D1E-E718-42EE-BC55-A1E261C37BFE"); //IShellItem
                    if (UnmanagedMethods.SHCreateItemFromParsingName(dialog.DefaultDirectory, IntPtr.Zero, ref riid, out directoryShellItem) == (uint)UnmanagedMethods.HRESULT.S_OK)
                    {
                        frm.SetDefaultFolder(directoryShellItem);
                    }
                }

                if (frm.Show(hWnd) == (uint)UnmanagedMethods.HRESULT.S_OK)
                {
                    IShellItem shellItem;
                    if (frm.GetResult(out shellItem) == (uint)UnmanagedMethods.HRESULT.S_OK)
                    {
                        IntPtr pszString;
                        if (shellItem.GetDisplayName(UnmanagedMethods.SIGDN_FILESYSPATH, out pszString) == (uint)UnmanagedMethods.HRESULT.S_OK)
                        {
                            if (pszString != IntPtr.Zero)
                            {
                                try
                                {
                                    result = Marshal.PtrToStringAuto(pszString);
                                }
                                finally
                                {
                                    Marshal.FreeCoTaskMem(pszString);
                                }
                            }
                        }
                    }
                }

                return result;
            }));
        }
        public SendFileViewModel()
        {
            FileCommand = ReactiveCommand.Create(async(Window window) =>
            {
                OpenFileDialog dialog = new OpenFileDialog();
                dialog.Filters.Add(new FileDialogFilter()
                {
                    Name = ".cs, .txt, .sh", Extensions = { "cs", "txt", "sh" }
                });
                string[] result = await dialog.ShowAsync(window);

                if (result.Length != 0)
                {
                    FileName = string.Join(" ", result);
                }
            });

            FolderCommand = ReactiveCommand.Create(async(Window window) =>
            {
                OpenFolderDialog dialog = new OpenFolderDialog();
                string result           = await dialog.ShowAsync(window);

                if (result.Length != 0)
                {
                    FolderName = result;
                }
            });

            GoToUrl = ReactiveCommand.Create((string url) =>
            {
                try
                {
                    Process.Start(url);
                }
                catch
                {
                    if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                    {
                        url = url.Replace("&", "^&");
                        Process.Start(new ProcessStartInfo("cmd", $"/c start {url}")
                        {
                            CreateNoWindow = true
                        });
                    }
                    else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
                    {
                        Process.Start("xdg-open", url);
                    }
                    else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
                    {
                        Process.Start("open", url);
                    }
                    else
                    {
                        throw;
                    }
                }
            });
        }
示例#29
0
        public async Task <string> ShowFolderDialogAsync(OpenFolderDialog dialog, GtkWindow parent,
                                                         Action <GtkFileChooser> modify = null)
        {
            var res = await ShowDialog(dialog.Title, parent,
                                       GtkFileChooserAction.SelectFolder, false, dialog.InitialDirectory, modify);

            return(res?.FirstOrDefault());
        }
示例#30
0
        public Task <string> ShowFolderDialogAsync(OpenFolderDialog dialog, IWindowBaseImpl parent)
        {
            var events = new SystemDialogEvents();

            _native.SelectFolderDialog((parent as WindowImpl)?.Native, events, dialog.Title ?? "", dialog.InitialDirectory ?? "");

            return(events.Task.ContinueWith(t => { events.Dispose(); return t.Result.FirstOrDefault(); }));
        }
示例#31
0
        public override WindowResponse Show()
        {
            if (DialogType == FileDialogType.SelectFolder)
            {
                fbdlg = new OpenFolderDialog();
                fbdlg.InitialFolder = InitialDirectory;
                fbdlg.Title = Title;

                WindowResponse resp = WinFormHelper.GetResponse(fbdlg.ShowDialog(owner));
                SelectedPath = fbdlg.Folder;
                return resp;
            }
            else
            {
                switch (DialogType)
                {
                    case FileDialogType.OpenFile:
                        fdlg = new OpenFileDialog();
                        break;
                    case FileDialogType.SaveFile:
                        fdlg = new SaveFileDialog();
                        break;
                }

                fdlg.InitialDirectory = InitialDirectory;
                fdlg.Title = Title;
                string tmpFilter = string.Empty;

                foreach (FileTypeFilter filter in FileTypeFilters)
                {
                    tmpFilter += filter.FilterName + "|";
                    for (int i = 0; i < filter.Filter.Length; i++) tmpFilter += (i == 0 ? "" : ";") + "*." + filter.Filter[i];
                }
                fdlg.Filter = tmpFilter;
                WindowResponse resp = WinFormHelper.GetResponse(fdlg.ShowDialog());
                SelectedPath = fdlg.FileName;
                return resp;
            }
        }
示例#32
0
        private void OnLoadFolder()
        {
            if (!CheckModifiedSaved()) return;

            ClearReadonlyFiles();
            var folderDlg = new OpenFolderDialog();
            folderDlg.Title = Tx.T("msg.load folder.title");
            if (folderDlg.ShowDialog(new Wpf32Window(MainWindow.Instance)) == true)
            {
                DoLoadFolder(folderDlg.Folder);
            }
        }
示例#33
0
 //Select a Text Button
 private void button2_Click(object sender, EventArgs e)
 {
     OpenFolderDialog openDlg = new OpenFolderDialog();
     if (openDlg.ShowDialog(@"All File(*.*)|*.*", "Select a File") == DialogResult.OK)
     {
         this.FileName = openDlg.Path;
         this.textBox1.Text = openDlg.Path;
     }
     else
     {
         this.FileName = "";
         this.textBox1.Text = "";
     }
 }
示例#34
0
 //Select a Script Button
 private void button4_Click(object sender, EventArgs e)
 {
     OpenFolderDialog openDlg = new OpenFolderDialog();
     if (openDlg.ShowDialog(@"X'moe Script(*.axs)|*.axs", "Select a Script") == DialogResult.OK)
     {
         this.ScriptName = openDlg.Path;
         this.textBox3.Text = openDlg.Path;
     }
     else
     {
         this.ScriptName = "";
         this.textBox3.Text = "";
     }
 }
示例#35
0
 /// <summary>
 /// 返回打开的目录路径
 /// </summary>
 private string OpenFolder()
 {
     System.Windows.Forms.FolderBrowserDialog dlg = new System.Windows.Forms.FolderBrowserDialog();
     System.Windows.Interop.HwndSource source = PresentationSource.FromVisual(this) as System.Windows.Interop.HwndSource;
     System.Windows.Forms.IWin32Window win = new OpenFolderDialog(source.Handle);
     System.Windows.Forms.DialogResult result = dlg.ShowDialog(win);
     return dlg.SelectedPath;
 }
示例#36
0
        private void btn_extract_Click(object sender, EventArgs e)
        {
            if (filelistview.SelectedObjects.Count < 1)
                return;

            List<fileSystemObject> objectList = new List<fileSystemObject>();
            if (filelistview.SelectedObjects.Count == 1)
            {
                // Handle single Dir
                if (filelistview.SelectedObject is RPFLib.Common.Directory)
                {
                    using (var sfrm = new OpenFolderDialog())
                    {
                        if (sfrm.ShowDialog(this) == DialogResult.OK)
                        {
                            try
                            {
                                using (Cursors.WaitCursor)
                                {
                                    objectList.Add(filelistview.SelectedObject as fileSystemObject);
                                    form_extract extract_form = new form_extract(objectList, Path.GetFullPath(sfrm.Folder));
                                    extract_form.ShowDialog();
                                    extract_form.Dispose();
                                }
                            }
                            catch
                            {
                                MessageBox.Show("Failed to extract files", "Extract Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                    }
                }
                else
                {
                    // Handle single file
                    using (var sfrm = new SaveFileDialog())
                    {
                        var file = filelistview.SelectedObject as RPFLib.Common.File;
                        sfrm.FileName = file.Name;
                        if (sfrm.ShowDialog(this) == DialogResult.OK)
                        {
                            byte[] data = file.GetData(false);
                            System.IO.File.WriteAllBytes(sfrm.FileName, data);
                        }
                    }
                }
            }
            //Handle multiple files/folders
            else if (filelistview.SelectedObjects.Count > 1)
            {
                using (var frm = new OpenFolderDialog())
                {
                    if (frm.ShowDialog(this) == DialogResult.OK)
                    {
                        try
                        {
                            using (Cursors.WaitCursor)
                            {
                                foreach (object item in filelistview.SelectedObjects)
                                {
                                    objectList.Add(item as fileSystemObject);
                                }
                                form_extract extract_form = new form_extract(objectList, frm.Folder);
                                extract_form.ShowDialog();
                                extract_form.Dispose();
                            }
                        }
                        catch
                        {
                            MessageBox.Show("Failed to extract files", "Extract Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
            else
                return;
        }
示例#37
0
        private void iExtractAll_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (filelistview.Items.Count > 0)
            {
                List<fileSystemObject> objectList = new List<fileSystemObject>();
                using (var frm = new OpenFolderDialog())
                {
                    if (frm.ShowDialog(this) == DialogResult.OK)
                    {
                        try
                        {
                            using (Cursors.WaitCursor)
                            {
                                objectList.Add(archiveFile.RootDirectory);
                                if (objectList.Count > 0)
                                {
                                    form_extract extract_form = new form_extract(objectList, frm.Folder);
                                    extract_form.ShowDialog();
                                    extract_form.Dispose();
                                }
                                else
                                    MessageBox.Show("Failed to find root Dir", "Extract Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                            }
                        }
                        catch
                        {
                            MessageBox.Show("Failed to extract files", "Extract Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
        }