示例#1
0
        /// <summary>
        /// Draws the Toggle
        /// </summary>
        /// <param name="graphics"></param>
        public override void Draw(Otter.Interface.Graphics graphics)
        {
            TextureInfo info  = Scene.GetTextureInfo(DefaultState == ToggleState.On ? OnTexture : OffTexture);
            int         texID = (info != null) ? info.TextureID : -1;

            graphics.DrawRectangle(texID, 0.0f, 0.0f, Layout.Size.Width, Layout.Size.Height, ((ToggleLayout)Layout).Color.ToArgb());
        }
示例#2
0
        /// <summary>
        /// Draws the sprite
        /// </summary>
        public override void Draw(Otter.Interface.Graphics graphics)
        {
            TextureInfo info  = Scene.GetTextureInfo(mTextureID);
            int         texID = (info != null) ? info.TextureID : -1;

            switch (Flip)
            {
            case FlipType.None:
            {
                graphics.DrawRectangle(texID, 0.0f, 0.0f, Layout.Size.Width, Layout.Size.Height, 0.0f, 0.0f, 1.0f, 1.0f, ((SpriteLayout)Layout).Color.ToArgb(), Skew, InheritedMask);
                break;
            }

            case FlipType.Vertical:
            {
                graphics.DrawRectangle(texID, 0.0f, 0.0f, Layout.Size.Width, Layout.Size.Height, 0.0f, 1.0f, 1.0f, 0.0f, ((SpriteLayout)Layout).Color.ToArgb(), Skew, InheritedMask);
                break;
            }

            case FlipType.Horizontal:
            {
                graphics.DrawRectangle(texID, 0.0f, 0.0f, Layout.Size.Width, Layout.Size.Height, 1.0f, 0.0f, 0.0f, 1.0f, ((SpriteLayout)Layout).Color.ToArgb(), -Skew, InheritedMask);
                break;
            }
            }

            base.Draw(graphics);
        }
示例#3
0
        /// <summary>
        /// Draws the mask
        /// </summary>
        public override void Draw(Otter.Interface.Graphics graphics)
        {
            if (Hidden)
            {
                return;
            }

            //draw a placeholder sprite to show the mask's position
            TextureInfo info  = Scene.GetTextureInfo(mTextureID);
            int         texID = (info != null) ? info.TextureID : -1;

            switch (Flip)
            {
            case GUISprite.FlipType.None:
            {
                graphics.DrawRectangle(texID, 0.0f, 0.0f, Layout.Size.Width, Layout.Size.Height, 0.0f, 0.0f, 1.0f, 1.0f, Color.ToArgb(), Skew, -1);
                break;
            }

            case GUISprite.FlipType.Vertical:
            {
                graphics.DrawRectangle(texID, 0.0f, 0.0f, Layout.Size.Width, Layout.Size.Height, 0.0f, 1.0f, 1.0f, 0.0f, Color.ToArgb(), Skew, -1);
                break;
            }

            case GUISprite.FlipType.Horizontal:
            {
                graphics.DrawRectangle(texID, 0.0f, 0.0f, Layout.Size.Width, Layout.Size.Height, 1.0f, 0.0f, 0.0f, 1.0f, Color.ToArgb(), -Skew, -1);
                break;
            }
            }
        }
示例#4
0
        public void DrawMask(Otter.Interface.Graphics graphics)
        {
            //set our stored matrix as the stencil matrix
            graphics.SetStencilMatrix(this.FullTransform.Entries);

            TextureInfo info  = Scene.GetTextureInfo(mTextureID);
            int         texID = (info != null) ? info.TextureID : -1;

            switch (Flip)
            {
            case GUISprite.FlipType.None:
            {
                graphics.DrawRectangleStencil(texID, 0.0f, 0.0f, Layout.Size.Width, Layout.Size.Height, 0.0f, 0.0f, 1.0f, 1.0f, Color.White.ToArgb(), Skew, ID);
                break;
            }

            case GUISprite.FlipType.Vertical:
            {
                graphics.DrawRectangleStencil(texID, 0.0f, 0.0f, Layout.Size.Width, Layout.Size.Height, 0.0f, 1.0f, 1.0f, 0.0f, Color.White.ToArgb(), Skew, ID);
                break;
            }

            case GUISprite.FlipType.Horizontal:
            {
                graphics.DrawRectangleStencil(texID, 0.0f, 0.0f, Layout.Size.Width, Layout.Size.Height, 1.0f, 0.0f, 0.0f, 1.0f, Color.White.ToArgb(), -Skew, ID);
                break;
            }
            }
        }
