public static void On_Skin_Init(Skin self)
        {
            if ((graphicsTex == null) || (graphicsTex.GraphicsDevice != GnomanEmpire.Instance.GraphicsDevice) || graphicsTex.IsDisposed)
            {
                graphicsTex = CustomTextureManager.GetFromAssemblyResource(Assembly.GetExecutingAssembly(), "Faark.Gnomoria.Mods.Resources.maxButtons.png");
                //Texture2D.FromStream(GnomanEmpire.Instance.GraphicsDevice, Assembly.GetExecutingAssembly().GetManifestResourceStream( "Faark.Gnomoria.Mods.Resources.maxButtons.png"));
            }
            var maxImg = new SkinImage();
            maxImg.Resource = graphicsTex; // warning have to load it here!
            maxImg.Name = "Window.MaximizeButton";
            self.Images.Add(maxImg);

            var mySkinLayer = new SkinLayer();
            mySkinLayer.Name = "Control";
            mySkinLayer.Alignment = Alignment.MiddleLeft;
            mySkinLayer.ContentMargins = new Margins(6);
            mySkinLayer.SizingMargins = new Margins(6);
            mySkinLayer.Image = maxImg;
            mySkinLayer.Height = 28;
            mySkinLayer.Width = 28;
            mySkinLayer.States.Disabled.Index = 2;
            mySkinLayer.States.Enabled.Index = 2;
            mySkinLayer.States.Focused.Index = 0;
            mySkinLayer.States.Hovered.Index = 0;
            mySkinLayer.States.Pressed.Index = 2;
            mySkinLayer.Text = new SkinText(self.Controls["Window.CloseButton"].Layers[0].Text);

            var mySkinControl = new SkinControl();
            mySkinControl.Inherits = "Button";
            mySkinControl.ResizerSize = 4;
            mySkinControl.DefaultSize = new Size(28, 28);
            mySkinControl.Name = "Window.MaximizeButton";
            mySkinControl.Layers.Add(mySkinLayer);
            self.Controls.Add(mySkinControl);
        }
示例#2
0
        ////////////////////////////////////////////////////////////////////////////

        #endregion

        #region //// Methods ///////////

        ////////////////////////////////////////////////////////////////////////////
        public override void Init()
        {
            base.Init();

            SkinLayer lc = new SkinLayer(lblCapt.Skin.Layers[0]);

            lc.Text.Font.Resource  = Manager.Skin.Fonts[Manager.Skin.Controls["Dialog"].Layers["TopPanel"].Attributes["CaptFont"].Value].Resource;
            lc.Text.Colors.Enabled = Utilities.ParseColor(Manager.Skin.Controls["Dialog"].Layers["TopPanel"].Attributes["CaptFontColor"].Value);

            SkinLayer ld = new SkinLayer(lblDesc.Skin.Layers[0]);

            ld.Text.Font.Resource  = Manager.Skin.Fonts[Manager.Skin.Controls["Dialog"].Layers["TopPanel"].Attributes["DescFont"].Value].Resource;
            ld.Text.Colors.Enabled = Utilities.ParseColor(Manager.Skin.Controls["Dialog"].Layers["TopPanel"].Attributes["DescFontColor"].Value);

            pnlTop.Color       = Utilities.ParseColor(Manager.Skin.Controls["Dialog"].Layers["TopPanel"].Attributes["Color"].Value);
            pnlTop.BevelMargin = int.Parse(Manager.Skin.Controls["Dialog"].Layers["TopPanel"].Attributes["BevelMargin"].Value);
            pnlTop.BevelStyle  = Utilities.ParseBevelStyle(Manager.Skin.Controls["Dialog"].Layers["TopPanel"].Attributes["BevelStyle"].Value);

            lblCapt.Skin           = new SkinControl(lblCapt.Skin);
            lblCapt.Skin.Layers[0] = lc;
            lblCapt.Height         = Manager.Skin.Fonts[Manager.Skin.Controls["Dialog"].Layers["TopPanel"].Attributes["CaptFont"].Value].Height;

            lblDesc.Skin           = new SkinControl(lblDesc.Skin);
            lblDesc.Skin.Layers[0] = ld;
            lblDesc.Height         = Manager.Skin.Fonts[Manager.Skin.Controls["Dialog"].Layers["TopPanel"].Attributes["DescFont"].Value].Height;
            lblDesc.Top            = lblCapt.Top + lblCapt.Height + 4;
            lblDesc.Height         = lblDesc.Parent.ClientHeight - lblDesc.Top - 8;

            pnlBottom.Color       = Utilities.ParseColor(Manager.Skin.Controls["Dialog"].Layers["BottomPanel"].Attributes["Color"].Value);
            pnlBottom.BevelMargin = int.Parse(Manager.Skin.Controls["Dialog"].Layers["BottomPanel"].Attributes["BevelMargin"].Value);
            pnlBottom.BevelStyle  = Utilities.ParseBevelStyle(Manager.Skin.Controls["Dialog"].Layers["BottomPanel"].Attributes["BevelStyle"].Value);
        }
