Ejemplo n.º 1
0
        } // ButtonSlider_KeyPress

        #endregion

        #region Recalculate Parameters

        /// <summary>
        /// Recalculate some parameters, like button size, slider position, etc.
        /// </summary>
        private void RecalculateParameters()
        {
            if (buttonSlider != null)
            {
                if (buttonSlider.Width > 12)
                {
                    buttonSlider.Glyph = new Glyph(Skin.Images["Shared.Glyph"].Texture) { SizeMode = SizeMode.Centered };
                }
                else
                {
                    buttonSlider.Glyph = null;
                }

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

                float px = (float)100 / (float)w;
                int pos = p.ContentMargins.Left + (int)(Math.Ceiling(internalValue / (float)px));
                
                if (pos < p.ContentMargins.Left) 
                    pos = p.ContentMargins.Left;
                if (pos > w + p.ContentMargins.Left) 
                    pos = w + p.ContentMargins.Left;

                buttonSlider.SetPosition(pos, 0);
            }
        } // RecalculateParameters
Ejemplo n.º 2
0
        } // DisposeManagedResources

        #endregion

        #region Draw

        /// <summary>
        /// Prerender the control into the control's render target.
        /// </summary>
        protected override void DrawControl(Rectangle rect)
        {
            RecalculateParameters();
            
            SkinLayer p = SkinInformation.Layers["Control"];
            SkinLayer l = SkinInformation.Layers["ScaleOrange"];

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

            float px = ((float)internalValue / (float)100);
            int w = (int)Math.Ceiling(px * (rect.Width - p.ContentMargins.Horizontal - buttonSlider.Width)) + 2;

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

            // Draw control
            base.DrawControl(new Rectangle(rect.Left, t, rect.Width, h));
            // Draw progress line.
            Rectangle r1 = new Rectangle(rect.Left + p.ContentMargins.Left, t + p.ContentMargins.Top, w, h - p.ContentMargins.Vertical);
            if (drawScale)
            {
                switch (scaleColor)
                {
                    case ScaleColor.Red     : Renderer.DrawLayer(this, SkinInformation.Layers["ScaleRed"], r1); break;
                    case ScaleColor.Green   : Renderer.DrawLayer(this, SkinInformation.Layers["ScaleGreen"], r1); break;
                    case ScaleColor.Blue    : Renderer.DrawLayer(this, SkinInformation.Layers["ScaleBlue"], r1); break;
                    case ScaleColor.Default : Renderer.DrawLayer(this, l, r1); break;
                }
            }
        } // DrawControl
Ejemplo n.º 3
0
        } // ButtonClose_Click

        #endregion

        #region Draw and Render

        /// <summary>
        /// Render the control to the main render target.
        /// </summary>
        internal override void DrawControlOntoMainTexture()
        {

            #region Shadow

            if (Visible && Shadow)
            {
                SkinControlInformation skinControlShadow = Skin.Controls[skinShadow];
                SkinLayer   skinLayerShadow   = skinControlShadow.Layers[layerShadow];

                Color shadowColor = Color.FromNonPremultiplied(skinLayerShadow.States.Enabled.Color.R, 
                                                               skinLayerShadow.States.Enabled.Color.G,
                                                               skinLayerShadow.States.Enabled.Color.B, Alpha);

                Renderer.Begin();
                    Renderer.DrawLayer(skinLayerShadow,
                                       new Rectangle(Left - skinControlShadow.OriginMargins.Left,
                                                     Top - skinControlShadow.OriginMargins.Top, 
                                                     Width + skinControlShadow.OriginMargins.Horizontal,
                                                     Height + skinControlShadow.OriginMargins.Vertical),
                                       shadowColor, 0);
                Renderer.End();
            }

            #endregion

            base.DrawControlOntoMainTexture();
        } // Render
Ejemplo n.º 4
0
        } // DisposeManagedResources

        #endregion

        #region Draw

        /// <summary>
        /// Prerender the control into the control's render target.
        /// </summary>
        protected override void DrawControl(Rectangle rect)
        {
            CheckLayer(SkinInformation, "Control");
            CheckLayer(SkinInformation, "Scale");

            base.DrawControl(rect);

            if (Value > 0 || mode == ProgressBarMode.Infinite)
            {
                SkinLayer p = SkinInformation.Layers["Control"];
                SkinLayer l = SkinInformation.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 == ProgressBarMode.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);
            }
        } // DrawControl
Ejemplo n.º 5
0
        } // DisposeManagedResources

        #endregion

        #region Draw

        /// <summary>
        /// Prerender the control into the control's render target.
        /// </summary>
        protected override void DrawControl(Rectangle rect)
        {
            SkinLayer l1 = SkinInformation.Layers["Control"];
            SkinLayer l2 = SkinInformation.Layers["Header"];
            Color col = Color != UndefinedColor ? 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(r1);

            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.Font.Resource;
                    Margins margins = l2.ContentMargins;
                    Point offset = new Point(l2.OffsetX, l2.OffsetY);
                    if (i > 0) prev = tabPages[i - 1].HeaderRectangle;

                    tabPages[i].CalculateRectangle(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].HeaderRectangle;
                    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.Font.Resource, tabPages[i].Text, sx, lc, l2.Text.Alignment);
                    }
                }

                Margins mi = l2.ContentMargins;
                Rectangle ri = tabPages[selectedIndex].HeaderRectangle;
                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.Font.Resource, tabPages[selectedIndex].Text, si, l2.Text.Colors.Focused, l2.Text.Alignment, l2.Text.OffsetX, l2.Text.OffsetY, false);
            }
        } // DrawControl
Ejemplo n.º 6
0
        } // Window

        #endregion

        #region Init

        protected internal override void Init()
        {
            base.Init();
            SkinLayer skinLayer = buttonClose.SkinInformation.Layers[layerButton];
            buttonClose.Width  = skinLayer.Width  - buttonClose.SkinInformation.OriginMargins.Horizontal;
            buttonClose.Height = skinLayer.Height - buttonClose.SkinInformation.OriginMargins.Vertical;
            buttonClose.Left   = ControlAndMarginsWidth - SkinInformation.OriginMargins.Right - buttonClose.Width + skinLayer.OffsetX;
            buttonClose.Top    = SkinInformation.OriginMargins.Top + skinLayer.OffsetY;
            buttonClose.Anchor = Anchors.Top | Anchors.Right;
        } // Init
