// 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;
        }
Exemple #2
0
        private void buttonNew_Click(object sender, EventArgs e)
        {
            using (var ofd = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog())
            {
                ofd.IsFolderPicker = true;
                ofd.Multiselect    = true;


                var rslt = ofd.ShowDialog();

                if (rslt != Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogResult.Ok)
                {
                    return;
                }

                foreach (var selectedPath in ofd.FileNames)
                {
                    if (listBoxFolders.Items.Contains(selectedPath))
                    {
                        return;
                    }

                    listBoxFolders.Items.Add(selectedPath);
                }
            }
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (fileOpen == false)
            {
                return;
            }

            Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog c = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog();
            c.IsFolderPicker = true;

            string path = "";

            if (c.ShowDialog() == Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogResult.Ok)
            {
                path = c.FileName;
            }
            else
            {
                return;
            }

            for (int x = 0; x < listBox1.Items.Count; x++)
            {
                string[] split      = listBox1.Items[x].ToString().Split(' ');
                int      actualNtp3 = int.Parse(split[1]);
                int      actualGidx = int.Parse(split[2]);

                ExportDDS(actualNtp3, actualGidx, false, path + "\\texture" + x.ToString() + ".dds");
            }
        }
        private void btSelectFile_Click(object sender, RoutedEventArgs e)
        {
            if (_folderMode)
            {
                var cfd = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog();
                cfd.IsFolderPicker = true;
                var result        = cfd.ShowDialog();
                var desiredResult = Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogResult.Ok;

                if (result == desiredResult && !string.IsNullOrEmpty(cfd.FileName))
                {
                    _backupTargetDirectory   = new DirectoryInfo(cfd.FileName);
                    btStartBackups.IsEnabled = true;
                }
            }
            else
            {
                Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog();
                bool result = (bool)ofd.ShowDialog();

                if (result && !string.IsNullOrEmpty(ofd.FileName))
                {
                    _backupTargetFile        = new FileInfo(ofd.FileName);
                    btStartBackups.IsEnabled = true;
                }
            }
        }
Exemple #6
0
        private void BtnSelectDestinationFolder_Click(object sender, RoutedEventArgs e)
        {
            //Source: https://stackoverflow.com/questions/4007882/select-folder-dialog-wpf?rq=1
            Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog openFolderDialog = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog();
            openFolderDialog.Title          = "Select Destination Folder for Reaper PitchMap-files";
            openFolderDialog.IsFolderPicker = true;
            //dlg.InitialDirectory = currentDirectory;

            openFolderDialog.AddToMostRecentlyUsedList = false;
            openFolderDialog.AllowNonFileSystemItems   = false;
            //dlg.DefaultDirectory = currentDirectory;
            openFolderDialog.EnsureFileExists = true;
            openFolderDialog.EnsurePathExists = true;
            openFolderDialog.EnsureReadOnly   = false;
            openFolderDialog.EnsureValidNames = true;
            openFolderDialog.Multiselect      = false;
            openFolderDialog.ShowPlacesList   = true;

            if (openFolderDialog.ShowDialog() == Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogResult.Ok)
            {
                var folder = openFolderDialog.FileName;
                txtEditor.Text = folder;
                targetFolder   = folder;
                // Do something with selected folder string
            }

            CheckAllConvertionConditions();
        }
        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;
        }
Exemple #8
0
        /// <summary>
        /// 作業ファイル保存先フォルダ設定ボタン
        /// </summary>
        private void SetWorkFilePass_Click(object sender, RoutedEventArgs e)
        {
            string current = System.IO.Directory.GetCurrentDirectory();

            var dlg = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog();

            dlg.Title                     = "作業ファイル保存先フォルダの選択";
            dlg.IsFolderPicker            = true;
            dlg.InitialDirectory          = EntryTextPass.Content.ToString();
            dlg.AddToMostRecentlyUsedList = false;
            dlg.AllowNonFileSystemItems   = false;
            dlg.DefaultDirectory          = EntryTextPass.Content.ToString();
            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)
            {
                WorkFilePass.Content = dlg.FileName;
            }

            System.IO.Directory.SetCurrentDirectory(current);
        }
