private void Start(Lst <MeshSet> meshSets) { var tasks = meshSets.Bind(m => m.Tasks).Filter(t => t.State != TaskState.UpToDate).Freeze(); ProgressBar.Value = 0; ProgressBar.MaxValue = tasks.Count(); var process = tasks.ToObservable() .TakeUntil(Disposed.Where(identity)) .ObserveOn(Scheduler.Default) .Do(t => t.Run(this, LoggerFactory)) .Do(t => { var selected = Optional(SourceList.GetSelected()).Map(i => i.GetText(0)); if (selected.Contains(t.Parent.Key)) { MorphList.GetRoot() .Children() .Find(i => i.GetText(0) == t.Key && i.GetText(1) == t.Surface) .Iter(n => n.SetText(2, Translate($"ui.BlendMapGenerator.status.{t.State}"))); } }) .Publish(); process .SubscribeOn(Node.GetScheduler()) .Subscribe(_ => ProgressBar.Value += 1, this); var running = process.Select(_ => false).TakeLast(1).StartWith(tasks.Any()); running .SubscribeOn(Node.GetScheduler()) .Subscribe(v => { StartButton.Disabled = v; InputButton.Disabled = v; InputEdit.Editable = !v; OutputButton.Disabled = v; OutputEdit.Editable = !v; }, this); process.Connect(); }
public static Lst <PredList, C> SelectMany <PredList, A, B, C>(this Lst <PredList, A> self, Func <A, Lst <PredList, B> > bind, Func <A, B, C> project) where PredList : struct, Pred <ListInfo> => self.Bind(t => bind(t).Map(u => project(t, u)));
public static Lst <C> SelectMany <A, B, C>(this Lst <A> self, Func <A, Lst <B> > bind, Func <A, B, C> project) => self.Bind(t => bind(t).Map(u => project(t, u)));
public static Lst <A> Flatten <A>(this Lst <Lst <A> > ma) => ma.Bind(identity);