Esempio n. 1
0
        public OpenFileDialogViewModel(
            IDialogView <OpenFileDialogResult> view,
            IClipboardService clipboard,
            IFileIconProvider fileIconProvider,
            IMessageDialogService messageDialogService,
            bool allowMultipleSelection,
            IEnumerable <FileDialogFilter> filters)
        {
            _view = view;

            Filters        = filters.Select(FileDialogFilterViewModel.New).ToImmutableArray();
            SelectedFilter = Filters.FirstOrDefault();

            _fileName = String.Empty;

            var filter = this.WhenAnyValue(vm => vm.SelectedFilter).Select(vm => vm?.Filter).Select(Filter.FileDialog.Matches);

            FileExplorer = new FileExplorerViewModel(clipboard, fileIconProvider, messageDialogService, allowMultipleSelection, filter);

            OpenCommand   = ReactiveCommand.Create(Open);
            CancelCommand = ReactiveCommand.Create(Cancel);

            FileExplorer.FileOpened.Subscribe(_ => Open());
            FileExplorer.FileExplorerFolder.WhenAnyValue(vm => vm.SelectedItem).Subscribe(SelectedItemChanged);
        }
Esempio n. 2
0
        public SaveFileDialogViewModel(
            IDialogView <SaveFileDialogResult> view,
            IClipboardService clipboard,
            IFileIconProvider fileIconProvider,
            IMessageDialogService messageDialogService)
        {
            _view = view;
            _messageDialogService = messageDialogService;

            FileExplorer = new FileExplorerViewModel(clipboard, fileIconProvider, messageDialogService, allowMultipleSelection: false);

            SaveCommand   = ReactiveCommand.Create(SaveAsync);
            CancelCommand = ReactiveCommand.Create(Cancel);

            FileExplorer.FileOpened.Subscribe(async file => await SaveAsync());

            FileExplorer.FileExplorerFolder.WhenAnyValue(vm => vm.SelectedItem).Subscribe(SelectedItemChanged);
        }