private void CreateNode(Task task) { var node = MorphList.CreateItem(MorphList.GetRoot()); node.SetCellMode(0, TreeItem.TreeCellMode.String); node.SetText(0, task.Key); node.SetCellMode(1, TreeItem.TreeCellMode.String); node.SetText(1, task.Surface); node.SetCellMode(2, TreeItem.TreeCellMode.String); node.SetText(2, Translate($"ui.BlendMapGenerator.status.{task.State}")); node.SetCellMode(3, TreeItem.TreeCellMode.String); node.SetText(3, task.File.Name); }
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(); }