Esempio n. 1
0
        /// <summary>
        /// Gets the <see cref="Cursor"/> for a <see cref="ITransBox"/>.
        /// </summary>
        /// <param name="type">The <see cref="TransBoxType"/>.</param>
        /// <returns>The <see cref="Cursor"/> of a <see cref="ITransBox"/> for the given <paramref name="type"/>.</returns>
        static Cursor GetCursor(TransBoxType type)
        {
            switch (type)
            {
            case TransBoxType.Bottom:
            case TransBoxType.Top:
                return(Cursors.SizeNS);

            case TransBoxType.Left:
            case TransBoxType.Right:
                return(Cursors.SizeWE);

            case TransBoxType.TopLeft:
            case TransBoxType.BottomRight:
                return(Cursors.SizeNWSE);

            case TransBoxType.TopRight:
            case TransBoxType.BottomLeft:
                return(Cursors.SizeNESW);

            case TransBoxType.Move:
                return(Cursors.SizeAll);

            default:
                const string errmsg = "Unsupported TransBoxType `{0}`.";
                if (log.IsErrorEnabled)
                {
                    log.ErrorFormat(errmsg, type);
                }
                Debug.Fail(string.Format(errmsg, type));
                return(Cursors.Default);
            }
        }
            /// <summary>
            /// Initializes a new instance of the <see cref="TransBox"/> class.
            /// </summary>
            /// <param name="owner">The <see cref="TransBoxManager"/>.</param>
            /// <param name="type">The <see cref="TransBoxType"/>.</param>
            /// <param name="spatial">The <see cref="ISpatial"/>.</param>
            TransBox(TransBoxManager owner, TransBoxType type, ISpatial spatial)
            {
                _owner = owner;

                _type = type;
                _spatial = spatial;

                _size = GetTransBoxSize(type);
                _position = GetPosition();
            }
            /// <summary>
            /// Initializes a new instance of the <see cref="TransBox"/> class.
            /// </summary>
            /// <param name="owner">The <see cref="TransBoxManager"/>.</param>
            /// <param name="type">The <see cref="TransBoxType"/>.</param>
            /// <param name="spatial">The <see cref="ISpatial"/>.</param>
            TransBox(TransBoxManager owner, TransBoxType type, ISpatial spatial)
            {
                _owner = owner;

                _type    = type;
                _spatial = spatial;

                _size     = GetTransBoxSize(type);
                _position = GetPosition();
            }
Esempio n. 4
0
        /// <summary>
        /// Gets the <see cref="ISprite"/> for a <see cref="ITransBox"/>.
        /// </summary>
        /// <param name="type">The <see cref="TransBoxType"/>.</param>
        /// <returns>The <see cref="ISprite"/> of a <see cref="ITransBox"/> for the given <paramref name="type"/>.</returns>
        static ISprite GetSprite(TransBoxType type)
        {
            switch (type)
            {
            case TransBoxType.Move:
                return(SystemSprites.Move);

            default:
                return(SystemSprites.Resize);
            }
        }
            static Vector2 GetResizeVector(TransBoxType t)
            {
                switch (t)
                {
                case TransBoxType.Bottom:
                    return(new Vector2(0, 1));

                case TransBoxType.BottomLeft:
                    return(new Vector2(-1, 1));

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

                case TransBoxType.Left:
                    return(new Vector2(-1, 0));

                case TransBoxType.Right:
                    return(new Vector2(1, 0));

                case TransBoxType.Top:
                    return(new Vector2(0, -1));

                case TransBoxType.TopLeft:
                    return(new Vector2(-1, -1));

                case TransBoxType.TopRight:
                    return(new Vector2(1, -1));

                default:
                    const string errmsg = "Unsupported TransBoxType `{0}`.";
                    if (log.IsErrorEnabled)
                    {
                        log.ErrorFormat(errmsg, t);
                    }
                    Debug.Fail(string.Format(errmsg, t));
                    return(Vector2.Zero);
                }
            }
Esempio n. 6
0
 /// <summary>
 /// Gets the size for a <see cref="ITransBox"/>.
 /// </summary>
 /// <param name="type">The <see cref="TransBoxType"/>.</param>
 /// <returns>The size of a <see cref="ITransBox"/> for the given <paramref name="type"/>.</returns>
 static Vector2 GetTransBoxSize(TransBoxType type)
 {
     return GetSprite(type).Size;
 }
Esempio n. 7
0
        /// <summary>
        /// Gets the <see cref="ISprite"/> for a <see cref="ITransBox"/>.
        /// </summary>
        /// <param name="type">The <see cref="TransBoxType"/>.</param>
        /// <returns>The <see cref="ISprite"/> of a <see cref="ITransBox"/> for the given <paramref name="type"/>.</returns>
        static ISprite GetSprite(TransBoxType type)
        {
            switch (type)
            {
                case TransBoxType.Move:
                    return SystemSprites.Move;

                default:
                    return SystemSprites.Resize;
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Gets the <see cref="Cursor"/> for a <see cref="ITransBox"/>.
        /// </summary>
        /// <param name="type">The <see cref="TransBoxType"/>.</param>
        /// <returns>The <see cref="Cursor"/> of a <see cref="ITransBox"/> for the given <paramref name="type"/>.</returns>
        static Cursor GetCursor(TransBoxType type)
        {
            switch (type)
            {
                case TransBoxType.Bottom:
                case TransBoxType.Top:
                    return Cursors.SizeNS;

                case TransBoxType.Left:
                case TransBoxType.Right:
                    return Cursors.SizeWE;

                case TransBoxType.TopLeft:
                case TransBoxType.BottomRight:
                    return Cursors.SizeNWSE;

                case TransBoxType.TopRight:
                case TransBoxType.BottomLeft:
                    return Cursors.SizeNESW;

                case TransBoxType.Move:
                    return Cursors.SizeAll;

                default:
                    const string errmsg = "Unsupported TransBoxType `{0}`.";
                    if (log.IsErrorEnabled)
                        log.ErrorFormat(errmsg, type);
                    Debug.Fail(string.Format(errmsg, type));
                    return Cursors.Default;
            }
        }
            static Vector2 GetResizeVector(TransBoxType t)
            {
                switch (t)
                {
                    case TransBoxType.Bottom:
                        return new Vector2(0, 1);

                    case TransBoxType.BottomLeft:
                        return new Vector2(-1, 1);

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

                    case TransBoxType.Left:
                        return new Vector2(-1, 0);

                    case TransBoxType.Right:
                        return new Vector2(1, 0);

                    case TransBoxType.Top:
                        return new Vector2(0, -1);

                    case TransBoxType.TopLeft:
                        return new Vector2(-1, -1);

                    case TransBoxType.TopRight:
                        return new Vector2(1, -1);

                    default:
                        const string errmsg = "Unsupported TransBoxType `{0}`.";
                        if (log.IsErrorEnabled)
                            log.ErrorFormat(errmsg, t);
                        Debug.Fail(string.Format(errmsg, t));
                        return Vector2.Zero;
                }
            }
Esempio n. 10
0
 /// <summary>
 /// Gets the size for a <see cref="ITransBox"/>.
 /// </summary>
 /// <param name="type">The <see cref="TransBoxType"/>.</param>
 /// <returns>The size of a <see cref="ITransBox"/> for the given <paramref name="type"/>.</returns>
 static Vector2 GetTransBoxSize(TransBoxType type)
 {
     return(GetSprite(type).Size);
 }