Ejemplo n.º 7
0
        } // Render

        /// <summary>
        /// Get the rectangle that contains the icon.
        /// </summary>
        private Rectangle GetIconRectangle()
        {
            SkinLayer skinLayerCaption = SkinInformation.Layers[layerCaption];
            SkinLayer skinLayerIcon    = SkinInformation.Layers[layerIcon];

            int iconHeight = skinLayerCaption.Height - skinLayerCaption.ContentMargins.Vertical;
            return new Rectangle(DrawingRectangle.Left + skinLayerCaption.ContentMargins.Left + skinLayerIcon.OffsetX,
                                 DrawingRectangle.Top  + skinLayerCaption.ContentMargins.Top  + skinLayerIcon.OffsetY,
                                 iconHeight, iconHeight);

        } // GetIconRectangle
Ejemplo n.º 8
0
        } // GroupPanel

        #endregion

        #region Draw Control

        /// <summary>
        /// Prerender the control into the control's render target.
        /// </summary>
        protected override void DrawControl(Rectangle rect)
        {
            SkinLayer layer = SkinInformation.Layers["Control"];
            SpriteFont font = (layer.Text != null && layer.Text.Font != null) ? layer.Text.Font.Font.Resource : null;
            Point offset = new Point(layer.Text.OffsetX, layer.Text.OffsetY);

            Renderer.DrawLayer(this, layer, rect);

            if (font != null && !string.IsNullOrEmpty(Text))
            {
                Renderer.DrawString(this, layer, Text, new Rectangle(rect.Left, rect.Top + layer.ContentMargins.Top, rect.Width, SkinInformation.ClientMargins.Top - layer.ContentMargins.Horizontal), false, offset.X, offset.Y, false);
            }
        } // DrawControl
Ejemplo n.º 9
0
        } // InitSkin

        #endregion

        #region Draw

        /// <summary>
        /// Prerender the control into the control's render target.
        /// </summary>
        protected override void DrawControl(Rectangle rect)
        {
            base.DrawControl(rect);

            if (ReadOnly && (Focused || listCombo.Focused) && drawSelection)
            {
                SkinLayer lr = SkinInformation.Layers[0];
                Rectangle rc = new Rectangle(rect.Left + lr.ContentMargins.Left,
                                             rect.Top + lr.ContentMargins.Top,
                                             Width - lr.ContentMargins.Horizontal - buttonDown.Width,
                                             Height - lr.ContentMargins.Vertical);
                Renderer.Draw(Skin.Images["ListBox.Selection"].Texture.Resource, rc, Color.FromNonPremultiplied(255, 255, 255, 128));
            }
        } // DrawControl
Ejemplo n.º 10
0
        } // GetTextCenter

        #endregion

        #region Draw Layer

        public static void DrawLayer(SkinLayer layer, Rectangle rect, Color color, int index)
        {
            Size imageSize = new Size(layer.Image.Texture.Width, layer.Image.Texture.Height);
            Size partSize = new Size(layer.Width, layer.Height);

            Draw(layer.Image.Texture.Resource, GetDestinationArea(rect, layer.SizingMargins, Alignment.TopLeft),      GetSourceArea(imageSize, partSize, layer.SizingMargins, Alignment.TopLeft, index), color);
            Draw(layer.Image.Texture.Resource, GetDestinationArea(rect, layer.SizingMargins, Alignment.TopCenter), GetSourceArea(imageSize, partSize, layer.SizingMargins, Alignment.TopCenter, index), color);
            Draw(layer.Image.Texture.Resource, GetDestinationArea(rect, layer.SizingMargins, Alignment.TopRight), GetSourceArea(imageSize, partSize, layer.SizingMargins, Alignment.TopRight, index), color);
            Draw(layer.Image.Texture.Resource, GetDestinationArea(rect, layer.SizingMargins, Alignment.MiddleLeft), GetSourceArea(imageSize, partSize, layer.SizingMargins, Alignment.MiddleLeft, index), color);
            Draw(layer.Image.Texture.Resource, GetDestinationArea(rect, layer.SizingMargins, Alignment.MiddleCenter), GetSourceArea(imageSize, partSize, layer.SizingMargins, Alignment.MiddleCenter, index), color);
            Draw(layer.Image.Texture.Resource, GetDestinationArea(rect, layer.SizingMargins, Alignment.MiddleRight), GetSourceArea(imageSize, partSize, layer.SizingMargins, Alignment.MiddleRight, index), color);
            Draw(layer.Image.Texture.Resource, GetDestinationArea(rect, layer.SizingMargins, Alignment.BottomLeft), GetSourceArea(imageSize, partSize, layer.SizingMargins, Alignment.BottomLeft, index), color);
            Draw(layer.Image.Texture.Resource, GetDestinationArea(rect, layer.SizingMargins, Alignment.BottomCenter), GetSourceArea(imageSize, partSize, layer.SizingMargins, Alignment.BottomCenter, index), color);
            Draw(layer.Image.Texture.Resource, GetDestinationArea(rect, layer.SizingMargins, Alignment.BottomRight), GetSourceArea(imageSize, partSize, layer.SizingMargins, Alignment.BottomRight, index), color);
        } // DrawLayer
Ejemplo n.º 11
0
        } // DisposeManagedResources

        #endregion

        #region Draw

        /// <summary>
        /// Prerender the control into the control's render target.
        /// </summary>
        protected override void DrawControl(Rectangle rect)
        {
            SkinLayer layer = SkinInformation.Layers["Checked"];

            if (!isChecked)
            {
                layer = SkinInformation.Layers["Control"];
            }

            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);
        } // DrawControl
