Exemple #1
0
        public MainWindowViewModel()
        {
            _manager = NamingServiceManager.Default;

            RecordersViewModel = new RecordersViewModel(_manager);
            PlayersViewModel   = new PlayersViewModel(_manager);
            SettingViewModel   = new SettingViewModel(_manager);
            AnalysisViewModel  = new AnalysisViewModel(_manager);
        }
        public SettingViewModel(NamingServiceManager manager)
        {
            _manager       = manager;
            NamingServices = ViewModelHelper.CreateReadOnlyDispatcherCollection <NamingServiceViewModel, NamingService>(
                _manager.NamingServices,
                ns => new NamingServiceViewModel(ns),
                DispatcherHelper.UIDispatcher);

            DataDirectory = Environment.ExpandEnvironmentVariables(Settings.Default.DataDirectory);
        }
        public AddNamingServiceWindowViewModel(NamingServiceManager manager)
        {
            _manager = manager;

            HostName = new ReactiveProperty <string>()
                       .SetValidateAttribute(() => HostName);

            PortNumber = new ReactiveProperty <string>()
                         .SetValidateAttribute(() => PortNumber);

            var errors = Observable.Merge(
                HostName.ObserveErrorChanged,
                PortNumber.ObserveErrorChanged);

            AddNamingServiceCommand = errors.Select(x => x == null).ToReactiveCommand(initialValue: false);

            AddNamingServiceCommand.Subscribe(_ => AddNamingService());
        }
        public RecordersViewModel(NamingServiceManager manager)
        {
            _manager   = manager;
            _recorders = new ObservableCollection <Recorder>();

            RecorderViewModels = ViewModelHelper.CreateReadOnlyDispatcherCollection <RecorderControlViewModel, Recorder>(
                _recorders,
                recorder => new RecorderControlViewModel(this, recorder),
                DispatcherHelper.UIDispatcher);

            NamingServiceTree = ViewModelHelper.CreateReadOnlyDispatcherCollection <TreeViewItemViewModel, TreeViewItemViewModel>(
                _manager.OutPortTree,
                item => item,
                DispatcherHelper.UIDispatcher);

            // NamingServiceManagerのIsUpdatingの状態が変わったら、UpdateTreeCommandの有効無効を切り替える
            Observable.FromEventPattern <PropertyChangedEventArgs>(_manager, "PropertyChanged")
            .Where(e => e.EventArgs.PropertyName == "IsUpdating")
            .Subscribe(_ => UpdateTreeCommand.RaiseCanExecuteChanged());
        }
        public AnalysisViewModel(NamingServiceManager maanger)
        {
            _manager = _manager;

            var isCreating = new SignalNotifier();

            // nullではないAnalyzerがセットされたら更新実行が可能
            UpdateCommand = Observable
                            .FromEventPattern <PropertyChangedEventArgs>(this, "PropertyChanged")
                            .Where(e => e.EventArgs.PropertyName == "Analyzer")
                            .Select(_ => _Analyzer != null)
                            .Merge(isCreating.Select(x => x == SignalChangedStatus.Empty))
                            .ToReactiveCommand(false);

            Items = UpdateCommand
                    .SelectMany(_ => AnalyzeAsync(isCreating))
                    .Do(_ => Items.ClearOnScheduler())
                    .SelectMany(_ => _)
                    .ToReactiveCollection();
        }