示例#3
0
		public override void Init() {
			base.Init();

			SkinLayer lc = new SkinLayer(lblCapt.Skin.Layers[0]);
			lc.Text.Font.Resource = Manager.Skin.Fonts[Manager.Skin.Controls["Dialog"].Layers["TopPanel"].Attributes["CaptFont"].Value].Resource;
			lc.Text.Colors.Enabled = Utilities.ParseColor(Manager.Skin.Controls["Dialog"].Layers["TopPanel"].Attributes["CaptFontColor"].Value);

			SkinLayer ld = new SkinLayer(lblDesc.Skin.Layers[0]);
			ld.Text.Font.Resource = Manager.Skin.Fonts[Manager.Skin.Controls["Dialog"].Layers["TopPanel"].Attributes["DescFont"].Value].Resource;
			ld.Text.Colors.Enabled = Utilities.ParseColor(Manager.Skin.Controls["Dialog"].Layers["TopPanel"].Attributes["DescFontColor"].Value);

			pnlTop.Color = Utilities.ParseColor(Manager.Skin.Controls["Dialog"].Layers["TopPanel"].Attributes["Color"].Value);
			pnlTop.BevelMargin = int.Parse(Manager.Skin.Controls["Dialog"].Layers["TopPanel"].Attributes["BevelMargin"].Value);
			pnlTop.BevelStyle = Utilities.ParseBevelStyle(Manager.Skin.Controls["Dialog"].Layers["TopPanel"].Attributes["BevelStyle"].Value);

			lblCapt.Skin = new SkinControl(lblCapt.Skin);
			lblCapt.Skin.Layers[0] = lc;
			lblCapt.Height = Manager.Skin.Fonts[Manager.Skin.Controls["Dialog"].Layers["TopPanel"].Attributes["CaptFont"].Value].Height;

			lblDesc.Skin = new SkinControl(lblDesc.Skin);
			lblDesc.Skin.Layers[0] = ld;
			lblDesc.Height = Manager.Skin.Fonts[Manager.Skin.Controls["Dialog"].Layers["TopPanel"].Attributes["DescFont"].Value].Height;
			lblDesc.Top = lblCapt.Top + lblCapt.Height + 4;
			lblDesc.Height = lblDesc.Parent.ClientHeight - lblDesc.Top - 8;

			pnlBottom.Color = Utilities.ParseColor(Manager.Skin.Controls["Dialog"].Layers["BottomPanel"].Attributes["Color"].Value);
			pnlBottom.BevelMargin = int.Parse(Manager.Skin.Controls["Dialog"].Layers["BottomPanel"].Attributes["BevelMargin"].Value);
			pnlBottom.BevelStyle = Utilities.ParseBevelStyle(Manager.Skin.Controls["Dialog"].Layers["BottomPanel"].Attributes["BevelStyle"].Value);
		}
