示例#1
0
文件: Label.cs 项目: KtBkkr/Asteria
        protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
        {
            //base.DrawControl(renderer, rect, gameTime);

            SkinLayer s = new SkinLayer(Skin.Layers[0]);
            s.Text.Alignment = alignment;
            renderer.DrawString(this, s, Text, rect, true, 0, 0, ellipsis);
        }
示例#2
0
        protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
        {
            SkinLayer layer = Skin.Layers["Control"];
            SpriteFont font = (layer.Text != null && layer.Text.Font != null) ? layer.Text.Font.Resource : null;
            Color col = (layer.Text != null) ? layer.Text.Colors.Enabled : Color.White;
            Point offset = new Point(layer.Text.OffsetX, layer.Text.OffsetY);

            renderer.DrawLayer(this, layer, rect);

            if (font != null && Text != null && Text != "")
                renderer.DrawString(this, layer, Text, new Rectangle(rect.Left, rect.Top + layer.ContentMargins.Top, rect.Width, Skin.ClientMargins.Top - layer.ContentMargins.Horizontal), false, offset.X, offset.Y, false);
        }
示例#3
0
        protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
        {
            SkinLayer l1 = Skin.Layers["Control"];
            SkinLayer l2 = Skin.Layers["Selection"];
            rs = new Rectangle[Items.Count];

            renderer.DrawLayer(this, l1, rect, ControlState.Enabled);

            int prev = l1.ContentMargins.Left;
            for (int i = 0; i < Items.Count; i++)
            {
                MenuItem mi = Items[i];

                int tw = (int)l1.Text.Font.Resource.MeasureString(mi.Text).X + l1.ContentMargins.Horizontal;
                rs[i] = new Rectangle(rect.Left + prev, rect.Top + l1.ContentMargins.Top, tw, Height - l1.ContentMargins.Vertical);
                prev += tw;

                if (ItemIndex != i)
                {
                    if (mi.Enabled && Enabled)
                        renderer.DrawString(this, l1, mi.Text, rs[i], ControlState.Enabled, false);
                    else
                        renderer.DrawString(this, l1, mi.Text, rs[i], ControlState.Disabled, false);
                }
                else
                {
                    if (Items[i].Enabled && Enabled)
                    {
                        renderer.DrawLayer(this, l2, rs[i], ControlState.Enabled);
                        renderer.DrawString(this, l2, mi.Text, rs[i], ControlState.Enabled, false);
                    }
                    else
                    {
                        renderer.DrawLayer(this, l2, rs[i], ControlState.Disabled);
                        renderer.DrawString(this, l2, mi.Text, rs[i], ControlState.Disabled, false);
                    }
                }
            }
        }
示例#4
0
        protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
        {
            SkinLayer layer = Skin.Layers[lrChecked];
            SkinText font = Skin.Layers[lrChecked].Text;

            if (!state)
            {
                layer = Skin.Layers[lrCheckBox];
                font = Skin.Layers[lrCheckBox].Text;
            }

            rect.Width = layer.Width;
            rect.Height = layer.Height;
            Rectangle rc = new Rectangle(rect.Left + rect.Width + 4, rect.Y, Width - (layer.Width + 4), rect.Height);

            renderer.DrawLayer(this, layer, rect);
            renderer.DrawString(this, layer, Text, rc, false, 0, 0);
        }
示例#5
0
        protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
        {
            SkinLayer l1 = Skin.Layers["Control"];
            SkinLayer l2 = Skin.Layers["Header"];
            Color col = this.Color != UndefinedColor ? this.Color : Color.White;

            Rectangle r1 = new Rectangle(rect.Left, rect.Top + l1.OffsetY, rect.Width, rect.Height - l1.OffsetY);
            if (tabPages.Count <= 0)
                r1 = rect;

            base.DrawControl(renderer, r1, gameTime);

            if (tabPages.Count > 0)
            {
                Rectangle prev = new Rectangle(rect.Left, rect.Top + l2.OffsetY, 0, l2.Height);
                for (int i = 0; i < tabPages.Count; i++)
                {
                    SpriteFont font = l2.Text.Font.Resource;
                    Margins margins = l2.ContentMargins;
                    Point offset = new Point(l2.OffsetX, l2.OffsetY);
                    if (i > 0) prev = tabPages[i - 1].HeaderRect;

                    tabPages[i].CalcRect(prev, font, margins, offset, i == 0);
                }

                for (int i = tabPages.Count - 1; i >= 0; i--)
                {
                    int li = tabPages[i].Enabled ? l2.States.Enabled.Index : l2.States.Disabled.Index;
                    Color lc = tabPages[i].Enabled ? l2.Text.Colors.Enabled : l2.Text.Colors.Disabled;
                    if (i == hoveredIndex)
                    {
                        li = l2.States.Hovered.Index;
                        lc = l2.Text.Colors.Hovered;
                    }

                    Margins m = l2.ContentMargins;
                    Rectangle rx = tabPages[i].HeaderRect;
                    Rectangle sx = new Rectangle(rx.Left + m.Left, rx.Top + m.Top, rx.Width - m.Horizontal, rx.Height - m.Vertical);
                    if (i != selectedIndex)
                    {
                        renderer.DrawLayer(l2, rx, col, li);
                        renderer.DrawString(l2.Text.Font.Resource, tabPages[i].Text, sx, lc, l2.Text.Alignment);
                    }
                }

                Margins mi = l2.ContentMargins;
                Rectangle ri = tabPages[selectedIndex].HeaderRect;
                Rectangle si = new Rectangle(ri.Left + mi.Left, ri.Top + mi.Top, ri.Width - mi.Horizontal, ri.Height - mi.Vertical);
                renderer.DrawLayer(l2, ri, col, l2.States.Focused.Index);
                renderer.DrawString(l2.Text.Font.Resource, tabPages[selectedIndex].Text, si, l2.Text.Colors.Focused, l2.Text.Alignment, l2.Text.OffsetX, l2.Text.OffsetY, false);
            }
        }
