Example #1
0
        private void DrawPane(object sender, DrawEventArgs e)
        {
            if (items != null && items.Count > 0)
            {
                SkinText  font = Skin.Layers["Control"].Text;
                SkinLayer sel  = Skin.Layers["ListBox.Selection"];
                int       h    = (int)font.Font.Resource.MeasureString(items[0].ToString()).Y;
                int       v    = (sbVert.Value / 10);
                int       p    = (sbVert.PageSize / 10);
                int       d    = (int)(((sbVert.Value % 10) / 10f) * h);
                int       c    = items.Count;
                int       s    = itemIndex;

                for (int i = v; i <= v + p + 1; i++)
                {
                    if (i < c)
                    {
                        e.Renderer.DrawString(this, Skin.Layers["Control"], items[i].ToString(), new Rectangle(e.Rectangle.Left, e.Rectangle.Top - d + ((i - v) * h), e.Rectangle.Width, h), false);
                    }
                }
                if (s >= 0 && s < c && (Focused || !hideSelection))
                {
                    int pos = -d + ((s - v) * h);
                    if (pos > -h && pos < (p + 1) * h)
                    {
                        e.Renderer.DrawLayer(this, sel, new Rectangle(e.Rectangle.Left, e.Rectangle.Top + pos, e.Rectangle.Width, h));
                        e.Renderer.DrawString(this, sel, items[s].ToString(), new Rectangle(e.Rectangle.Left, e.Rectangle.Top + pos, e.Rectangle.Width, h), false);
                    }
                }
            }
        }
Example #2
0
        protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
        {
            RecalcParams();

            SkinLayer p = Skin.Layers["Control"];
            SkinLayer l = Skin.Layers["Scale"];

            float ratio = 0.66f;
            int   h     = (int)(ratio * rect.Height);
            int   t     = rect.Top + (Height - h) / 2;

            float px = ((float)value / (float)range);
            int   w  = (int)Math.Ceiling(px * (rect.Width - p.ContentMargins.Horizontal - btnSlider.Width)) + 2;

            if (w < l.SizingMargins.Vertical)
            {
                w = l.SizingMargins.Vertical;
            }
            if (w > rect.Width - p.ContentMargins.Horizontal)
            {
                w = rect.Width - p.ContentMargins.Horizontal;
            }

            Rectangle r1 = new Rectangle(rect.Left + p.ContentMargins.Left, t + p.ContentMargins.Top, w, h - p.ContentMargins.Vertical);

            base.DrawControl(renderer, new Rectangle(rect.Left, t, rect.Width, h), gameTime);
            if (scale)
            {
                renderer.DrawLayer(this, l, r1);
            }
        }
Example #3
0
		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);
		}
Example #4
0
        private void RecalcParams()
        {
            if (btnSlider != null)
            {
                if (btnSlider.Width > 12)
                {
                    btnSlider.Glyph          = new Glyph(Manager.Skin.Images["Shared.Glyph"].Resource);
                    btnSlider.Glyph.SizeMode = ESizeMode.Centered;
                }
                else
                {
                    btnSlider.Glyph = null;
                }

                SkinLayer p = Skin.Layers["Control"];
                btnSlider.Width  = (int)(Height * 0.8);
                btnSlider.Height = Height;
                int size = btnSlider.Width;
                int w    = Width - p.ContentMargins.Horizontal - size;

                float px  = (float)range / (float)w;
                int   pos = p.ContentMargins.Left + (int)(Math.Ceiling(Value / (float)px));

                if (pos < p.ContentMargins.Left)
                {
                    pos = p.ContentMargins.Left;
                }
                if (pos > w + p.ContentMargins.Left)
                {
                    pos = w + p.ContentMargins.Left;
                }

                btnSlider.SetPosition(pos, 0);
            }
        }
Example #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);
            }
        }
Example #6
0
        protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
        {
            RecalcParams();

            SkinLayer bg = Skin.Layers[strRail];

            renderer.DrawLayer(bg, rect, Color.White, bg.States.Enabled.Index);
        }
Example #7
0
        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);
        }
Example #8
0
        private int LineHeight()
        {
            int h = 0;

            if (Items.Count > 0)
            {
                SkinLayer l = Skin.Layers["Control"];
                h = (int)l.Text.Font.Resource.LineSpacing + 9;
            }
            return(h);
        }
Example #9
0
        private Rectangle GetIconRect()
        {
            SkinLayer l1 = Skin.Layers[lrCaption];
            SkinLayer l5 = Skin.Layers[lrIcon];

            int s = l1.Height - l1.ContentMargins.Vertical;

            return(new Rectangle(DrawingRect.Left + l1.ContentMargins.Left + l5.OffsetX,
                                 DrawingRect.Top + l1.ContentMargins.Top + l5.OffsetY,
                                 s, s));
        }
Example #10
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);
            }
        }
Example #11
0
        protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
        {
            base.DrawControl(renderer, rect, gameTime);

            if (ReadOnly && Focused)
            {
                SkinLayer lr = Skin.Layers[0];
                Rectangle rc = new Rectangle(rect.Left + lr.ContentMargins.Left,
                                             rect.Top + lr.ContentMargins.Top,
                                             Width - lr.ContentMargins.Horizontal - btnDown.Width - btnUp.Width,
                                             Height - lr.ContentMargins.Vertical);
                renderer.Draw(Manager.Skin.Images["ListBox.Selection"].Resource, rc, Color.FromNonPremultiplied(255, 255, 255, 128));
            }
        }
Example #12
0
        internal override void Render(Renderer renderer, GameTime gameTime)
        {
            if (Visible && Shadow)
            {
                SkinControl c = Manager.Skin.Controls[skShadow];
                SkinLayer   l = c.Layers[lrShadow];

                Color cl = Color.FromNonPremultiplied(l.States.Enabled.Color.R, l.States.Enabled.Color.G, l.States.Enabled.Color.B, Alpha);

                renderer.Begin(EBlendingMode.Default);
                renderer.DrawLayer(l, new Rectangle(Left - c.OriginMargins.Left, Top - c.OriginMargins.Top, Width + c.OriginMargins.Horizontal, Height + c.OriginMargins.Vertical), cl, 0);
                renderer.End();
            }
            base.Render(renderer, gameTime);
        }
