private void SelectPath()
        {
            string initialDirectory = GetDirectoryPath(correctPath: true);

            while (!Directory.Exists(initialDirectory) && !String.IsNullOrEmpty(initialDirectory))
            {
                initialDirectory = Path.GetDirectoryName(initialDirectory);
            }
            if (String.IsNullOrEmpty(initialDirectory))
            {
                initialDirectory = Environment.AppDataDirectory;
            }
            SaveFileDialogParameters saveFileDialogParameters = new SaveFileDialogParameters
            {
                DialogTitle      = "Экспортировать результаты поиска",
                Filter           = GetFileFilter(),
                OverwritePrompt  = false,
                InitialDirectory = initialDirectory,
                InitialFileName  = GetFileNameWithoutExtension(correctFileName: true) + "." + GenerateFileExtension()
            };
            SaveFileDialogResult saveFileDialogResult = WindowManager.ShowSaveFileDialog(saveFileDialogParameters);

            if (saveFileDialogResult.DialogResult)
            {
                FilePathTemplate = saveFileDialogResult.SelectedFilePath;
            }
        }
Esempio n. 2
0
        public override async Task ExecuteAsync()
        {
            if (_docInfoService.IsOpenedDocument)
            {
                await _textFileWriter.WriteAsync(new WriteTextFileModel { FilePath = _docInfoService.UsedFilePath, Content = CallerViewModel.InputTextBoxViewModel.Content });

                _docInfoService.SetUnmodifiedDocumentState();

                CallerViewModel.WindowSettingsViewModel.Title = _docInfoService.UsedFileNameWithoutExtension;
            }
            else
            {
                SaveFileDialogResult saveFileDialogResult =
                    await _saveFileDialog.ShowDialogAsync(new SaveFileDialogOptions { FileFilters = GetSaveFileDialogFilters() });

                if (saveFileDialogResult.SaveFileDialogResultType == SaveFileDialogResultType.Ok)
                {
                    await _textFileWriter.WriteAsync(new WriteTextFileModel { FilePath = saveFileDialogResult.SavedFilePath, Content = CallerViewModel.InputTextBoxViewModel.Content });

                    _docInfoService.SetFilePath(saveFileDialogResult.SavedFilePath);
                    _docInfoService.SetUnmodifiedDocumentState();

                    CallerViewModel.WindowSettingsViewModel.Title = _docInfoService.UsedFileNameWithoutExtension;
                }
            }
        }
Esempio n. 3
0
        public IEnumerable <IResult> DownloadMatch()
        {
            if (FileName == null || FileName == string.Empty)
            {
                var dialog = new SaveFileDialogResult()
                {
                    Title           = string.Format("Save match \"{0}\"...", Match.Title()),
                    Filter          = Format.XML.DialogFilter,
                    DefaultFileName = Match.DefaultFilename(),
                };
                yield return(dialog);

                FileName = dialog.Result;
            }

            var serialization = new SerializeMatchResult(Match, FileName, Format.XML.Serializer);

            yield return(serialization
                         .Rescue()
                         .WithMessage("Error saving the match", string.Format("Could not save the match to {0}.", FileName))
                         .Propagate()); // Reraise the error to abort the coroutine

            MatchModified = false;
            NotifyOfPropertyChange("MatchModified");
        }