Exemple #9
0
        private void button_SavaPath_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);

                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        FileInfo infoSave = new FileInfo(Convert.ToString(dataGridView1.Rows[i].Cells[0].Value));
                        string   name     = infoSave.Name;
                        saveDir = dlg.FileName + "\\";
                        dataGridView1.Rows[i].Cells[2].Value = dirInfo + "\\" + Path.ChangeExtension(name, ".lrp");
                    }
                }
                else
                {
                    saveDir = dlg.FileName + "\\";
                }
            }
            dataGridView1.Refresh();
            this.Cursor = Cursors.Default;
        }
Exemple #10
0
        public static PathString ShowBrowseDirectoryDialog(PathString startDir)
        {
            var dlg = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog();

            if (startDir.DirectoryExists)
            {
                dlg.DefaultDirectory = startDir;
            }

            dlg.IsFolderPicker   = true;
            dlg.RestoreDirectory = true;

            var dlgResult = dlg.ShowDialog();

            if (dlgResult != Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogResult.Ok)
            {
                return(PathString.Empty);
            }

            var path = dlg.FileName;

            path = System.IO.Path.Combine(path, "."); // we use a trailing "." to ensure that a filename change does not remove the last part of the path

            return(new PathString(path));
        }
Exemple #11
0
        protected override void ExecuteSelectDirectory()
        {
            using (var dlg = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog())
            {
                dlg.Title            = Resources.Word_SelectTargetDirectoryTitle;
                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;
                    this.UpdateDiskSpace();

                    this.RaiseCanExecuteBackupRestoreChanged();
                }
            }
        }
 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);
     }
 }
Exemple #13
0
        private void pathToDatawin32ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog c = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog();
            c.IsFolderPicker = true;

            if (c.ShowDialog() == Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogResult.Ok)
            {
                datawin32Path = c.FileName;
            }
        }
Exemple #14
0
 private void selectApp_Click(object sender, RoutedEventArgs e)
 {
     using (var ofd = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog()) {
         ofd.Filters.Add(new Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogFilter("Application", "*.exe"));
         if (ofd.ShowDialog() == Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogResult.Ok)
         {
             _commandbox_.Text = ofd.FileName;
         }
     }
 }
        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 okButtonOnClick(object sender, RoutedEventArgs e)
 {
     Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog dialog = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog();
     dialog.IsFolderPicker = true;
     if (dialog.ShowDialog() == Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogResult.Ok)
     {
         manager.addLoadingPath(dialog.FileName);
         seletedPathLabel = null;
         initializeComponentContents();
     }
 }
        private void FolderOpenButton(object sender, RoutedEventArgs e)
        {
            var folderDialog = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog();

            folderDialog.Title            = "Select layout folder";
            folderDialog.IsFolderPicker   = true;
            folderDialog.EnsurePathExists = true;
            if (folderDialog.ShowDialog() == WindowsAPICodePack.Dialogs.CommonFileDialogResult.Ok)
            {
                LayoutFolder.Text = folderDialog.FileName;
            }
        }
        private void selectUnzipFolderPath_Click(object sender, RoutedEventArgs e)
        {
            var cofd = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog()
            {
                IsFolderPicker = true
            };

            if (cofd.ShowDialog() == Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogResult.Ok)
            {
                tbUnzipFolderPath.ToolTip = tbUnzipFolderPath.Text = cofd.FileName;
            }
        }
        private void SaveLogToFileButtonClicked(object sender, RoutedEventArgs e)
        {
            Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog _dialog = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog();
            _dialog.IsFolderPicker   = true;
            _dialog.Title            = "Log File Location";
            _dialog.EnsurePathExists = true;
            _dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            if (_dialog.ShowDialog() == Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogResult.Ok)
            {
                string _folder = _dialog.FileName;

                int  _tries = 0;
                bool _logSuccessfullyWritten = false;

                string _hash;
                using (var md5 = System.Security.Cryptography.MD5.Create())
                {
                    using (var stream = System.IO.File.OpenRead(System.Reflection.Assembly.GetExecutingAssembly().Location))
                    {
                        _hash = BitConverter.ToString(md5.ComputeHash(stream)).Replace("-", "").ToLower();
                    }
                }

                string _data = "Please send this log with a brief description of what caused this error/ what you were doing to kaustubht96<at>gmail<dot>com\r\n\r\n" + "Application Details-\r\n============================\r\n\r\n-> Version: " + MainWindow.version + "\r\n-> File MD5 Hash: " + _hash + "\r\n\r\n" + DetailsTabTextBox.Text + "\r\n\r\n" + "Application Log-\r\n============================\r\n\r\n" + LogTabTextBox.Text;

                Exception ex = exception;

                while (_tries < 5 & !_logSuccessfullyWritten)
                {
                    try
                    {
                        using (System.IO.StreamWriter file = new System.IO.StreamWriter(_folder + "\\ChatApp_Error_Log_" + DateTime.Now.ToLongTimeString().Replace(':', '-') + "_" + DateTime.Now.ToShortDateString() + ".txt"))
                        {
                            file.WriteLine(_data);
                        }
                        _logSuccessfullyWritten = true;
                    }
                    catch
                    {
                        _tries++;
                    }
                }

                if (!_logSuccessfullyWritten)
                {
                    MessageBox.Show("Failed To Write Log to File");
                }
                else
                {
                    MessageBox.Show("Log Successfully Written to File");
                }
            }
        }
