Beispiel #1
0
        public void Constructor_SetsProperties()
        {
            var snapPosition = new SnapPosition(SnapKind.Leading, 10);

            Assert.AreEqual(SnapKind.Leading, snapPosition.Kind);
            Assert.AreEqual(10, snapPosition.CharIndex);
        }
Beispiel #2
0
        private void splashView_MouseClick(object sender, MouseEventArgs e)
        {
            SnapPosition snapPosition = splashView.GetSnapPositionAtPoint(splashView.MousePositionToLayout(e.Location));

            if (snapPosition.Kind == SnapKind.Exact)
            {
                string href;
                if (splashView.Document.TryGetAnnotationAtIndex(HRefKey, snapPosition.CharIndex, out href))
                {
                    MessageBox.Show(string.Format("Clicked on link to '{0}'.", href), "Link");
                }
            }
        }
Beispiel #3
0
    private void AddControlPoint()
    {
        Vector3    myRelPos = target.InverseTransformPoint(transform.position);
        Quaternion myRelRot = Quaternion.Inverse(target.rotation) * transform.rotation;

        SnapPosition newSnapPosition = ScriptableObject.CreateInstance <SnapPosition>();

        newSnapPosition.LocalPosition = myRelPos;
        newSnapPosition.LocalRotation = myRelRot;

        AssetDatabase.CreateAsset(newSnapPosition, "Assets/Snapping/Snap Points/Standard/Standard " + Counter + ".asset");
        AssetDatabase.SaveAssets();

        SnapPositions.Positions.Add(newSnapPosition);
        Counter++;
    }
Beispiel #4
0
        private void splashView_MouseMove(object sender, MouseEventArgs e)
        {
            SnapPosition snapPosition = splashView.GetSnapPositionAtPoint(splashView.MousePositionToLayout(e.Location));

            snapPositionStatusLabel.Text = string.Format("Snap Position: {0} at {1}.", snapPosition.Kind, snapPosition.CharIndex);

            if (snapPosition.Kind == SnapKind.Exact)
            {
                string href;
                if (splashView.Document.TryGetAnnotationAtIndex(HRefKey, snapPosition.CharIndex, out href))
                {
                    splashView.Cursor = Cursors.Hand;
                    return;
                }
            }

            splashView.Cursor = Cursors.IBeam;
        }
Beispiel #5
0
    /// <summary>
    /// Snaps a collider to a specific side of the screen with relative offset
    /// </summary>
    /// <param name="toSnap">The collider to snap</param>
    /// <param name="positionToSnap">Which side of the screen to snap the collider to</param>
    /// <param name="relativeSnapOffset">The relative offset to snap the collider (Calculated by the collider's size)</param>
    public static void SnapCollider(Collider2D toSnap, SnapPosition positionToSnap, Vector2 relativeSnapOffset)
    {
        // Calculate actual offset
        var     actualOffset = new Vector3(toSnap.bounds.size.x * relativeSnapOffset.x, toSnap.bounds.size.y * relativeSnapOffset.y);
        Vector3 newPosition;

        // Calculate actual position
        switch (positionToSnap)
        {
        case SnapPosition.Top:
        {
            newPosition = new Vector3(0, ScreenPhysicalBounds.yMax + actualOffset.y);
            break;
        }

        case SnapPosition.Bottom:
        {
            newPosition = new Vector3(0, ScreenPhysicalBounds.yMin - actualOffset.y);
            break;
        }

        case SnapPosition.Left:
        {
            newPosition = new Vector3(ScreenPhysicalBounds.xMin + actualOffset.x, 0);
            break;
        }

        case SnapPosition.Right:
        {
            newPosition = new Vector3(ScreenPhysicalBounds.xMax - actualOffset.x, 0);
            break;
        }

        default:
        {
            throw new ArgumentOutOfRangeException("positionToSnap");
        }
        }

        // Snap
        toSnap.transform.position = newPosition;
    }
Beispiel #6
0
 public To(SnapPosition positionData)
 {
     this.positionData = positionData;
 }
 public void Constructor_SetsProperties()
 {
     var snapPosition = new SnapPosition(SnapKind.Leading, 10);
     Assert.AreEqual(SnapKind.Leading, snapPosition.Kind);
     Assert.AreEqual(10, snapPosition.CharIndex);
 }
Beispiel #8
0
 private bool OutsideSnapDistance(SnapPosition snapPoint)
 {
     return(Vector3.Distance(_myPosInTargetSpace, snapPoint.LocalPosition) > SnapDistance);
 }