Exemple #1
0
            public static void CreateSaveDialog(string title, string message, string[] allowed_file_types, Action callback)
            {
                _SaveDialog    = new SaveDialog(title, message);
                _SaveDialog.Id = "SaveFileDialog";

                _SaveDialog.X           = Pos.Center();
                _SaveDialog.Y           = Pos.Center();
                _SaveDialog.ColorScheme = Colors.Dialog;

                _SaveDialog.AllowedFileTypes = allowed_file_types;
                _SaveDialog.AddButton(new Button("Set Dir...")
                {
                    Clicked = () => { try { _OpenDialog.DirectoryPath = _OpenDialog.DirectoryPath; } catch (Exception) { /* nothing */ } }
                });

                (_SaveDialog.Subviews.First().Subviews.FirstOrDefault(x => (x as Button ?? new Button("x")).Text == "Save") as Button).Clicked += () => callback();

                (_SaveDialog.Subviews.First().Subviews.FirstOrDefault(x => (x as Button ?? new Button("x")).Text == "Cancel") as Button).Clicked += () => Application.Top.SetFocus(Application.Top.MostFocused);

                Application.Run(_SaveDialog);
            }