public static InstantActionSaveModel CreateFromInstantActionModel(InstantActionModel instantAction) { return new InstantActionSaveModel() { TargetFiles = instantAction.TargetFiles.Select(x => x.FilePath).ToArray(), Actions = instantAction.Actions.ToArray(), OutputFolderPath = instantAction.OutputFolderPath }; }
public override void OnNavigatedTo(NavigationContext navigationContext) { if (Model == null) { Model = new InstantActionModel(AppPolicyManger); Model.OutputFolderPath = InstantActionManager.TempSaveFolder; } if (navigationContext.Parameters.Any(x => x.Key == "targetfiles")) { try { var paths = (string[])navigationContext.Parameters["targetfiles"]; foreach (var path in paths) { Model.AddTargetFile(path); } } catch { } } else if (navigationContext.Parameters.Any(x => x.Key == "filepath")) { try { var filepath = (string)navigationContext.Parameters["filepath"]; Model = InstantActionManager.Load(filepath); } catch { } } // ファイル選択画面からスタート ShowFileSelectStep(); }
public ProcessingFileViewModel(InstantActionModel instantAction, InstantActionTargetFile targetFile) { InstantAction = instantAction; TargetFile = targetFile; FilePath = targetFile.FilePath; ProcessState = targetFile.ObserveProperty(x => x.ProcessState) .ToReactiveProperty(); Message = TargetFile.ObserveProperty(x => x.ProcessMessage) .ToReactiveProperty(); }
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(); }
public ActionsSelectInstantActionStepViewModel(InstantActionPageViewModel pageVM, InstantActionModel instantAction) : base(pageVM, instantAction) { ActionVMs = new ObservableCollection<AppLaunchActionInstanceViewModel>( instantAction.Actions.Select(x => new AppLaunchActionInstanceViewModel(this, x)) ); }
public FileSelectInstantActionStepViewModel(InstantActionPageViewModel pageVM, InstantActionModel instantAction) : base(pageVM, instantAction) { Files = instantAction.TargetFiles.ToReadOnlyReactiveCollection(x => x.FilePath) .AddTo(_CompositeDisposable); }
public InstantActionStepViewModel(InstantActionPageViewModel pageVM, InstantActionModel instantAction) { PageVM = pageVM; InstantAction = instantAction; _CompositeDisposable = new CompositeDisposable(); }
public static InstantActionModel FromSerializedData(InstantActionSaveModel saveModel, IAppPolicyManager appPolicyManager) { var instantAction = new InstantActionModel(appPolicyManager); instantAction.Guid = saveModel.Guid; foreach (var targetFile in saveModel.TargetFiles.Select(x => new InstantActionTargetFile(x))) { instantAction._TargetFiles.Add(targetFile); } foreach (var action in saveModel.Actions) { instantAction._Actions.Add(action); } instantAction.OutputFolderPath = saveModel.OutputFolderPath; return instantAction; }
public string GetSavePath(InstantActionModel instantAction) { var fileName = instantAction.Guid.ToString() + INSTANT_ACTION_FILE_EXTENTION; return Path.Combine(SaveFolder, fileName); }
public void Save(InstantActionModel instantAction) { var serializeData = InstantActionSaveModel.CreateFromInstantActionModel(instantAction); var savePath = GetSavePath(instantAction); FileSerializeHelper.Save(savePath, serializeData); }