コード例 #1
0
		public FinishingInstantActionStepViewModel(InstantActionPageViewModel pageVM, InstantActionModel instantAction)
			: base(pageVM, instantAction)
		{
			Files = InstantAction.TargetFiles.ToReadOnlyReactiveCollection(x =>
				new ProcessingFileViewModel(InstantAction, x)
				)
				.AddTo(_CompositeDisposable);

			OutputFolderPath = InstantAction.ObserveProperty(x => x.OutputFolderPath)
				.ToReactiveProperty()
				.AddTo(_CompositeDisposable);

			FileCount = InstantAction.TargetFiles.CollectionChangedAsObservable().ToUnit()
				.Select(_ => InstantAction.TargetFiles.Count)
				.ToReactiveProperty(InstantAction.TargetFiles.Count)
				.AddTo(_CompositeDisposable);

			ProcessedCount = Observable.Merge(
				InstantAction.TargetFiles.CollectionChangedAsObservable().ToUnit(),
				InstantAction.TargetFiles.ObserveElementProperty(x => x.ProcessState).ToUnit()
				)
				.Select(_ =>
				{
					return InstantAction.TargetFiles.Where(x => x.IsComplete).Count();
				})
				.ToReactiveProperty()
				.AddTo(_CompositeDisposable);

			FailedCount = ProcessedCount.Select(x => FileCount.Value - x)
				.ToReactiveProperty()
				.AddTo(_CompositeDisposable);

			IsAllChecked = new ReactiveProperty<bool>(false)
				.AddTo(_CompositeDisposable);

			IsAllChecked.Subscribe(_ => 
			{
				if (NowWorkingFileSelection) { return; }

				var allCheck = ! Files.Any(x => x.IsSelected == true);

				foreach (var file in Files)
				{
					file.IsSelected = allCheck;
				}
			})
				.AddTo(_CompositeDisposable);

			Files.ObserveElementProperty(x => x.IsSelected)
				.Subscribe(_ => 
				{
					NowWorkingFileSelection = true;

					IsAllChecked.Value = Files.Any(x => x.IsSelected == true);

					NowWorkingFileSelection = false;
				})
				.AddTo(_CompositeDisposable);

			InstantAction.TargetFiles.ObserveAddChanged()
				.Subscribe(x => 
				{
					Task.Run(() =>
					{
						lock (_InstantActionProcessLock)
						{
							if (x.IsReady)
							{
								InstantAction.Execute(x);
							}
						}
					});
				})
				.AddTo(_CompositeDisposable);

			StartProcess();
		}
コード例 #2
0
		public FileSelectInstantActionStepViewModel(InstantActionPageViewModel pageVM, InstantActionModel instantAction)
			: base(pageVM, instantAction)
		{
			Files = instantAction.TargetFiles.ToReadOnlyReactiveCollection(x => x.FilePath)
				.AddTo(_CompositeDisposable);
		}
コード例 #3
0
		public ActionsSelectInstantActionStepViewModel(InstantActionPageViewModel pageVM, InstantActionModel instantAction)
			: base(pageVM, instantAction)
		{
			ActionVMs = new ObservableCollection<AppLaunchActionInstanceViewModel>(
				instantAction.Actions.Select(x => new AppLaunchActionInstanceViewModel(this, x))
				);
			

		}
コード例 #4
0
		public InstantActionStepViewModel(InstantActionPageViewModel pageVM, InstantActionModel instantAction)
		{
			PageVM = pageVM;
			InstantAction = instantAction;

			_CompositeDisposable = new CompositeDisposable();
		}