示例#4
0
文件: Label.cs 项目: KtBkkr/Asteria
        protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
        {
            //base.DrawControl(renderer, rect, gameTime);

            SkinLayer s = new SkinLayer(Skin.Layers[0]);
            s.Text.Alignment = alignment;
            renderer.DrawString(this, s, Text, rect, true, 0, 0, ellipsis);
        }
示例#5
0
        /// <summary>
        /// Draws the list pane containing the collection items.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public override void DrawPane(object sender, DrawEventArgs e)
        {
            // Collection is non-empty?
            if (items != null && items.Count > 0)
            {
                SkinText  font = Skin.Layers["Control"].Text;
                SkinLayer sel  = Skin.Layers["ListBox.Selection"];
                int       h    = (items[0] as T).Height;
                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;
                // Draw selection overlay?
                if (s >= 0 && s < c && (Focused || !hideSelection))
                {
                    int pos = -d + ((s - v) * h);

                    // Selected index is visible?
                    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));
                    }
                }
                // Draw the visible collection items in the list pane.
                for (int i = v; i <= v + p + 1; i++)
                {
                    if (i < c)
                    {
                        foreach (Control ctr in (items[i] as T).Controls)
                        {
                            ctr.DrawControl(e.Renderer, new Rectangle(e.Rectangle.Left + ctr.Left, (e.Rectangle.Top - d + ((i - v) * h)) + ctr.Top, e.Rectangle.Width, h), e.GameTime);
                        }
                    }
                }
                // Draw selection overlay?
                if (s >= 0 && s < c && (Focused || !hideSelection))
                {
                    int pos = -d + ((s - v) * h);

                    // Selected index is visible?
                    if (pos > -h && pos < (p + 1) * h)
                    {
                        e.Renderer.DrawLayer(sel, new Rectangle(e.Rectangle.Left, e.Rectangle.Top + pos, e.Rectangle.Width, h), Color.White * .2f, 0);
                    }
                }
            }
        }
示例#6
0
        void DrawStrings(DrawEventArgs e, Control control, SkinLayer layer, String[] str, Rectangle rectangle, bool margins)
        {
            Rectangle rect = rectangle;

            for (int i = 0; i < Headers.HeaderButtons.Count; i++)
            {
                //Section off each "cell"
                rect.X     = Headers.HeaderButtons[i].Left;
                rect.Width = Headers.HeaderButtons[i].Width;

                //Draw a line on top, draw the string, draw a line on the bottom, draw a line on the left
                e.Renderer.Draw(line, new Rectangle(rect.X - 2, rect.Y, rect.Width, 1), Color.Black);
                e.Renderer.DrawString(control, layer, " " + str[i], rect, margins);
                e.Renderer.Draw(line, new Rectangle(rect.X - 2, rect.Y + rect.Height, rect.Width, 1), Color.Black);
                e.Renderer.Draw(line, new Rectangle(rect.X - 2, rect.Y, 1, rect.Height), Color.Black);
            }
        }
示例#7
0
        protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
        {
            base.DrawControl(renderer, rect, gameTime);

            SkinLayer layer = Skin.Layers["Control"];

            if (Text != null && Text != "")
            {
                int width = (int)layer.Text.Font.Resource.MeasureString(Text).X;
                int ox    = 5;

                if (width < this.Width)
                {
                    ox = (this.Width - width) / 2;
                }
                renderer.DrawString(this, layer, Text, rect, true, ox, 0);
            }
        }
示例#8
0
        ////////////////////////////////////////////////////////////////////////////

        ////////////////////////////////////////////////////////////////////////////
        protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
        {
            // We draw the control the same way the ancestor does.
            // In this case, ancestor draws all states automatically according to description in the skin file.
            base.DrawControl(renderer, rect, gameTime);

            SkinLayer layer = Skin.Layers[lrButton];
            int       ox = 0; int oy = 0;

            // We want to have the text pushed a bit down, when we press the button
            if (ControlState == ControlState.Pressed)
            {
                ox = 1; oy = 1;
            }

            // Now we draw text over our control. This method does it automatically,
            // based on the description in the skin file.
            // We use our pressed-state offset for text position.
            renderer.DrawString(this, layer, Text, rect, true, ox, oy);
        }