示例#5
0
        /// <summary>
        /// Draws the Slider
        /// </summary>
        public override void Draw(Otter.Interface.Graphics graphics)
        {
            TextureInfo info = null;

            info = Scene.GetTextureInfo(mStartTextureID);
            int startTexID = (info != null) ? info.TextureID : -1;

            info = Scene.GetTextureInfo(mMiddleTextureID);
            int middleTexID = (info != null) ? info.TextureID : -1;

            info = Scene.GetTextureInfo(mEndTextureID);
            int endTexID = (info != null) ? info.TextureID : -1;

            info = Scene.GetTextureInfo(mThumbTextureID);
            int thumbTexID = (info != null) ? info.TextureID : -1;

            float x        = 0.0f;
            float y        = Layout.Size.Height / 2.0f - ThumbHeight / 2.0f;
            float midWidth = Math.Max(0.0f, Layout.Size.Width - ThumbWidth * 2.0f);
            int   col      = ((SliderLayout)Layout).Color.ToArgb();

            graphics.DrawRectangle(startTexID, x, y, ThumbWidth, ThumbHeight, col);

            x += ThumbWidth;
            graphics.DrawRectangle(middleTexID, x, y, midWidth, ThumbHeight, col);

            x += midWidth;
            graphics.DrawRectangle(endTexID, x, y, ThumbWidth, ThumbHeight, col);

            x = ThumbWidth + midWidth / 2.0f - ThumbWidth / 2.0f;
            graphics.DrawRectangle(thumbTexID, x, y, ThumbWidth, ThumbHeight, col);
        }
示例#6
0
        /// <summary>
        /// Draws the label
        /// </summary>
        public override void Draw(Otter.Interface.Graphics graphics)
        {
            if (mText == "" || mText == null)
            {
                return;
            }

            if (mFont == null)
            {
                return;
            }

            LabelLayout layout = Layout as LabelLayout;

            mFont.Draw(mText, 0, 0, layout.Size.Width, layout.Size.Height, layout.Color, layout.Scale, HorizontalAlignment, VerticalAlignment, mLeading, mTracking, Skew, mTextFit, DropShadow, InheritedMask);
        }
示例#7
0
        /// <summary>
        /// Draws the table
        /// </summary>
        /// <param name="graphics"></param>
        public override void Draw(Otter.Interface.Graphics graphics)
        {
            int rowIndex = 0;
            int colEven  = Color.FromArgb(200, Color.Gainsboro).ToArgb();
            int colOdd   = Color.FromArgb(200, Color.WhiteSmoke).ToArgb();

            for (float y = 0; y < Layout.Size.Height; y += (float)(DefaultRowHeight + RowSpacing))
            {
                float height = (Layout.Size.Height - y) > DefaultRowHeight ? DefaultRowHeight : (Layout.Size.Height - y);
                int   col    = (rowIndex == 0) ? colEven : colOdd;

                graphics.DrawRectangle(-1, 0.0f, y, Layout.Size.Width, height, col);

                rowIndex = (++rowIndex) % 2;
            }
        }
示例#8
0
        /// <summary>
        /// Draws the button
        /// </summary>
        public override void Draw(Otter.Interface.Graphics graphics)
        {
            TextureInfo info  = Scene.GetTextureInfo(mCurrentState == ButtonState.Default ? mDefaultTextureID : mDownTextureID);
            Color       color = mCurrentState == ButtonState.Default ? mDefaultColor : mDownColor;
            int         texID = (info != null) ? info.TextureID : -1;

            graphics.DrawRectangle(texID, 0.0f, 0.0f, this.Size.Width, this.Size.Height, color.ToArgb());

            if (mLabel.Text != "")
            {
                GUIFont font = GUIProject.CurrentProject.GetFont(mLabel.FontID);
                if (font != null)
                {
                    ButtonLayout layout = Layout as ButtonLayout;
                    font.Draw(mLabel.Text, 0, 0, layout.Size.Width, layout.Size.Height, layout.TextColor, layout.TextScale, HorizontalAlignment, VerticalAlignment);
                }
            }
        }