Ejemplo n.º 12
0
        } // DrawString

        public static void DrawString(Control control, SkinLayer layer, string text, Rectangle rect, ControlState state, bool margins, int ox, int oy, bool ellipsis)
        {
            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);
                }

                #region Resolve Text Color

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

                #endregion

                if (!string.IsNullOrEmpty(text))
                {
                    SkinText font = layer.Text;
                    if (control.TextColor != Control.UndefinedColor && control.ControlState != ControlState.Disabled) 
                        color = control.TextColor;
                    DrawString(font.Font.Font.Resource, text, rect, color, font.Alignment, font.OffsetX + ox, font.OffsetY + oy, ellipsis);
                }
            }
        } // DrawString
Ejemplo n.º 13
0
        } // DrawControl

        private void DrawPane(object sender, DrawEventArgs e)
        {
            if (items != null && items.Count > 0)
            {
                SkinText  fontLayer     = SkinInformation.Layers["Control"].Text;
                SkinLayer selectedLayer = SkinInformation.Layers["ListBox.Selection"];
                int       fontHeight    = (int)fontLayer.Font.Font.MeasureString(items[0].ToString()).Y;
                int       v             = (scrollBarVertical.Value / 10);
                if (!scrollBarVertical.Visible) // If the scrooll bar is invisible then this value should be 0 (first page).
                {
                    v = 0;
                }
                int p = (scrollBarVertical.PageSize / 10);
                int d = (int)(((scrollBarVertical.Value % 10) / 10f) * fontHeight);
                // This is done to show all last elements in the same page.
                if (v + p + 1 > items.Count)
                {
                    v = items.Count - p;
                    if (v < 0)
                    {
                        v = 0;
                    }
                }
                // Draw elements
                for (int i = v; i <= v + p + 1; i++)
                {
                    if (i < items.Count)
                    {
                        Renderer.DrawString(this, SkinInformation.Layers["Control"], items[i].ToString(),
                                            new Rectangle(e.Rectangle.Left, e.Rectangle.Top - d + ((i - v) * fontHeight), e.Rectangle.Width, fontHeight), false);
                    }
                }
                // Draw selection
                if (itemIndex >= 0 && itemIndex < items.Count && (Focused || !hideSelection))
                {
                    int pos = -d + ((itemIndex - v) * fontHeight);
                    if (pos > -fontHeight && pos < (p + 1) * fontHeight)
                    {
                        Renderer.DrawLayer(this, selectedLayer, new Rectangle(e.Rectangle.Left, e.Rectangle.Top + pos, e.Rectangle.Width, fontHeight));
                        Renderer.DrawString(this, selectedLayer, items[itemIndex].ToString(), new Rectangle(e.Rectangle.Left, e.Rectangle.Top + pos, e.Rectangle.Width, fontHeight), false);
                    }
                }
            }
        } // DrawPane
Ejemplo n.º 14
0
        } // GroupBox

        #endregion

        #region Draw

        /// <summary>
        /// Prerender the control into the control's render target.
        /// </summary>
        protected override void DrawControl(Rectangle rect)
        {
            SkinLayer  layer  = type == GroupBoxType.Normal ? SkinInformation.Layers["Control"] : SkinInformation.Layers["Flat"];
            SpriteFont font   = layer.Text.Font.Font.Resource;
            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 (!string.IsNullOrEmpty(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(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);
            }
        } // DrawControl
Ejemplo n.º 15
0
        } // CalculateInternalValue

        #endregion

        #region Event

        private void ButtonSlider_Move(object sender, MoveEventArgs e)
        {
            SkinLayer p = SkinInformation.Layers["Control"];
            int size = buttonSlider.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;

            buttonSlider.SetPosition(pos, 0);
            float px = (float)100 / (float)w;

            // Update value. But in this case the value can't be out of range.
            bool temp = ValueCanBeOutOfRange;
            ValueCanBeOutOfRange = false;
            InternalValue = (pos - p.ContentMargins.Left) * px;
            ValueCanBeOutOfRange = temp;
        } // ButtonSlider_Move
Ejemplo n.º 16
0
        } // LoadColors

        #endregion

        #region Load Layer Attributes

        /// <summary>
        /// Load Layer Attributes
        /// </summary>
        private static void LoadLayerAttribute(SkinLayer skinLayer, XElement e)
        {
            string        name          = ReadAttribute(e, "Name", null, true);
            SkinAttribute skinAttribute = skinLayer.Attributes[name];
            bool          inherent      = true;

            if (skinAttribute == null)
            {
                skinAttribute = new SkinAttribute();
                inherent      = false;
            }

            skinAttribute.Name = name;
            ReadAttribute(ref skinAttribute.Value, inherent, e, "Value", null, true);

            if (!inherent)
            {
                skinLayer.Attributes.Add(skinAttribute);
            }
        } // LoadLayerAttribute
Ejemplo n.º 17
0
        } // InitSkin

        #endregion

        #region Draw

        /// <summary>
        /// Prerender the control into the control's render target.
        /// </summary>
        protected override void DrawControl(Rectangle rect)
        {
            SkinLayer layerControl   = SkinInformation.Layers["Control"];
            SkinLayer layerSelection = SkinInformation.Layers["Selection"];
            rectangle = new Rectangle[Items.Count];

            Renderer.DrawLayer(this, layerControl, rect, ControlState.Enabled);
            
            int prev = layerControl.ContentMargins.Left;
            
            // Draw root menu items (the others are rendered using context menu controls)
            for (int i = 0; i < Items.Count; i++)
            {
                MenuItem menuItem = Items[i];

                int textWidth = (int)layerControl.Text.Font.Font.MeasureString(menuItem.Text).X + layerControl.ContentMargins.Horizontal;
                rectangle[i] = new Rectangle(rect.Left + prev, rect.Top + layerControl.ContentMargins.Top, textWidth, Height - layerControl.ContentMargins.Vertical);
                prev += textWidth;

                if (ItemIndex != i)
                {
                    if (menuItem.Enabled && Enabled)
                        Renderer.DrawString(this, layerControl, menuItem.Text, rectangle[i], ControlState.Enabled, false);
                    else
                        Renderer.DrawString(this, layerControl, menuItem.Text, rectangle[i], ControlState.Disabled, false);
                }
                else
                {
                    if (Items[i].Enabled && Enabled)
                    {
                        Renderer.DrawLayer(this, layerSelection, rectangle[i], ControlState.Enabled);
                        Renderer.DrawString(this, layerSelection, menuItem.Text, rectangle[i], ControlState.Enabled, false);
                    }
                    else
                    {
                        Renderer.DrawLayer(this, layerSelection, rectangle[i], ControlState.Disabled);
                        Renderer.DrawString(this, layerSelection, menuItem.Text, rectangle[i], ControlState.Disabled, false);
                    }
                }
            }
        } // DrawControl
