public bool Run(AddFileDialogData data) { var parentWindow = data.TransientFor ?? MessageService.RootWindow; parentWindow.FocusInEvent += OnParentFocusIn; bool result = SelectFileDialogHandler.RunWinUIMethod(RunDialog, data); parentWindow.FocusInEvent -= OnParentFocusIn; parentWindow.Present(); return(result); }
bool RunDialog(OpenFileDialogData data) { Application.EnableVisualStyles(); FileDialog fileDlg = null; if (data.Action == Gtk.FileChooserAction.Open) { fileDlg = new OpenFileDialog(); } else { fileDlg = new SaveFileDialog(); } var dlg = new CustomOpenFileDialog(fileDlg, data); SelectFileDialogHandler.SetCommonFormProperties(data, dlg.FileDialog); using (dlg) { rootForm = new WinFormsRoot(); if (dlg.ShowDialog(rootForm) == DialogResult.Cancel) { return(false); } FilePath[] paths = new FilePath [fileDlg.FileNames.Length]; for (int n = 0; n < fileDlg.FileNames.Length; n++) { paths [n] = fileDlg.FileNames [n]; } data.SelectedFiles = paths; if (dlg.SelectedEncodingId != null) { data.Encoding = dlg.SelectedEncodingId > 0 ? Encoding.GetEncoding(dlg.SelectedEncodingId) : null; } if (dlg.SelectedViewer != null) { data.SelectedViewer = dlg.SelectedViewer; } data.CloseCurrentWorkspace = dlg.CloseCurrentWorkspace; } return(true); }
public bool Run(AddFileDialogData data) { var parent = data.TransientFor ?? MessageService.RootWindow; var dialog = new CommonOpenFileDialog(); SelectFileDialogHandler.SetCommonFormProperties(data, dialog); var buildActionCombo = new CommonFileDialogComboBox(); var group = new CommonFileDialogGroupBox("overridebuildaction", "Override build action:"); buildActionCombo.Items.Add(new CommonFileDialogComboBoxItem(GettextCatalog.GetString("Default"))); foreach (var ba in data.BuildActions) { if (ba == "--") { continue; } buildActionCombo.Items.Add(new CommonFileDialogComboBoxItem(ba)); } buildActionCombo.SelectedIndex = 0; group.Items.Add(buildActionCombo); dialog.Controls.Add(group); if (!GdkWin32.RunModalWin32Dialog(dialog, parent)) { return(false); } SelectFileDialogHandler.GetCommonFormProperties(data, dialog); var idx = buildActionCombo.SelectedIndex; if (idx > 0) { data.OverrideAction = buildActionCombo.Items [idx].Text; } return(true); }
bool RunDialog(AddFileDialogData data) { Application.EnableVisualStyles(); CustomAddFilesDialog adlg = new CustomAddFilesDialog(); adlg.StartLocation = AddonWindowLocation.Bottom; adlg.BuildActions = data.BuildActions; bool result = false; SelectFileDialogHandler.SetCommonFormProperties(data, adlg.FileDialog); try { rootForm = new WinFormsRoot(); if (adlg.ShowDialog(rootForm) == DialogResult.Cancel) { result = false; } else { FilePath[] paths = new FilePath [adlg.FileDialog.FileNames.Length]; for (int n = 0; n < adlg.FileDialog.FileNames.Length; n++) { paths [n] = adlg.FileDialog.FileNames [n]; } data.SelectedFiles = paths; data.OverrideAction = adlg.OverrideAction; result = true; } } finally { adlg.Dispose(); } return(result); }
public bool Run(OpenFileDialogData data) { var parent = data.TransientFor ?? MessageService.RootWindow; CommonFileDialog dialog; if (data.Action == FileChooserAction.Open) { dialog = new CustomCommonOpenFileDialog(); } else { dialog = new CustomCommonSaveFileDialog(); } SelectFileDialogHandler.SetCommonFormProperties(data, dialog); CustomCommonFileDialogComboBox encodingCombo = null; if (data.ShowEncodingSelector) { var group = new CommonFileDialogGroupBox("encoding", "Encoding:"); encodingCombo = new CustomCommonFileDialogComboBox(); BuildEncodingsCombo(encodingCombo, data.Action != FileChooserAction.Save, data.Encoding); group.Items.Add(encodingCombo); dialog.Controls.Add(group); encodingCombo.SelectedIndexChanged += (sender, e) => { if (encodingCombo.SelectedIndex == encodingCombo.Items.Count - 1) { var dlg = new System.Windows.Window { Title = "Choose encodings", Content = new SelectEncodingControl(), SizeToContent = SizeToContent.WidthAndHeight }; if (dlg.ShowDialog().Value) { BuildEncodingsCombo(encodingCombo, data.Action != FileChooserAction.Save, data.Encoding); dialog.ApplyControlPropertyChange("Items", encodingCombo); } } }; } CustomCommonFileDialogComboBox viewerCombo = null; CommonFileDialogCheckBox closeSolution = null; if (data.ShowViewerSelector && data.Action == FileChooserAction.Open) { var group = new CommonFileDialogGroupBox("openWith", "Open with:"); viewerCombo = new CustomCommonFileDialogComboBox { Enabled = false }; group.Items.Add(viewerCombo); dialog.Controls.Add(group); if (IdeApp.Workspace.IsOpen) { var group2 = new CommonFileDialogGroupBox(); // "Close current workspace" is too long and splits the text on 2 lines. closeSolution = new CommonFileDialogCheckBox("Close workspace", true) { Visible = false }; group2.Items.Add(closeSolution); dialog.Controls.Add(group2); } dialog.SelectionChanged += (sender, e) => { try { var files = GetSelectedItems(dialog); var file = files.Count == 0 ? null : files[0]; bool hasBench = FillViewers(viewerCombo, file); if (closeSolution != null) { closeSolution.Visible = hasBench; } dialog.ApplyControlPropertyChange("Items", viewerCombo); } catch (Exception ex) { LoggingService.LogError(e.ToString()); } }; } if (!GdkWin32.RunModalWin32Dialog(dialog, parent)) { return(false); } SelectFileDialogHandler.GetCommonFormProperties(data, dialog); if (encodingCombo != null) { data.Encoding = ((EncodingComboItem)encodingCombo.Items [encodingCombo.SelectedIndex]).Encoding; } if (viewerCombo != null) { if (closeSolution != null) { data.CloseCurrentWorkspace = closeSolution.Visible && closeSolution.IsChecked; } data.SelectedViewer = ((ViewerComboItem)viewerCombo.Items [viewerCombo.SelectedIndex]).Viewer; } return(true); }