示例#9
0
        public static void On_Skin_Init(Skin self)
        {
            if ((graphicsTex == null) || (graphicsTex.GraphicsDevice != GnomanEmpire.Instance.GraphicsDevice) || graphicsTex.IsDisposed)
            {
                graphicsTex = CustomTextureManager.GetFromAssemblyResource(Assembly.GetExecutingAssembly(), "Faark.Gnomoria.Mods.Resources.maxButtons.png");
                //Texture2D.FromStream(GnomanEmpire.Instance.GraphicsDevice, Assembly.GetExecutingAssembly().GetManifestResourceStream( "Faark.Gnomoria.Mods.Resources.maxButtons.png"));
            }
            var maxImg = new SkinImage();

            maxImg.Resource = graphicsTex; // warning have to load it here!
            maxImg.Name     = "Window.MaximizeButton";
            self.Images.Add(maxImg);

            var mySkinLayer = new SkinLayer();

            mySkinLayer.Name                  = "Control";
            mySkinLayer.Alignment             = Alignment.MiddleLeft;
            mySkinLayer.ContentMargins        = new Margins(6);
            mySkinLayer.SizingMargins         = new Margins(6);
            mySkinLayer.Image                 = maxImg;
            mySkinLayer.Height                = 28;
            mySkinLayer.Width                 = 28;
            mySkinLayer.States.Disabled.Index = 2;
            mySkinLayer.States.Enabled.Index  = 2;
            mySkinLayer.States.Focused.Index  = 0;
            mySkinLayer.States.Hovered.Index  = 0;
            mySkinLayer.States.Pressed.Index  = 2;
            mySkinLayer.Text                  = new SkinText(self.Controls["Window.CloseButton"].Layers[0].Text);

            var mySkinControl = new SkinControl();

            mySkinControl.Inherits    = "Button";
            mySkinControl.ResizerSize = 4;
            mySkinControl.DefaultSize = new Size(28, 28);
            mySkinControl.Name        = "Window.MaximizeButton";
            mySkinControl.Layers.Add(mySkinLayer);
            self.Controls.Add(mySkinControl);
        }
示例#10
0
        ////////////////////////////////////////////////////////////////////////////

        ////////////////////////////////////////////////////////////////////////////
        protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
        {
            SkinLayer l = Skin.Layers[0];

            // We render background of the tooltip
            renderer.DrawLayer(this, l, rect);

            Rectangle rc1 = Rectangle.Empty;

            if (image != null)
            {
                // Now we draw image in the left top corner of the tooltip
                rc1 = new Rectangle(l.ContentMargins.Left, l.ContentMargins.Top + 4, IconSize, IconSize);
                renderer.Draw(image, rc1, Color.White);
            }

            // Text is rendered next to the image
            rect = new Rectangle(rc1.Right, rect.Top + 4, rect.Width, rect.Height);

            // We alter text alignment from the default skin
            l.Text.Alignment = Alignment.TopLeft;
            renderer.DrawString(this, l, Text, rect, true);
        }
示例#11
0
 ////////////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////////////
 public virtual void DrawString(Control control, SkinLayer layer, string text, Rectangle rect, ControlState state, bool margins, int ox, int oy)
 {
     DrawString(control, layer, text, rect, state, margins, ox, oy, true);
 }
示例#12
0
 ////////////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////////////
 public virtual void DrawString(Control control, SkinLayer layer, string text, Rectangle rect, bool margins)
 {
     DrawString(control, layer, text, rect, margins, 0, 0, true);
 }
示例#13
0
 ////////////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////////////
 public virtual void DrawString(Control control, SkinLayer layer, string text, Rectangle rect, ControlState state)
 {
     DrawString(control, layer, text, rect, state, true, 0, 0, true);
 }
