public override bool SnapCheck(GripType gt, ref Point delta) { if (IsSnapToBeIgnored()) { return(false); } return(canvas.Controller.Snap(GripType.None, ref delta)); }
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); }
void Start() { m_body = GetComponent <Rigidbody>(); m_body.centerOfMass = Vector3.down; m_layerMask = 1 << LayerMask.NameToLayer("Characters"); m_layerMask = ~m_layerMask; gripType = defaultGripType; }
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; }
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; }
/// <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; }
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]; }
public override void MoveAnchor(GripType type, Point delta) { if (type == GripType.Start) { startPoint = startPoint.Move(delta); } else { endPoint = endPoint.Move(delta); } UpdatePath(); DisplayRectangle = RecalcDisplayRectangle(); }
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); }
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); } }
// 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(); }
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; } } }
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); }
/// <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 }; }
public virtual void DisconnectShapeFromConnector(GripType gt) { }
// Placeholders: public virtual void SetConnection(GripType gt, GraphicElement shape) { }
public virtual void MoveAnchor(GripType type, Point delta) { }
public ConnectionPoint(GripType pos, Point p) { Type = pos; Point = p; }
public virtual bool Snap(GripType type, ref Point delta) { return(false); }
public override void RemoveConnection(GripType gt) { (gt.In(startGrips)).If(() => StartConnectedShape = null).Else(() => EndConnectedShape = null); }
public override bool SnapCheck(GripType gt, ref Point delta) { return(canvas.Controller.Snap(GripType.None, ref delta)); }
public override void SetConnection(GripType gt, GraphicElement shape) { (gt == GripType.Start).If(() => StartConnectedShape = shape).Else(() => EndConnectedShape = shape); }
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); }
public virtual void RemoveConnection(GripType gt) { // Connections.SingleOrDefault(c=>c.ElementConnectionPoint.Type == gr) }
public override void MoveElementOrAnchor(GripType gt, Point delta) { canvas.Controller.MoveElement(this, delta); }
public override void MoveElementOrAnchor(GripType gt, Point delta) { MoveAnchor(gt, delta); }
protected void Disconnect(GraphicElement el, GripType gripType) { el.DisconnectShapeFromConnector(gripType); el.RemoveConnection(gripType); }
// 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); }
/// <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; }
// Placeholders: public virtual void MoveElementOrAnchor(GripType gt, Point delta) { }