Example #13
0
        public virtual void DrawLayer(SkinLayer layer, Rectangle rect, Color color, int index)
        {
            Size imageSize = new Size(layer.Image.Resource.Width, layer.Image.Resource.Height);
            Size partSize  = new Size(layer.Width, layer.Height);

            Draw(layer.Image.Resource, GetDestinationArea(rect, layer.SizingMargins, EAlignment.TopLeft), GetSourceArea(imageSize, partSize, layer.SizingMargins, EAlignment.TopLeft, index), color);
            Draw(layer.Image.Resource, GetDestinationArea(rect, layer.SizingMargins, EAlignment.TopCenter), GetSourceArea(imageSize, partSize, layer.SizingMargins, EAlignment.TopCenter, index), color);
            Draw(layer.Image.Resource, GetDestinationArea(rect, layer.SizingMargins, EAlignment.TopRight), GetSourceArea(imageSize, partSize, layer.SizingMargins, EAlignment.TopRight, index), color);
            Draw(layer.Image.Resource, GetDestinationArea(rect, layer.SizingMargins, EAlignment.MiddleLeft), GetSourceArea(imageSize, partSize, layer.SizingMargins, EAlignment.MiddleLeft, index), color);
            Draw(layer.Image.Resource, GetDestinationArea(rect, layer.SizingMargins, EAlignment.MiddleCenter), GetSourceArea(imageSize, partSize, layer.SizingMargins, EAlignment.MiddleCenter, index), color);
            Draw(layer.Image.Resource, GetDestinationArea(rect, layer.SizingMargins, EAlignment.MiddleRight), GetSourceArea(imageSize, partSize, layer.SizingMargins, EAlignment.MiddleRight, index), color);
            Draw(layer.Image.Resource, GetDestinationArea(rect, layer.SizingMargins, EAlignment.BottomLeft), GetSourceArea(imageSize, partSize, layer.SizingMargins, EAlignment.BottomLeft, index), color);
            Draw(layer.Image.Resource, GetDestinationArea(rect, layer.SizingMargins, EAlignment.BottomCenter), GetSourceArea(imageSize, partSize, layer.SizingMargins, EAlignment.BottomCenter, index), color);
            Draw(layer.Image.Resource, GetDestinationArea(rect, layer.SizingMargins, EAlignment.BottomRight), GetSourceArea(imageSize, partSize, layer.SizingMargins, EAlignment.BottomRight, index), color);
        }
Example #14
0
        protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
        {
            if (mode == EButtonMode.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 == EControlState.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);
            }
        }
Example #15
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, EControlState.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], EControlState.Enabled, false);
                    }
                    else
                    {
                        renderer.DrawString(this, l1, mi.Text, rs[i], EControlState.Disabled, false);
                    }
                }
                else
                {
                    if (Items[i].Enabled && Enabled)
                    {
                        renderer.DrawLayer(this, l2, rs[i], EControlState.Enabled);
                        renderer.DrawString(this, l2, mi.Text, rs[i], EControlState.Enabled, false);
                    }
                    else
                    {
                        renderer.DrawLayer(this, l2, rs[i], EControlState.Disabled);
                        renderer.DrawString(this, l2, mi.Text, rs[i], EControlState.Disabled, false);
                    }
                }
            }
        }
Example #16
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);
        }
Example #17
0
        public override void Init()
        {
            base.Init();

            SkinLayer l = btnClose.Skin.Layers[lrButton];

            btnClose.Width  = l.Width - btnClose.Skin.OriginMargins.Horizontal;
            btnClose.Height = l.Height - btnClose.Skin.OriginMargins.Vertical;
            btnClose.Left   = OriginWidth - Skin.OriginMargins.Right - btnClose.Width + l.OffsetX;
            btnClose.Top    = Skin.OriginMargins.Top + l.OffsetY;
            btnClose.Anchor = EAnchors.Top | EAnchors.Right;

            //SkinControl sc = new SkinControl(ClientArea.Skin);
            //sc.Layers[0] = Skin.Layers[lrWindow];
            //ClientArea.Color = Color.Transparent;
            //ClientArea.BackColor = Color.Transparent;
            //ClientArea.Skin = sc;
        }
Example #18
0
        public virtual void DrawString(Control control, SkinLayer layer, string text, Rectangle rect, EControlState state, bool margins, int ox, int oy, bool ellipsis)
        {
            Color col = Color.White;

            if (layer.Text != null)
            {
                if (margins)
                {
                    Margins m = layer.ContentMargins;
                    rect = new Rectangle(rect.Left + m.Left, rect.Top + m.Top, rect.Width - m.Horizontal, rect.Height - m.Vertical);
                }

                if (state == EControlState.Hovered && (layer.States.Hovered.Index != -1))
                {
                    col = layer.Text.Colors.Hovered;
                }
                else if (state == EControlState.Pressed)
                {
                    col = layer.Text.Colors.Pressed;
                }
                else if (state == EControlState.Focused || (control.Focused && state == EControlState.Hovered && layer.States.Hovered.Index == -1))
                {
                    col = layer.Text.Colors.Focused;
                }
                else if (state == EControlState.Disabled)
                {
                    col = layer.Text.Colors.Disabled;
                }
                else
                {
                    col = layer.Text.Colors.Enabled;
                }

                if (text != null && text != "")
                {
                    SkinText font = layer.Text;
                    if (control.TextColor != Control.UndefinedColor && control.ControlState != EControlState.Disabled)
                    {
                        col = control.TextColor;
                    }
                    DrawString(font.Font.Resource, text, rect, col, font.Alignment, font.OffsetX + ox, font.OffsetY + oy, ellipsis);
                }
            }
        }
Example #19
0
		public SkinLayer(SkinLayer source)
			: base(source) {
			if (source != null) {
				this.Image = new SkinImage(source.Image);
				this.Width = source.Width;
				this.Height = source.Height;
				this.OffsetX = source.OffsetX;
				this.OffsetY = source.OffsetY;
				this.Alignment = source.Alignment;
				this.SizingMargins = source.SizingMargins;
				this.ContentMargins = source.ContentMargins;
				this.States = source.States;
				this.Overlays = source.Overlays;
				this.Text = new SkinText(source.Text);
				this.Attributes = new SkinList<SkinAttribute>(source.Attributes);
			} else {
				throw new Exception("Parameter for SkinLayer copy constructor cannot be null.");
			}
		}
Example #20
0
        protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
        {
            SkinLayer  layer  = type == EGroupBoxType.Normal ? Skin.Layers["Control"] : Skin.Layers["Flat"];
            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);
            Vector2    size   = font.MeasureString(Text);

            size.Y = font.LineSpacing;
            Rectangle r = new Rectangle(rect.Left, rect.Top + (int)(size.Y / 2), rect.Width, rect.Height - (int)(size.Y / 2));

            renderer.DrawLayer(this, layer, r);

            if (font != null && Text != null && Text != "")
            {
                Rectangle bg = new Rectangle(r.Left + offset.X, (r.Top - (int)(size.Y / 2)) + offset.Y, (int)size.X + layer.ContentMargins.Horizontal, (int)size.Y);
                renderer.DrawLayer(Manager.Skin.Controls["Control"].Layers[0], bg, new Color(64, 64, 64), 0);
                renderer.DrawString(this, layer, Text, new Rectangle(r.Left, r.Top - (int)(size.Y / 2), (int)(size.X), (int)size.Y), true, 0, 0, false);
            }
        }
