Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EnterCsvFileNameViewModel"/> class.
        /// </summary>
        /// <param name="validSaveFilePathChecker">The valid save file path checker</param>
        public EnterCsvFileNameViewModel([NotNull] IValidSaveFilePathChecker validSaveFilePathChecker)
        {
            if (validSaveFilePathChecker == null)
            {
                throw new ArgumentNullException(nameof(validSaveFilePathChecker));
            }

            var canOkExecute = this.WhenAnyValue(
                x => x.CsvFilePath,
                p => validSaveFilePathChecker.IsFilePathValid(p, p1 => p1.EndsWith(".csv", StringComparison.OrdinalIgnoreCase)))
                               .ObserveOn(RxApp.MainThreadScheduler);

            OkCommand = ReactiveCommand.Create(
                (Window window) =>
            {
                window.DialogResult = true;
                window.Close();
            },
                canOkExecute);

            CancelCommand = ReactiveCommand.Create(
                (Window window) =>
            {
                window.DialogResult = false;
                window.Close();
            });

            BrowseCommand = ReactiveCommand.Create(
                (Window window) =>
            {
                var dialog = new VistaSaveFileDialog
                {
                    Filter       = "CSV Files (*.csv)|*.csv",
                    AddExtension = true
                };

                var result = dialog.ShowDialog(window);

                if (result != true)
                {
                    return;
                }

                CsvFilePath = dialog.FileName;
            });
        }
Ejemplo n.º 2
0
 public DataWriter([NotNull] IValidSaveFilePathChecker validSaveFilePathChecker) =>
Ejemplo n.º 3
0
 public FilePathSelector([NotNull] IValidSaveFilePathChecker validSaveFilePathChecker) =>