Ejemplo n.º 18
0
        } // SkinLayer

        public SkinLayer(SkinLayer source) : base(source)
        {
            if (source != null)
            {
                Image          = new SkinImage(source.Image);
                Width          = source.Width;
                Height         = source.Height;
                OffsetX        = source.OffsetX;
                OffsetY        = source.OffsetY;
                Alignment      = source.Alignment;
                SizingMargins  = source.SizingMargins;
                ContentMargins = source.ContentMargins;
                States         = source.States;
                Overlays       = source.Overlays;
                Text           = new SkinText(source.Text);
                Attributes     = new SkinList <SkinAttribute>(source.Attributes);
            }
            else
            {
                throw new Exception("Parameter for SkinLayer copy constructor cannot be null.");
            }
        } // SkinLayer
Ejemplo n.º 19
0
        } // DrawString

        public static 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);
        } // DrawString
Ejemplo n.º 20
0
        } // Label

        #endregion

        #region Draw Control

        /// <summary>
        /// Prerender the control into the control's render target.
        /// </summary>
        protected override void DrawControl(Rectangle rect)
        {
            SkinLayer skinLayer = SkinInformation.Layers[0];

            Renderer.DrawString(this, skinLayer, Text, rect, true, 0, 0, ellipsis);
        } // DrawControl
Ejemplo n.º 21
0
        } // DrawLayer

        public static void DrawLayer(Control control, SkinLayer layer, Rectangle rect)
        {
            DrawLayer(control, layer, rect, control.ControlState);
        } // DrawLayer
Ejemplo n.º 22
0
        } // DrawLayer

        public static void DrawLayer(Control control, SkinLayer layer, Rectangle rect, ControlState state)
        {
            Color color;
            Color overlayColor = Color.White;
            int index;
            int overlayIndex = -1;

            if (state == ControlState.Hovered && (layer.States.Hovered.Index != -1))
            {
                color = layer.States.Hovered.Color;
                index = layer.States.Hovered.Index;

                if (layer.States.Hovered.Overlay)
                {
                    overlayColor = layer.Overlays.Hovered.Color;
                    overlayIndex = layer.Overlays.Hovered.Index;
                }
            }
            else if (state == ControlState.Focused || (control.Focused && state == ControlState.Hovered && layer.States.Hovered.Index == -1))
            {
                color = layer.States.Focused.Color;
                index = layer.States.Focused.Index;

                if (layer.States.Focused.Overlay)
                {
                    overlayColor = layer.Overlays.Focused.Color;
                    overlayIndex = layer.Overlays.Focused.Index;
                }
            }
            else if (state == ControlState.Pressed)
            {
                color = layer.States.Pressed.Color;
                index = layer.States.Pressed.Index;

                if (layer.States.Pressed.Overlay)
                {
                    overlayColor = layer.Overlays.Pressed.Color;
                    overlayIndex = layer.Overlays.Pressed.Index;
                }
            }
            else if (state == ControlState.Disabled)
            {
                color = layer.States.Disabled.Color;
                index = layer.States.Disabled.Index;

                if (layer.States.Disabled.Overlay)
                {
                    overlayColor = layer.Overlays.Disabled.Color;
                    overlayIndex = layer.Overlays.Disabled.Index;
                }
            }
            else
            {
                color = layer.States.Enabled.Color;
                index = layer.States.Enabled.Index;

                if (layer.States.Enabled.Overlay)
                {
                    overlayColor = layer.Overlays.Enabled.Color;
                    overlayIndex = layer.Overlays.Enabled.Index;
                }
            }

            if (control.Color != Control.UndefinedColor) 
                color = control.Color * (control.Color.A / 255f);
            DrawLayer(layer, rect, color, index);

            if (overlayIndex != -1)
            {
                DrawLayer(layer, rect, overlayColor, overlayIndex);
            }
        } // DrawLayer
Ejemplo n.º 23
0
        } // DrawControl

        private void DrawPart(Rectangle rect, BevelBorder pos, BevelStyle style, bool all)
        {
            SkinLayer layer = SkinInformation.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;

            Texture texture = SkinInformation.Layers["Control"].Image.Texture;

            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 == BevelStyle.Bumped || style == BevelStyle.Etched)
            {
                if (all && (pos == BevelBorder.Top || pos == BevelBorder.Bottom))
                {
                    rect = new Rectangle(rect.Left + 1, rect.Top, rect.Width - 2, rect.Height);
                }
                else if (all && (pos == BevelBorder.Left))
                {
                    rect = new Rectangle(rect.Left, rect.Top, rect.Width, rect.Height - 1);
                }
                switch (pos)
                {
                    case BevelBorder.Left:
                        {
                            x1 = rect.Left; y1 = rect.Top; w1 = 1; h1 = rect.Height;
                            x2 = x1 + 1; y2 = y1; w2 = w1; h2 = h1;
                            break;
                        }
                    case BevelBorder.Top:
                        {
                            x1 = rect.Left; y1 = rect.Top; w1 = rect.Width; h1 = 1;
                            x2 = x1; y2 = y1 + 1; w2 = w1; h2 = h1;
                            break;
                        }
                    case BevelBorder.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 BevelBorder.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 BevelBorder.Left:
                        {
                            x1 = rect.Left; y1 = rect.Top; w1 = 1; h1 = rect.Height;
                            break;
                        }
                    case BevelBorder.Top:
                        {
                            x1 = rect.Left; y1 = rect.Top; w1 = rect.Width; h1 = 1;
                            break;
                        }
                    case BevelBorder.Right:
                        {
                            x1 = rect.Left + rect.Width - 1; y1 = rect.Top; w1 = 1; h1 = rect.Height;
                            break;
                        }
                    case BevelBorder.Bottom:
                        {
                            x1 = rect.Left; y1 = rect.Top + rect.Height - 1; w1 = rect.Width; h1 = 1;
                            break;
                        }
                }
            }

            switch (Style)
            {
                case BevelStyle.Bumped:
                    {
                        Renderer.Draw(texture.Resource, new Rectangle(x1, y1, w1, h1), c1);
                        Renderer.Draw(texture.Resource, new Rectangle(x2, y2, w2, h2), c2);
                        break;
                    }
                case BevelStyle.Etched:
                    {
                        Renderer.Draw(texture.Resource, new Rectangle(x1, y1, w1, h1), c2);
                        Renderer.Draw(texture.Resource, new Rectangle(x2, y2, w2, h2), c1);
                        break;
                    }
                case BevelStyle.Raised:
                    {
                        Color c = c1;
                        if (pos == BevelBorder.Left || pos == BevelBorder.Top) c = c1;
                        else c = c2;

                        Renderer.Draw(texture.Resource, new Rectangle(x1, y1, w1, h1), c);
                        break;
                    }
                case BevelStyle.Lowered:
                    {
                        Color c = c1;
                        if (pos == BevelBorder.Left || pos == BevelBorder.Top) c = c2;
                        else c = c1;

                        Renderer.Draw(texture.Resource, new Rectangle(x1, y1, w1, h1), c);
                        break;
                    }
                default:
                    {
                        Renderer.Draw(texture.Resource, new Rectangle(x1, y1, w1, h1), c3);
                        break;
                    }
            }
        } // DrawPart
