public GeometryViewModel() { Geometries = AUTDSettings.Instance.GeometriesReactive; Current = new ReactivePropertySlim <GeometrySettingReactive?>(); AddItem = new ReactiveCommand(); RemoveItem = Current.Select(c => c != null).ToReactiveCommand(); UpItem = Current.Select(c => c != null && c.No.Value != 0).ToReactiveCommand(); DownItem = Current.Select(c => c != null && c.No.Value != Geometries.Count - 1).ToReactiveCommand(); AddItem.Subscribe(_ => { var item = new GeometrySettingReactive(Geometries.Count); Geometries.Add(item); Current.Value = item; }); RemoveItem.Subscribe(_ => { if (Current.Value == null) { return; } var delNo = Current.Value.No.Value; Geometries.RemoveAt(delNo); ResetNo(); Current.Value = Geometries.Count > delNo ? Geometries[delNo] : Geometries.Count > 0 ? Geometries[delNo - 1] : null; }); UpItem.Subscribe(_ => { if (Current.Value == null) { return; } var cNo = Current.Value.No.Value; var up = Geometries[cNo - 1]; Geometries.Insert(cNo - 1, Current.Value); Geometries.RemoveAt(cNo); Geometries[cNo] = up; ResetNo(); Current.Value = Geometries[cNo - 1]; }); DownItem.Subscribe(_ => { if (Current.Value == null) { return; } var cNo = Current.Value.No.Value; var down = Geometries[cNo + 1]; Geometries.RemoveAt(cNo + 1); Geometries.Insert(cNo + 1, Current.Value); Geometries[cNo] = down; ResetNo(); Current.Value = Geometries[cNo + 1]; }); }
public HoloViewModel() { Holo = AUTDSettings.Instance.ToReactivePropertySlimAsSynchronized(i => i.Holo); HoloSettings = AUTDSettings.Instance.Holo.HoloSettingsReactive; Current = new ReactivePropertySlim <HoloSettingReactive?>(); AddItem = new ReactiveCommand(); RemoveItem = Current.Select(c => c != null).ToReactiveCommand(); UpItem = Current.Select(c => c != null && c.No.Value != 0).ToReactiveCommand(); DownItem = Current.Select(c => c != null && c.No.Value != HoloSettings.Count - 1).ToReactiveCommand(); AddItem.Subscribe(_ => { var item = new HoloSettingReactive(HoloSettings.Count); HoloSettings.Add(item); Current.Value = item; }); RemoveItem.Subscribe(_ => { if (Current.Value == null) { return; } var delNo = Current.Value.No.Value; HoloSettings.RemoveAt(delNo); ResetNo(); Current.Value = HoloSettings.Count > delNo ? HoloSettings[delNo] : HoloSettings.Count > 0 ? HoloSettings[delNo - 1] : null; }); UpItem.Subscribe(_ => { if (Current.Value == null) { return; } var cNo = Current.Value.No.Value; var up = HoloSettings[cNo - 1]; HoloSettings.Insert(cNo - 1, Current.Value); HoloSettings.RemoveAt(cNo); HoloSettings[cNo] = up; ResetNo(); Current.Value = HoloSettings[cNo - 1]; }); DownItem.Subscribe(_ => { if (Current.Value == null) { return; } var cNo = Current.Value.No.Value; var down = HoloSettings[cNo + 1]; HoloSettings.RemoveAt(cNo + 1); HoloSettings.Insert(cNo + 1, Current.Value); HoloSettings[cNo] = down; ResetNo(); Current.Value = HoloSettings[cNo + 1]; }); }
public SeqViewModel() { Seq = AUTDSettings.Instance.ToReactivePropertySlimAsSynchronized(i => i.Seq); Points = AUTDSettings.Instance.Seq.PointsReactive; SendSeqCommand = AUTDHandler.Instance.IsOpen.Select(b => b).ToReactiveCommand(); SendSeqCommand.Subscribe(_ => { if (Points.Count == 0) { return; } AUTDHandler.Instance.SendSeq(); }); Current = new ReactivePropertySlim <Vector3Reactive?>(); AddItem = new ReactiveCommand(); RemoveItem = Current.Select(c => c != null).ToReactiveCommand(); UpItem = Current.Select(c => c != null && c.No.Value != 0).ToReactiveCommand(); DownItem = Current.Select(c => c != null && c.No.Value != Points.Count - 1).ToReactiveCommand(); AddItem.Subscribe(_ => { var item = new Vector3Reactive(Points.Count); Points.Add(item); Current.Value = item; }); RemoveItem.Subscribe(_ => { if (Current.Value == null) { return; } var delNo = Current.Value.No.Value; Points.RemoveAt(delNo); ResetNo(); Current.Value = Points.Count > delNo ? Points[delNo] : Points.Count > 0 ? Points[delNo - 1] : null; }); UpItem.Subscribe(_ => { if (Current.Value == null) { return; } var cNo = Current.Value.No.Value; var up = Points[cNo - 1]; Points.Insert(cNo - 1, Current.Value); Points.RemoveAt(cNo); Points[cNo] = up; ResetNo(); Current.Value = Points[cNo - 1]; }); DownItem.Subscribe(_ => { if (Current.Value == null) { return; } var cNo = Current.Value.No.Value; var down = Points[cNo + 1]; Points.RemoveAt(cNo + 1); Points.Insert(cNo + 1, Current.Value); Points[cNo] = down; ResetNo(); Current.Value = Points[cNo + 1]; }); }