Esempio n. 4
0
        public IEnumerable <IResult> ExportExcel()
        {
            // yield return new SequentialResult(this.SwapPlayersIfNecessary().GetEnumerator());

            var dialog = new SaveFileDialogResult()
            {
                Title           = string.Format("Export match \"{0}\" to Excel...", Match.Title()),
                Filter          = Format.Excel.DialogFilter,
                DefaultFileName = Match.DefaultFilename(),
            };

            yield return(dialog);

            var fileName = dialog.Result;

            var serialization = new SerializeMatchResult(Match, fileName, Format.Excel.Serializer);

            yield return(serialization
                         .Rescue()
                         .WithMessage("Error exporting the match", string.Format("Could not export the match to {0}.", FileName))
                         .Propagate()); // Reraise the error to abort the coroutine


            //yield return new SerializeMatchResult(Match, FileName, Format.Excel.Serializer)
            //    //.IsBusy("Exporting")
            //    .Rescue()
            //    .WithMessage("Error exporting the match", string.Format("Could not export the match to {0}.", FileName))
            //    .Propagate();
        }
        public override async Task ExecuteAsync()
        {
            if (_docInfoService.IsModifiedDocument)
            {
                MessageDialogResult messageDialogResult = await _messageDialog.ShowDialogAsync(
                    new MessageDialogOptions { Title = "Notepad", Content = $"Do you want to save the {_docInfoService.UsedFileNameWithExtension} changes?", Button = MessageBoxButton.YesNoCancel });

                switch (messageDialogResult.MessageDialogResultType)
                {
                case MessageDialogResultType.Yes:
                {
                    if (_docInfoService.IsOpenedDocument)
                    {
                        await _textFileWriter.WriteAsync(new WriteTextFileModel { FilePath = _docInfoService.UsedFilePath, Content = CallerViewModel.InputTextBoxViewModel.Content });
                    }
                    else
                    {
                        SaveFileDialogResult saveFileDialogResult = await _saveFileDialog.ShowDialogAsync(new SaveFileDialogOptions { FileFilters = GetSaveFileDialogFilters() });

                        if (saveFileDialogResult.SaveFileDialogResultType == SaveFileDialogResultType.Ok)
                        {
                            await _textFileWriter.WriteAsync(new WriteTextFileModel { FilePath = saveFileDialogResult.SavedFilePath, Content = CallerViewModel.InputTextBoxViewModel.Content });

                            _docInfoService.SetFilePath(saveFileDialogResult.SavedFilePath);
                        }
                        else if (saveFileDialogResult.SaveFileDialogResultType == SaveFileDialogResultType.Cancel)
                        {
                            return;
                        }
                    }

                    _docInfoService.SetUnmodifiedDocumentState();
                    CallerViewModel.WindowSettingsViewModel.Title = _docInfoService.UsedFileNameWithoutExtension;

                    break;
                }

                case MessageDialogResultType.Cancel:
                {
                    return;
                }
                }
            }

            OpenFileDialogResult openFileDialogResult = await _openFileDialog.ShowDialogAsync(new OpenFileDialogOptions { FileFilters = GetOpenFileDialogFilters() });

            if (openFileDialogResult.OpenFileDialogResultType == OpenFileDialogResultType.Ok)
            {
                CallerViewModel.InputTextBoxViewModel.Content = await _textFileReader.ReadAsync <string>(new ReadTextFileModel { FilePath = openFileDialogResult.FilePath });

                _docInfoService.SetFilePath(openFileDialogResult.FilePath);
                _docInfoService.SetUnmodifiedDocumentState();

                CallerViewModel.WindowSettingsViewModel.Title = _docInfoService.UsedFileNameWithoutExtension;
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Generates a PDF report.
        /// </summary>
        /// <returns>The actions to generate the report.</returns>
        public IEnumerable <IResult> GenerateReport(string type)
        {
            var dialog = new SaveFileDialogResult()
            {
                Title           = "Choose a target for PDF report",
                Filter          = "PDF reports|*.pdf",
                DefaultFileName = this.Match.DefaultFilename(),
            };

            yield return(dialog);

            var fileName = dialog.Result;

            yield return(new GenerateReportResult(this.Match, fileName, type)
                         .Rescue()
                         .WithMessage("Error generating report", string.Format("Could not save the report to {0}.", fileName))
                         .Propagate());
        }
Esempio n. 7
0
        public IEnumerable <IResult> SaveGeneratedReport()
        {
            if (_issuedReportId == null && _generatedReport.GetValueOrDefault("reportid") == null)
            {
                Debug.WriteLine("Saving generated report failed. Report neither generated nor issued.");
            }
            else
            {
                var dialog = new SaveFileDialogResult()
                {
                    Title           = "Choose a target for PDF report",
                    Filter          = "PDF reports|*.pdf",
                    DefaultFileName = MatchManager.Match.DefaultFilename(),
                };
                yield return(dialog);

                ReportGenerationQueueManager.ReportPathUser = dialog.Result;
            }
        }
        public IEnumerable <IResult> DownloadMatch()
        {
            if (isCorrectMatchSelected())
            {
                errorMessageVisible = Visibility.Collapsed;
                headerVisible       = Visibility.Visible;
                var dialog = new SaveFileDialogResult()
                {
                    Title           = string.Format("Download match..."),
                    Filter          = string.Format("{0}|{1}", "Flash Video", "*.flv"),
                    DefaultFileName = OutputStringVideoName(),
                };
                yield return(dialog);

                outputString = dialog.Result;

                inputString    = InputString();
                argumentString = "/c rtmpdump -r \"" + @inputString + "\" -o \"" + @outputString + "\" -W http://cdn.laola1.tv/ittf/iframe/ittfplayer_v10.swf";

                //Create a Process

                Process process = new Process();
                process.StartInfo.FileName        = "cmd.exe";
                process.StartInfo.Arguments       = argumentString;
                process.StartInfo.UseShellExecute = false;
                process.Start();
                //process.WaitForExit();
            }
            else
            {
                errorMessageVisible = Visibility.Visible;
                headerVisible       = Visibility.Collapsed;
                // Webbrowser allways on Top....no Dialog possible

                //var errorDialog = new ErrorMessageResult()
                //{
                //    Title = "Keine Video ausgewählt!",
                //    Message = "Bitte wählen sie ein korrektes Match aus!",
                //    Dialogs = DialogCoordinator
                //};
                //yield return errorDialog;
            }
        }
        public override async Task ExecuteAsync(CancelEventArgs eventArgs)
        {
            if (_docInfoService.IsModifiedDocument)
            {
                MessageDialogResult messageDialogResult = await _messageDialog.ShowDialogAsync(
                    new MessageDialogOptions { Title = "Notepad", Content = $"Do you want to save the {_docInfoService.UsedFileNameWithExtension} changes?", Button = MessageBoxButton.YesNoCancel });

                switch (messageDialogResult.MessageDialogResultType)
                {
                case MessageDialogResultType.Yes:
                {
                    if (_docInfoService.IsOpenedDocument)
                    {
                        await _textFileWriter.WriteAsync(new WriteTextFileModel { FilePath = _docInfoService.UsedFilePath, Content = CallerViewModel.InputTextBoxViewModel.Content });
                    }
                    else
                    {
                        SaveFileDialogResult saveFileDialogResult = await _saveFileDialog.ShowDialogAsync(new SaveFileDialogOptions { FileFilters = GetSaveFileDialogFilters() });

                        if (saveFileDialogResult.SaveFileDialogResultType == SaveFileDialogResultType.Ok)
                        {
                            await _textFileWriter.WriteAsync(new WriteTextFileModel { FilePath = saveFileDialogResult.SavedFilePath, Content = CallerViewModel.InputTextBoxViewModel.Content });
                        }
                        else if (saveFileDialogResult.SaveFileDialogResultType == SaveFileDialogResultType.Cancel)
                        {
                            eventArgs.Cancel = true;
                            return;
                        }
                    }

                    break;
                }

                case MessageDialogResultType.Cancel:
                {
                    eventArgs.Cancel = true;
                    return;
                }
                }
            }

            System.Windows.Application.Current.Shutdown();
        }
Esempio n. 10
0
        public IEnumerable <IResult> SaveMatch()
        {
            if (FileName == null || FileName == string.Empty)
            {
                var dialog = new SaveFileDialogResult()
                {
                    Title           = string.Format("Save match \"{0}\"...", Match.Title()),
                    Filter          = Format.XML.DialogFilter,
                    DefaultFileName = Match.DefaultFilename(),
                };
                yield return(dialog);

                FileName    = dialog.Result;
                MatchSaveAs = true;
                NotifyOfPropertyChange("MatchSaveAs");
            }

            //Remove Dummy Rally from Scouter
            var  lastRally      = Match.Rallies.LastOrDefault();
            bool haveToAddAgain = false;

            if (Match.Rallies.Any())
            {
                if (lastRally.Winner == MatchPlayer.None)
                {
                    Match.Rallies.Remove(lastRally);
                    haveToAddAgain = true;
                }
            }
            var serialization = new SerializeMatchResult(Match, FileName, Format.XML.Serializer);

            yield return(serialization
                         .Rescue()
                         .WithMessage("Error saving the match", string.Format("Could not save the match to {0}.", FileName))
                         .Propagate()); // Reraise the error to abort the coroutine

            if (haveToAddAgain)
            {
                Execute.OnUIThread((System.Action)(() => Match.Rallies.Add(lastRally)));
            }
            MatchModified = false;
            NotifyOfPropertyChange("MatchModified");
        }
Esempio n. 11
0
        private async void SaveFileDialogButtonClickHandler(object sender, RoutedEventArgs args)
        {
            SaveFileDialogArguments dialogArgs = new SaveFileDialogArguments()
            {
                Width   = 600,
                Height  = 400,
                Filters = "All files|*.*|C# files|*.cs|XAML files|*.xaml"
            };

            SaveFileDialogResult result = await SaveFileDialog.ShowDialogAsync(MainWindow.DialogHostName, dialogArgs);

            if (DataContext is FileSystemDialogViewModel viewModel)
            {
                if (!result.Canceled)
                {
                    viewModel.SelectedAction = "Selected file: " + result.FileInfo.FullName;
                }
                else
                {
                    viewModel.SelectedAction = "Cancel save file";
                }
            }
        }
        private void SelectDatabaseFilePath()
        {
            StringBuilder filterBuilder = new StringBuilder();

            filterBuilder.Append(Localization.Databases);
            filterBuilder.Append(" (*.db)|*.db|");
            filterBuilder.Append(Localization.AllFiles);
            filterBuilder.Append(" (*.*)|*.*");
            SaveFileDialogParameters saveFileDialogParameters = new SaveFileDialogParameters
            {
                DialogTitle     = Localization.SelectDatabaseFilePathDialogTitle,
                Filter          = filterBuilder.ToString(),
                OverwritePrompt = true
            };

            saveFileDialogParameters.InitialDirectory = Path.GetDirectoryName(DatabaseFilePath);
            saveFileDialogParameters.InitialFileName  = Path.GetFileName(DatabaseFilePath);
            SaveFileDialogResult saveFileDialogResult = WindowManager.ShowSaveFileDialog(saveFileDialogParameters);

            if (saveFileDialogResult.DialogResult)
            {
                DatabaseFilePath = saveFileDialogResult.SelectedFilePath;
            }
        }
Esempio n. 13
0
 private void OkButtonClick()
 {
     if (IsCreateDatabaseSelected)
     {
         SaveFileDialogParameters saveFileDialogParameters = new SaveFileDialogParameters
         {
             DialogTitle     = "Сохранение новой базы данных",
             Filter          = "Базы данных (*.db)|*.db|Все файлы (*.*)|*.*",
             OverwritePrompt = true
         };
         if (eventType == EventType.DATABASE_CORRUPTED)
         {
             string databaseFilePath = mainModel.GetDatabaseFullPath(mainModel.AppSettings.DatabaseFileName);
             saveFileDialogParameters.InitialDirectory = Path.GetDirectoryName(databaseFilePath);
             saveFileDialogParameters.InitialFileName  = Path.GetFileName(databaseFilePath);
         }
         else
         {
             saveFileDialogParameters.InitialDirectory = Environment.AppDataDirectory;
             saveFileDialogParameters.InitialFileName  = Constants.DEFAULT_DATABASE_FILE_NAME;
         }
         SaveFileDialogResult saveFileDialogResult = WindowManager.ShowSaveFileDialog(saveFileDialogParameters);
         if (saveFileDialogResult.DialogResult)
         {
             if (mainModel.CreateDatabase(saveFileDialogResult.SelectedFilePath))
             {
                 mainModel.AppSettings.DatabaseFileName = mainModel.GetDatabaseNormalizedPath(saveFileDialogResult.SelectedFilePath);
                 mainModel.SaveSettings();
                 CurrentWindowContext.CloseDialog(true);
             }
             else
             {
                 MessageBoxWindow.ShowMessage("Ошибка", "Не удалось создать базу данных.", CurrentWindowContext);
             }
         }
     }
     else
     {
         OpenFileDialogParameters openFileDialogParameters = new OpenFileDialogParameters
         {
             DialogTitle = "Выбор базы данных",
             Filter      = "Базы данных (*.db)|*.db|Все файлы (*.*)|*.*",
             Multiselect = false
         };
         OpenFileDialogResult openFileDialogResult = WindowManager.ShowOpenFileDialog(openFileDialogParameters);
         if (openFileDialogResult.DialogResult)
         {
             string databaseFilePath = openFileDialogResult.SelectedFilePaths.First();
             if (mainModel.OpenDatabase(databaseFilePath))
             {
                 mainModel.AppSettings.DatabaseFileName = mainModel.GetDatabaseNormalizedPath(databaseFilePath);
                 mainModel.SaveSettings();
                 CurrentWindowContext.CloseDialog(true);
             }
             else
             {
                 UpdateHeaderAndEventType(Path.GetFileName(databaseFilePath));
                 NotifyPropertyChanged(nameof(Header));
             }
         }
     }
 }
Esempio n. 14
0
        private void ExportWaypoints(SaveFileDialogResult result)
        {
            var exporter = _exporters.Find(e => e.GetFileType() == result.FileType);

            exporter.ExportWaypoints(result.FileName, _waypointsService.Waypoints.ToList());
        }
Esempio n. 15
0
        private void OkButtonClick()
        {
            StringBuilder filterBuilder = new StringBuilder();

            filterBuilder.Append(Localization.Databases);
            filterBuilder.Append(" (*.db)|*.db|");
            filterBuilder.Append(Localization.AllFiles);
            filterBuilder.Append(" (*.*)|*.*");
            if (IsCreateDatabaseSelected)
            {
                SaveFileDialogParameters saveFileDialogParameters = new SaveFileDialogParameters
                {
                    DialogTitle     = Localization.BrowseNewDatabaseDialogTitle,
                    Filter          = filterBuilder.ToString(),
                    OverwritePrompt = true
                };
                if (eventType == EventType.DATABASE_CORRUPTED)
                {
                    string databaseFilePath = MainModel.GetDatabaseFullPath(MainModel.AppSettings.DatabaseFileName);
                    saveFileDialogParameters.InitialDirectory = Path.GetDirectoryName(databaseFilePath);
                    saveFileDialogParameters.InitialFileName  = Path.GetFileName(databaseFilePath);
                }
                else
                {
                    saveFileDialogParameters.InitialDirectory = Environment.AppDataDirectory;
                    saveFileDialogParameters.InitialFileName  = Constants.DEFAULT_DATABASE_FILE_NAME;
                }
                SaveFileDialogResult saveFileDialogResult = WindowManager.ShowSaveFileDialog(saveFileDialogParameters);
                if (saveFileDialogResult.DialogResult)
                {
                    if (MainModel.CreateDatabase(saveFileDialogResult.SelectedFilePath))
                    {
                        MainModel.AppSettings.DatabaseFileName = MainModel.GetDatabaseNormalizedPath(saveFileDialogResult.SelectedFilePath);
                        MainModel.SaveSettings();
                        CurrentWindowContext.CloseDialog(true);
                    }
                    else
                    {
                        ShowMessage(Localization.Error, Localization.CannotCreateDatabase);
                    }
                }
            }
            else
            {
                OpenFileDialogParameters openFileDialogParameters = new OpenFileDialogParameters
                {
                    DialogTitle = Localization.BrowseExistingDatabaseDialogTitle,
                    Filter      = filterBuilder.ToString(),
                    Multiselect = false
                };
                OpenFileDialogResult openFileDialogResult = WindowManager.ShowOpenFileDialog(openFileDialogParameters);
                if (openFileDialogResult.DialogResult)
                {
                    string databaseFilePath = openFileDialogResult.SelectedFilePaths.First();
                    if (MainModel.OpenDatabase(databaseFilePath))
                    {
                        MainModel.AppSettings.DatabaseFileName = MainModel.GetDatabaseNormalizedPath(databaseFilePath);
                        MainModel.SaveSettings();
                        CurrentWindowContext.CloseDialog(true);
                    }
                    else
                    {
                        UpdateHeaderAndEventType(Path.GetFileName(databaseFilePath));
                        NotifyPropertyChanged(nameof(Header));
                    }
                }
            }
        }