Ejemplo n.º 24
0
        } // InitSkin

        #endregion

        #region Draw

        /// <summary>
        /// Prerender the control into the control's render target.
        /// </summary>
        protected override void DrawControl(Rectangle rect)
        {
            base.DrawControl(rect);

            SkinLayer layerControl   = SkinInformation.Layers["Control"];
            SkinLayer layerSelection = SkinInformation.Layers["Selection"];
            int verticalSize = LineHeight();
            Color color;

            // Find maximum width (not including right side text)
            // This information will be used to render the right side text, if any.
            int maximumWidth = 0;
            foreach (MenuItem menuItem in Items)
            {
                int textWidth = (int)layerControl.Text.Font.Font.MeasureString(menuItem.Text).X + 16;
                if (textWidth > maximumWidth)
                    maximumWidth = textWidth;
            }

            // Render all menu items.
            for (int i = 0; i < Items.Count; i++)
            {
                int mod = i > 0 ? 2 : 0;
                int left = rect.Left + layerControl.ContentMargins.Left + verticalSize;
                int hight = verticalSize - mod - (i < (Items.Count - 1) ? 1 : 0);
                int top = rect.Top + layerControl.ContentMargins.Top + (i * verticalSize) + mod;


                if (Items[i].SeparationLine && i > 0)
                {
                    Rectangle rectangle = new Rectangle(left, rect.Top + layerControl.ContentMargins.Top + (i * verticalSize), LineWidth() - verticalSize + 4, 1);
                    Renderer.Draw(Skin.Controls["Control"].Layers[0].Image.Texture.Resource, rectangle, layerControl.Text.Colors.Enabled);
                }

                #region No Selected
                if (ItemIndex != i)
                {
                    if (Items[i].Enabled)
                    {
                        Rectangle rectangle = new Rectangle(left, top, LineWidth() - verticalSize, hight);
                        // Render Text.
                        Renderer.DrawString(this, layerControl, Items[i].Text, rectangle, false);
                        // Render Right Side Text.
                        if (!string.IsNullOrEmpty(Items[i].RightSideText))
                        {
                            rectangle = new Rectangle(rectangle.Left + maximumWidth, rectangle.Top,
                                                     (int)layerControl.Text.Font.Font.MeasureString(Items[i].RightSideText).X + 16, rectangle.Height);
                            Renderer.DrawString(this, layerControl, Items[i].RightSideText, rectangle, false);
                        }
                        color = layerControl.Text.Colors.Enabled;
                    }
                    else
                    {
                        Rectangle rectangle = new Rectangle(left + layerControl.Text.OffsetX, top + layerControl.Text.OffsetY, LineWidth() - verticalSize, hight);
                        // Render Text.
                        Renderer.DrawString(layerControl.Text.Font.Font.Resource, Items[i].Text, rectangle, layerControl.Text.Colors.Disabled, layerControl.Text.Alignment);
                        // Render Right Side Text.
                        if (!string.IsNullOrEmpty(Items[i].RightSideText))
                        {
                            rectangle = new Rectangle(rectangle.Left + maximumWidth, rectangle.Top,
                                                     (int)layerControl.Text.Font.Font.MeasureString(Items[i].RightSideText).X + 16, rectangle.Height);
                            Renderer.DrawString(layerControl.Text.Font.Font.Resource, Items[i].RightSideText, rectangle, layerControl.Text.Colors.Disabled, layerControl.Text.Alignment);
                        }
                        color = layerControl.Text.Colors.Disabled;
                    }
                }
                #endregion

                #region Selected
                else
                {
                    if (Items[i].Enabled)
                    {
                        Rectangle rs = new Rectangle(rect.Left + layerControl.ContentMargins.Left, 
                                                     top,
                                                     Width - (layerControl.ContentMargins.Horizontal - SkinInformation.OriginMargins.Horizontal),
                                                     hight);
                        Renderer.DrawLayer(this, layerSelection, rs);

                        Rectangle rectangle = new Rectangle(left, top, LineWidth() - verticalSize, hight);
                        // Render String.
                        Renderer.DrawString(this, layerSelection, Items[i].Text, rectangle, false);
                        // Render Right Side Text.
                        if (!string.IsNullOrEmpty(Items[i].RightSideText))
                        {
                            rectangle = new Rectangle(rectangle.Left + maximumWidth, rectangle.Top,
                                                     (int)layerControl.Text.Font.Font.MeasureString(Items[i].RightSideText).X + 16, rectangle.Height);
                            Renderer.DrawString(this, layerSelection, Items[i].RightSideText, rectangle, false);
                        }
                        color = layerSelection.Text.Colors.Enabled;
                    }
                    else
                    {
                        Rectangle rs = new Rectangle(rect.Left + layerControl.ContentMargins.Left,
                                                     top,
                                                     Width - (layerControl.ContentMargins.Horizontal - SkinInformation.OriginMargins.Horizontal),
                                                     verticalSize);
                        Renderer.DrawLayer(layerSelection, rs, layerSelection.States.Disabled.Color, layerSelection.States.Disabled.Index);

                        Rectangle rectangle = new Rectangle(left + layerControl.Text.OffsetX,
                                                    top + layerControl.Text.OffsetY,
                                                    LineWidth() - verticalSize, hight);
                        // Render Text.
                        Renderer.DrawString(layerSelection.Text.Font.Font.Resource, Items[i].Text, rectangle,
                                            layerSelection.Text.Colors.Disabled, layerSelection.Text.Alignment);
                        // Render Right Side Text.
                        if (!string.IsNullOrEmpty(Items[i].RightSideText))
                        {
                            rectangle = new Rectangle(rectangle.Left + maximumWidth, rectangle.Top,
                                                     (int)layerControl.Text.Font.Font.MeasureString(Items[i].RightSideText).X + 16, rectangle.Height);
                            Renderer.DrawString(layerSelection.Text.Font.Font.Resource, Items[i].RightSideText, rectangle,
                                                layerSelection.Text.Colors.Disabled, layerSelection.Text.Alignment);
                        }
                        color = layerSelection.Text.Colors.Disabled;
                    }
                }
                #endregion

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

                if (Items[i].Items != null && Items[i].Items.Count > 0)
                {
                    Renderer.Draw(Skin.Images["Shared.ArrowRight"].Texture.Resource, rect.Left + LineWidth() - 4, rect.Top + layerControl.ContentMargins.Top + (i * verticalSize) + 8, color);
                }
            }
        } // DrawControl
