Example #1
0
 private void Simulator_MouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         if (CurrentMouseState == MouseState.Default)
         {
             WireHandle wh       = Scene.ClickedOutHandle(e.Location);
             Component  selected = Scene.ClickSelect(e.Location);
             if (wh != null)
             {
                 WireBuilder.Init(wh.Source, wh);
                 CurrentMouseState = MouseState.Wire;
             }
             else if (selected != null)
             {
                 SelectedElement   = selected;
                 CurrentMouseState = MouseState.Drag;
                 ClickedPosition   = e.Location;
                 SelectionOffset   = GeometryUtil.GetOffset(selected.TopLeft, e.Location);
             }
         }
         else if (CurrentMouseState == MouseState.Wire)
         {
             WireHandle wh = Scene.ClickedInHandle(e.Location);
             if (wh != null)
             {
                 Wire w = WireBuilder.Finalize(wh);
                 Scene.AddElement(w);
                 CurrentMouseState = MouseState.Default;
             }
             else
             {
                 WireBuilder.AddPoint(e.Location);
             }
         }
     }
     Invalidate(true);
 }
Example #2
0
 public void Move(Point delta)
 {
     Location = GeometryUtil.ApplyOffset(Location, delta);
 }
Example #3
0
 public bool Selected(Point p)
 {
     Debug.WriteLine(GeometryUtil.PointSquareDstance(Location, p));
     return((GeometryUtil.PointSquareDstance(Location, p)) <= Radius * Radius);
 }