示例#14
0
        ////////////////////////////////////////////////////////////////////////////   
        ////////////////////////////////////////////////////////////////////////////    
        public virtual void DrawLayer(Control control, SkinLayer layer, Rectangle rect, ControlState state)
        {
            Color c = Color.White;
            Color oc = Color.White;
            int i = 0;
            int oi = -1;
            SkinLayer l = layer;

            if (state == ControlState.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 == ControlState.Focused || (control.Focused && state == ControlState.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 == ControlState.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 == ControlState.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);
            }
        }
示例#15
0
 ////////////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////////////
 public virtual void DrawLayer(Control control, SkinLayer layer, Rectangle rect)
 {
     DrawLayer(control, layer, rect, control.ControlState);
 }
示例#16
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, Alignment.TopLeft), GetSourceArea(imageSize, partSize, layer.SizingMargins, Alignment.TopLeft, index), color);
            Draw(layer.Image.Resource, GetDestinationArea(rect, layer.SizingMargins, Alignment.TopCenter), GetSourceArea(imageSize, partSize, layer.SizingMargins, Alignment.TopCenter, index), color);
            Draw(layer.Image.Resource, GetDestinationArea(rect, layer.SizingMargins, Alignment.TopRight), GetSourceArea(imageSize, partSize, layer.SizingMargins, Alignment.TopRight, index), color);
            Draw(layer.Image.Resource, GetDestinationArea(rect, layer.SizingMargins, Alignment.MiddleLeft), GetSourceArea(imageSize, partSize, layer.SizingMargins, Alignment.MiddleLeft, index), color);
            Draw(layer.Image.Resource, GetDestinationArea(rect, layer.SizingMargins, Alignment.MiddleCenter), GetSourceArea(imageSize, partSize, layer.SizingMargins, Alignment.MiddleCenter, index), color);
            Draw(layer.Image.Resource, GetDestinationArea(rect, layer.SizingMargins, Alignment.MiddleRight), GetSourceArea(imageSize, partSize, layer.SizingMargins, Alignment.MiddleRight, index), color);
            Draw(layer.Image.Resource, GetDestinationArea(rect, layer.SizingMargins, Alignment.BottomLeft), GetSourceArea(imageSize, partSize, layer.SizingMargins, Alignment.BottomLeft, index), color);
            Draw(layer.Image.Resource, GetDestinationArea(rect, layer.SizingMargins, Alignment.BottomCenter), GetSourceArea(imageSize, partSize, layer.SizingMargins, Alignment.BottomCenter, index), color);
            Draw(layer.Image.Resource, GetDestinationArea(rect, layer.SizingMargins, Alignment.BottomRight), GetSourceArea(imageSize, partSize, layer.SizingMargins, Alignment.BottomRight, index), color);
        }
