private void SetSavePathExecute()
        {
            FileSelectorView fileSelectorView = new FileSelectorView();
            Window           popup            = new DialogWindow(fileSelectorView, ResApplication.Explorer);

            popup.ShowDialog();

            if (popup.DialogResult.Value == true)
            {
                var dialogWindowViewModel = popup.DataContext as DialogWindowViewModel;
                var currentPage           = dialogWindowViewModel.CurrentPage as FileSelectorView;
                var vm = currentPage.DataContext as FileSelectorViewModel;

                var path = vm.SelectedDirectory.FullPath + "\\";

                SaveFilePath = path;
            }
        }
Beispiel #2
0
        public MainViewModel()
        {
            this.State     = State.Idle;
            this.IsUnsaved = false;

            this.CommandOpenRecent = new CommandWithDelegates((n) =>
            {
                var recentfiles = Settings.Default.GetRecentFiles();
                var file        = recentfiles[Convert.ToInt32(n) - 1];
                this.OpenImage(file);
            }, () => true);

            this.InitializeRecentFiles();
            this.CommandOpen = new CommandWithDelegates(() =>
            {
                RecentFile file       = new RecentFile();
                FileSelectorView view = new FileSelectorView();
                view.DataContext      = file;
                var result            = view.ShowDialog();

                if (result.HasValue && result.Value)
                {
                    var recentfiles = Settings.Default.GetRecentFiles();
                    recentfiles.Insert(0, file);
                    Settings.Default.SetRecentFiles(recentfiles);
                    Settings.Default.Save();
                    this.InitializeRecentFiles();

                    this.OpenImage(file);
                }
            }, () => true);

            this.CommandSave = new CommandWithDelegates(() => this.SaveImage(this.CurrentFile), () => this.State == State.Encrypted && this.IsUnsaved);

            this.CommandDecrypt = new CommandWithDelegates(this.Decrypt, () => this.State == State.Encrypted);
            this.CommandEncrypt = new CommandWithDelegates(this.Encrypt, () => this.State == State.Decrypted);
            this.CommandExit    = new CommandWithDelegates(this.Exit, () => true);
        }