private void saveDataPath_MouseDoubleClick(object sender, MouseButtonEventArgs e) { try { var dialog = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog(); dialog.IsFolderPicker = true; dialog.InitialDirectory = GlobalData.SavePath; dialog.DefaultFileName = GlobalData.SavePath; var result = dialog.ShowDialog(); if (result != Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogResult.Ok) return; GlobalData.SavePath = dialog.FileName; } catch (System.PlatformNotSupportedException) { var dialog = new System.Windows.Forms.FolderBrowserDialog(); dialog.SelectedPath = GlobalData.SavePath; var result = dialog.ShowDialog(); if (result != System.Windows.Forms.DialogResult.OK) return; GlobalData.SavePath = dialog.SelectedPath; } saveDataPathTextBox.Text = GlobalData.SavePath; }
private void button_SelectRDAFiles_Click(object sender, RoutedEventArgs e) { var dialog = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog(); dialog.IsFolderPicker = true; dialog.InitialDirectory = this.FindRDAFilesInitialDirectory(); if (dialog.ShowDialog(this) == Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogResult.Ok) { this.SelectRDAFilesFolder(dialog.FileName); } }
private void button_AddDir_Click(object sender, EventArgs e) { Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog dlg = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog(); dlg.IsFolderPicker = true; dlg.Multiselect = false; if (dlg.ShowDialog() == Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogResult.Ok) { this.Cursor = Cursors.WaitCursor; DirectoryInfo dirInfo = new DirectoryInfo(dlg.FileName); FileInfo[] fileInfo = dirInfo.GetFiles(); if (fileInfo != null && fileInfo.Length > 0) { for (int i = 0; i < fileInfo.Length; i++) { FileInfo info = fileInfo[i]; if (info.Extension.ToLower() == ".img" || info.Extension.ToLower() == ".tif") { string fileName = info.FullName; GSODataset set = dataManager.AddFileDataset(fileName); GeoScene.Data.EnumGeoReferenceType m = set.GeoReferenceType; if (m == GeoScene.Data.EnumGeoReferenceType.LatLon) { DataRow row = dt.Rows.Add(); row[0] = fileName; row[1] = "经纬度数据"; } else if (m == EnumGeoReferenceType.Project) { DataRow row = dt.Rows.Add(); row[0] = fileName; row[1] = set.ExportProjectionRefToWkt(); } else { DataRow row = dt.Rows.Add(); row[0] = fileName; row[1] = "无投影信息"; //XtraMessageBox.Show("数据投影信息不符合要求,请先转换为经纬度数据"); } } } dataGridView1.DataSource = dt; dataGridView1.Refresh(); } this.Cursor = Cursors.Default; } }
private bool SetGamePath() { //require [Windows API Code Pack] //in Visual Studio, open [Tool->Package Manager Consol] //input the command [Install-Package WindowsAPICodePack-Shell] var dialog = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog(); dialog.IsFolderPicker = true; Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogResult result = dialog.ShowDialog(); if (result != Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogResult.Ok) { return(false); } Configure.InstallPath = dialog.FileName; WindowCallbacks.Print(StringAdapter.GetResource("Menu_SetPath") + " : " + dialog.FileName); return(true); }
private void SetSearchFolder() { if (!string.IsNullOrWhiteSpace(DefaultFolder) && Directory.Exists(DefaultFolder)) { var dlg = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog { IsFolderPicker = true, InitialDirectory = DefaultFolder }; var result = dlg.ShowDialog(); if (result == Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogResult.Ok && !string.IsNullOrWhiteSpace(dlg.FileName)) { SearchFolder = dlg.FileName; } } }
public static DirectoryInfo pickFolder(string title = null, string initialDirectory = null) { Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog dialog = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog(); if (title != null) { dialog.Title = title; } dialog.IsFolderPicker = true; dialog.DefaultDirectory = initialDirectory ?? "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"; if (dialog.ShowDialog() == Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogResult.Ok) { var dir = new DirectoryInfo(dialog.FileName); if (dir.Exists) { return(dir); } } return(null); }
private void BtnBrowserPathInstaller_Click(object sender, RoutedEventArgs e) { try { Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog cfd = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog() { IsFolderPicker = true, Title = "Apps Center" }; if (cfd.ShowDialog() == Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogResult.Ok) { TxtPathInstaller.Text = cfd.FileName; } } catch (Exception ex) { MessageBox.Show("Error : " + ex.Message, "Apps Center", MessageBoxButton.OK, MessageBoxImage.Error); return; } }
public void Cmd_Browse(object param) { var cofd = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog() { IsFolderPicker = true, Multiselect = false, Title = Properties.Localization.WorkspaceSelectorDialog_Description }; if (!string.IsNullOrWhiteSpace(this.CurrentPath)) { cofd.InitialDirectory = CurrentPath; } var dlgResult = cofd.ShowDialog(); if (dlgResult == Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogResult.Ok) { this.CurrentPath = cofd.FileName; } }
private void Open_Executed(object sender, ExecutedRoutedEventArgs e) { string path; var tb = e.Source as TextBox; if (tb == null || !Directory.Exists(path = tb.Text)) { using (var bfd = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog()) { bfd.IsFolderPicker = true; bfd.RestoreDirectory = true; if (HasAnalysis) { path = Analysis.Path; } else { path = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Python Tools" ); } while (path.Length >= 4 && !Directory.Exists(path)) { path = Path.GetDirectoryName(path); } if (path.Length <= 3) { path = null; } bfd.InitialDirectory = path; if (bfd.ShowDialog() == WindowsAPICodePack.Dialogs.CommonFileDialogResult.Cancel) { return; } path = bfd.FileName; } } Load(path); }
private void Dialog_Click(object sender, RoutedEventArgs e) { Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog openFileDialog = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog(); openFileDialog.InitialDirectory = ""; openFileDialog.IsFolderPicker = true; openFileDialog.RestoreDirectory = true; var result = openFileDialog.ShowDialog(new WindowInteropHelper(Window.GetWindow(this)).Handle); if (result == Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogResult.Ok) { Path.Text = openFileDialog.FileName + "\\"; } if (RootPathBinding != null) { var rootPath = (string)BindingSource.GetType().GetProperties().Cast <PropertyInfo>() .First(obj => obj.GetCustomAttribute(typeof(InspectorModel.RootPathBindingAttribute)) is InspectorModel.RootPathBindingAttribute bindingAttribute && bindingAttribute.Name == RootPathBinding) .GetValue(BindingSource); Path.Text = InspectorModel.Path.GetRelativePath(Path.Text, RootPathBinding); } }
private void BrowseFolder_Executed(object sender, ExecutedRoutedEventArgs e) { using (var bfd = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog()) { bfd.IsFolderPicker = true; bfd.RestoreDirectory = true; var path = ((TextBox)e.Source).Text; while (path.Length >= 4 && !Directory.Exists(path)) { path = Path.GetDirectoryName(path); } if (path.Length <= 3) { path = null; } bfd.InitialDirectory = path; if (bfd.ShowDialog() == WindowsAPICodePack.Dialogs.CommonFileDialogResult.Cancel) { return; } ((TextBox)e.Source).SetCurrentValue(TextBox.TextProperty, bfd.FileName); } }
public bool OpenFolderDialog(string title, string initialPath, out string selectedPath) { var dialog = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog { IsFolderPicker = true, DefaultDirectory = initialPath, Title = title, ShowPlacesList = true }; var result = dialog.ShowDialog(Window.Value); if (result == Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogResult.Ok) { selectedPath = dialog.FileName; return(true); } else { selectedPath = null; return(false); } }
private async void btnOpenFolder_Click(object sender, EventArgs e) { #if NETCOREAPP3_1 || NET var folderBrowserDialog1 = new FolderBrowserDialog(); folderBrowserDialog1.SelectedPath = SelectedPath; if (DialogResult.OK == folderBrowserDialog1.ShowDialog(this)) { SelectedPath = folderBrowserDialog1.SelectedPath; await PopulateFolders(SelectedPath, DataProvider); } #else using (var dialog = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog()) { dialog.InitialDirectory = SelectedPath; dialog.IsFolderPicker = true; if (dialog.ShowDialog() == Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogResult.Ok) { SelectedPath = dialog.FileName; await PopulateFolders(SelectedPath, DataProvider); } } #endif }
protected override void ExecuteSelectDirectory() { using (var dlg = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog()) { dlg.Title = Resources.Word_SelectSourceDirectoryTitle; dlg.IsFolderPicker = true; dlg.InitialDirectory = this.Directory; dlg.AddToMostRecentlyUsedList = false; dlg.AllowNonFileSystemItems = false; dlg.EnsureFileExists = true; dlg.EnsurePathExists = true; dlg.EnsureReadOnly = false; dlg.EnsureValidNames = true; dlg.Multiselect = false; dlg.ShowPlacesList = true; if (dlg.ShowDialog() == Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogResult.Ok) { this.Directory = dlg.FileName; } } }
private void saveDataPath_MouseDoubleClick(object sender, MouseButtonEventArgs e) { try { var dialog = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog(); dialog.IsFolderPicker = true; dialog.InitialDirectory = GlobalData.SavePath; dialog.DefaultFileName = GlobalData.SavePath; var result = dialog.ShowDialog(); if (result != Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogResult.Ok) { return; } GlobalData.SavePath = dialog.FileName; } catch (System.PlatformNotSupportedException) { var dialog = new System.Windows.Forms.FolderBrowserDialog(); dialog.SelectedPath = GlobalData.SavePath; var result = dialog.ShowDialog(); if (result != System.Windows.Forms.DialogResult.OK) { return; } GlobalData.SavePath = dialog.SelectedPath; } saveDataPathTextBox.Text = GlobalData.SavePath; }
public void LoadFromXML(string xml) { // current search/replace pattern in case base directory has moved List <SearchReplace> paths = new List <SearchReplace>(); XmlDocument xmldoc = new XmlDocument(); xmldoc.LoadXml(xml); XPathNavigator nav = xmldoc.CreateNavigator(); XPathNodeIterator iterator = nav.Select("/FlickrSync/SyncFolder"); while (iterator.MoveNext()) { SyncFolder sf = new SyncFolder(); XPathNavigator nav2 = iterator.Current; sf.LoadFromXPath(nav2); DirectoryInfo dir = new DirectoryInfo(sf.FolderPath); if (!dir.Exists && paths.Count > 0) { for (int i = 0; i < paths.Count; i++) { if (sf.FolderPath.StartsWith(paths[i].oldpath)) { // Directory no longer exists, but it seems that we might be able to find its new location, // based on an alternate directory location we got from a previously missing directory string potentialFolderPath = sf.FolderPath.Replace(paths[i].oldpath, paths[i].newpath); // replace prefix as we did last time dir = new DirectoryInfo(potentialFolderPath); // Have we succeeded? silently replace prefix if (dir.Exists) { FlickrSync.Log(FlickrSync.LogLevel.LogAll, "Replaced " + sf.FolderPath + " with " + potentialFolderPath + " based on previous alternate directory location"); sf.FolderPath = potentialFolderPath; paths[i].use_count++; } } } } if (!dir.Exists) { if (FlickrSync.messages_level != FlickrSync.MessagesLevel.MessagesNone) { InformationBoxResult r = InformationBox.Show( "Folder " + sf.FolderPath + " no longer exists. Remove from list of folders to sync?", "Folder not found", InformationBoxButtons.YesNoUser1, new string[] { "Find on disk", String.Empty }, InformationBoxIcon.Exclamation, InformationBoxDefaultButton.Button2); if (r == InformationBoxResult.Yes) { FlickrSync.Log(FlickrSync.LogLevel.LogAll, sf.FolderPath + "marked for removal from configuration"); continue; } else if (r == InformationBoxResult.User1) { Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog cofd = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog(); //cofd.InitialDirectory = oldpaths[oldpaths.Length-1]; cofd.Multiselect = false; cofd.IsFolderPicker = true; if (cofd.ShowDialog() == Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogResult.Ok) { string newfolderpath = cofd.FileName.ToString(); SearchReplace p = new SearchReplace(sf.FolderPath, newfolderpath); paths.Add(p); FlickrSync.Log(FlickrSync.LogLevel.LogAll, sf.FolderPath + "replaced by " + newfolderpath + " in the configuration"); FlickrSync.Log(FlickrSync.LogLevel.LogAll, "From now on, we will try replacing " + p.oldpath + " by " + p.newpath); sf.FolderPath = newfolderpath; } else { FlickrSync.Log(FlickrSync.LogLevel.LogAll, sf.FolderPath + "not replaced after all"); continue; } } else { FlickrSync.Log(FlickrSync.LogLevel.LogAll, sf.FolderPath + "does not exists"); } } } SyncFolders.Add(sf); } foreach (var p in paths) { if (p.use_count > 0) { MessageBox.Show("Replaced Folder prefix " + p.oldpath + " with " + p.newpath + ((p.use_count == 1) ? " once" : " " + p.use_count.ToString() + " times"), "Info", MessageBoxButtons.OK); } } iterator = nav.Select("/FlickrSync/PathInfo"); while (iterator.MoveNext()) { PathInfo pi = new PathInfo(); XPathNavigator nav2 = iterator.Current; pi.LoadFromXPath(nav2); DirectoryInfo dir = new DirectoryInfo(pi.Path); if (!dir.Exists) { if (!pi.ManualAdd) { continue; } if (FlickrSync.messages_level != FlickrSync.MessagesLevel.MessagesNone) { if (MessageBox.Show("Folder " + pi.Path + " no longer exists. Remove from configuration?", "Warning", MessageBoxButtons.YesNo) == DialogResult.Yes) { FlickrSync.Log(FlickrSync.LogLevel.LogAll, "Path" + pi.Path + " marked for removal from configuration"); continue; } else { FlickrSync.Log(FlickrSync.LogLevel.LogAll, "Path" + pi.Path + " no longer exists"); } } } PathInfoList.Add(pi); } }
// This is an event handler that generates and returns QueryStore refresh parameters as necessary private void QueryImageStoreControl_LoadQueryListClick(object sender, Utils.GenericEventArgs <object, Dictionary <string, object> > e) { var isvm = e.Data as QueryImageStoreViewModel; if (isvm == null) { return; } Dictionary <string, object> storeRefreshPropertyBag = null; if (isvm.Name == "Local") // Right now, only the local QueryStore needs a file popup, this can be expanded later { using (var ofd = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog()) { ofd.IsFolderPicker = true; ofd.Title = "Choose folder containing query images"; Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogResult result = ofd.ShowDialog(); if (result == Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogResult.Ok) { storeRefreshPropertyBag = new Dictionary <string, object>(); storeRefreshPropertyBag.Add("filePath", ofd.FileName); } } } else if (isvm.Name == "Azure") { storeRefreshPropertyBag = new Dictionary <string, object>(); //no parameters for Azure store } e.ReturnValue = storeRefreshPropertyBag; }
private void loadProject_Click(object sender, RoutedEventArgs e) { Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog dlg = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog(); dlg.Title = "Select Project Folder"; dlg.IsFolderPicker = true; dlg.AddToMostRecentlyUsedList = false; dlg.AllowNonFileSystemItems = false; dlg.EnsureFileExists = true; dlg.EnsurePathExists = true; dlg.EnsureReadOnly = false; dlg.EnsureValidNames = true; dlg.Multiselect = false; dlg.ShowPlacesList = true; if (dlg.ShowDialog() == Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogResult.Ok) { treeView.ItemsSource = null; Project.LoadProject(dlg.FileName); treeView.ItemsSource = Project.Tracked; } }
private void DoBrowseFolderCommand() { if (!CanDoBrowseFolderCommand()) return; var Browser = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog(); Browser.IsFolderPicker = true; var LastBrowsedDirectory = ImageOrganizer.Properties.Settings.Default.LastBrowsedDirectory; if (!string.IsNullOrEmpty(LastBrowsedDirectory) && System.IO.Directory.Exists(LastBrowsedDirectory)) Browser.InitialDirectory = LastBrowsedDirectory; else Browser.InitialDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); var Result = Browser.ShowDialog(); if (Result != Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogResult.Ok) return; ImageOrganizer.Properties.Settings.Default.LastBrowsedDirectory = Browser.FileName; this.ActiveImagesViewModel.LoadImages(Browser.FileName); }