Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix allowed filetypes in open/save dialogs #40

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions ShowEditorCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Management.Automation.Runspaces;
using System.Text;
using Terminal.Gui;
using System.Collections.Generic;

namespace psedit
{
Expand Down Expand Up @@ -68,11 +69,12 @@ protected override void ProcessRecord()
new MenuBarItem ("_File", new MenuItem [] {
new MenuItem ("_New", "", New),
new MenuItem ("_Open", "", () => {
var dialog = new OpenDialog("Open file", "Open file");
List<string> allowedFileTypes = new List<string>();
allowedFileTypes.Add(".ps1");
var dialog = new OpenDialog("Open file", "", allowedFileTypes);
dialog.CanChooseDirectories = false;
dialog.CanChooseFiles = true;
dialog.AllowsMultipleSelection = false;
dialog.AllowedFileTypes = new [] {".ps1"};

Application.Run(dialog);

Expand Down Expand Up @@ -381,8 +383,9 @@ private void Save(bool saveAs)
{
if (string.IsNullOrEmpty(Path) || saveAs)
{
var dialog = new SaveDialog("Save file", "Save file");
dialog.AllowedFileTypes = new string[] { ".ps1" };
List<string> allowedFileTypes = new List<string>();
allowedFileTypes.Add(".ps1");
var dialog = new SaveDialog(saveAs ? "Save file as" : "Save file","", allowedFileTypes);
Application.Run(dialog);

if (dialog.FilePath.IsEmpty || dialog.Canceled == true || Directory.Exists(dialog.FilePath.ToString()))
Expand Down