private void HTMLFileButton_Click(object sender, RoutedEventArgs e) { VistaOpenFileDialog fileDialog = new VistaOpenFileDialog(); fileDialog.AddExtension = true; fileDialog.CheckFileExists = true; fileDialog.CheckPathExists = true; fileDialog.DefaultExt = ".html"; fileDialog.Filter = "HTML files (*.html)|*.html"; fileDialog.Multiselect = false; fileDialog.Title = "Choose source HTML"; bool?res = fileDialog.ShowDialog(this); if (res ?? false) { HTMLFileTextBox.Text = fileDialog.FileName; } }
private async void LoadFile() { VistaFileDialog fileDialog = new VistaOpenFileDialog { Title = Resources.MainWindowViewModel_LoadFile, Multiselect = true }; if (fileDialog.ShowDialog() != true) { return; } foreach (var name in fileDialog.FileNames) { await Model.LoadMetadata(name); } }
private async void cmdOpenArchive_Executed(Object sender, ExecutedRoutedEventArgs e) { var openFileDialog = new VistaOpenFileDialog { Filter = "Star Citizen Data Files|*.p4k", CheckFileExists = true, AddExtension = true, DefaultExt = ".p4k" }; if (openFileDialog.ShowDialog() == true) { // Move to background thread new Thread(async() => await this.OpenP4kAsync(openFileDialog.FileName)).Start(); } await Task.CompletedTask; }
/// <summary> /// Initializes a new instance of the <see cref="CustomOpenFileDialog"/> class. /// </summary> /// <param name="settings">The settings for the open file dialog.</param> public CustomOpenFileDialog(OpenFileDialogSettings settings) { this.settings = settings ?? throw new ArgumentNullException(nameof(settings)); openFileDialog = new VistaOpenFileDialog { AddExtension = settings.AddExtension, CheckFileExists = settings.CheckFileExists, CheckPathExists = settings.CheckPathExists, DefaultExt = settings.DefaultExt, FileName = settings.FileName, Filter = settings.Filter, FilterIndex = settings.FilterIndex, InitialDirectory = settings.InitialDirectory, Multiselect = settings.Multiselect, Title = settings.Title }; }
private void ExecuteLoadLayoutCommand(object sender, ExecutedRoutedEventArgs e) { var dlg = new VistaOpenFileDialog { Filter = LocalizedStrings.Str3584, CheckFileExists = true, RestoreDirectory = true }; if (dlg.ShowDialog(Application.Current.GetActiveOrMainWindow()) != true) { return; } var data = File.ReadAllText(dlg.FileName); new LoadLayoutCommand(data).SyncProcess(SelectedStrategy); }
/// <summary> /// Получает список выбранных файлов его в результирующий список /// </summary> /// <param name="resFileList">результирующий список</param> private void GetFromFileList(out List <string> resFileList) { resFileList = new List <string>(); VistaOpenFileDialog dialog = new VistaOpenFileDialog(); dialog.Title = "Выберете файлы изображений"; dialog.Filter = "Файлы изображений (*.jpg;*.jpeg;*.png;*.bmp)|*.jpg;*.jpeg;*.png"; dialog.Multiselect = true; if (!VistaOpenFileDialog.IsVistaFileDialogSupported) { MessageBox.Show("Because you are not using Windows Vista or later, the regular folder browser dialog will be used. Please use Windows Vista to see the new dialog.", "Sample folder browser dialog"); } if ((bool)dialog.ShowDialog()) { //добавление resFileList.AddRange(dialog.FileNames); } }
//UI Action implementations private void BrowseWindow(String Source) { try { string strSelectedFolder = string.Empty; VistaOpenFileDialog selectFileDialog = new VistaOpenFileDialog(); selectFileDialog.Title = "Select S7 project."; if (Source.Equals("Left")) { if (Directory.Exists(S7Model.LeftProjectPath)) { selectFileDialog.InitialDirectory = Properties.Settings.Default.LeftProjectPath; } } else if (Source.Equals("Right")) { if (Directory.Exists(S7Model.RightProjectPath)) { selectFileDialog.InitialDirectory = Properties.Settings.Default.RightProjectPath; } } selectFileDialog.Filter = "S7 Projects(*.zip, *.s7p, *.s7l)|*.s7p;*.s7l;*.zip"; if ((bool)selectFileDialog.ShowDialog())// == DialogResult.OK) { if (Source.Equals("Left")) { LeftProjectPath = selectFileDialog.FileName; Properties.Settings.Default.LeftProjectPath = LeftProjectPath; } else if (Source.Equals("Right")) { RightProjectPath = selectFileDialog.FileName; Properties.Settings.Default.RightProjectPath = RightProjectPath; } Properties.Settings.Default.Save(); } } catch (Exception err) { EventFire.Error(err.ToString()); } }
/// <summary> /// Import a CSV file /// </summary> public void Import() { var dialog = new VistaOpenFileDialog { Filter = "CSV files (*.csv)|*.csv", CheckFileExists = true }; dialog.ShowDialog(); string filename = dialog.FileName; if (string.IsNullOrEmpty(filename)) { return; } IDictionary <int, string> chapterMap = new Dictionary <int, string>(); try { using (CsvReader csv = new CsvReader(new StreamReader(filename), false)) { while (csv.ReadNextRecord()) { if (csv.FieldCount == 2) { int chapter; int.TryParse(csv[0], out chapter); chapterMap[chapter] = csv[1]; } } } } catch (Exception) { // Do Nothing } // Now iterate over each chatper we have, and set it's name foreach (ChapterMarker item in this.Task.ChapterNames) { string chapterName; chapterMap.TryGetValue(item.ChapterNumber, out chapterName); item.ChapterName = chapterName; } }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { using (Ookii.Dialogs.VistaOpenFileDialog ofd = new VistaOpenFileDialog()) { ofd.Multiselect = false; string[] s1Descript = context.PropertyDescriptor.Description.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); ofd.Filter = @"|*.csv"; if (ofd.ShowDialog() == DialogResult.OK) { return(ofd.FileName); } } return(value); }
private void OnOpen() { var dialog = new VistaOpenFileDialog(); dialog.DefaultExt = "txt"; dialog.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*";; if ((bool)!dialog.ShowDialog()) { return; } string filePath = dialog.FileName; string[] lines = File.ReadAllLines(filePath); foreach (string line in lines) { AddLink(line); } }
private void tileOpen_Click(object sender, RoutedEventArgs e) { VistaOpenFileDialog o = new VistaOpenFileDialog(); o.Filter = "Apollo story|*.apstp"; o.Title = "Open Apollo story..."; o.FileOk += (s, ev) => { if ((App.Current.MainWindow as MainWindow).Open(o.FileName)) { OpenMain(); } else { this.ShowMessageAsync("Oops...", $"Error occured while loading story \"{System.IO.Path.GetFileName(o.FileName)}\""); } }; o.ShowDialog(); }
private void Browse_Click(object sender, RoutedEventArgs e) { var dlg = new VistaOpenFileDialog { Filter = "Assembly Files (*.dll)|*.dll", Multiselect = true, }; if (dlg.ShowDialog(this) != true) { return; } Toc.Items.Clear(); var navigation = new Navigation { UrlPrefix = "http://stocksharp.com/doc/ref/", EmptyImage = "http://stocksharp.com/images/blank.gif" }; GenerateHtml.CssUrl = @"file:///C:/VisualStudio/Web/trunk/Site/css/style.css"; GenerateHtml.Navigation = navigation; //ToDo: переделать GenerateHtml.IsHtmlAsDiv = false; GenerateHtml.IsRussian = true; var asmFiles = dlg.FileNames; var docFiles = asmFiles .Select(f => Path.Combine(Path.GetDirectoryName(f), Path.GetFileNameWithoutExtension(f) + ".xml")) .Where(File.Exists) .ToArray(); var slnDom = SolutionDom.Build("StockSharp. Описание типов", asmFiles, docFiles, Path.GetFullPath(@"..\..\..\..\..\StockSharp\trunk\Documentation\DocSandCastle\Comments\project.xml"), null, new FindOptions { InternalClasses = false, UndocumentedClasses = true, PrivateMembers = false, UndocumentedMembers = true }); _root = BuildPages.BuildSolution(slnDom); BuildTree(_root, Toc.Items); }
private void ButtonClickAddPaths(object sender, RoutedEventArgs e) { //var dialog = new OpenFileDialog { Multiselect = true, CheckFileExists = true, CheckPathExists = true }; var dialog = new VistaOpenFileDialog { Multiselect = true, CheckFileExists = true, CheckPathExists = true }; dialog.ShowDialog(); var paths = dialog.FileNames; var confPaths = paths.Select(f => new FileProfile { LastSynced = DateTime.MinValue, Path = f }); //avoid duplicate paths _vm.Config.Paths.AddRange(confPaths.Where(f => !_vm.Config.Paths.Contains(f))); RefreshListBinding(); }
private async void Button_WholePeriod_File_Click(object sender, RoutedEventArgs e) { var openFileDialog = new VistaOpenFileDialog() { Filter = "Excel |*.xlsx;*.xlsm;*.xlsb;*.xltx;*.xltm;*.xls;*.xlt;*.xls;*.xml;*.xml;*.xlam;*.xla;*.xlw;*.xlr", Multiselect = false, Title = "Выбор Банковского отчета", ShowReadOnly = false, CheckFileExists = true, CheckPathExists = true, DereferenceLinks = true, }; if (openFileDialog.ShowDialog() == false) { return; } await ViewModel.CheckTotalReportAsync(openFileDialog.FileName); }
void BrowseButton_Click(object Sender, RoutedEventArgs E) { VistaOpenFileDialog OpenDialog = new VistaOpenFileDialog { AddExtension = true, Filter = Filter, FilterIndex = 0, FileName = SelectedOpenPath, InitialDirectory = ExecutingLocation().FullName, Title = "Pick a file", ValidateNames = true }; switch (OpenDialog.ShowDialog()) { case true: PathTextBox.Text = OpenDialog.FileName; OnChange?.Invoke(PathTextBox.Text); break; } }
//private void DownloadFile(FileExplorerViewModel obj) //{ // throw new System.NotImplementedException(); //} private void UploadFile(FileExplorerViewModel context) { var ofd = new VistaOpenFileDialog { Title = Tx.T("FileExplorer:SelectFilesToUpload"), Filter = Tx.T("FileExplorer:AllFilesFilter"), CheckFileExists = true, CheckPathExists = true, Multiselect = true }; if (context.Window.ShowDialog(ofd) == true) { foreach (var fileInfo in ofd.FileNames.Select(x => new FileInfo(x))) { context.FileTransferManagerViewModel.ExecuteTransfer( new FileTransferViewModel(fileInfo, context.CurrentPath)); } } }
private void Button_Click_1(object sender, RoutedEventArgs e) { var openFileDialog = new VistaOpenFileDialog() { Filter = "Excel |*.xlsx;*.xlsm;*.xlsb;*.xltx;*.xltm;*.xls;*.xlt;*.xls;*.xml;*.xml;*.xlam;*.xla;*.xlw;*.xlr", Multiselect = true, Title = "Выбор Форумного отчета", ShowReadOnly = false, CheckFileExists = true, CheckPathExists = true, DereferenceLinks = true, }; if (openFileDialog.ShowDialog() == false) { return; } ViewModel.ImportDailyReportAsync(openFileDialog.FileNames); }
//UI Action implementations private void BrowseWindow(String Source) { string strSelectedFolder = string.Empty; VistaOpenFileDialog selectFileDialog = new VistaOpenFileDialog(); selectFileDialog.Title = "Select S7 project."; if (Directory.Exists(S7Model.ProjectPath)) { selectFileDialog.InitialDirectory = Properties.Settings.Default.ProjectPath; } selectFileDialog.Filter = "S7 Projects(*.zip, *.s7p, *.s7l, *.ap13)|*.s7p;*.s7l;*.zip;*.ap13"; if ((bool)selectFileDialog.ShowDialog())// == DialogResult.OK) { ProjectPath = selectFileDialog.FileName; Properties.Settings.Default.ProjectPath = ProjectPath; Properties.Settings.Default.Save(); } }
private void ChoseKeyPairOnDisk(object sender, RoutedEventArgs e) { var dialog = new VistaOpenFileDialog() { Title = "Select Virgil Card", Multiselect = false, CheckFileExists = true, CheckPathExists = true, ReadOnlyChecked = true, DefaultExt = "*.vcard", Filter = "All files (*.*)|*.*|Virgil Card Files (*.vcard)|*.vcard", FilterIndex = 2 }; if (dialog.ShowDialog() == true) { this.SelectedPath = dialog.FileName; this.OnFileChangedCommand?.Execute(dialog.FileName); } }
public static string[] ShowOpenFileDialog(string dialogTitle, string filter, bool allowMultiSelect) { VistaOpenFileDialog dialog = new VistaOpenFileDialog(); dialog.Title = dialogTitle; dialog.Filter = filter;// "All files (*.*)|*.*";"Text files (*.txt)|*.txt|All files (*.*)|*.*"; dialog.Multiselect = allowMultiSelect; if (dialog.ShowDialog(new WindowWrapper(GetActiveWindow())) == DialogResult.OK) { if (allowMultiSelect) { return(dialog.FileNames); } return(new string[] { dialog.FileName }); } else { return(null); } }
/// <summary> /// Gets path to TC/ConEmu from settings or prompts the user if that fails /// </summary> private (bool, string) GetExePath(string setting) { var cancelled = false; var path = (WritableSettingsStore.PropertyExists(SS_Collection, setting) == true)? WritableSettingsStore.GetString(SS_Collection, setting) : null as string; if (path.IsNullOrWhitespace() == true || File.Exists(path) == false) { try { var dlg = new VistaOpenFileDialog { CheckFileExists = true, FileName = path, Filter = "Program files (*.exe)|*.exe", InitialDirectory = (path.IsNullOrWhitespace() == true)? "" : System.IO.Path.GetDirectoryName(path), Multiselect = false, RestoreDirectory = true, Title = "Enter path to " + setting, }; if ((bool)dlg.ShowDialog(this) == true) { path = dlg.FileName; } else { cancelled = true; } } catch (PathTooLongException ex) { Box.Error("Path too long, exception:", ex.Message); cancelled = true; } } return(cancelled, path); }
public void OpenExisting(ref string filename) { if (filename == null) { VistaOpenFileDialog ofd = new VistaOpenFileDialog { Title = R.openFileTitle, Filter = R.saveAsFilter, }; bool?result = ofd.ShowDialog(); if (!result.HasValue || !result.Value) { return; } filename = ofd.FileName; } XDocument doc = XDocument.Load(filename); if (!(doc.Root is XElement eltSolutionCollection)) { return; } Solutions.Clear(); Title = Path.GetFileNameWithoutExtension(filename); Filename = filename; foreach (XElement eltSolution in eltSolutionCollection.Elements("Solution")) { Solution solution = Solution.OpenSolution(eltSolution.Attribute("filename")?.Value); SolutionItem solutionItem = AddSolution(solution); solutionItem.IsActive = bool.Parse(eltSolution.Attribute("isActive")?.Value ?? "true"); solutionItem.SelectedConfiguration = eltSolution.Attribute("selectedConfiguration")?.Value; } SelectedConfiguration = eltSolutionCollection.Attribute("configuration")?.Value; Modified = false; }
public static string BrowseTsiFile(System.Windows.Window owner, bool isSaveDialog, string initialDirectory = null, string fileName = null) { VistaFileDialog dlg; if (isSaveDialog) { dlg = new VistaSaveFileDialog { DefaultExt = "tsi", AddExtension = true, ValidateNames = true }; } else { dlg = new VistaOpenFileDialog { Multiselect = false }; } dlg.Filter = "TSI | *.tsi"; dlg.CheckPathExists = true; if (initialDirectory != null) { dlg.InitialDirectory = initialDirectory; // workaround to set InitialDirectory dlg.FileName = Path.Combine(dlg.InitialDirectory, " "); } if (fileName != null) { dlg.FileName = fileName; } if (dlg.ShowDialog(owner).GetValueOrDefault()) { return(dlg.FileName); } return(null); }
private void btn_FindOutputRevenueFile_Click(object sender, RoutedEventArgs e) { try { VistaOpenFileDialog ofd = new VistaOpenFileDialog() { Filter = "Excel Sheet (*.xlsx)|*.xlsx", ValidateNames = true, Multiselect = false }; if (ofd.ShowDialog().Value == true) { OutputRevenueFilePath.Text = ofd.FileName; SetOutputRevFilePathSetting(ofd.FileName); SetDebugMessage($"OutputRevenueFilePath Successfully Changed."); } } catch (Exception ex) { MessageBox.Show(ex.Message); SetDebugMessage(ex.Message); } }
private void menu_openfile_Click(object sender, RoutedEventArgs e) { Debug.WriteLine("Loading cpk"); string fName; string baseName; VistaOpenFileDialog openFileDialog = new VistaOpenFileDialog(); openFileDialog.InitialDirectory = ""; openFileDialog.Filter = "Criware CPK|*.cpk"; openFileDialog.RestoreDirectory = true; openFileDialog.FilterIndex = 1; if (openFileDialog.ShowDialog().Value) { fName = openFileDialog.FileName; baseName = System.IO.Path.GetFileName(fName); status_cpkname.Content = baseName; beginLoadCPK(fName); button_extract.IsEnabled = true; button_importassets.IsEnabled = true; } }
private void FileBrowseButton_Click(object sender, RoutedEventArgs e) { var dlg = new VistaOpenFileDialog { Filter = $"{Properties.Resources.MWOpenAllFiles}|*.*|" + $"{Properties.Resources.MWOpenAllSupported}|*.doc;*.dot;*.xls;*.xlt;*.docm;*.dotm;*.docb;*.xlsm;*.xla;*.xlam;*.xlsb;" + "*.pptm;*.potm;*.ppam;*.ppsm;*.sldm;*.docx;*.dotx;*.xlsx;*.xltx;*.pptx;*.potx;*.ppsx;*.sldx;*.otm;*.bin|" + $"{Properties.Resources.MWOpenWord97}|*.doc;*.dot|" + $"{Properties.Resources.MWOpenExcel97}|*.xls;*.xlt;*.xla|" + $"{Properties.Resources.MWOpenWord07}|*.docx;*.docm;*.dotx;*.dotm;*.docb|" + $"{Properties.Resources.MWOpenExcel07}|*.xlsx;*.xlsm;*.xltx;*.xltm;*.xlsb;*.xlam|" + $"{Properties.Resources.MWOpenPpt07}|*.pptx;*.pptm;*.potx;*.potm;*.ppam;*.ppsx;*.ppsm;*.sldx;*.sldm|" + $"{Properties.Resources.MWOpenOutlook}|*.otm|" + $"{Properties.Resources.MWOpenSAlone}|*.bin", FilterIndex = 2 }; if (dlg.ShowDialog() == true) { Session.FilePath = dlg.FileName; } }
private void ReplaceFrame() { VistaOpenFileDialog dialog = new VistaOpenFileDialog(); dialog.Filter = "Image Files(*.bmp;*.jpg;*.gif;*.png)|*.bmp;*.jpg;*.gif;*.png"; if ((bool)dialog.ShowDialog(this)) { newImage = new Bitmap(dialog.FileName, false); progress = new ProgressDialog() { WindowTitle = "Removing frame", Text = "Please wait while the frame is removed...", ShowTimeRemaining = true, ShowCancelButton = false }; progress.ProgressBarStyle = ProgressBarStyle.ProgressBar; progress.DoWork += progress3_DoWork; progress.Show(); } }
private async void RawFileButtonClick(object sender, RoutedEventArgs e) { // Create OpenFileDialog and Set filter for file extension and default file extension var dialog = new VistaOpenFileDialog { DefaultExt = ".raw", Filter = "Thermo(*.raw)|*.raw|mzML(*.mzML, *.mzML.gz)|*.mzml;*.mzML;*.mzML.gz;*.mzml.gz" }; // Get the selected file name and display in a TextBox var result = dialog.ShowDialog(); if (result.HasValue && result.Value) { // Disable buttons while files is loading ProcessAllTargetsButton.IsEnabled = false; SearchForTargetButton.IsEnabled = false; // Open file var fileName = dialog.FileName; var fileInfo = new FileInfo(fileName); await Task.Run(() => SingleTargetViewModel.UpdateRawFileLocation(fileInfo.FullName)); //Make sure we loaded a file if (SingleTargetViewModel.LcMsRun != null) { // Enable processing all targets button if applicable if (SingleTargetViewModel.LipidTargetList != null && SingleTargetViewModel.LipidTargetList.Any()) { ProcessAllTargetsButton.IsEnabled = true; } // Enable search for target button SearchForTargetButton.IsEnabled = true; } // Delay before clearing the progress to give the data loading thread a chance to report the final progress value System.Threading.Thread.Sleep(250); SingleTargetViewModel.ClearProgress(); } }
private void Open_project_click(object sender, RoutedEventArgs e) { if (paragr.Text != "Документ не открыт") { paragr.Text = ""; } VistaOpenFileDialog dialog = new VistaOpenFileDialog(); dialog.Filter = "Все файлы (*.html*)|*.html*"; if ((bool)dialog.ShowDialog(this)) { if (dialog.FileName == "") { return; } Path_link.Text = System.IO.Path.GetDirectoryName(dialog.FileName); EnableScreen(dialog.FileName); RTB.IsEnabled = true; } ClosePr.IsEnabled = true; Save.IsEnabled = true; }
/// <summary> /// Allows a user to load a new mod set. /// </summary> public async void LoadModSet() { var dialog = new VistaOpenFileDialog { Title = _xamlLoadModSetTitle.Get(), Filter = Constants.WpfJsonFormat, AddExtension = true, DefaultExt = ".json" }; if ((bool)dialog.ShowDialog()) { ModSet.FromFile(dialog.FileName).ToApplicationConfig(ApplicationTuple.Config); ApplicationTuple.SaveAsync(); // Check for mod updates/dependencies. if (Update.CheckMissingDependencies(out var missingDependencies)) { try { await Update.DownloadNuGetPackagesAsync(missingDependencies, false, false); } catch (Exception) { } } CheckModCompatibility(); OnLoadModSet(); } }
private void ShowOpenFileDialog() { // As of .Net 3.5 SP1, WPF's Microsoft.Win32.OpenFileDialog class still uses the old style VistaOpenFileDialog dialog = new VistaOpenFileDialog(); dialog.Filter = "All files (*.*)|*.*"; if( !VistaFileDialog.IsVistaFileDialogSupported ) MessageBox.Show(this, "Because you are not using Windows Vista or later, the regular open file dialog will be used. Please use Windows Vista to see the new dialog.", "Sample open file dialog"); if( (bool)dialog.ShowDialog(this) ) MessageBox.Show(this, "The selected file was: " + dialog.FileName, "Sample open file dialog"); }