示例#17
0
        public void CreateTopPanel()
        {
            pnlTop = new Panel(Manager);
            pnlTop.Anchor = Anchors.Left | Anchors.Top | Anchors.Right;
            pnlTop.Init();
            pnlTop.Parent = this;
            pnlTop.Width = ClientWidth;
            pnlTop.Height = 64;
            pnlTop.BevelBorder = BevelBorder.Bottom;

            lblCapt = new Label(Manager);
            lblCapt.Init();
            lblCapt.Parent = pnlTop;
            lblCapt.Width = lblCapt.Parent.ClientWidth - 16;
            lblCapt.Text = "Caption";
            lblCapt.Left = 8;
            lblCapt.Top = 8;
            lblCapt.Alignment = Alignment.TopLeft;
            lblCapt.Anchor = Anchors.Left | Anchors.Top | Anchors.Right;

            lblDesc = new Label(Manager);
            lblDesc.Init();
            lblDesc.Parent = pnlTop;
            lblDesc.Width = lblDesc.Parent.ClientWidth - 16;
            lblDesc.Left = 8;
            lblDesc.Text = "Description text.";
            lblDesc.Alignment = Alignment.TopLeft;
            lblDesc.Anchor = Anchors.Left | Anchors.Top | Anchors.Right;

            SkinLayer dialogSkinLayer = Manager.Skin.GetSkinControlLayer("Dialog", "TopPanel");

            SkinLayer lc = new SkinLayer(lblCapt.Skin.Layers[0]);
            lc.Text.Font.Resource = Manager.Skin.Fonts[dialogSkinLayer.Attributes["CaptFont"].Value].Resource;
            lc.Text.Colors.Enabled = Utilities.ParseColor(dialogSkinLayer.Attributes["CaptFontColor"].Value);

            SkinLayer ld = new SkinLayer(lblDesc.Skin.Layers[0]);
            ld.Text.Font.Resource = Manager.Skin.Fonts[dialogSkinLayer.Attributes["DescFont"].Value].Resource;
            ld.Text.Colors.Enabled = Utilities.ParseColor(dialogSkinLayer.Attributes["DescFontColor"].Value);

            pnlTop.Color = Utilities.ParseColor(dialogSkinLayer.Attributes["Color"].Value);
            pnlTop.BevelMargin = int.Parse(dialogSkinLayer.Attributes["BevelMargin"].Value);
            pnlTop.BevelStyle = Utilities.ParseBevelStyle(dialogSkinLayer.Attributes["BevelStyle"].Value);

            lblCapt.Skin = new SkinControl(lblCapt.Skin);
            lblCapt.Skin.Layers[0] = lc;
            lblCapt.Height = Manager.Skin.Fonts[dialogSkinLayer.Attributes["CaptFont"].Value].Height;

            lblDesc.Skin = new SkinControl(lblDesc.Skin);
            lblDesc.Skin.Layers[0] = ld;
            lblDesc.Height = Manager.Skin.Fonts[dialogSkinLayer.Attributes["DescFont"].Value].Height;
            lblDesc.Top = lblCapt.Top + lblCapt.Height + 4;
            lblDesc.Height = lblDesc.Parent.ClientHeight - lblDesc.Top - 8;
        }
示例#18
0
        /// <summary>
        /// Draws the specified layer of the control in the defined region.
        /// </summary>
        /// <param name="control">Control to draw the layer of.</param>
        /// <param name="layer">Skin layer of the control to draw.</param>
        /// <param name="rect">Destination region where the control layer will be drawn.</param>
        /// <param name="state">Control state to apply to the layer.</param>
        public virtual void DrawLayer(Control control, SkinLayer layer, Rectangle rect, ControlState state)
        {
            // Get the layer color and overlay color.
            Color c = Color.White;
            Color oc = Color.White;

            // And the index to the layer and overlay image assets.
            int i = 0;
            int oi = -1;
            SkinLayer l = layer;

            // Use the hovered state colors and assets?
            if (state == ControlState.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;
                }
            }

            // Use the focused state colors and assets?
            else if (state == ControlState.Focused || (control.Focused && state == ControlState.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;
                }
            }

            // Use the pressed state colors and assets?
            else if (state == ControlState.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;
                }
            }

            // Use the disabled state colors and assets?
            else if (state == ControlState.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;
                }
            }

            // Use the enabled state colors and assets?
            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;
                }
            }

            // Override layer color with control color?
            if (control.Color != Control.UndefinedColor)
            {
                c = control.Color * (control.Color.A / 255f);
            }

            // Draw the control layer.
            DrawLayer(l, rect, c, i);

            // And draw the overlay if needed.
            if (oi != -1)
            {
                DrawLayer(l, rect, oc, oi);
            }
        }
示例#19
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);
 }