示例#6
0
文件: Button.cs 项目: KtBkkr/Asteria
        protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
        {
            if (mode == ButtonMode.PushButton && pushed)
            {
                SkinLayer l = Skin.Layers[lrButton];
                renderer.DrawLayer(l, rect, l.States.Pressed.Color, l.States.Pressed.Index);
                if (l.States.Pressed.Overlay)
                    renderer.DrawLayer(l, rect, l.Overlays.Pressed.Color, l.Overlays.Pressed.Index);
            }
            else
                base.DrawControl(renderer, rect, gameTime);

            SkinLayer layer = Skin.Layers[lrButton];
            SpriteFont font = (layer.Text != null && layer.Text.Font != null) ? layer.Text.Font.Resource : null;
            Color col = Color.White;
            int ox = 0; int oy = 0;

            if (ControlState == ControlState.Pressed)
            {
                if (layer.Text != null) col = layer.Text.Colors.Pressed;
                ox = 1; oy = 1;
            }

            if (glyph != null)
            {
                Margins cont = layer.ContentMargins;
                Rectangle r = new Rectangle(rect.Left + cont.Left, rect.Top + cont.Top, rect.Width - cont.Horizontal, rect.Height - cont.Vertical);
                renderer.DrawGlyph(glyph, r);
            }
            else
                renderer.DrawString(this, layer, Text, rect, true, ox, oy);
        }
示例#7
0
文件: Window.cs 项目: KtBkkr/Asteria
        protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
        {
            SkinLayer l1 = captionVisible ? Skin.Layers[lrCaption] : Skin.Layers[lrFrameTop];
            SkinLayer l2 = Skin.Layers[lrFrameLeft];
            SkinLayer l3 = Skin.Layers[lrFrameRight];
            SkinLayer l4 = Skin.Layers[lrFrameBottom];
            SkinLayer l5 = Skin.Layers[lrIcon];
            LayerStates s1, s2, s3, s4;
            SpriteFont f1 = l1.Text.Font.Resource;
            Color c1 = l1.Text.Colors.Enabled;

            if ((Focused || (Manager.FocusedControl != null && Manager.FocusedControl.Root == this.Root)) && ControlState != ControlState.Disabled)
            {
                s1 = l1.States.Focused;
                s2 = l2.States.Focused;
                s3 = l3.States.Focused;
                s4 = l4.States.Focused;
                c1 = l1.Text.Colors.Focused;
            }
            else if (ControlState == ControlState.Disabled)
            {
                s1 = l1.States.Disabled;
                s2 = l2.States.Disabled;
                s3 = l3.States.Disabled;
                s4 = l4.States.Disabled;
                c1 = l1.Text.Colors.Disabled;
            }
            else
            {
                s1 = l1.States.Enabled;
                s2 = l2.States.Enabled;
                s3 = l3.States.Enabled;
                s4 = l4.States.Enabled;
                c1 = l1.Text.Colors.Enabled;
            }

            renderer.DrawLayer(Skin.Layers[lrWindow], rect, Skin.Layers[lrWindow].States.Enabled.Color, Skin.Layers[lrWindow].States.Enabled.Index);

            if (borderVisible)
            {
                renderer.DrawLayer(l1, new Rectangle(rect.Left, rect.Top, rect.Width, l1.Height), s1.Color, s1.Index);
                renderer.DrawLayer(l2, new Rectangle(rect.Left, rect.Top + l1.Height, l2.Width, rect.Height - l1.Height - l4.Height), s2.Color, s2.Index);
                renderer.DrawLayer(l3, new Rectangle(rect.Right - l3.Width, rect.Top + l1.Height, l3.Width, rect.Height - l1.Height - l4.Height), s3.Color, s3.Index);
                renderer.DrawLayer(l4, new Rectangle(rect.Left, rect.Bottom - l4.Height, rect.Width, l4.Height), s4.Color, s4.Index);

                if (iconVisible && (icon != null || l5 != null) && captionVisible)
                {
                    Texture2D i = (icon != null) ? icon : l5.Image.Resource;
                    renderer.Draw(i, GetIconRect(), Color.White);
                }

                int icosize = 0;
                if (l5 != null && iconVisible && captionVisible)
                    icosize = l1.Height - l1.ContentMargins.Vertical + 4 + l5.OffsetX;

                int closesize = 0;
                if (btnClose.Visible)
                    closesize = btnClose.Width - (btnClose.Skin.Layers[lrButton].OffsetX);

                Rectangle r = new Rectangle(rect.Left + l1.ContentMargins.Left + icosize,
                                            rect.Top + l1.ContentMargins.Top,
                                            rect.Width - l1.ContentMargins.Horizontal - closesize - icosize,
                                            l1.Height - l1.ContentMargins.Top - l1.ContentMargins.Bottom);
                int ox = l1.Text.OffsetX;
                int oy = l1.Text.OffsetY;
                renderer.DrawString(f1, Text, r, c1, l1.Text.Alignment, ox, oy, true);
            }
        }