Esempio n. 1
0
        public override bool SnapCheck(GripType gt, ref Point delta)
        {
            if (IsSnapToBeIgnored())
            {
                return(false);
            }

            return(canvas.Controller.Snap(GripType.None, ref delta));
        }
Esempio n. 2
0
        public bool SnapCheck(GripType gripType, Point delta, Action <Point> update, bool isByKeyPress = false)
        {
            SnapAction action = Snap(gripType, delta, isByKeyPress);

            if (action != null)
            {
                if (action.SnapType == SnapAction.Action.Attach)
                {
                    runningDelta = action.Delta;
                    update(action.Delta);
                    // Controller.DragSelectedElements(action.Delta);
                    // Don't attach at this point, as this will be handled by the mouse-up action.
                    SetCurrentAction(action);
                }
                else if (action.SnapType == SnapAction.Action.Detach)
                {
                    runningDelta = action.Delta;
                    update(action.Delta);
                    // Controller.DragSelectedElements(action.Delta);
                    // Don't detach at this point, as this will be handled by the mouse-up action.
                    SetCurrentAction(action);
                }
                else // Attached
                {
                    // The mouse move had no affect in detaching because it didn't have sufficient velocity.
                    // The problem here is that the mouse moves, affecting the total delta, but the shape doesn't move.
                    // This affects the computation in the MouseUp handler:
                    // Point delta = CurrentMousePosition.Delta(startedDraggingShapesAt);

                    // ===================
                    // We could set the mouse cursor position, which isn't a bad idea, as it keeps the mouse with the shape:

                    //Controller.Canvas.MouseMove -= HandleMouseMoveEvent;
                    //Cursor.Position = Controller.Canvas.PointToScreen(LastMousePosition);
                    //Application.DoEvents();         // sigh - we need the event to trigger, even though it's unwired.
                    //Controller.Canvas.MouseMove += HandleMouseMoveEvent;

                    // The above really doesn't work well because I think we can get multiple move events, and this only handles the first event.
                    // ===================

                    // ===================
                    // Or we could add a "compensation" accumulator for dealing with the deltas that don't move the shape.
                    // This works better, except the attached compensation has to be stored for each detach.
                    // attachedCompensation = attachedCompensation.Add(delta);

                    // That doesn't work either, as the attachedCompensation is treated as a move even though there is no actual movement of the connector!
                    // ===================

                    // Final implementation is to use the runningDelta instead of the CurrentMouseMosition - startDraggingShapesAt difference.

                    // startedDraggingShapesAt = CurrentMousePosition;
                }
            }

            return(action != null);
        }
Esempio n. 3
0
    void Start()
    {
        m_body = GetComponent <Rigidbody>();
        m_body.centerOfMass = Vector3.down;

        m_layerMask = 1 << LayerMask.NameToLayer("Characters");
        m_layerMask = ~m_layerMask;

        gripType = defaultGripType;
    }
Esempio n. 4
0
 public SnapAction(Action action, GraphicElement lineShape, GripType gripType, GraphicElement targetShape, ConnectionPoint lineConnectionPoint, ConnectionPoint shapeConnectionPoint, Point delta)
 {
     SnapType                  = action;
     this.connector            = lineShape;
     this.gripType             = gripType;
     this.targetShape          = targetShape;
     this.lineConnectionPoint  = lineConnectionPoint;
     this.shapeConnectionPoint = shapeConnectionPoint;
     Delta = delta;
 }
