Example #1
0
 public void OpenFolderDialog()
 {
     try
     {
         var dialog = new CommonOpenFileDialog();
         dialog.IsFolderPicker = true;
         CommonFileDialogResult result = dialog.ShowDialog();
         if (result.ToString() != "Cancel" && result.ToString() != null)
         {
             FolderPath = dialog.FileName;
         }
     }
     catch (Exception e)
     {
         throw new Exception("Возникла ошибка в выборе папки. " + e.Message);
     }
 }
Example #2
0
        /// <summary>
        /// Show a FolderPicker Dialog for the user to select the game directory, then validates it is correct
        /// </summary>
        public static void AskFilePathAndValidate(MainWindow window, PatcherPOCO patcher)
        {
            _log.Info("Checking if path is valid");
            var dialog = new CommonOpenFileDialog();

            dialog.IsFolderPicker = true;
            CommonFileDialogResult result = dialog.ShowDialog();

            if (result.ToString() == "Ok")
            {
                ValidateFilePath(window, patcher, dialog.FileName);
            }
        }
Example #3
0
 public void chooseFolder()
 {
     Application.Current.Dispatcher.Invoke(() =>
     {
         var dialog                    = new CommonOpenFileDialog();
         dialog.IsFolderPicker         = true;
         CommonFileDialogResult result = dialog.ShowDialog();
         if (result.ToString().Equals("Ok"))
         {
             Console.WriteLine(dialog.FileName);
             MainWindow.GetFiles(dialog.FileName);
         }
     });
 }
Example #4
0
        private void MatBtnPostgreSqlDir_Click(object sender, EventArgs e)
        {
            using (var folderDialog = new CommonOpenFileDialog())
            {
                folderDialog.IsFolderPicker = true;
                folderDialog.Title          = "Selecione a pasta bin do PostgreSQL";

                CommonFileDialogResult result = folderDialog.ShowDialog();

                if (result.ToString() == "Ok")
                {
                    AbaConfiguracoes.ConfiguracaoModel.DiretorioPostgreSql = folderDialog.FileName;
                }
            }
        }
Example #5
0
        private void MatBtnSistemDir_Click(object sender, EventArgs e)
        {
            using (var folderDialog = new CommonOpenFileDialog())
            {
                folderDialog.IsFolderPicker = true;
                folderDialog.Title          = "Selecione o local do sistema";

                CommonFileDialogResult result = folderDialog.ShowDialog();

                if (result.ToString() == "Ok")
                {
                    AbaConfiguracoes.ConfiguracaoModel.DiretorioSistema = folderDialog.FileName;
                }
            }
        }
Example #6
0
        private void AddNewDirInplementation(object obj)
        {
            var dialog = new CommonOpenFileDialog();

            dialog.IsFolderPicker = true;
            CommonFileDialogResult result = dialog.ShowDialog();

            if (result.ToString() == "Ok")
            {
                String newPath = dialog.FileName.ToString();
                StationManager.DataStorage.AddPath(newPath);
                IndexedPathsList = new ObservableCollection <String>(StationManager.DataStorage.PathsList);
                IndexingPath     = newPath;
            }
        }
Example #7
0
        // used in UserSettings and FilesAcceptance
        public static String RetrieveDirectoryLocation()
        {
            var dialog = new CommonOpenFileDialog {
                IsFolderPicker = true
            };

            CommonFileDialogResult result = dialog.ShowDialog();

            if (result.ToString() == "Ok")
            {
                return(dialog.FileName);
            }

            return(null);
        }
Example #8
0
        private List <ModelPath> GetModelPaths()
        {
            // Collect folders to update
            var dialog = new CommonOpenFileDialog();

            dialog.IsFolderPicker = true;
            CommonFileDialogResult result = dialog.ShowDialog();

            if (result.ToString() == "Ok")
            {
                var path          = dialog.FileName;
                var directoryInfo = new DirectoryInfo(path);

                return(ParseModelPaths(directoryInfo));
            }
            else
            {
                return(null);
            }
        }
Example #9
0
        private void ExportToTxtButton_Click(object sender, RoutedEventArgs e)
        {
            ExportToTxtButton.IsEnabled = false;

            var revs = DbReviews_DataGrid.SelectedItems;

            if (revs.Count == 0)
            {
                revs = DbReviews_DataGrid.Items;
            }

            if (revs.Count > 1)
            {
                CommonOpenFileDialog dialog = new CommonOpenFileDialog()
                {
                    IsFolderPicker = true
                };

                CommonFileDialogResult result = dialog.ShowDialog();

                if (result.ToString() == "Ok")
                {
                    foreach (DbReview rev in revs)
                    {
                        string fileName = dialog.FileName + "\\rev_" + rev.Rev_CeneoID + ".txt";

                        using (StreamWriter sw = new StreamWriter(fileName))
                        {
                            sw.WriteLine("ID: " + rev.Rev_CeneoID);
                            sw.WriteLine("Data: " + rev.Rev_Date);
                            sw.WriteLine("Reviewer: " + rev.Rev_Reviewer);
                            sw.WriteLine("Advantages: " + rev.Rev_Advantages);
                            sw.WriteLine("Defects: " + rev.Rev_Defects);
                            sw.WriteLine("Review: " + rev.Rev_Content);
                            sw.WriteLine("Down votes: " + rev.Rev_DownVotes);
                            sw.WriteLine("Up votes: " + rev.Rev_UpVotes);
                            sw.WriteLine("Rating: " + rev.Rev_Rating);
                            sw.WriteLine("Recom: " + rev.Rev_Recom);
                        }
                    }

                    MessageBox.Show("Files are saved in: " + dialog.FileName);
                    ExportToTxtButton.IsEnabled = true;
                }
                else
                {
                    ExportToTxtButton.IsEnabled = true;
                    return;
                }
            }
            else if (revs.Count == 1)
            {
                DbReview rev = revs[0] as DbReview;

                SaveFileDialog dialog = new SaveFileDialog()
                {
                    FileName = "rev_" + rev.Rev_CeneoID + ".txt",
                    Filter   = "Text files (*.txt)|*.txt|All files (*.*)|*.*"
                };

                var result = dialog.ShowDialog();

                if (result.Value)
                {
                    using (StreamWriter sw = new StreamWriter(dialog.FileName))
                    {
                        sw.WriteLine("ID: " + rev.Rev_CeneoID);
                        sw.WriteLine("Data: " + rev.Rev_Date);
                        sw.WriteLine("Reviewer: " + rev.Rev_Reviewer);
                        sw.WriteLine("Advantages: " + rev.Rev_Advantages);
                        sw.WriteLine("Defects: " + rev.Rev_Defects);
                        sw.WriteLine("Review: " + rev.Rev_Content);
                        sw.WriteLine("Down votes: " + rev.Rev_DownVotes);
                        sw.WriteLine("Up votes: " + rev.Rev_UpVotes);
                        sw.WriteLine("Rating: " + rev.Rev_Rating);
                        sw.WriteLine("Recom: " + rev.Rev_Recom);
                    }

                    ExportToTxtButton.IsEnabled = true;

                    if (MessageBox.Show("File saved!\nDo you want to open new file?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                    {
                        Process.Start(dialog.FileName);
                    }
                }
                else
                {
                    ExportToTxtButton.IsEnabled = true;
                    return;
                }
            }
        }