コード例 #1
0
        public ExplorerAddressBarViewModel(IContainerExtension container, ImageViewParameter parameter)
        {
            var compositeDirectory = container.Resolve <ICompositeImageDirectory>();
            var imageDirectory     = compositeDirectory.ImageDirectries[parameter.ContentIndex];

            // ディレクトリPATHをModelに通知するAction(子View用)
            _sendSerectedDirectoryPathAction = path => TargetDirectory.Value = path;

            VisibleTextBoxCommand   = new DelegateCommand(() => IsVisibleDirectoryNode.TurnOff());
            CollapsedTextBoxCommand = new DelegateCommand(() => IsVisibleDirectoryNode.TurnOn());

            // directory from model
            imageDirectory
            .ObserveProperty(x => x.DirectoryPath)
            .Where(path => path != null)
            .Subscribe(path => UpdateViewsSource(path))
            .AddTo(CompositeDisposable);

            // directory to model
            TargetDirectory
            .Subscribe(path => imageDirectory.SetSelectedDictionaryPath(DirectoryNode.EmendFullPathFromViewModel(path)))
            .AddTo(CompositeDisposable);


            // TextBox入力確定時のディレクトリ通知
            TextEnterCommand = new DelegateCommand <string>(path =>
            {
                if (Directory.Exists(path))
                {
                    TargetDirectory.Value = path;
                }

                IsVisibleDirectoryNode.TurnOn();
            });

            // キャンセル時は表示切替のみ(テキストボックスに入力中の文字は残している)
            TextCancelCommand = new DelegateCommand(() => IsVisibleDirectoryNode.TurnOn());
        }