Example #21
0
        protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
        {
            CheckLayer(Skin, "Control");
            CheckLayer(Skin, "Scale");

            base.DrawControl(renderer, rect, gameTime);

            if (Value > 0 || mode == EProgressBarMode.Infinite)
            {
                SkinLayer p = Skin.Layers["Control"];
                SkinLayer l = Skin.Layers["Scale"];
                Rectangle r = new Rectangle(rect.Left + p.ContentMargins.Left,
                                            rect.Top + p.ContentMargins.Top,
                                            rect.Width - p.ContentMargins.Vertical,
                                            rect.Height - p.ContentMargins.Horizontal);

                float     perc = ((float)value / range) * 100;
                int       w    = (int)((perc / 100) * r.Width);
                Rectangle rx;
                if (mode == EProgressBarMode.Default)
                {
                    if (w < l.SizingMargins.Vertical)
                    {
                        w = l.SizingMargins.Vertical;
                    }
                    rx = new Rectangle(r.Left, r.Top, w, r.Height);
                }
                else
                {
                    int s = r.Left + w;
                    if (s > r.Left + p.ContentMargins.Left + r.Width - (r.Width / 4))
                    {
                        s = r.Left + p.ContentMargins.Left + r.Width - (r.Width / 4);
                    }
                    rx = new Rectangle(s, r.Top, (r.Width / 4), r.Height);
                }

                renderer.DrawLayer(this, l, rx);
            }
        }
Example #22
0
        void btnSlider_Move(object sender, MoveEventArgs e)
        {
            SkinLayer p    = Skin.Layers["Control"];
            int       size = btnSlider.Width;
            int       w    = Width - p.ContentMargins.Horizontal - size;
            int       pos  = e.Left;

            if (pos < p.ContentMargins.Left)
            {
                pos = p.ContentMargins.Left;
            }
            if (pos > w + p.ContentMargins.Left)
            {
                pos = w + p.ContentMargins.Left;
            }

            btnSlider.SetPosition(pos, 0);

            float px = (float)range / (float)w;

            Value = (int)(Math.Ceiling((pos - p.ContentMargins.Left) * px));
        }
Example #23
0
 public SkinLayer(SkinLayer source)
     : base(source)
 {
     if (source != null)
     {
         this.Image          = new SkinImage(source.Image);
         this.Width          = source.Width;
         this.Height         = source.Height;
         this.OffsetX        = source.OffsetX;
         this.OffsetY        = source.OffsetY;
         this.Alignment      = source.Alignment;
         this.SizingMargins  = source.SizingMargins;
         this.ContentMargins = source.ContentMargins;
         this.States         = source.States;
         this.Overlays       = source.Overlays;
         this.Text           = new SkinText(source.Text);
         this.Attributes     = new SkinList <SkinAttribute>(source.Attributes);
     }
     else
     {
         throw new Exception("Parameter for SkinLayer copy constructor cannot be null.");
     }
 }
Example #24
0
        private void LoadLayerAttributes(SkinLayer sl, XmlNodeList l)
        {
            foreach (XmlElement e in l)
            {
                string        name = ReadAttribute(e, "Name", null, true);
                SkinAttribute sa   = sl.Attributes[name];
                bool          inh  = true;

                if (sa == null)
                {
                    sa  = new SkinAttribute();
                    inh = false;
                }

                sa.Name = name;
                ReadAttribute(ref sa.Value, inh, e, "Value", null, true);

                if (!inh)
                {
                    sl.Attributes.Add(sa);
                }
            }
        }
Example #25
0
        public virtual void DrawLayer(Control control, SkinLayer layer, Rectangle rect, EControlState state)
        {
            Color     c  = Color.White;
            Color     oc = Color.White;
            int       i  = 0;
            int       oi = -1;
            SkinLayer l  = layer;

            if (state == EControlState.Hovered && (layer.States.Hovered.Index != -1))
            {
                c = l.States.Hovered.Color;
                i = l.States.Hovered.Index;

                if (l.States.Hovered.Overlay)
                {
                    oc = l.Overlays.Hovered.Color;
                    oi = l.Overlays.Hovered.Index;
                }
            }
            else if (state == EControlState.Focused || (control.Focused && state == EControlState.Hovered && layer.States.Hovered.Index == -1))
            {
                c = l.States.Focused.Color;
                i = l.States.Focused.Index;

                if (l.States.Focused.Overlay)
                {
                    oc = l.Overlays.Focused.Color;
                    oi = l.Overlays.Focused.Index;
                }
            }
            else if (state == EControlState.Pressed)
            {
                c = l.States.Pressed.Color;
                i = l.States.Pressed.Index;

                if (l.States.Pressed.Overlay)
                {
                    oc = l.Overlays.Pressed.Color;
                    oi = l.Overlays.Pressed.Index;
                }
            }
            else if (state == EControlState.Disabled)
            {
                c = l.States.Disabled.Color;
                i = l.States.Disabled.Index;

                if (l.States.Disabled.Overlay)
                {
                    oc = l.Overlays.Disabled.Color;
                    oi = l.Overlays.Disabled.Index;
                }
            }
            else
            {
                c = l.States.Enabled.Color;
                i = l.States.Enabled.Index;

                if (l.States.Enabled.Overlay)
                {
                    oc = l.Overlays.Enabled.Color;
                    oi = l.Overlays.Enabled.Index;
                }
            }

            if (control.Color != Control.UndefinedColor)
            {
                c = control.Color * (control.Color.A / 255f);
            }
            DrawLayer(l, rect, c, i);

            if (oi != -1)
            {
                DrawLayer(l, rect, oc, oi);
            }
        }
Example #26
0
 public virtual void DrawString(Control control, SkinLayer layer, string text, Rectangle rect)
 {
     DrawString(control, layer, text, rect, true, 0, 0, true);
 }
