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");
        }
Пример #2
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);
        }
Пример #3
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);
        }
Пример #4
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);
        }
Пример #5
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;
                }
            }
        }
Пример #6
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;
        }
Пример #7
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;
                    }
                });
            });
        }
Пример #8
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;
        }
Пример #9
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);
            }
        }
Пример #10
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);
            });
        }
Пример #11
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();
                }
            });
        }
        private async void FindPathButton_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
        {
            var dialog = new OpenFolderDialog();
            var path   = await dialog.ShowAsync(this);

            PathTextBox.Text = path;
        }
        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;
                    }
                }
            });
        }
    public async Task SelectGameDirectory()
    {
        OpenFolderDialog dialog = new OpenFolderDialog();

        DDPath = await dialog.ShowAsync(window);

        this.RaisePropertyChanged(nameof(DDPath));
    }
Пример #15
0
        public async Task <string> GetDirectoryAsync(string?initialDirectory = null)
        {
            var dialog = new OpenFolderDialog {
                Directory = initialDirectory
            };
            var window = _mainWindowProvider.Get();

            return(await dialog.ShowAsync(window));
        }
Пример #16
0
        private async Task <string> GetPath()
        {
            OpenFolderDialog openFolderDialog = new OpenFolderDialog();

            openFolderDialog.Directory = TBSolutionDirectory.Text;
            string s = await openFolderDialog.ShowAsync(this);

            return(s);
        }
Пример #17
0
        private void Initialise(EntityDirectory directory)
        {
            CmdSaveDirectory = ReactiveCommand.CreateFromTask(async() =>
            {
                OpenFolderDialog dlg = new OpenFolderDialog();
                dlg.Title            = "Select the location to save the directory";
                string filePath      = await dlg.ShowAsync(CommonUtils.MainWindow);
                if (!string.IsNullOrEmpty(filePath))
                {
                    try
                    {
                        EntityDirectory.WriteDirectory(filePath);
                        CurrentDirectoryPath = filePath;
                        directorySaved       = true;
                    }
                    catch (Exception ex)
                    {
                        var msg = CommonUtils.GetMessageBox("Error opening save file",
                                                            "An error occured while saving the save file: " + ex.Message, ButtonEnum.Ok, Icon.Error);
                        await msg.ShowDialog(CommonUtils.MainWindow);
                    }
                }
            }, this.WhenAnyValue(x => x.DirectoryInUse));

            CmdAddEntity = ReactiveCommand.Create(() =>
            {
                Entity ent       = new Entity();
                ent.Name         = "New Entity";
                ent.EntityType   = NPCType.NPC;
                ent.ObjectType   = ObjectTypes.None;
                ent.DestroyType  = DeathType.None;
                ent.InteractType = Interaction.None;
                ent.Behaviors[0] = ActionBehaviors.None;
                ent.Behaviors[1] = ActionBehaviors.None;
                EntityDirectory.Entities[CurrentKey].Add(ent);
                RebuildLineIndexesDescriptions();
                SelectedLineIndex = EntityDirectory.Entities[CurrentKey].Count - 1;
            }, this.WhenAnyValue(x => x.DirectoryInUse, x => x.CurrentKey,
                                 (directoryInUse, currentKey) => directoryInUse && currentKey != -1));

            CmdEditEntityName = ReactiveCommand.CreateFromTask(async() =>
            {
                EditEntityNameView dlg = new EditEntityNameView(this);
                string savedName       = CurrentEntity.Name;
                await dlg.ShowDialog(CommonUtils.MainWindow);
                if (dlg.Confirmed)
                {
                    int index = SelectedLineIndex;
                    RebuildLineIndexesDescriptions();
                    SelectedLineIndex = index;
                }
                else
                {
                    CurrentEntity.Name = savedName;
                }
            }, this.WhenAnyValue(x => x.EntitySelected));
        }
Пример #18
0
        public async Task <Stream> OpenWrite(string name)
        {
            var fileDialog = new OpenFolderDialog();
            var folder     = await fileDialog.ShowAsync();

            var path = Path.Combine(folder, name);

            return(File.Create(path));
        }
Пример #19
0
        public NewProjectDialogViewModel() : base("New Project", true, true)
        {
            shell            = IoC.Get <IShell>();
            projectTemplates = new ObservableCollection <IProjectTemplate>();
            Languages        = new List <ILanguageService>(shell.LanguageServices);

            location         = Platform.ProjectDirectory;
            SelectedLanguage = Languages.FirstOrDefault();
            SelectedTemplate = ProjectTemplates.FirstOrDefault();

            BrowseLocationCommand = ReactiveCommand.Create(async() =>
            {
                var ofd = new OpenFolderDialog
                {
                    InitialDirectory = location
                };

                var result = await ofd.ShowAsync();

                if (!string.IsNullOrEmpty(result))
                {
                    Location = result;
                }
            });

            OKCommand = ReactiveCommand.Create(async() =>
            {
                bool generateSolutionDirs = false;

                if (solution == null)
                {
                    generateSolutionDirs = true;

                    var destination = Path.Combine(location, solutionName);
                    solution        = Solution.Create(destination, solutionName, false);
                }

                if (await selectedTemplate.Generate(solution, name) != null)
                {
                    if (generateSolutionDirs)
                    {
                        if (!Directory.Exists(solution.CurrentDirectory))
                        {
                            Directory.CreateDirectory(solution.CurrentDirectory);
                        }
                    }
                }

                solution.Save();
                shell.CurrentSolution = solution;
                solution = null;

                Close();
            },
                                               this.WhenAny(x => x.Location, x => x.SolutionName, (location, solution) => solution.Value != null && !Directory.Exists(Path.Combine(location.Value, solution.Value))));
        }