Ejemplo n.º 25
0
        } // GetIconRectangle

        /// <summary>
        /// Prerender the control into the control's render target.
        /// </summary>
        protected override void DrawControl(Rectangle rect)
        {
            SkinLayer skinLayerFrameTop    = captionVisible ? SkinInformation.Layers[layerCaption] : SkinInformation.Layers[layerFrameTop];
            SkinLayer skinLayerFrameLeft   = SkinInformation.Layers[layerFrameLeft];
            SkinLayer skinLayerFrameRight  = SkinInformation.Layers[layerFrameRight];
            SkinLayer skinLayerFrameBottom = SkinInformation.Layers[layerFrameBottom];
            SkinLayer skinLayerIcon        = SkinInformation.Layers[layerIcon];
            LayerStates layerStateFrameTop, layerStateFrameLeft, layerStateFrameRight, layerStateFrameButtom;
            SpriteFont font = skinLayerFrameTop.Text.Font.Font.Resource;
            Color color;

            if ((Focused || (UserInterfaceManager.FocusedControl != null && UserInterfaceManager.FocusedControl.Root == Root)) && ControlState != ControlState.Disabled)
            {
                layerStateFrameTop = skinLayerFrameTop.States.Focused;
                layerStateFrameLeft = skinLayerFrameLeft.States.Focused;
                layerStateFrameRight = skinLayerFrameRight.States.Focused;
                layerStateFrameButtom = skinLayerFrameBottom.States.Focused;
                color = skinLayerFrameTop.Text.Colors.Focused;
            }
            else if (ControlState == ControlState.Disabled)
            {
                layerStateFrameTop = skinLayerFrameTop.States.Disabled;
                layerStateFrameLeft = skinLayerFrameLeft.States.Disabled;
                layerStateFrameRight = skinLayerFrameRight.States.Disabled;
                layerStateFrameButtom = skinLayerFrameBottom.States.Disabled;
                color = skinLayerFrameTop.Text.Colors.Disabled;
            }
            else
            {
                layerStateFrameTop = skinLayerFrameTop.States.Enabled;
                layerStateFrameLeft = skinLayerFrameLeft.States.Enabled;
                layerStateFrameRight = skinLayerFrameRight.States.Enabled;
                layerStateFrameButtom = skinLayerFrameBottom.States.Enabled;
                color = skinLayerFrameTop.Text.Colors.Enabled;
            }
            // Render Background plane
            Renderer.DrawLayer(SkinInformation.Layers[layerWindow], rect, SkinInformation.Layers[layerWindow].States.Enabled.Color, SkinInformation.Layers[layerWindow].States.Enabled.Index);
            // Render border
            if (borderVisible)
            {
                Renderer.DrawLayer(skinLayerFrameTop, new Rectangle(rect.Left, rect.Top, rect.Width, skinLayerFrameTop.Height), layerStateFrameTop.Color, layerStateFrameTop.Index);
                Renderer.DrawLayer(skinLayerFrameLeft, new Rectangle(rect.Left, rect.Top + skinLayerFrameTop.Height, skinLayerFrameLeft.Width, rect.Height - skinLayerFrameTop.Height - skinLayerFrameBottom.Height), layerStateFrameLeft.Color, layerStateFrameLeft.Index);
                Renderer.DrawLayer(skinLayerFrameRight, new Rectangle(rect.Right - skinLayerFrameRight.Width, rect.Top + skinLayerFrameTop.Height, skinLayerFrameRight.Width, rect.Height - skinLayerFrameTop.Height - skinLayerFrameBottom.Height), layerStateFrameRight.Color, layerStateFrameRight.Index);
                Renderer.DrawLayer(skinLayerFrameBottom, new Rectangle(rect.Left, rect.Bottom - skinLayerFrameBottom.Height, rect.Width, skinLayerFrameBottom.Height), layerStateFrameButtom.Color, layerStateFrameButtom.Index);

                if (iconVisible && (Icon != null || skinLayerIcon != null) && captionVisible)
                {
                    Texture2D i = Icon ?? skinLayerIcon.Image.Texture.Resource;
                    Renderer.Draw(i, GetIconRectangle(), Color.White);
                }

                int icosize = 0;
                if (skinLayerIcon != null && iconVisible && captionVisible)
                {
                    icosize = skinLayerFrameTop.Height - skinLayerFrameTop.ContentMargins.Vertical + 4 + skinLayerIcon.OffsetX;
                }
                int closesize = 0;
                if (buttonClose.Visible)
                {
                    closesize = buttonClose.Width - (buttonClose.SkinInformation.Layers[layerButton].OffsetX);
                }

                Rectangle r = new Rectangle(rect.Left + skinLayerFrameTop.ContentMargins.Left + icosize,
                                            rect.Top + skinLayerFrameTop.ContentMargins.Top,
                                            rect.Width - skinLayerFrameTop.ContentMargins.Horizontal - closesize - icosize,
                                            skinLayerFrameTop.Height - skinLayerFrameTop.ContentMargins.Top - skinLayerFrameTop.ContentMargins.Bottom);
                int ox = skinLayerFrameTop.Text.OffsetX;
                int oy = skinLayerFrameTop.Text.OffsetY;
                Renderer.DrawString(font, Text, r, color, skinLayerFrameTop.Text.Alignment, ox, oy, true);
            }
        } // DrawControl