Example #27
0
        private void LoadLayers(SkinControl sc, XmlNodeList l)
        {
            foreach (XmlElement e in l)
            {
                string    name = ReadAttribute(e, "Name", null, true);
                bool      over = ReadAttributeBool(e, "Override", false, false);
                SkinLayer sl   = sc.Layers[name];
                bool      inh  = true;

                if (sl == null)
                {
                    sl  = new SkinLayer();
                    inh = false;
                }

                if (inh && over)
                {
                    sl = new SkinLayer();
                    sc.Layers[name] = sl;
                }

                ReadAttribute(ref sl.Name, inh, e, "Name", null, true);
                ReadAttribute(ref sl.Image.Name, inh, e, "Image", "Control", false);
                ReadAttributeInt(ref sl.Width, inh, e, "Width", 0, false);
                ReadAttributeInt(ref sl.Height, inh, e, "Height", 0, false);

                string tmp = sl.Alignment.ToString();
                ReadAttribute(ref tmp, inh, e, "Alignment", "MiddleCenter", false);
                sl.Alignment = (EAlignment)Enum.Parse(typeof(EAlignment), tmp, true);

                ReadAttributeInt(ref sl.OffsetX, inh, e, "OffsetX", 0, false);
                ReadAttributeInt(ref sl.OffsetY, inh, e, "OffsetY", 0, false);

                ReadAttributeInt(ref sl.SizingMargins.Left, inh, e["SizingMargins"], "Left", 0, false);
                ReadAttributeInt(ref sl.SizingMargins.Top, inh, e["SizingMargins"], "Top", 0, false);
                ReadAttributeInt(ref sl.SizingMargins.Right, inh, e["SizingMargins"], "Right", 0, false);
                ReadAttributeInt(ref sl.SizingMargins.Bottom, inh, e["SizingMargins"], "Bottom", 0, false);

                ReadAttributeInt(ref sl.ContentMargins.Left, inh, e["ContentMargins"], "Left", 0, false);
                ReadAttributeInt(ref sl.ContentMargins.Top, inh, e["ContentMargins"], "Top", 0, false);
                ReadAttributeInt(ref sl.ContentMargins.Right, inh, e["ContentMargins"], "Right", 0, false);
                ReadAttributeInt(ref sl.ContentMargins.Bottom, inh, e["ContentMargins"], "Bottom", 0, false);

                if (e["States"] != null)
                {
                    ReadAttributeInt(ref sl.States.Enabled.Index, inh, e["States"]["Enabled"], "Index", 0, false);
                    int di = sl.States.Enabled.Index;
                    ReadAttributeInt(ref sl.States.Hovered.Index, inh, e["States"]["Hovered"], "Index", di, false);
                    ReadAttributeInt(ref sl.States.Pressed.Index, inh, e["States"]["Pressed"], "Index", di, false);
                    ReadAttributeInt(ref sl.States.Focused.Index, inh, e["States"]["Focused"], "Index", di, false);
                    ReadAttributeInt(ref sl.States.Disabled.Index, inh, e["States"]["Disabled"], "Index", di, false);

                    ReadAttributeColor(ref sl.States.Enabled.Color, inh, e["States"]["Enabled"], "Color", Color.White, false);
                    Color dc = sl.States.Enabled.Color;
                    ReadAttributeColor(ref sl.States.Hovered.Color, inh, e["States"]["Hovered"], "Color", dc, false);
                    ReadAttributeColor(ref sl.States.Pressed.Color, inh, e["States"]["Pressed"], "Color", dc, false);
                    ReadAttributeColor(ref sl.States.Focused.Color, inh, e["States"]["Focused"], "Color", dc, false);
                    ReadAttributeColor(ref sl.States.Disabled.Color, inh, e["States"]["Disabled"], "Color", dc, false);

                    ReadAttributeBool(ref sl.States.Enabled.Overlay, inh, e["States"]["Enabled"], "Overlay", false, false);
                    bool dv = sl.States.Enabled.Overlay;
                    ReadAttributeBool(ref sl.States.Hovered.Overlay, inh, e["States"]["Hovered"], "Overlay", dv, false);
                    ReadAttributeBool(ref sl.States.Pressed.Overlay, inh, e["States"]["Pressed"], "Overlay", dv, false);
                    ReadAttributeBool(ref sl.States.Focused.Overlay, inh, e["States"]["Focused"], "Overlay", dv, false);
                    ReadAttributeBool(ref sl.States.Disabled.Overlay, inh, e["States"]["Disabled"], "Overlay", dv, false);
                }

                if (e["Overlays"] != null)
                {
                    ReadAttributeInt(ref sl.Overlays.Enabled.Index, inh, e["Overlays"]["Enabled"], "Index", 0, false);
                    int di = sl.Overlays.Enabled.Index;
                    ReadAttributeInt(ref sl.Overlays.Hovered.Index, inh, e["Overlays"]["Hovered"], "Index", di, false);
                    ReadAttributeInt(ref sl.Overlays.Pressed.Index, inh, e["Overlays"]["Pressed"], "Index", di, false);
                    ReadAttributeInt(ref sl.Overlays.Focused.Index, inh, e["Overlays"]["Focused"], "Index", di, false);
                    ReadAttributeInt(ref sl.Overlays.Disabled.Index, inh, e["Overlays"]["Disabled"], "Index", di, false);

                    ReadAttributeColor(ref sl.Overlays.Enabled.Color, inh, e["Overlays"]["Enabled"], "Color", Color.White, false);
                    Color dc = sl.Overlays.Enabled.Color;
                    ReadAttributeColor(ref sl.Overlays.Hovered.Color, inh, e["Overlays"]["Hovered"], "Color", dc, false);
                    ReadAttributeColor(ref sl.Overlays.Pressed.Color, inh, e["Overlays"]["Pressed"], "Color", dc, false);
                    ReadAttributeColor(ref sl.Overlays.Focused.Color, inh, e["Overlays"]["Focused"], "Color", dc, false);
                    ReadAttributeColor(ref sl.Overlays.Disabled.Color, inh, e["Overlays"]["Disabled"], "Color", dc, false);
                }

                if (e["Text"] != null)
                {
                    ReadAttribute(ref sl.Text.Name, inh, e["Text"], "Font", null, true);
                    ReadAttributeInt(ref sl.Text.OffsetX, inh, e["Text"], "OffsetX", 0, false);
                    ReadAttributeInt(ref sl.Text.OffsetY, inh, e["Text"], "OffsetY", 0, false);

                    tmp = sl.Text.Alignment.ToString();
                    ReadAttribute(ref tmp, inh, e["Text"], "Alignment", "MiddleCenter", false);
                    sl.Text.Alignment = (EAlignment)Enum.Parse(typeof(EAlignment), tmp, true);

                    LoadColors(inh, e["Text"], ref sl.Text.Colors);
                }
                if (e["Attributes"] != null)
                {
                    XmlNodeList l2 = e["Attributes"].GetElementsByTagName("Attribute");
                    if (l2 != null && l2.Count > 0)
                    {
                        LoadLayerAttributes(sl, l2);
                    }
                }
                if (!inh)
                {
                    sc.Layers.Add(sl);
                }
            }
        }
Example #28
0
		public virtual void DrawString(Control control, SkinLayer layer, string text, Rectangle rect, bool margins, int ox, int oy, bool ellipsis) {
			DrawString(control, layer, text, rect, control.ControlState, margins, ox, oy, ellipsis);
		}
