Ejemplo n.º 1
0
        private void tmrTyping_Tick(object sender, EventArgs e)
        {
            if (m_Filling)
            {
                return;
            }
            tmrTyping.Enabled = false;
            int index = m_IndexTyped;

            m_IndexTyped = -1;
            if (!m_X[index].IsValidAndNotEmpty || (!m_Y[index].IsValidAndNotEmpty && m_Y[index].Visible))
            {
                return;
            }

            Transaction transaction = new Transaction();

            Shape.GrabSpot grab  = m_GrabSpots[index];
            PointF         point = new PointF(m_X[index].Value, -m_Y[index].Value);

            if (grab.Focus.IsEmpty)
            {            // edge with no focus is actually X/Y coords - which is a move.  This needs to be changed to a move as the GrabMove will fail for these without a real focus
                switch (grab.GrabType)
                {
                case Shape.GrabTypes.EdgeMoveH:
                    grab    = new Shape.GrabSpot(grab.Shape, Shape.GrabTypes.Move, grab.Position);
                    point.Y = grab.Position.Y;                             // no vertical movement
                    break;

                case Shape.GrabTypes.EdgeMoveV:
                    grab  = new Shape.GrabSpot(grab.Shape, Shape.GrabTypes.Move, grab.Position);
                    point = new PointF(grab.Position.X, -m_X[index].Value);                             // only the normal X box was used even though it's a Y coord
                    break;
                }
            }
            Page page = grab.Shape.FindPage();

            Shape.GrabMovement move = new Shape.GrabMovement(grab, page, Shape.SnapModes.Off, transaction);
            move.SetGrabMoveTransform(page, grab);
            move.Shape.StartGrabMove(move);

            switch (grab.GrabType)
            {            // focus is set if these are width/height logic.  In fact same code can run either way - since if not set then Focus.X/Y = 0
            case Shape.GrabTypes.EdgeMoveH:
                point = new PointF(grab.Focus.X + m_X[index].Value * Math.Sign(grab.Position.X - grab.Focus.X), grab.Focus.Y);
                break;

            case Shape.GrabTypes.EdgeMoveV:
                point = new PointF(grab.Focus.X, grab.Focus.Y + m_X[index].Value * Math.Sign(grab.Position.Y - grab.Focus.Y));                         // correct that this still uses m_x - it's always m_X when just one box is used
                break;
            }
            move.Current = new EditableView.ClickPosition(point, null, 1, Shape.SnapModes.Off, Shape.SnapModes.Off, null, EditableView.ClickPosition.Sources.Irrelevant);
            move.Transform?.SetGrabTransform(grab.Position, move.Current.Exact);

            move.Shape.GrabMove(move);
            Globals.Root.StoreNewTransaction(transaction, true);
            move.Shape.Parent.NotifyIndirectChange(move.Shape, ChangeAffects.GrabSpots | ChangeAffects.Bounds | ChangeAffects.Diagnostic);
            grab.Position = point;
        }
Ejemplo n.º 2
0
        public static Target FromGrabSpot(Shape.GrabSpot grab)
        {
            switch (grab.GrabType)
            {
            case Shape.GrabTypes.SingleVertex:
                return(new Target(grab.Shape, grab.Position, Types.Vertex, null, Priorities.Standard, Geometry.PI / 2, grab.ShapeIndex));

            case Shape.GrabTypes.Bezier:
                return(new Target(grab.Shape, grab.Position, Types.Line, null, Priorities.Standard, Geometry.PI / 2,
                                  grab.ShapeIndex - (grab.ShapeParameter == -1 ? 2 : 1)));              // shapeParameter indicates whether bezier is first (+1) or second (-1) in segment

            default:
                return(new ForGrabSpot(grab));
            }
        }
Ejemplo n.º 3
0
 public ForGrabSpot(Shape.GrabSpot grab) : base(grab.Shape, grab.Position, Types.GrabSpot, null)
 {
     Grab = grab;
 }