示例#20
0
        /// <summary>
        /// Draws the text in the supplied region on the specified layer of the control
        /// </summary>
        /// <param name="control">Control to draw the text on.</param>
        /// <param name="layer">Control layer to draw the text on.</param>
        /// <param name="text">Text to draw.</param>
        /// <param name="rect">Destination region where text should be drawn.</param>
        /// <param name="state">Control state to get the text color from.</param>
        /// <param name="margins">Respect the control margins when positioning text?</param>
        /// <param name="ox">X offset to apply when positioning text in the defined region.</param>
        /// <param name="oy">Y offset to apply when positioning text in the defined region.</param>
        /// <param name="ellipsis">Indicates if text that doesn't fit in the specified region should be truncated with "..."</param>
        public virtual void DrawString(Control control, SkinLayer layer, string text, Rectangle rect, ControlState state, bool margins, int ox, int oy, bool ellipsis)
        {
            Color col = Color.White;

            // Layer has text component defined?
            if (layer.Text != null)
            {
                // And it has margins?
                if (margins)
                {
                    // Grab the layer's margins and update the destination region to account for them.
                    Margins m = layer.ContentMargins;
                    rect = new Rectangle(rect.Left + m.Left, rect.Top + m.Top, rect.Width - m.Horizontal, rect.Height - m.Vertical);
                }

                // Grab the text color of the Hovered state?
                if (state == ControlState.Hovered && (layer.States.Hovered.Index != -1))
                {
                    col = layer.Text.Colors.Hovered;
                }

                // Grab the text color of the Pressed state?
                else if (state == ControlState.Pressed)
                {
                    col = layer.Text.Colors.Pressed;
                }

                // Grab the text color of the Focused state?
                else if (state == ControlState.Focused || (control.Focused && state == ControlState.Hovered && layer.States.Hovered.Index == -1))
                {
                    col = layer.Text.Colors.Focused;
                }

                // Grab the text color of the Disabled state?
                else if (state == ControlState.Disabled)
                {
                    col = layer.Text.Colors.Disabled;
                }

                // Grab the text color of the Enabled state.
                else
                {
                    col = layer.Text.Colors.Enabled;
                }

                // Valid text string supplied?
                if (text != null && text != "")
                {
                    SkinText font = layer.Text;

                    // Control has a defined color to override if not disabled?
                    if (control.TextColor != Control.UndefinedColor && control.ControlState != ControlState.Disabled)
                    {
                        col = control.TextColor;
                    }

                    // Pass the updated arguments off to the real draw function.
                    DrawString(font.Font.Resource, text, rect, col, font.Alignment, font.OffsetX + ox, font.OffsetY + oy, ellipsis);
                }
            }
        }
示例#21
0
        void DrawStrings(DrawEventArgs e, Control control, SkinLayer layer, String[] str, Rectangle rectangle, bool margins)
        {
            Rectangle rect = rectangle;

            for (int i = 0; i < Headers.HeaderButtons.Count; i++)
            {
                //Section off each "cell"
                rect.X = Headers.HeaderButtons[i].Left;
                rect.Width = Headers.HeaderButtons[i].Width;

                //Draw a line on top, draw the string, draw a line on the bottom, draw a line on the left
                e.Renderer.Draw(line, new Rectangle(rect.X - 2, rect.Y, rect.Width, 1), Color.Black);
                e.Renderer.DrawString(control, layer, " " + str[i], rect, margins);
                e.Renderer.Draw(line, new Rectangle(rect.X - 2, rect.Y+rect.Height, rect.Width, 1), Color.Black);
                e.Renderer.Draw(line, new Rectangle(rect.X - 2, rect.Y, 1, rect.Height), Color.Black);
            }
        }
示例#22
0
        ////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////
        public virtual void DrawString(Control control, SkinLayer layer, string text, Rectangle rect, ControlState 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 == ControlState.Hovered && (layer.States.Hovered.Index != -1))
                {
                    col = layer.Text.Colors.Hovered;
                }
                else if (state == ControlState.Pressed)
                {
                    col = layer.Text.Colors.Pressed;
                }
                else if (state == ControlState.Focused || (control.Focused && state == ControlState.Hovered && layer.States.Hovered.Index == -1))
                {
                    col = layer.Text.Colors.Focused;
                }
                else if (state == ControlState.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 != ControlState.Disabled) col = control.TextColor;
                    if(control.Font != null)
                        DrawString(control.Font, text, rect, col, font.Alignment, font.OffsetX + ox, font.OffsetY + oy, ellipsis);
                    else
                        DrawString(font.Font.Resource, text, rect, col, font.Alignment, font.OffsetX + ox, font.OffsetY + oy, ellipsis);
                }
            }
        }