Example #29
0
        protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
        {
            base.DrawControl(renderer, rect, gameTime);

            SkinLayer l1 = Skin.Layers["Control"];
            SkinLayer l2 = Skin.Layers["Selection"];

            int   vsize = LineHeight();
            Color col   = Color.White;

            for (int i = 0; i < Items.Count; i++)
            {
                int mod  = i > 0 ? 2 : 0;
                int left = rect.Left + l1.ContentMargins.Left + vsize;
                int h    = vsize - mod - (i < (Items.Count - 1) ? 1 : 0);
                int top  = rect.Top + l1.ContentMargins.Top + (i * vsize) + mod;


                if (Items[i].Separated && i > 0)
                {
                    Rectangle r = new Rectangle(left, rect.Top + l1.ContentMargins.Top + (i * vsize), LineWidth() - vsize + 4, 1);
                    renderer.Draw(Manager.Skin.Controls["Control"].Layers[0].Image.Resource, r, l1.Text.Colors.Enabled);
                }
                if (ItemIndex != i)
                {
                    if (Items[i].Enabled)
                    {
                        Rectangle r = new Rectangle(left, top, LineWidth() - vsize, h);
                        renderer.DrawString(this, l1, Items[i].Text, r, false);
                        col = l1.Text.Colors.Enabled;
                    }
                    else
                    {
                        Rectangle r = new Rectangle(left + l1.Text.OffsetX,
                                                    top + l1.Text.OffsetY,
                                                    LineWidth() - vsize, h);
                        renderer.DrawString(l1.Text.Font.Resource, Items[i].Text, r, l1.Text.Colors.Disabled, l1.Text.Alignment);
                        col = l1.Text.Colors.Disabled;
                    }
                }
                else
                {
                    if (Items[i].Enabled)
                    {
                        Rectangle rs = new Rectangle(rect.Left + l1.ContentMargins.Left,
                                                     top,
                                                     Width - (l1.ContentMargins.Horizontal - Skin.OriginMargins.Horizontal),
                                                     h);
                        renderer.DrawLayer(this, l2, rs);

                        Rectangle r = new Rectangle(left,
                                                    top, LineWidth() - vsize, h);

                        renderer.DrawString(this, l2, Items[i].Text, r, false);
                        col = l2.Text.Colors.Enabled;
                    }
                    else
                    {
                        Rectangle rs = new Rectangle(rect.Left + l1.ContentMargins.Left,
                                                     top,
                                                     Width - (l1.ContentMargins.Horizontal - Skin.OriginMargins.Horizontal),
                                                     vsize);
                        renderer.DrawLayer(l2, rs, l2.States.Disabled.Color, l2.States.Disabled.Index);

                        Rectangle r = new Rectangle(left + l1.Text.OffsetX,
                                                    top + l1.Text.OffsetY,
                                                    LineWidth() - vsize, h);
                        renderer.DrawString(l2.Text.Font.Resource, Items[i].Text, r, l2.Text.Colors.Disabled, l2.Text.Alignment);
                        col = l2.Text.Colors.Disabled;
                    }
                }

                if (Items[i].Image != null)
                {
                    Rectangle r = new Rectangle(rect.Left + l1.ContentMargins.Left + 3,
                                                rect.Top + top + 3,
                                                LineHeight() - 6,
                                                LineHeight() - 6);
                    renderer.Draw(Items[i].Image, r, Color.White);
                }

                if (Items[i].Items != null && Items[i].Items.Count > 0)
                {
                    renderer.Draw(Manager.Skin.Images["Shared.ArrowRight"].Resource, rect.Left + LineWidth() - 4, rect.Top + l1.ContentMargins.Top + (i * vsize) + 8, col);
                }
            }
        }
Example #30
0
		public virtual void DrawString(Control control, SkinLayer layer, string text, Rectangle rect, EControlState state, bool margins) {
			DrawString(control, layer, text, rect, state, margins, 0, 0, true);
		}
Example #31
0
 public virtual void DrawLayer(Control control, SkinLayer layer, Rectangle rect)
 {
     DrawLayer(control, layer, rect, control.ControlState);
 }
Example #32
0
		public virtual void DrawLayer(Control control, SkinLayer layer, Rectangle rect, EControlState state) {
			Color c = Color.White;
			Color oc = Color.White;
			int i = 0;
			int oi = -1;
			SkinLayer l = layer;

			if (state == EControlState.Hovered && (layer.States.Hovered.Index != -1)) {
				c = l.States.Hovered.Color;
				i = l.States.Hovered.Index;

				if (l.States.Hovered.Overlay) {
					oc = l.Overlays.Hovered.Color;
					oi = l.Overlays.Hovered.Index;
				}
			} else if (state == EControlState.Focused || (control.Focused && state == EControlState.Hovered && layer.States.Hovered.Index == -1)) {
				c = l.States.Focused.Color;
				i = l.States.Focused.Index;

				if (l.States.Focused.Overlay) {
					oc = l.Overlays.Focused.Color;
					oi = l.Overlays.Focused.Index;
				}
			} else if (state == EControlState.Pressed) {
				c = l.States.Pressed.Color;
				i = l.States.Pressed.Index;

				if (l.States.Pressed.Overlay) {
					oc = l.Overlays.Pressed.Color;
					oi = l.Overlays.Pressed.Index;
				}
			} else if (state == EControlState.Disabled) {
				c = l.States.Disabled.Color;
				i = l.States.Disabled.Index;

				if (l.States.Disabled.Overlay) {
					oc = l.Overlays.Disabled.Color;
					oi = l.Overlays.Disabled.Index;
				}
			} else {
				c = l.States.Enabled.Color;
				i = l.States.Enabled.Index;

				if (l.States.Enabled.Overlay) {
					oc = l.Overlays.Enabled.Color;
					oi = l.Overlays.Enabled.Index;
				}
			}

			if (control.Color != Control.UndefinedColor)
				c = control.Color * (control.Color.A / 255f);
			DrawLayer(l, rect, c, i);

			if (oi != -1) {
				DrawLayer(l, rect, oc, oi);
			}
		}
Example #33
0
		public virtual void DrawString(Control control, SkinLayer layer, string text, Rectangle rect) {
			DrawString(control, layer, text, rect, true, 0, 0, true);
		}
Example #34
0
		public virtual void DrawLayer(Control control, SkinLayer layer, Rectangle rect) {
			DrawLayer(control, layer, rect, control.ControlState);
		}
