예제 #1
0
 public void updateConnections()
 {
     for (int i = 0; i < connections.Count; i++)
     {
         Vector     p1 = Vector.V();
         Vector     p2 = Vector.V();
         Vector     dir1 = Vector.V();
         Vector     dir2 = Vector.V();
         VectorRect R1 = new VectorRect();
         VectorRect R2 = new VectorRect();
         int        rank1 = 0, rank2 = 0;
         connectedIOs[connections[i].i1].getPosAndDir(ref p1, ref dir1, ref R1, ref rank1);
         connectedIOs[connections[i].i2].getPosAndDir(ref p2, ref dir2, ref R2, ref rank2);
         if (connections[i].bc == null)
         {
             connections[i].bc = new GraphicsUtil.BlockConnection(
                 owner.toScreen(p1), dir1, owner.toScreen(R1), (10 + 5 * rank1) * owner.scale,
                 owner.toScreen(p2), dir2, owner.toScreen(R2), (10 + 5 * rank2) * owner.scale);
         }
         else
         {
             connections[i].bc.A  = owner.toScreen(p1);
             connections[i].bc.B  = owner.toScreen(p2);
             connections[i].bc.VA = owner.toScreen(R1);
             connections[i].bc.VB = owner.toScreen(R2);
         }
     }
 }
예제 #2
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);
            switch (dragMode)
            {
            case DragMode.Moving:
                Vector mpos  = Vector.V(Location.X + e.X, Location.Y + e.Y);
                Vector delta = dragPa.fromScreen(mpos) - dragStart;
                center = prevPos + delta;
                Vector loc = center - dim / 2;
                if (shrinked)
                {
                    loc = center - Vector.V(_shrinkSize) * scale / 2;
                }
                // loc.round(20);
                Location = dragPa.toScreen(loc).Point;
                dragPa.temporaryMove(this, delta);
                dragPa.Invalidate();
                break;

            case DragMode.DeleteBtn:
                Rectangle deleteButton = getDeleteButton();
                if (deleteButton.Contains(e.Location))
                {
                    if (!onDeleteButton)
                    {
                        onDeleteButton = true;
                        Invalidate();
                    }
                }
                else
                {
                    if (onDeleteButton)
                    {
                        onDeleteButton = false;
                        Invalidate();
                    }
                }
                break;

            case DragMode.ShrinkBtn:
                Rectangle shrinkButton = getShrinkButton();
                if (shrinkButton.Contains(e.Location))
                {
                    if (!onShrinkButton)
                    {
                        onShrinkButton = true;
                        Invalidate();
                    }
                }
                else
                {
                    if (onShrinkButton)
                    {
                        onShrinkButton = false;
                        Invalidate();
                    }
                }
                break;

            case DragMode.ActiveBtn:
                Rectangle activeButton = getActiveButton();
                if (activeButton.Contains(e.Location))
                {
                    if (!onActiveButton)
                    {
                        onActiveButton = true;
                        Invalidate();
                    }
                }
                else
                {
                    if (onActiveButton)
                    {
                        onActiveButton = false;
                        Invalidate();
                    }
                }
                break;
            }
        }