Exemple #20
0
        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;
                            string     savePath = Path.ChangeExtension(fileName, ".lrp");
                            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] = "经纬度数据";
                                row[2] = savePath;
                            }
                            else if (m == EnumGeoReferenceType.Project)
                            {
                                DataRow row = dt.Rows.Add();
                                row[0] = fileName;
                                row[1] = set.ExportProjectionRefToWkt();
                                row[2] = savePath;
                            }
                            else
                            {
                                DataRow row = dt.Rows.Add();
                                row[0] = fileName;
                                row[1] = "无投影信息";
                                row[2] = savePath;
                                //XtraMessageBox.Show("数据投影信息不符合要求,请先转换为经纬度数据");
                            }
                        }
                    }
                    dataGridView1.DataSource = dt;

                    dataGridView1.Refresh();
                }
                this.Cursor = Cursors.Default;
            }
        }
Exemple #21
0
        public void BrowseFile()
        {
            var ofd = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog
            {
                Multiselect = false
            };

            var result = ofd.ShowDialog();

            if (result == Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogResult.Ok)
            {
                File = ofd.FileName;
            }
        }
 private void btnAddDir_Click(object sender, RoutedEventArgs e)
 {
     Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog fd =
         new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog();
     //System.Windows.Forms.FolderBrowserDialog fd = new System.Windows.Forms.FolderBrowserDialog();
     fd.EnsurePathExists = true;
     fd.IsFolderPicker   = true;
     fd.Title            = "Choose a directory...";
     fd.InitialDirectory = Properties.Settings.Default.VideoDir;
     if (fd.ShowDialog() == Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogResult.OK)
     {
         Playlist.ActivePlaylist.AddVideosFromDirectory(fd.FileName);
     }
 }
Exemple #23
0
        private void SetDefaultFolder()
        {
            var dlg = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog
            {
                IsFolderPicker = true
            };

            var result = dlg.ShowDialog();

            if (result == Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogResult.Ok && !string.IsNullOrWhiteSpace(dlg.FileName))
            {
                DefaultFolder = dlg.FileName;
            }
        }