Example #35
0
		public virtual void DrawLayer(SkinLayer layer, Rectangle rect, Color color, int index) {
			Size imageSize = new Size(layer.Image.Resource.Width, layer.Image.Resource.Height);
			Size partSize = new Size(layer.Width, layer.Height);

			Draw(layer.Image.Resource, GetDestinationArea(rect, layer.SizingMargins, EAlignment.TopLeft), GetSourceArea(imageSize, partSize, layer.SizingMargins, EAlignment.TopLeft, index), color);
			Draw(layer.Image.Resource, GetDestinationArea(rect, layer.SizingMargins, EAlignment.TopCenter), GetSourceArea(imageSize, partSize, layer.SizingMargins, EAlignment.TopCenter, index), color);
			Draw(layer.Image.Resource, GetDestinationArea(rect, layer.SizingMargins, EAlignment.TopRight), GetSourceArea(imageSize, partSize, layer.SizingMargins, EAlignment.TopRight, index), color);
			Draw(layer.Image.Resource, GetDestinationArea(rect, layer.SizingMargins, EAlignment.MiddleLeft), GetSourceArea(imageSize, partSize, layer.SizingMargins, EAlignment.MiddleLeft, index), color);
			Draw(layer.Image.Resource, GetDestinationArea(rect, layer.SizingMargins, EAlignment.MiddleCenter), GetSourceArea(imageSize, partSize, layer.SizingMargins, EAlignment.MiddleCenter, index), color);
			Draw(layer.Image.Resource, GetDestinationArea(rect, layer.SizingMargins, EAlignment.MiddleRight), GetSourceArea(imageSize, partSize, layer.SizingMargins, EAlignment.MiddleRight, index), color);
			Draw(layer.Image.Resource, GetDestinationArea(rect, layer.SizingMargins, EAlignment.BottomLeft), GetSourceArea(imageSize, partSize, layer.SizingMargins, EAlignment.BottomLeft, index), color);
			Draw(layer.Image.Resource, GetDestinationArea(rect, layer.SizingMargins, EAlignment.BottomCenter), GetSourceArea(imageSize, partSize, layer.SizingMargins, EAlignment.BottomCenter, index), color);
			Draw(layer.Image.Resource, GetDestinationArea(rect, layer.SizingMargins, EAlignment.BottomRight), GetSourceArea(imageSize, partSize, layer.SizingMargins, EAlignment.BottomRight, index), color);
		}
Example #36
0
		public virtual void DrawString(Control control, SkinLayer layer, string text, Rectangle rect, EControlState state, bool margins, int ox, int oy, bool ellipsis) {
			Color col = Color.White;

			if (layer.Text != null) {
				if (margins) {
					Margins m = layer.ContentMargins;
					rect = new Rectangle(rect.Left + m.Left, rect.Top + m.Top, rect.Width - m.Horizontal, rect.Height - m.Vertical);
				}

				if (state == EControlState.Hovered && (layer.States.Hovered.Index != -1)) {
					col = layer.Text.Colors.Hovered;
				} else if (state == EControlState.Pressed) {
					col = layer.Text.Colors.Pressed;
				} else if (state == EControlState.Focused || (control.Focused && state == EControlState.Hovered && layer.States.Hovered.Index == -1)) {
					col = layer.Text.Colors.Focused;
				} else if (state == EControlState.Disabled) {
					col = layer.Text.Colors.Disabled;
				} else {
					col = layer.Text.Colors.Enabled;
				}

				if (text != null && text != "") {
					SkinText font = layer.Text;
					if (control.TextColor != Control.UndefinedColor && control.ControlState != EControlState.Disabled)
						col = control.TextColor;
					DrawString(font.Font.Resource, text, rect, col, font.Alignment, font.OffsetX + ox, font.OffsetY + oy, ellipsis);
				}
			}
		}
Example #37
0
        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 != EControlState.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 == EControlState.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);
            }
        }
Example #38
0
        private void DrawPart(Renderer renderer, Rectangle rect, EBevelBorder pos, EBevelStyle style, bool all)
        {
            SkinLayer layer = Skin.Layers["Control"];
            Color     c1    = Utilities.ParseColor(layer.Attributes["LightColor"].Value);
            Color     c2    = Utilities.ParseColor(layer.Attributes["DarkColor"].Value);
            Color     c3    = Utilities.ParseColor(layer.Attributes["FlatColor"].Value);

            if (Color != UndefinedColor)
            {
                c3 = Color;
            }

            Texture2D img = Skin.Layers["Control"].Image.Resource;

            int x1 = 0;
            int y1 = 0;
            int w1 = 0;
            int h1 = 0;
            int x2 = 0;
            int y2 = 0;
            int w2 = 0;
            int h2 = 0;

            if (style == EBevelStyle.Bumped || style == EBevelStyle.Etched)
            {
                if (all && (pos == EBevelBorder.Top || pos == EBevelBorder.Bottom))
                {
                    rect = new Rectangle(rect.Left + 1, rect.Top, rect.Width - 2, rect.Height);
                }
                else if (all && (pos == EBevelBorder.Left))
                {
                    rect = new Rectangle(rect.Left, rect.Top, rect.Width, rect.Height - 1);
                }
                switch (pos)
                {
                case EBevelBorder.Left: {
                    x1 = rect.Left;
                    y1 = rect.Top;
                    w1 = 1;
                    h1 = rect.Height;
                    x2 = x1 + 1;
                    y2 = y1;
                    w2 = w1;
                    h2 = h1;
                    break;
                }

                case EBevelBorder.Top: {
                    x1 = rect.Left;
                    y1 = rect.Top;
                    w1 = rect.Width;
                    h1 = 1;
                    x2 = x1;
                    y2 = y1 + 1;
                    w2 = w1;
                    h2 = h1;
                    break;
                }

                case EBevelBorder.Right: {
                    x1 = rect.Left + rect.Width - 2;
                    y1 = rect.Top;
                    w1 = 1;
                    h1 = rect.Height;
                    x2 = x1 + 1;
                    y2 = y1;
                    w2 = w1;
                    h2 = h1;
                    break;
                }

                case EBevelBorder.Bottom: {
                    x1 = rect.Left;
                    y1 = rect.Top + rect.Height - 2;
                    w1 = rect.Width;
                    h1 = 1;
                    x2 = x1;
                    y2 = y1 + 1;
                    w2 = w1;
                    h2 = h1;
                    break;
                }
                }
            }
            else
            {
                switch (pos)
                {
                case EBevelBorder.Left: {
                    x1 = rect.Left;
                    y1 = rect.Top;
                    w1 = 1;
                    h1 = rect.Height;
                    break;
                }

                case EBevelBorder.Top: {
                    x1 = rect.Left;
                    y1 = rect.Top;
                    w1 = rect.Width;
                    h1 = 1;
                    break;
                }

                case EBevelBorder.Right: {
                    x1 = rect.Left + rect.Width - 1;
                    y1 = rect.Top;
                    w1 = 1;
                    h1 = rect.Height;
                    break;
                }

                case EBevelBorder.Bottom: {
                    x1 = rect.Left;
                    y1 = rect.Top + rect.Height - 1;
                    w1 = rect.Width;
                    h1 = 1;
                    break;
                }
                }
            }

            switch (Style)
            {
            case EBevelStyle.Bumped: {
                renderer.Draw(img, new Rectangle(x1, y1, w1, h1), c1);
                renderer.Draw(img, new Rectangle(x2, y2, w2, h2), c2);
                break;
            }

            case EBevelStyle.Etched: {
                renderer.Draw(img, new Rectangle(x1, y1, w1, h1), c2);
                renderer.Draw(img, new Rectangle(x2, y2, w2, h2), c1);
                break;
            }

            case EBevelStyle.Raised: {
                Color c = c1;
                if (pos == EBevelBorder.Left || pos == EBevelBorder.Top)
                {
                    c = c1;
                }
                else
                {
                    c = c2;
                }

                renderer.Draw(img, new Rectangle(x1, y1, w1, h1), c);
                break;
            }

            case EBevelStyle.Lowered: {
                Color c = c1;
                if (pos == EBevelBorder.Left || pos == EBevelBorder.Top)
                {
                    c = c2;
                }
                else
                {
                    c = c1;
                }

                renderer.Draw(img, new Rectangle(x1, y1, w1, h1), c);
                break;
            }

            default: {
                renderer.Draw(img, new Rectangle(x1, y1, w1, h1), c3);
                break;
            }
            }
        }
