Exemple #1
0
    /// <summary>
    /// Returns the offset of the control's upper left corner with respect to
    /// the GameObject's Transform.localposition value
    /// </summary>
    /// <param name="pivot"></param>
    /// <returns></returns>
    public static Vector3 TransformToUpperLeft(this dfPivotPoint pivot, Vector2 size)
    {
        switch (pivot)
        {
        case dfPivotPoint.TopLeft:
            return(new Vector2(0f, 0f));

        case dfPivotPoint.TopCenter:
            return(new Vector2(0.5f * -size.x, 0f));

        case dfPivotPoint.TopRight:
            return(new Vector2(-size.x, 0f));

        case dfPivotPoint.MiddleLeft:
            return(new Vector2(0f, 0.5f * size.y));

        case dfPivotPoint.MiddleCenter:
            return(new Vector2(0.5f * -size.x, 0.5f * size.y));

        case dfPivotPoint.MiddleRight:
            return(new Vector2(-size.x, 0.5f * size.y));

        case dfPivotPoint.BottomLeft:
            return(new Vector2(0, size.y));

        case dfPivotPoint.BottomCenter:
            return(new Vector2(0.5f * -size.x, size.y));

        case dfPivotPoint.BottomRight:
            return(new Vector2(-size.x, size.y));
        }

        throw new Exception("Unhandled " + pivot.GetType().Name + " value: " + pivot);
    }
Exemple #2
0
    /// <summary>
    /// Returns the pivot as an offset where 0,0 corresponds to the top-left corner
    /// of the control and 1,1 corresponds to the bottom right
    /// </summary>
    /// <param name="?"></param>
    /// <returns></returns>
    public static Vector2 AsOffset(this dfPivotPoint pivot)
    {
        switch (pivot)
        {
        case dfPivotPoint.TopLeft:
            return(Vector2.zero);

        case dfPivotPoint.TopCenter:
            return(new Vector2(0.5f, 0));

        case dfPivotPoint.TopRight:
            return(new Vector2(1f, 0));

        case dfPivotPoint.MiddleLeft:
            return(new Vector2(0, 0.5f));

        case dfPivotPoint.MiddleCenter:
            return(new Vector2(0.5f, 0.5f));

        case dfPivotPoint.MiddleRight:
            return(new Vector2(1f, 0.5f));

        case dfPivotPoint.BottomLeft:
            return(new Vector2(0, 1f));

        case dfPivotPoint.BottomCenter:
            return(new Vector2(0.5f, 1f));

        case dfPivotPoint.BottomRight:
            return(new Vector2(1f, 1f));

        default:
            return(Vector2.zero);
        }
    }
Exemple #3
0
    public static Vector3 TransformToCenter(this dfPivotPoint pivot, Vector2 size)
    {
        switch (pivot)
        {
        case dfPivotPoint.TopLeft:
            return((Vector3) new Vector2(0.5f * size.x, 0.5f * -size.y));

        case dfPivotPoint.TopCenter:
            return((Vector3) new Vector2(0f, 0.5f * -size.y));

        case dfPivotPoint.TopRight:
            return((Vector3) new Vector2(0.5f * -size.x, 0.5f * -size.y));

        case dfPivotPoint.MiddleLeft:
            return((Vector3) new Vector2(0.5f * size.x, 0f));

        case dfPivotPoint.MiddleCenter:
            return((Vector3) new Vector2(0f, 0f));

        case dfPivotPoint.MiddleRight:
            return((Vector3) new Vector2(0.5f * -size.x, 0f));

        case dfPivotPoint.BottomLeft:
            return((Vector3) new Vector2(0.5f * size.x, 0.5f * size.y));

        case dfPivotPoint.BottomCenter:
            return((Vector3) new Vector2(0f, 0.5f * size.y));

        case dfPivotPoint.BottomRight:
            return((Vector3) new Vector2(0.5f * -size.x, 0.5f * size.y));
        }
        object[] objArray1 = new object[] { "Unhandled ", pivot.GetType().Name, " value: ", pivot };
        throw new Exception(string.Concat(objArray1));
    }
Exemple #4
0
    public static Vector3 TransformToUpperLeft(this dfPivotPoint pivot, Vector2 size)
    {
        switch (pivot)
        {
        case dfPivotPoint.TopLeft:
        {
            return(new Vector2(0f, 0f));
        }

        case dfPivotPoint.TopCenter:
        {
            return(new Vector2(0.5f * -size.x, 0f));
        }

        case dfPivotPoint.TopRight:
        {
            return(new Vector2(-size.x, 0f));
        }

        case dfPivotPoint.MiddleLeft:
        {
            return(new Vector2(0f, 0.5f * size.y));
        }

        case dfPivotPoint.MiddleCenter:
        {
            return(new Vector2(0.5f * -size.x, 0.5f * size.y));
        }

        case dfPivotPoint.MiddleRight:
        {
            return(new Vector2(-size.x, 0.5f * size.y));
        }

        case dfPivotPoint.BottomLeft:
        {
            return(new Vector2(0f, size.y));
        }

        case dfPivotPoint.BottomCenter:
        {
            return(new Vector2(0.5f * -size.x, size.y));
        }

        case dfPivotPoint.BottomRight:
        {
            return(new Vector2(-size.x, size.y));
        }
        }
        throw new Exception(string.Concat(new object[] { "Unhandled ", pivot.GetType().Name, " value: ", pivot }));
    }
Exemple #5
0
 public void PropertyChangedProxy(dfControl control, dfPivotPoint value)
 {
     callProxyEventHandler(control, value);
 }
Exemple #6
0
 public static Vector3 UpperLeftToTransform(this dfPivotPoint pivot, Vector2 size)
 {
     return(TransformToUpperLeft(pivot, size).Scale(-1, -1, 1));
 }
 private void PropertyChangedProxy( dfControl control, dfPivotPoint value )
 {
     callProxyEventHandler();
 }
 public void PropertyChangedProxy( dfControl control, dfPivotPoint value )
 {
     callProxyEventHandler( control, value );
 }
Exemple #9
0
 private void PropertyChangedProxy(dfControl control, dfPivotPoint value)
 {
     this.callProxyEventHandler();
 }