Exemple #24
0
        private void SetupEventsHandlers()
        {
            sbtnFolderProbingBrowse.Click += (s, e) =>
            {
#if NETCOREAPP3_1 || NET
                using (FolderBrowserDialog folderDlg = new FolderBrowserDialog
                {
                    ShowNewFolderButton = false
                })
                {
                    // Show the FolderBrowserDialog.
                    DialogResult result = folderDlg.ShowDialog();
                    if (result == DialogResult.OK)
                    {
                        teFoldersProbing.Text = folderDlg.SelectedPath;
                    }
                }
#else
                using (var dialog = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog())
                {
                    dialog.IsFolderPicker = true;
                    if (dialog.ShowDialog() == Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogResult.Ok)
                    {
                        teFoldersProbing.Text = dialog.FileName;
                    }
                }
#endif
            };

            sbtnFolderProbingAdd.Click += (s, e) =>
            {
                if (string.IsNullOrEmpty(teFoldersProbing.Text))
                {
                    return;
                }

                listBoxFoldersProbing.Items.Add(teFoldersProbing.Text);
                Settings.AdditionalProbingLocations.Add(teFoldersProbing.Text);
            };

            sbtnDeleteFolderProbing.Click += (s, e) =>
            {
                if (listBoxFoldersProbing.SelectedItem != null)
                {
                    Settings.AdditionalProbingLocations.Remove(listBoxFoldersProbing.SelectedItem.ToString());
                    listBoxFoldersProbing.Items.Remove(listBoxFoldersProbing.SelectedItem);
                }
            };
        }
Exemple #25
0
        private string BrowseForDirectory(string currentPath)
        {
            var dialog = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog
            {
                IsFolderPicker = true
            };
            var result = dialog.ShowDialog();

            if (result == Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogResult.Cancel)
            {
                return(currentPath);
            }

            return(dialog.FileName);
        }
Exemple #26
0
        private void Button_Click_TabDecrypt_SelectInputFile(object sender, RoutedEventArgs e)
        {
            var dialog = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog();

            if (dialog.ShowDialog() == Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogResult.Ok)
            {
                TabDecrypt_InputFilePath.Text = dialog.FileName;
                var fileName =
                    Path.GetFileNameWithoutExtension(dialog.FileName) +
                    "_decrypted" +
                    Path.GetExtension(dialog.FileName);
                TabDecrypt_OutputFilePath.Text = Path.Combine(
                    Path.GetDirectoryName(dialog.FileName),
                    fileName);
            }
        }
        /// <summary>
        /// Sets the destination directory where the files of the Unit Test are
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ClickDestDir(object sender, MouseButtonEventArgs e)
        {
            // Initializes an CommonOpenFileDialog for choosing a folder
            Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog openFileDialog = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog
            {
                IsFolderPicker   = true,
                InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
                Multiselect      = false
            };

            if (openFileDialog.ShowDialog() == Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogResult.Ok)
            {
                UnitTest.SetDirectory     = openFileDialog.FileName;
                destinationDirectory.Text = openFileDialog.FileName;
            }
        }
Exemple #28
0
        private void GetScreenShotPath_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new MSAPI.Dialogs.CommonOpenFileDialog()
            {
                IsFolderPicker   = true,
                Multiselect      = false,
                Title            = "フォルダーを選択してください",
                InitialDirectory = ScreenShotSavePath
            };

            if (dialog.ShowDialog() == MSAPI.Dialogs.CommonFileDialogResult.Ok)
            {
                ScreenShotSavePath = dialog.FileName;
                TextSavePath.Text  = ScreenShotSavePath;
            }
        }
        /// <summary>
        /// Opens a dialog to choose a destination folder
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DestFolder_MouseDown(object sender, MouseButtonEventArgs e)
        {
            Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog openFileDialog = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog
            {
                IsFolderPicker   = true,
                InitialDirectory = Values.source.DirectoryName,
                Multiselect      = false
            };


            if (openFileDialog.ShowDialog() == Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogResult.Ok)
            {
                Values.destinationDirectory = openFileDialog.FileName;
                destinationDirectory.Text   = Values.destinationDirectory;
            }
        }
Exemple #30
0
        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;
                }
            }
        }
Exemple #31
0
        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);
        }
Exemple #32
0
 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);
 }
Exemple #33
0
 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);
     }
 }
Exemple #34
0
        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 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);
        }