コード例 #1
0
        //public InteractionRequest<Notification> AddRequest { get; } = new InteractionRequest<Notification>();

        //public InteractionRequest<Notification> EditRequest { get; } = new InteractionRequest<Notification>();

        public MetadataImportSettingDialogViewModel(IDirectoryNameParserManager directoryNameParserManager)
        {
            DirectoryNameParserManager = directoryNameParserManager;
            DirectoryNameParsers       = DirectoryNameParserManager
                                         .Items
                                         .ToReadOnlyReactiveCollection(x => new DirectoryNameParserViewModel(DirectoryNameParserManager, x));
            UpCommand = SelectedParser
                        .Select(x => x != null &&
                                DirectoryNameParserManager.Items.Count >= 2 &&
                                GetIndex(x.Model) > 0)
                        .ToReactiveCommand();
            UpCommand
            .Subscribe(() => Up());
            DownCommand = SelectedParser
                          .Select(x => x != null &&
                                  DirectoryNameParserManager.Items.Count >= 2 &&
                                  GetIndex(x.Model) < DirectoryNameParserManager.Items.Count - 1)
                          .ToReactiveCommand();
            DownCommand
            .Subscribe(() => Down());
            AddCommand
            .Select(_ => new DirectoryNameParser())
            .Subscribe(x =>
                       throw new NotImplementedException()
                       //AddRequest.Raise(new Notification
                       //{
                       //    Title = Resources.EditMetadataImportSettingDialogTitle_Add,
                       //    Content = x
                       //})
                       );
            EditCommand = SelectedParser
                          .Select(x => x != null)
                          .ToReactiveCommand();
            EditCommand
            .Select(_ => SelectedParser.Value.Model)
            .Subscribe(x =>
                       throw new NotImplementedException()
                       //EditRequest.Raise(new Notification
                       //{
                       //    Title = Resources.EditMetadataImportSettingDialogTitle_Edit,
                       //    Content = x
                       //})
                       );
            RemoveCommand = SelectedParser
                            .Select(x => x != null)
                            .ToReactiveCommand();
            RemoveCommand
            .Subscribe(() => Remove());
            CloseCommand
            .Subscribe(dialog =>
            {
                DirectoryNameParserManager.Save();
                dialog.DialogResult = true;
            });
        }