Example #39
0
        void ClientArea_Draw(object sender, DrawEventArgs e)
        {
            SkinLayer  layer    = Skin.Layers[lrTextBox];
            Color      col      = Skin.Layers[lrTextBox].Text.Colors.Enabled;
            SkinLayer  cursor   = Skin.Layers[lrCursor];
            EAlignment al       = mode == ETextBoxMode.Multiline ? EAlignment.TopLeft : EAlignment.MiddleLeft;
            Renderer   renderer = e.Renderer;
            Rectangle  r        = e.Rectangle;
            bool       drawsel  = !selection.IsEmpty;
            string     tmpText  = "";

            font = (Skin.Layers[lrTextBox].Text != null) ? Skin.Layers[lrTextBox].Text.Font.Resource : null;

            if (Text != null && font != null)
            {
                DeterminePages();

                if (mode == ETextBoxMode.Multiline)
                {
                    shownText = Text;
                    tmpText   = Lines[PosY];
                }
                else if (mode == ETextBoxMode.Password)
                {
                    shownText = "";
                    for (int i = 0; i < Text.Length; i++)
                    {
                        shownText = shownText + passwordChar;
                    }
                    tmpText = shownText;
                }
                else
                {
                    shownText = Text;
                    tmpText   = Lines[PosY];
                }

                if (TextColor != UndefinedColor && ControlState != EControlState.Disabled)
                {
                    col = TextColor;
                }

                if (mode != ETextBoxMode.Multiline)
                {
                    linesDrawn = 0;
                    vert.Value = 0;
                }

                if (drawsel)
                {
                    DrawSelection(e.Renderer, r);

                    /*
                     *                renderer.End();
                     *                renderer.SpriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.None);
                     *                renderer.SpriteBatch.GraphicsDevice.RenderState.SeparateAlphaBlendEnabled = true;
                     *                renderer.SpriteBatch.GraphicsDevice.RenderState.SourceBlend = Blend.DestinationColor;
                     *                renderer.SpriteBatch.GraphicsDevice.RenderState.DestinationBlend = Blend.SourceColor;
                     *                renderer.SpriteBatch.GraphicsDevice.RenderState.BlendFunction = BlendFunction.Subtract;
                     *                //renderer.SpriteBatch.GraphicsDevice.RenderState.AlphaFunction = CompareFunction.Equal;
                     *                //renderer.SpriteBatch.GraphicsDevice.RenderState.AlphaSourceBlend = Blend.One;
                     *                //renderer.SpriteBatch.GraphicsDevice.RenderState.AlphaDestinationBlend = Blend.DestinationAlpha;
                     */
                }

                int sizey = (int)font.LineSpacing;

                if (showCursor && caretVisible)
                {
                    Vector2 size = Vector2.Zero;
                    if (PosX > 0 && PosX <= tmpText.Length)
                    {
                        size = font.MeasureString(tmpText.Substring(0, PosX));
                    }
                    if (size.Y == 0)
                    {
                        size   = font.MeasureString(" ");
                        size.X = 0;
                    }

                    int m = r.Height - font.LineSpacing;

                    Rectangle rc = new Rectangle(r.Left - horz.Value + (int)size.X, r.Top + m / 2, cursor.Width, font.LineSpacing);

                    if (mode == ETextBoxMode.Multiline)
                    {
                        rc = new Rectangle(r.Left + (int)size.X - horz.Value, r.Top + (int)((PosY - vert.Value) * font.LineSpacing), cursor.Width, font.LineSpacing);
                    }
                    cursor.Alignment = al;
                    renderer.DrawLayer(cursor, rc, col, 0);
                }

                for (int i = 0; i < linesDrawn + 1; i++)
                {
                    int ii = i + vert.Value;
                    if (ii >= Lines.Count || ii < 0)
                    {
                        break;
                    }

                    if (Lines[ii] != "")
                    {
                        if (mode == ETextBoxMode.Multiline)
                        {
                            renderer.DrawString(font, Lines[ii], r.Left - horz.Value, r.Top + (i * sizey), col);
                        }
                        else
                        {
                            Rectangle rx = new Rectangle(r.Left - horz.Value, r.Top, r.Width, r.Height);
                            renderer.DrawString(font, shownText, rx, col, al, false);
                        }
                    }
                }

                /*  if (drawsel)
                 * {
                 *      renderer.End();
                 *      renderer.Begin(BlendingMode.Premultiplied);
                 * }*/
            }
        }