示例#9
0
        /// <summary>
        /// Draws the Circle.
        /// </summary>
        /// <param name="graphics"></param>
        public override void Draw(Otter.Interface.Graphics graphics)
        {
            // Do not draw if there are less than 3 segments in the circle
            if (Segments <= 2)
            {
                return;
            }

            Triangle[] triangles = new Triangle[Segments * 2];

            double x = 1.0f;
            double y = 0.0f;

            float radius    = ((CircleLayout)Layout).Radius;
            uint  halfWidth = ((CircleLayout)Layout).Width / 2;
            Color color     = ((CircleLayout)Layout).Color;

            PointF center = new PointF(Layout.Size.Width / 2.0f, Layout.Size.Height / 2.0f);

            // For each segment create two triangles
            for (int i = 0; i < Segments; i++)
            {
                double angle1 = (i / (double)Segments) * Math.PI * 2;
                double angle2 = ((i + 1) / (double)Segments) * Math.PI * 2;

                float rx1 = (float)(x * Math.Cos(angle1) - y * Math.Sin(angle1));
                float ry1 = (float)(x * Math.Sin(angle1) + y * Math.Cos(angle1));

                float rx2 = (float)(x * Math.Cos(angle2) - y * Math.Sin(angle2));
                float ry2 = (float)(x * Math.Sin(angle2) + y * Math.Cos(angle2));

                triangles[i * 2 + 0] = new Triangle();
                triangles[i * 2 + 0].SetVertex(0, center.X + rx1 * (radius + halfWidth), center.Y + ry1 * (radius + halfWidth), 0.0f, 0.0f, 0.0f, color.ToArgb());
                triangles[i * 2 + 0].SetVertex(1, center.X + rx2 * (radius + halfWidth), center.Y + ry2 * (radius + halfWidth), 0.0f, 0.0f, 0.0f, color.ToArgb());
                triangles[i * 2 + 0].SetVertex(2, center.X + rx1 * (radius - halfWidth), center.Y + ry1 * (radius - halfWidth), 0.0f, 0.0f, 0.0f, color.ToArgb());

                triangles[i * 2 + 1] = new Triangle();
                triangles[i * 2 + 1].SetVertex(0, center.X + rx1 * (radius - halfWidth), center.Y + ry1 * (radius - halfWidth), 0.0f, 0.0f, 0.0f, color.ToArgb());
                triangles[i * 2 + 1].SetVertex(1, center.X + rx2 * (radius + halfWidth), center.Y + ry2 * (radius + halfWidth), 0.0f, 0.0f, 0.0f, color.ToArgb());
                triangles[i * 2 + 1].SetVertex(2, center.X + rx2 * (radius - halfWidth), center.Y + ry2 * (radius - halfWidth), 0.0f, 0.0f, 0.0f, color.ToArgb());
            }

            graphics.DrawTriangles(-1, triangles);
        }
示例#10
0
        /// <summary>
        /// Draws the control
        /// </summary>
        public virtual void Draw(Otter.Interface.Graphics graphics)
        {
            foreach (GUIControl control in Controls)
            {
                if (control.Hidden && control.GetType() != typeof(GUIMask))
                {
                    continue;
                }

                graphics.PushMatrix(control.Transform.Entries);

                //check whether we have a mask to render first
                int inheritedMaskID = control.InheritedMask;
                if (inheritedMaskID != -1)
                {
                    GUIMask maskControl = ParentView.Controls.GetControl(inheritedMaskID) as GUIMask;
                    maskControl.DrawMask(Otter.Interface.Graphics.Instance);
                }

                control.Draw(graphics);
                graphics.PopMatrix();
            }
        }
示例#11
0
 /// <summary>
 /// Draws the group
 /// </summary>
 public override void Draw(Otter.Interface.Graphics graphics)
 {
     graphics.DrawRectangle(-1, 0.0f, 0.0f, Layout.Size.Width, Layout.Size.Height, mColor.ToArgb());
     base.Draw(graphics);
 }