Esempio n. 1
0
        private void UpdateHighlightElements()
        {
            SetLineRectangleAroundIpso(GetOrMakeRectangleAtIndex(0), mHighlightedIpso);

            if (mHighlightedIpso.Component is NineSlice)
            {
                NineSlice nineSlice = mHighlightedIpso.Component as NineSlice;

                float topHeight    = 0;
                float centerHeight = 0;
                float bottomHeight = 0;

                float leftWidth   = 0;
                float rightWidth  = 0;
                float centerWidth = 0;

                if (nineSlice.TopTexture != null && nineSlice.BottomTexture != null &&
                    nineSlice.LeftTexture != null && nineSlice.RightTexture != null)
                {
                    topHeight = nineSlice.OutsideSpriteHeight;

                    bottomHeight = nineSlice.OutsideSpriteHeight;

                    leftWidth = nineSlice.OutsideSpriteWidth;

                    rightWidth = nineSlice.OutsideSpriteWidth;

                    centerHeight = nineSlice.Height - (topHeight + bottomHeight);
                    centerWidth  = nineSlice.Width - (leftWidth + rightWidth);

                    LineRectangle tallRectangle = GetOrMakeRectangleAtIndex(1);
                    tallRectangle.Color  = Color.Red;
                    tallRectangle.X      = nineSlice.GetAbsoluteX() + leftWidth;
                    tallRectangle.Y      = nineSlice.GetAbsoluteY();
                    tallRectangle.Width  = centerWidth;
                    tallRectangle.Height = nineSlice.Height;

                    LineRectangle wideRectangle = GetOrMakeRectangleAtIndex(2);
                    wideRectangle.Color  = Color.Red;
                    wideRectangle.X      = nineSlice.GetAbsoluteX();
                    wideRectangle.Y      = nineSlice.GetAbsoluteY() + topHeight;
                    wideRectangle.Width  = nineSlice.Width;
                    wideRectangle.Height = centerHeight;
                }
            }
        }
Esempio n. 2
0
        private void CreateNineSliceSplitLines()
        {
            NineSlice nineSlice = mHighlightedIpso.Component as NineSlice;

            float topHeight    = 0;
            float centerHeight = 0;
            float bottomHeight = 0;

            float leftWidth   = 0;
            float rightWidth  = 0;
            float centerWidth = 0;

            if (nineSlice.TopTexture != null && nineSlice.BottomTexture != null &&
                nineSlice.LeftTexture != null && nineSlice.RightTexture != null)
            {
                topHeight = nineSlice.OutsideSpriteHeight;

                bottomHeight = nineSlice.OutsideSpriteHeight;

                leftWidth = nineSlice.OutsideSpriteWidth;

                rightWidth = nineSlice.OutsideSpriteWidth;

                centerHeight = nineSlice.Height - (topHeight + bottomHeight);
                centerWidth  = nineSlice.Width - (leftWidth + rightWidth);

                float offsetX = leftWidth;
                float offsetY = 0;

                //Vector3 right;
                //Vector3 up;

                //if (nineSlice.Rotation == 0)
                //{
                //    right = Vector3.Right;
                //    up = Vector3.Up;
                //}
                //else
                //{
                //    var matrix = Matrix.CreateRotationZ(-MathHelper.ToRadians(nineSlice.Rotation));

                //    right = matrix.Right;
                //    up = matrix.Up;
                //}

                LineRectangle tallRectangle = GetOrMakeRectangleAtIndex(1);
                tallRectangle.Color    = Color.Red;
                tallRectangle.X        = nineSlice.GetAbsoluteX() + offsetX;
                tallRectangle.Y        = nineSlice.GetAbsoluteY();
                tallRectangle.Width    = centerWidth;
                tallRectangle.Height   = nineSlice.Height;
                tallRectangle.Rotation = nineSlice.GetAbsoluteRotation();


                offsetX = 0;
                offsetY = topHeight;

                LineRectangle wideRectangle = GetOrMakeRectangleAtIndex(2);
                wideRectangle.Color    = Color.Red;
                wideRectangle.X        = nineSlice.GetAbsoluteX();
                wideRectangle.Y        = nineSlice.GetAbsoluteY() + offsetY;
                wideRectangle.Width    = nineSlice.Width;
                wideRectangle.Height   = centerHeight;
                wideRectangle.Rotation = nineSlice.GetAbsoluteRotation();
            }
        }