Ejemplo n.º 26
0
        } // GetMaxLine

        /// <summary>
        /// Draw the text.
        /// </summary>
        private void ClientAreaDraw(object sender, DrawEventArgs e)
        {
            Color col = SkinInformation.Layers["Control"].Text.Colors.Enabled;
            SkinLayer cursor = SkinInformation.Layers["Cursor"];
            Alignment al = mode == TextBoxMode.Multiline ? Alignment.TopLeft : Alignment.MiddleLeft;
            Rectangle r = e.Rectangle;
            bool drawsel = !selection.IsEmpty;
            string tmpText;

            font = (SkinInformation.Layers["Control"].Text != null) ? SkinInformation.Layers["Control"].Text.Font.Font : null;

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

                if (mode == TextBoxMode.Multiline)
                {
                    shownText = Text;
                    tmpText = lines[PositionY];
                }
                else if (mode == TextBoxMode.Password)
                {
                    shownText = "";
                    foreach (char character in Text)
                    {
                        shownText = shownText + passwordCharacter;
                    }
                    tmpText = shownText;
                }
                else
                {
                    shownText = Text;
                    tmpText = lines[PositionY];
                }

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

                if (mode != TextBoxMode.Multiline)
                {
                    linesDrawn = 0;
                    verticalScrollBar.Value = 0;
                }

                if (drawsel)
                {
                    DrawSelection(r);
                }

                int sizey = font.LineSpacing;

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

                    int m = r.Height - font.LineSpacing;

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

                    if (mode == TextBoxMode.Multiline)
                    {
                        rc = new Rectangle(r.Left + (int)size.X - horizontalScrollBar.Value, r.Top + (int)((PositionY - verticalScrollBar.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 + verticalScrollBar.Value;
                    if (ii >= lines.Count || ii < 0) break;

                    if (lines[ii] != "")
                    {
                        if (mode == TextBoxMode.Multiline)
                        {
                            Renderer.DrawString(font.Resource, lines[ii], r.Left - horizontalScrollBar.Value, r.Top + (i * sizey), col);
                        }
                        else
                        {
                            Rectangle rx = new Rectangle(r.Left - horizontalScrollBar.Value, r.Top, r.Width, r.Height);
                            Renderer.DrawString(font.Resource, shownText, rx, col, al, false);
                        }
                    }
                }
            }
        } // ClientArea_Draw
Ejemplo n.º 27
0
        } // LoadControls

        #endregion

        #region Load Layers

        /// <summary>
        /// Load layers information.
        /// </summary>
        private static void LoadLayer(SkinControlInformation skinControl, XElement layerNode)
        {
            string    name      = ReadAttribute(layerNode, "Name", null, true);
            bool      over      = ReadAttribute(layerNode, "Override", false, false);
            SkinLayer skinLayer = skinControl.Layers[name];

            bool inherent = true;

            if (skinLayer == null)
            {
                skinLayer = new SkinLayer();
                inherent  = false;
            }

            if (inherent && over)
            {
                skinLayer = new SkinLayer();
                skinControl.Layers[name] = skinLayer;
            }

            ReadAttribute(ref skinLayer.Name, inherent, layerNode, "Name", null, true);
            ReadAttribute(ref skinLayer.Image.Name, inherent, layerNode, "Image", "Control", false);
            ReadAttribute(ref skinLayer.Width, inherent, layerNode, "Width", 0, false);
            ReadAttribute(ref skinLayer.Height, inherent, layerNode, "Height", 0, false);

            string layerAlignment = skinLayer.Alignment.ToString();

            ReadAttribute(ref layerAlignment, inherent, layerNode, "Alignment", "MiddleCenter", false);
            skinLayer.Alignment = (Alignment)Enum.Parse(typeof(Alignment), layerAlignment, true);

            ReadAttribute(ref skinLayer.OffsetX, inherent, layerNode, "OffsetX", 0, false);
            ReadAttribute(ref skinLayer.OffsetY, inherent, layerNode, "OffsetY", 0, false);

            ReadAttribute(ref skinLayer.SizingMargins.Left, inherent, layerNode.Element("SizingMargins"), "Left", 0, false);
            ReadAttribute(ref skinLayer.SizingMargins.Top, inherent, layerNode.Element("SizingMargins"), "Top", 0, false);
            ReadAttribute(ref skinLayer.SizingMargins.Right, inherent, layerNode.Element("SizingMargins"), "Right", 0, false);
            ReadAttribute(ref skinLayer.SizingMargins.Bottom, inherent, layerNode.Element("SizingMargins"), "Bottom", 0, false);

            ReadAttribute(ref skinLayer.ContentMargins.Left, inherent, layerNode.Element("ContentMargins"), "Left", 0, false);
            ReadAttribute(ref skinLayer.ContentMargins.Top, inherent, layerNode.Element("ContentMargins"), "Top", 0, false);
            ReadAttribute(ref skinLayer.ContentMargins.Right, inherent, layerNode.Element("ContentMargins"), "Right", 0, false);
            ReadAttribute(ref skinLayer.ContentMargins.Bottom, inherent, layerNode.Element("ContentMargins"), "Bottom", 0, false);

            #region States

            if (layerNode.Element("States") != null)
            {
                ReadAttribute(ref skinLayer.States.Enabled.Index, inherent, layerNode.Element("States").Element("Enabled"), "Index", 0, false);
                int di = skinLayer.States.Enabled.Index;
                ReadAttribute(ref skinLayer.States.Hovered.Index, inherent, layerNode.Element("States").Element("Hovered"), "Index", di, false);
                ReadAttribute(ref skinLayer.States.Pressed.Index, inherent, layerNode.Element("States").Element("Pressed"), "Index", di, false);
                ReadAttribute(ref skinLayer.States.Focused.Index, inherent, layerNode.Element("States").Element("Focused"), "Index", di, false);
                ReadAttribute(ref skinLayer.States.Disabled.Index, inherent, layerNode.Element("States").Element("Disabled"), "Index", di, false);

                ReadAttribute(ref skinLayer.States.Enabled.Color, inherent, layerNode.Element("States").Element("Enabled"), "Color", Color.White, false);
                Color dc = skinLayer.States.Enabled.Color;
                ReadAttribute(ref skinLayer.States.Hovered.Color, inherent, layerNode.Element("States").Element("Hovered"), "Color", dc, false);
                ReadAttribute(ref skinLayer.States.Pressed.Color, inherent, layerNode.Element("States").Element("Pressed"), "Color", dc, false);
                ReadAttribute(ref skinLayer.States.Focused.Color, inherent, layerNode.Element("States").Element("Focused"), "Color", dc, false);
                ReadAttribute(ref skinLayer.States.Disabled.Color, inherent, layerNode.Element("States").Element("Disabled"), "Color", dc, false);

                ReadAttribute(ref skinLayer.States.Enabled.Overlay, inherent, layerNode.Element("States").Element("Enabled"), "Overlay", false, false);
                bool dv = skinLayer.States.Enabled.Overlay;
                ReadAttribute(ref skinLayer.States.Hovered.Overlay, inherent, layerNode.Element("States").Element("Hovered"), "Overlay", dv, false);
                ReadAttribute(ref skinLayer.States.Pressed.Overlay, inherent, layerNode.Element("States").Element("Pressed"), "Overlay", dv, false);
                ReadAttribute(ref skinLayer.States.Focused.Overlay, inherent, layerNode.Element("States").Element("Focused"), "Overlay", dv, false);
                ReadAttribute(ref skinLayer.States.Disabled.Overlay, inherent, layerNode.Element("States").Element("Disabled"), "Overlay", dv, false);
            }

            #endregion

            #region Overlays

            if (layerNode.Element("Overlays") != null)
            {
                ReadAttribute(ref skinLayer.Overlays.Enabled.Index, inherent, layerNode.Element("Overlays").Element("Enabled"), "Index", 0, false);
                int di = skinLayer.Overlays.Enabled.Index;
                ReadAttribute(ref skinLayer.Overlays.Hovered.Index, inherent, layerNode.Element("Overlays").Element("Hovered"), "Index", di, false);
                ReadAttribute(ref skinLayer.Overlays.Pressed.Index, inherent, layerNode.Element("Overlays").Element("Pressed"), "Index", di, false);
                ReadAttribute(ref skinLayer.Overlays.Focused.Index, inherent, layerNode.Element("Overlays").Element("Focused"), "Index", di, false);
                ReadAttribute(ref skinLayer.Overlays.Disabled.Index, inherent, layerNode.Element("Overlays").Element("Disabled"), "Index", di, false);

                ReadAttribute(ref skinLayer.Overlays.Enabled.Color, inherent, layerNode.Element("Overlays").Element("Enabled"), "Color", Color.White, false);
                Color dc = skinLayer.Overlays.Enabled.Color;
                ReadAttribute(ref skinLayer.Overlays.Hovered.Color, inherent, layerNode.Element("Overlays").Element("Hovered"), "Color", dc, false);
                ReadAttribute(ref skinLayer.Overlays.Pressed.Color, inherent, layerNode.Element("Overlays").Element("Pressed"), "Color", dc, false);
                ReadAttribute(ref skinLayer.Overlays.Focused.Color, inherent, layerNode.Element("Overlays").Element("Focused"), "Color", dc, false);
                ReadAttribute(ref skinLayer.Overlays.Disabled.Color, inherent, layerNode.Element("Overlays").Element("Disabled"), "Color", dc, false);
            }

            #endregion

            #region Text

            if (layerNode.Element("Text") != null)
            {
                ReadAttribute(ref skinLayer.Text.Name, inherent, layerNode.Element("Text"), "Font", null, true);
                ReadAttribute(ref skinLayer.Text.OffsetX, inherent, layerNode.Element("Text"), "OffsetX", 0, false);
                ReadAttribute(ref skinLayer.Text.OffsetY, inherent, layerNode.Element("Text"), "OffsetY", 0, false);

                layerAlignment = skinLayer.Text.Alignment.ToString();
                ReadAttribute(ref layerAlignment, inherent, layerNode.Element("Text"), "Alignment", "MiddleCenter", false);
                skinLayer.Text.Alignment = (Alignment)Enum.Parse(typeof(Alignment), layerAlignment, true);

                LoadColors(inherent, layerNode.Element("Text"), ref skinLayer.Text.Colors);
            }

            #endregion

            #region Attributes

            if (layerNode.Element("Attributes") != null)
            {
                foreach (var attribute in layerNode.Element("Attributes").Elements())
                {
                    if (attribute.Name == "Attribute")
                    {
                        LoadLayerAttribute(skinLayer, attribute);
                    }
                }
            }

            #endregion

            if (!inherent)
            {
                skinControl.Layers.Add(skinLayer);
            }
        } // LoadLayer
Ejemplo n.º 28
0
        } // DrawString

        public static void DrawString(Control control, SkinLayer layer, string text, Rectangle rect, ControlState state, bool margins)
        {
            DrawString(control, layer, text, rect, state, margins, 0, 0, true);
        } // DrawString
Ejemplo n.º 29
0
        } // DrawString

        public static 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);
        } // DrawString