Exemple #1
0
    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);
      }
    }
Exemple #2
0
 protected override void OnMouseMove(MouseEventArgs e) {
   var cp=e.GetPosition(this);
   if(IsMouseCaptured && Keyboard.IsKeyDown(Key.LeftCtrl)) {
     var pnt=(IInputElement)this.Parent;
     Point p=e.GetPosition(pnt);
     double toX=startOffset.X+p.X-ScreenStartPoint.X;
     double toY=startOffset.Y+p.Y-ScreenStartPoint.Y;
     _translateTransform.X=toX;
     _translateTransform.Y=toY;
   } else if(e.LeftButton==MouseButtonState.Pressed && (move || (Math.Abs(cp.X-ScreenStartPoint.X)>SystemParameters.MinimumHorizontalDragDistance || Math.Abs(cp.Y-ScreenStartPoint.Y)>SystemParameters.MinimumVerticalDragDistance))) {
     move=true;
     if(selected!=null) {
       SchemaElement el;
       uiWire w;
       uiPin pin;
       if((el=selected as SchemaElement)!=null) {
         el.SetLocation(new Vector(el.OriginalLocation.X+(cp.X-ScreenStartPoint.X), el.OriginalLocation.Y+(cp.Y-ScreenStartPoint.Y)), false);
       } else if((pin=selected as uiPin)!=null) {
         w=new uiWire(selected as uiPin, this);
         w.Update(ScreenStartPoint);
         selected=w;
       } else if((w=selected as uiWire)!=null && w.B==null) {
         w.Update(cp);
       }
     } else if(_mSelected!=null) {
       foreach(var el in _mSelected.Where(z=>!(z is uiTracer))) {
         el.SetLocation(new Vector(el.OriginalLocation.X+(cp.X-ScreenStartPoint.X), el.OriginalLocation.Y+(cp.Y-ScreenStartPoint.Y)), false);
       }
     } else {
       if(!_multipleSelection) {
         _multipleSelection=true;
         base.AddVisualChild(_mSelectVisual);
       }
       using(DrawingContext dc=_mSelectVisual.RenderOpen()) {
         dc.DrawRectangle(null, Schema.SelectionPen, new Rect(ScreenStartPoint, cp));
       }
     }
   } else {
     base.OnMouseMove(e);
   }
 }
Exemple #3
0
 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);
   }
 }