Esempio n. 5
0
 public void Apply(IToolstripControls Import)
 {
     this._sepDark      = Import._sepDark;
     this._sepLight     = Import._sepLight;
     this._sepHeight    = Import._sepHeight;
     this._gripTop      = Import._gripTop;
     this._gripBottom   = Import._gripBottom;
     this._gripDistance = Import._gripDistance;
     this._gripStyle    = Import._gripStyle;
     this._gripSize     = Import._gripSize;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="NodalLeaderGrip"/> class.
 /// </summary>
 /// <param name="nodalLeader">Экземпляр <see cref="mpNodalLeader.NodalLeader"/></param>
 /// <param name="gripType">Вид ручки</param>
 /// <param name="gripName">Имя ручки</param>
 /// <param name="gripPoint">Точка ручки</param>
 public NodalLeaderGrip(
     NodalLeader nodalLeader,
     GripType gripType,
     GripName gripName,
     Point3d gripPoint)
 {
     NodalLeader = nodalLeader;
     GripName    = gripName;
     GripType    = gripType;
     GripPoint   = gripPoint;
 }
Esempio n. 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SecantNodalLeaderGrip"/> class.
 /// </summary>
 /// <param name="secantNodalLeader">Экземпляр <see cref="mpSecantNodalLeader.SecantNodalLeader"/></param>
 /// <param name="gripType">Вид ручки</param>
 /// <param name="gripName">Имя ручки</param>
 /// <param name="gripPoint">Точка ручки</param>
 public SecantNodalLeaderGrip(
     SecantNodalLeader secantNodalLeader,
     GripType gripType,
     GripName gripName,
     Point3d gripPoint)
 {
     SecantNodalLeader = secantNodalLeader;
     GripName          = gripName;
     GripType          = gripType;
     GripPoint         = gripPoint;
 }
Esempio n. 8
0
 public Grip(string na, string desc, byte _gs = 0, short _str = 0, short _int = 0, short _agi = 0, short blunt = 0, short edged = 0, short piercing = 0, byte type = 0)
 {
     name                      = na;
     statistics                = new Statistics();
     gemSlots                  = _gs;
     statistics.STR.value      = _str;
     statistics.INT.value      = _int;
     statistics.AGI.value      = _agi;
     statistics.BLUNT.value    = blunt;
     statistics.EDGED.value    = edged;
     statistics.PIERCING.value = piercing;
     gripType                  = gripTypes[type];
 }
Esempio n. 9
0
        public override void MoveAnchor(GripType type, Point delta)
        {
            if (type == GripType.Start)
            {
                startPoint = startPoint.Move(delta);
            }
            else
            {
                endPoint = endPoint.Move(delta);
            }

            UpdatePath();
            DisplayRectangle = RecalcDisplayRectangle();
        }
Esempio n. 10
0
        protected GripType[] GetTrueConnections(IIfBox el)
        {
            GripType[] path;

            if (el.TruePath == TruePath.Down)
            {
                path = new GripType[] { GripType.BottomMiddle };
            }
            else
            {
                path = new GripType[] { GripType.LeftMiddle, GripType.RightMiddle };
            }

            return(path);
        }
Esempio n. 11
0
        public float GripToFallAngle(GripType type)
        {
            switch (type)
            {
            default:
                return(defaultSlopeAngle);

            case GripType.Slippery:
                return(slipperySlopeAngle);

            case GripType.Grippy:
                return(grippySlopeAngle);

            case GripType.InstantSlide:
                return(90f);
            }
        }
Esempio n. 12
0
        // Executes when shape connected to this connector moves.
        public override void MoveAnchor(GripType type, Point delta)
        {
            if (type == GripType.Start)
            {
                // X1
                //this.AnchorMoveUndoRedo(nameof(StartPoint), StartPoint.Move(delta), false);
                StartPoint = StartPoint.Move(delta);
            }
            else
            {
                // X1
                //this.AnchorMoveUndoRedo(nameof(EndPoint), EndPoint.Move(delta), false);
                EndPoint = EndPoint.Move(delta);
            }

            UpdatePath();
            DisplayRectangle = RecalcDisplayRectangle();
        }
Esempio n. 13
0
        public override void MouseDown(MouseEventArgs e)
        {
            FResizeGrip = GripType.gtNone;
            base.MouseDown(e);
            if (Active)
            {
                FResizeGrip = GetGripType(e.X, e.Y);
                FResizing   = FResizeGrip != GripType.gtNone;

                if (FResizing)
                {
                    FResizeX      = e.X;
                    FResizeY      = e.Y;
                    FResizeWidth  = Width;
                    FResizeHeight = Height;
                }
            }
        }
Esempio n. 14
0
        public override bool MouseDown(MouseEventArgs e)
        {
            FResizeGrip = GripType.gtNone;
            bool vResult = base.MouseDown(e);

            if (Active)
            {
                FResizeGrip = GetGripType(e.X, e.Y);
                FResizing   = FResizeGrip != GripType.gtNone;

                if (FResizing)
                {
                    FResizeX      = e.X;
                    FResizeY      = e.Y;
                    FResizeWidth  = Width;
                    FResizeHeight = Height;
                }
            }

            return(vResult);
        }
Esempio n. 15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LevelMarkGrip"/> class.
        /// </summary>
        /// <param name="levelMark">Экземпляр класса <see cref="mpLevelMark.LevelMark"/></param>
        /// <param name="gripType">Вид ручки</param>
        /// <param name="gripName">Имя ручки</param>
        /// <param name="gripPoint">Точка ручки</param>
        public LevelMarkGrip(
            LevelMark levelMark,
            GripType gripType,
            LevelMarkGripName gripName,
            Point3d gripPoint)
        {
            LevelMark = levelMark;
            GripName  = gripName;
            GripType  = gripType;
            GripPoint = gripPoint;

            /* При инициализации ручки нужно собрать все точки и поместить их в поле _points.
             * Это создаст кэш точек. Если в методе WorldDraw брать точки из самого объекта (LevelMark),
             * то вспомогательные линии будут меняться при зуммировании. Это связано с тем, что в методе
             * MoveGripPointsAt происходит вызов метода UpdateEntities */
            _points = new List <Point3d>
            {
                LevelMark.InsertionPoint,
                LevelMark.ObjectPoint,
                LevelMark.BottomShelfStartPoint
            };
        }
Esempio n. 16
0
 public virtual void DisconnectShapeFromConnector(GripType gt)
 {
 }
Esempio n. 17
0
 // Placeholders:
 public virtual void SetConnection(GripType gt, GraphicElement shape)
 {
 }
Esempio n. 18
0
 public virtual void MoveAnchor(GripType type, Point delta)
 {
 }
Esempio n. 19
0
 public ConnectionPoint(GripType pos, Point p)
 {
     Type  = pos;
     Point = p;
 }
Esempio n. 20
0
 public virtual bool Snap(GripType type, ref Point delta)
 {
     return(false);
 }
Esempio n. 21
0
 public override void RemoveConnection(GripType gt)
 {
     (gt.In(startGrips)).If(() => StartConnectedShape = null).Else(() => EndConnectedShape = null);
 }
Esempio n. 22
0
 public override bool SnapCheck(GripType gt, ref Point delta)
 {
     return(canvas.Controller.Snap(GripType.None, ref delta));
 }
Esempio n. 23
0
 public override void SetConnection(GripType gt, GraphicElement shape)
 {
     (gt == GripType.Start).If(() => StartConnectedShape = shape).Else(() => EndConnectedShape = shape);
 }
Esempio n. 24
0
        public override bool Snap(GripType type, ref Point delta)
        {
            // Snapping permitted only when one and only one element is selected.
            if (selectedElements.Count != 1)
            {
                return(false);
            }

            bool           snapped         = false;
            GraphicElement selectedElement = selectedElements[0];

            // Look for connection points on nearby elements.
            // If a connection point is nearby, and the delta is moving toward that connection point, then snap to that connection point.

            // So, it seems odd that we're using the connection points of the line, rather than the anchors.
            // However, this is actually simpler, and a line's connection points should at least include the endpoint anchors.
            IEnumerable <ConnectionPoint> connectionPoints = selectedElement.GetConnectionPoints().Where(p => type == GripType.None || p.Type == type);

            nearElements = GetNearbyElements(connectionPoints);
            ShowConnectionPoints(nearElements.Select(e => e.NearElement), true);
            ShowConnectionPoints(currentlyNear.Where(e => !nearElements.Any(e2 => e.NearElement == e2.NearElement)).Select(e => e.NearElement), false);
            currentlyNear = nearElements;

            // Issue #6
            // TODO: Again, sort of kludgy.
            UpdateWithNearElementConnectionPoints(nearElements);
            nearElements = nearElements.OrderBy(si => si.AbsDx + si.AbsDy).ToList();    // abs(dx) + abs(dy) as a fast "distance" sorter, no need for sqrt(dx^2 + dy^2)

            foreach (SnapInfo si in nearElements)
            {
                ConnectionPoint nearConnectionPoint = si.NearElement.GetConnectionPoints().FirstOrDefault(cp => cp.Point.IsNear(si.LineConnectionPoint.Point, SNAP_CONNECTION_POINT_RANGE));

                if (nearConnectionPoint != null)
                {
                    Point sourceConnectionPoint = si.LineConnectionPoint.Point;
                    int   neardx     = nearConnectionPoint.Point.X - sourceConnectionPoint.X; // calculate to match possible delta sign
                    int   neardy     = nearConnectionPoint.Point.Y - sourceConnectionPoint.Y;
                    int   neardxsign = neardx.Sign();
                    int   neardysign = neardy.Sign();
                    int   deltaxsign = delta.X.Sign();
                    int   deltaysign = delta.Y.Sign();

                    // Are we attached already or moving toward the shape's connection point?
                    if ((neardxsign == 0 || deltaxsign == 0 || neardxsign == deltaxsign) &&
                        (neardysign == 0 || deltaysign == 0 || neardysign == deltaysign))
                    {
                        // If attached, are we moving away from the connection point to detach it?
                        if (neardxsign == 0 && neardxsign == 0 && (delta.X.Abs() >= SNAP_DETACH_VELOCITY || delta.Y.Abs() >= SNAP_DETACH_VELOCITY))
                        {
                            Disconnect(selectedElement, type);
                        }
                        else
                        {
                            // Not already connected?
                            if (neardxsign != 0 || neardysign != 0)
                            {
                                // Remove any current connections.  See issue #41
                                Disconnect(selectedElement, type);
                                si.NearElement.Connections.Add(new Connection()
                                {
                                    ToElement = selectedElement, ToConnectionPoint = si.LineConnectionPoint, ElementConnectionPoint = nearConnectionPoint
                                });
                                selectedElement.SetConnection(si.LineConnectionPoint.Type, si.NearElement);
                            }

                            delta   = new Point(neardx, neardy);
                            snapped = true;
                            break;
                        }
                    }
                }
            }

            return(snapped);
        }
Esempio n. 25
0
 public virtual void RemoveConnection(GripType gt)
 {
     // Connections.SingleOrDefault(c=>c.ElementConnectionPoint.Type == gr)
 }
Esempio n. 26
0
 public override void MoveElementOrAnchor(GripType gt, Point delta)
 {
     canvas.Controller.MoveElement(this, delta);
 }
Esempio n. 27
0
 public override void MoveElementOrAnchor(GripType gt, Point delta)
 {
     MoveAnchor(gt, delta);
 }
Esempio n. 28
0
 protected void Disconnect(GraphicElement el, GripType gripType)
 {
     el.DisconnectShapeFromConnector(gripType);
     el.RemoveConnection(gripType);
 }
Esempio n. 29
0
 // Default returns true so we don't detach a shape's connectors when moving a shape.
 public virtual bool SnapCheck(GripType gt, ref Point delta)
 {
     return(false);
 }
Esempio n. 30
0
        /// <summary>
        /// Imports the settings from a previous or pre-defined IToolstripControls and applies it to the current
        /// </summary>
        /// <param name="Import">The IToolstripControls to import the settings from</param>
        public void Apply(IToolstripControls Import)
        {
            _sepDark = Import._sepDark;
            _sepLight = Import._sepLight;
            _sepHeight = Import._sepHeight;

            _gripTop = Import._gripTop;
            _gripBottom = Import._gripBottom;
            _gripDistance = Import._gripDistance;
            _gripStyle = Import._gripStyle;
            _gripSize = Import._gripSize;
        }
Esempio n. 31
0
 // Placeholders:
 public virtual void MoveElementOrAnchor(GripType gt, Point delta)
 {
 }