private void ModelItemChanged(Topic source, TopicChanged.ChangeArt art) { if(art==TopicChanged.ChangeArt.Add) { return; } try { DrawingVisual cur; if(art==TopicChanged.ChangeArt.Value) { if(source.name=="_width") { var w=model.Get<long>("_width"); if(w.value==0) { w.saved=true; w.value=24; } this.Width=w.value*LogramView.CellSize; } else if(source.name=="_height") { var h=model.Get<long>("_height"); if(h.value<=0) { h.saved=true; h.value=24; } this.Height=h.value*LogramView.CellSize; } else if(source.valueType==typeof(Topic)) { if(!_visuals.Where(z => z is uiAlias).Cast<uiAlias>().Any(z => z.model==source)) { cur=new uiAlias(source as DVar<Topic>, this); } } else if(source.valueType==typeof(PiStatement)) { if(!_visuals.Where(z => z is uiStatement).Cast<uiStatement>().Any(z => z.model==source)) { System.Threading.Thread.Sleep(180); // filling of the fields executed by the broker cur=new uiStatement(source as DVar<PiStatement>, this); } } else if(source.valueType==typeof(PiWire)) { if(!_visuals.Where(z => z is uiWire).Cast<uiWire>().Any(z => z.GetModel()==source)) { cur=new uiWire(source as DVar<PiWire>, this); } } else if(source.valueType==typeof(PiTracer)) { if(!_visuals.Where(z => z is uiTracer).Cast<uiTracer>().Any(z => z.GetModel()==source)) { cur=new uiTracer(source as DVar<PiTracer>, this); } } } } catch(Exception ex) { Log.Error("Schema.ModelItemChanged({0}, {1}) - {2}", art, source.path, ex.Message); } }
public void Attach(DVar<PiLogram> model) { if(this.model!=model) { this.model=model; var w=model.Get<long>("_width"); if(w.value==0) { w.saved=true; w.value=24; } this.Width=w.value*LogramView.CellSize; var h=model.Get<long>("_height"); if(h.value<=0) { h.saved=true; h.value=24; } this.Height=h.value*LogramView.CellSize; _map.Clear(); DrawingVisual cur; foreach(var p in model.children.Where(z => z.valueType==typeof(Topic)).Cast<DVar<Topic>>()) { try { cur=new uiAlias(p, this); } catch(Exception ex) { Log.Error("create uiAlias({0}) - {1}", p.path, ex.ToString()); } } foreach(var p in model.children.Where(z => z.valueType==typeof(PiStatement)).Cast<DVar<PiStatement>>()) { try { cur=new uiStatement(p, this); } catch(Exception ex) { Log.Error("create uiStatement({0}) - {1}", p.path, ex.ToString()); } } foreach(var p in model.children.Where(z => z.valueType==typeof(PiWire)).Cast<DVar<PiWire>>()) { try { cur=new uiWire(p, this); } catch(Exception ex) { Log.Error("create uiWire({0}) - {1}", p.path, ex.ToString()); } } foreach(var p in model.children.Where(z => z.valueType==typeof(PiTracer)).Cast<DVar<PiTracer>>()) { try { cur=new uiTracer(p, this); } catch(Exception ex) { Log.Error("create uiTracer({0}) - {1}", p.path, ex.ToString()); } } model.Subscribe("+", ModelChanged); } }