Пример #20
0
        private async void SaveAllImagesWithObjects()
        {
            try
            {
                if (Frames == null || Frames.Count < 1)
                {
                    Status = new AppStatusInfo()
                    {
                        Status = Enums.Status.Ready
                    };
                    return;
                }
                Status = new AppStatusInfo()
                {
                    Status = Enums.Status.Working
                };

                var openDig = new OpenFolderDialog()
                {
                    Title = "Choose a directory to save images with objects"
                };
                var dirName = await openDig.ShowAsync(new Window());


                if (string.IsNullOrEmpty(dirName) || !Directory.Exists(dirName))
                {
                    Status = new AppStatusInfo()
                    {
                        Status = Enums.Status.Ready
                    };
                    return;
                }

                foreach (var frame in Frames)
                {
                    if (frame.Rectangles == null || frame.Rectangles.Count <= 0)
                    {
                        continue;
                    }
                    File.Copy(frame.Patch, Path.Combine(dirName, Path.GetFileName(frame.Patch)));
                }
                Console.WriteLine($"Saved to {dirName}");
                Status = new AppStatusInfo()
                {
                    Status = Enums.Status.Ready, StringStatus = $"Success | saved to {dirName}"
                };
            }
            catch (Exception ex)
            {
                Status = new AppStatusInfo()
                {
                    Status       = Enums.Status.Error,
                    StringStatus = $"Error | {ex.Message.Replace('\n', ' ')}"
                };
            }
        }
Пример #21
0
        public async Task <string> OpenFolderDialog(string title, string directory = "")
        {
            var openFolderDialog = new OpenFolderDialog
            {
                Title     = title,
                Directory = directory
            };

            return(await openFolderDialog.ShowAsync(this));
        }
Пример #22
0
        private async void GetSaveFolder()
        {
            var dialog = new OpenFolderDialog();

            dialog.Title            = "Select directory to save downloads";
            dialog.InitialDirectory = GuiState.OutputPath;
            var k = await dialog.ShowAsync();

            GuiState.OutputPath = k;
        }
Пример #23
0
        //UCOptionsVM Commands
        public static async void ChangeJavaLocationFolderCommand()
        {
            MainWindow mv = new MainWindow();

            OpenFolderDialog openFolderDialog = new OpenFolderDialog();

            openFolderDialog.Title = "Укажите путь к Java";

            UCOptionsViewModel.JavaFolder.Value = string.Join("", await openFolderDialog.ShowAsync(mv));
        }
Пример #24
0
        public static async void ChangeDowloadFolder()
        {
            MainWindow mv = new MainWindow();

            OpenFolderDialog openFolderDialog = new OpenFolderDialog();

            openFolderDialog.Title = "Выберите папку загрузки сервера";

            UCServerCreateViewModel.FileLocation.Value = string.Join("", await openFolderDialog.ShowAsync(mv));
        }
Пример #25
0
        private async void BrowseTarget_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new OpenFolderDialog();
            var result = await dialog.ShowAsync();

            if (!string.IsNullOrWhiteSpace(result))
            {
                TargetFolderBox.Text = result;
            }
        }
Пример #26
0
        //---------------------------------------------------------------------
        //		Methods
        //---------------------------------------------------------------------
        public async Task <string> AskUserForDirectoryPath()
        {
            OpenFolderDialog dialog = new OpenFolderDialog();

            string result = await dialog.ShowAsync(window);

            return(((result != null) && (result.Length > 0))
                    ? result
                    : "");
        }
Пример #27
0
        protected override async Task Execute(RtdxRomViewModel viewModel)
        {
            var dialog = new OpenFolderDialog();
            var path   = await dialog.ShowAsync(Application.Current.GetMainWindowOrThrow());

            if (!string.IsNullOrEmpty(path))
            {
                viewModel.Save(path);
            }
        }
Пример #28
0
        public async void BrowseButton_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new OpenFolderDialog();
            var result = await dialog.ShowAsync(new Window());

            if ((result != null) && (result.Length > 0))
            {
                m_InputFolderEdit.Text = result;
            }
        }
        public async Task NewProject()
        {
            var dialog = new OpenFolderDialog();
            var result = await dialog.ShowAsync(new Window());

            if (!String.IsNullOrEmpty(result))
            {
                var window = new NewProjectDialog(result);
                window.Show();
            }
        }
        public async void OpenFolderClick()
        {
            // The dialog requires the window reference, so this can't be in the viewmodel.
            var dialog = new OpenFolderDialog();
            var result = await dialog.ShowAsync(this);

            if (!string.IsNullOrEmpty(result) && ViewModel != null)
            {
                ViewModel.ExtractLocation = result;
            }
        }