示例#23
0
        public static void OnSet_Window_Resizable(Window self, bool newState)
        {
            var oldState = self.Resizable;

            if (newState != oldState)
            {
                if (newState)
                {
                    CurrentSelf              = self;
                    CurrentWinMaxButton      = new Button(self.Manager);
                    CurrentWinMaxButton.Skin = new SkinControl(self.Manager.Skin.Controls["Window.MaximizeButton"]);
                    CurrentWinMaxButton.Init();
                    CurrentWinMaxButton.Detached = true;
                    CurrentWinMaxButton.CanFocus = false;
                    CurrentWinMaxButton.Text     = null;
                    CurrentWinMaxButton.Click   += new Game.GUI.Controls.EventHandler((sender, args) =>
                    {
                        Rectangle initalPos;
                        if (!initialWindowPositions.TryGetValue(self.GetType(), out initalPos))
                        {
                            initalPos = initialWindowPositions[self.GetType()] = new Rectangle(self.Left, self.Top, self.Width, self.Height);
                        }

                        var isMax = true;

                        if (((self.ResizeEdge & Anchors.Top) == Anchors.Top) || ((self.ResizeEdge & Anchors.Bottom) == Anchors.Bottom))
                        {
                            //var h = Math.Min(self.MaximumHeight, self.Manager.TargetHeight);
                            //var half_h = (self.Manager.TargetHeight / 2) - (Math.Min(self.MaximumHeight, self.Manager.TargetHeight) / 2);
                            var top    = Math.Max(100, (int)(self.Manager.TargetHeight * 0.1f));
                            var bottom = Math.Max(60, (int)(self.Manager.TargetHeight * 0.09f));
                            var height = Math.Min(self.MaximumHeight, self.Manager.TargetHeight - top - bottom);
                            if ((self.Top != top) || (self.Height != height))
                            {
                                isMax       = false;
                                self.Top    = top;
                                self.Height = height;
                            }
                        }
                        if (((self.ResizeEdge & Anchors.Left) == Anchors.Left) || ((self.ResizeEdge & Anchors.Right) == Anchors.Right))
                        {
                            var w    = Math.Min((int)(self.Manager.TargetWidth * 0.8f), self.MaximumWidth);
                            var left = (int)(self.Manager.TargetWidth * 0.1f);
                            if ((self.Left != left) || (self.Width != w))
                            {
                                self.Left  = left;
                                self.Width = w;
                                isMax      = false;
                            }
                        }

                        if (isMax)
                        {
                            self.Top    = initalPos.Top;
                            self.Left   = initalPos.Left;
                            self.Width  = initalPos.Width;
                            self.Height = initalPos.Height;
                        }
                    });
                    var       closeSkin = self.Manager.Skin.Controls["Window.MaximizeButton"];
                    SkinLayer skinLayer = closeSkin.Layers["Control"];
                    CurrentWinMaxButton.Width  = skinLayer.Width;
                    CurrentWinMaxButton.Height = skinLayer.Height - closeSkin.OriginMargins.Vertical;
                    CurrentWinMaxButton.Left   = self.OriginWidth - self.Skin.OriginMargins.Right - skinLayer.Width - closeSkin.OriginMargins.Horizontal + skinLayer.OffsetX - CurrentWinMaxButton.Width;
                    CurrentWinMaxButton.Top    = self.Skin.OriginMargins.Top + skinLayer.OffsetY;
                    CurrentWinMaxButton.Anchor = (Anchors.Top | Anchors.Right);
                    self.Add(CurrentWinMaxButton, false);
                }
                else
                {
                    if (self == CurrentSelf)
                    {
                        self.Remove(CurrentWinMaxButton);
                        CurrentWinMaxButton = null;
                        CurrentSelf         = null;
                    }
                }
            }
        }