Example #40
0
		private void LoadLayers(SkinControl sc, XmlNodeList l) {
			foreach (XmlElement e in l) {
				string name = ReadAttribute(e, "Name", null, true);
				bool over = ReadAttributeBool(e, "Override", false, false);
				SkinLayer sl = sc.Layers[name];
				bool inh = true;

				if (sl == null) {
					sl = new SkinLayer();
					inh = false;
				}

				if (inh && over) {
					sl = new SkinLayer();
					sc.Layers[name] = sl;
				}

				ReadAttribute(ref sl.Name, inh, e, "Name", null, true);
				ReadAttribute(ref sl.Image.Name, inh, e, "Image", "Control", false);
				ReadAttributeInt(ref sl.Width, inh, e, "Width", 0, false);
				ReadAttributeInt(ref sl.Height, inh, e, "Height", 0, false);

				string tmp = sl.Alignment.ToString();
				ReadAttribute(ref tmp, inh, e, "Alignment", "MiddleCenter", false);
				sl.Alignment = (EAlignment)Enum.Parse(typeof(EAlignment), tmp, true);

				ReadAttributeInt(ref sl.OffsetX, inh, e, "OffsetX", 0, false);
				ReadAttributeInt(ref sl.OffsetY, inh, e, "OffsetY", 0, false);

				ReadAttributeInt(ref sl.SizingMargins.Left, inh, e["SizingMargins"], "Left", 0, false);
				ReadAttributeInt(ref sl.SizingMargins.Top, inh, e["SizingMargins"], "Top", 0, false);
				ReadAttributeInt(ref sl.SizingMargins.Right, inh, e["SizingMargins"], "Right", 0, false);
				ReadAttributeInt(ref sl.SizingMargins.Bottom, inh, e["SizingMargins"], "Bottom", 0, false);

				ReadAttributeInt(ref sl.ContentMargins.Left, inh, e["ContentMargins"], "Left", 0, false);
				ReadAttributeInt(ref sl.ContentMargins.Top, inh, e["ContentMargins"], "Top", 0, false);
				ReadAttributeInt(ref sl.ContentMargins.Right, inh, e["ContentMargins"], "Right", 0, false);
				ReadAttributeInt(ref sl.ContentMargins.Bottom, inh, e["ContentMargins"], "Bottom", 0, false);

				if (e["States"] != null) {
					ReadAttributeInt(ref sl.States.Enabled.Index, inh, e["States"]["Enabled"], "Index", 0, false);
					int di = sl.States.Enabled.Index;
					ReadAttributeInt(ref sl.States.Hovered.Index, inh, e["States"]["Hovered"], "Index", di, false);
					ReadAttributeInt(ref sl.States.Pressed.Index, inh, e["States"]["Pressed"], "Index", di, false);
					ReadAttributeInt(ref sl.States.Focused.Index, inh, e["States"]["Focused"], "Index", di, false);
					ReadAttributeInt(ref sl.States.Disabled.Index, inh, e["States"]["Disabled"], "Index", di, false);

					ReadAttributeColor(ref sl.States.Enabled.Color, inh, e["States"]["Enabled"], "Color", Color.White, false);
					Color dc = sl.States.Enabled.Color;
					ReadAttributeColor(ref sl.States.Hovered.Color, inh, e["States"]["Hovered"], "Color", dc, false);
					ReadAttributeColor(ref sl.States.Pressed.Color, inh, e["States"]["Pressed"], "Color", dc, false);
					ReadAttributeColor(ref sl.States.Focused.Color, inh, e["States"]["Focused"], "Color", dc, false);
					ReadAttributeColor(ref sl.States.Disabled.Color, inh, e["States"]["Disabled"], "Color", dc, false);

					ReadAttributeBool(ref sl.States.Enabled.Overlay, inh, e["States"]["Enabled"], "Overlay", false, false);
					bool dv = sl.States.Enabled.Overlay;
					ReadAttributeBool(ref sl.States.Hovered.Overlay, inh, e["States"]["Hovered"], "Overlay", dv, false);
					ReadAttributeBool(ref sl.States.Pressed.Overlay, inh, e["States"]["Pressed"], "Overlay", dv, false);
					ReadAttributeBool(ref sl.States.Focused.Overlay, inh, e["States"]["Focused"], "Overlay", dv, false);
					ReadAttributeBool(ref sl.States.Disabled.Overlay, inh, e["States"]["Disabled"], "Overlay", dv, false);
				}

				if (e["Overlays"] != null) {
					ReadAttributeInt(ref sl.Overlays.Enabled.Index, inh, e["Overlays"]["Enabled"], "Index", 0, false);
					int di = sl.Overlays.Enabled.Index;
					ReadAttributeInt(ref sl.Overlays.Hovered.Index, inh, e["Overlays"]["Hovered"], "Index", di, false);
					ReadAttributeInt(ref sl.Overlays.Pressed.Index, inh, e["Overlays"]["Pressed"], "Index", di, false);
					ReadAttributeInt(ref sl.Overlays.Focused.Index, inh, e["Overlays"]["Focused"], "Index", di, false);
					ReadAttributeInt(ref sl.Overlays.Disabled.Index, inh, e["Overlays"]["Disabled"], "Index", di, false);

					ReadAttributeColor(ref sl.Overlays.Enabled.Color, inh, e["Overlays"]["Enabled"], "Color", Color.White, false);
					Color dc = sl.Overlays.Enabled.Color;
					ReadAttributeColor(ref sl.Overlays.Hovered.Color, inh, e["Overlays"]["Hovered"], "Color", dc, false);
					ReadAttributeColor(ref sl.Overlays.Pressed.Color, inh, e["Overlays"]["Pressed"], "Color", dc, false);
					ReadAttributeColor(ref sl.Overlays.Focused.Color, inh, e["Overlays"]["Focused"], "Color", dc, false);
					ReadAttributeColor(ref sl.Overlays.Disabled.Color, inh, e["Overlays"]["Disabled"], "Color", dc, false);
				}

				if (e["Text"] != null) {
					ReadAttribute(ref sl.Text.Name, inh, e["Text"], "Font", null, true);
					ReadAttributeInt(ref sl.Text.OffsetX, inh, e["Text"], "OffsetX", 0, false);
					ReadAttributeInt(ref sl.Text.OffsetY, inh, e["Text"], "OffsetY", 0, false);

					tmp = sl.Text.Alignment.ToString();
					ReadAttribute(ref tmp, inh, e["Text"], "Alignment", "MiddleCenter", false);
					sl.Text.Alignment = (EAlignment)Enum.Parse(typeof(EAlignment), tmp, true);

					LoadColors(inh, e["Text"], ref sl.Text.Colors);
				}
				if (e["Attributes"] != null) {
					XmlNodeList l2 = e["Attributes"].GetElementsByTagName("Attribute");
					if (l2 != null && l2.Count > 0) {
						LoadLayerAttributes(sl, l2);
					}
				}
				if (!inh)
					sc.Layers.Add(sl);
			}
		}
Example #41
0
		public virtual void DrawString(Control control, SkinLayer layer, string text, Rectangle rect, bool margins, int ox, int oy) {
			DrawString(control, layer, text, rect, margins, ox, oy, true);
		}
Example #42
0
		private void LoadLayerAttributes(SkinLayer sl, XmlNodeList l) {
			foreach (XmlElement e in l) {
				string name = ReadAttribute(e, "Name", null, true);
				SkinAttribute sa = sl.Attributes[name];
				bool inh = true;

				if (sa == null) {
					sa = new SkinAttribute();
					inh = false;
				}

				sa.Name = name;
				ReadAttribute(ref sa.Value, inh, e, "Value", null, true);

				if (!inh)
					sl.Attributes.Add(sa);
			}
		}