Example #1
0
        } // DisposeManagedResources

        #endregion

        #region Draw

        /// <summary>
        /// Prerender the control into the control's render target.
        /// </summary>
        protected override void DrawControl(Rectangle rect)
        {
            if (mode == ButtonMode.PushButton && pushed)
            {
                SkinLayer l = SkinInformation.Layers["Control"];
                Renderer.DrawLayer(l, rect, l.States.Pressed.Color, l.States.Pressed.Index);
                if (l.States.Pressed.Overlay)
                {
                    Renderer.DrawLayer(l, rect, l.Overlays.Pressed.Color, l.Overlays.Pressed.Index);
                }
            }
            else
            {
                base.DrawControl(rect);
            }

            SkinLayer layer = SkinInformation.Layers["Control"];
            int ox = 0; int oy = 0;

            if (ControlState == ControlState.Pressed)
            {
                ox = 1; oy = 1;
            }
            if (glyph != null)
            {
                Margins cont = layer.ContentMargins;
                Rectangle r = new Rectangle(rect.Left + cont.Left, rect.Top + cont.Top, rect.Width - cont.Horizontal, rect.Height - cont.Vertical);
                Renderer.DrawGlyph(glyph, r);
            }
            else
            {
                Renderer.DrawString(this, layer, Text, rect, true, ox, oy);
            }
        } // DrawControl
Example #2
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
Example #3
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
Example #4
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
Example #5
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
Example #6
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
Example #7
0
        } // DisposeManagedResources

        #endregion
        
        #region Draw

        private void ClientArea_Draw(object sender, DrawEventArgs e)
        {
            SpriteFont font = SkinInformation.Layers[0].Text.Font.Font.Resource;
            Rectangle r = new Rectangle(e.Rectangle.Left, e.Rectangle.Top, e.Rectangle.Width, e.Rectangle.Height);
            int pos = 0;

            if (buffer.Count > 0)
            {
                EventedList<ConsoleMessage> b = GetFilteredBuffer(filter);
                int s = (sbVert.Value + sbVert.PageSize);
                int f = s - sbVert.PageSize;

                if (b.Count > 0)
                {
                    for (int i = s - 1; i >= f; i--)
                    {
                        {
                            int y = r.Bottom - (pos + 1) * (font.LineSpacing + 0);

                            string msg = b[i].Text;
                            string pre = "";
                            ConsoleChannel ch = channels[b[i].Channel];

                            if ((messageFormat & ConsoleMessageFormats.ChannelName) == ConsoleMessageFormats.ChannelName)
                            {
                                pre += string.Format("[{0}]", channels[b[i].Channel].Name);
                            }
                            if ((messageFormat & ConsoleMessageFormats.TimeStamp) == ConsoleMessageFormats.TimeStamp)
                            {
                                pre = string.Format("[{0}]", b[i].Time.ToLongTimeString()) + pre;
                            }

                            if (pre != "") msg = pre + ": " + msg;

                            Renderer.DrawString(font, msg, 4, y, ch.Color);
                            pos += 1;
                        }
                    }
                }
            }
        } // ClientArea_Draw
Example #8
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
Example #9
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
Example #10
0
        } // InitSkin

        #endregion
        
        #region Draw

        /// <summary>
        /// Prerender the control into the control's render target.
        /// </summary>
        protected override void DrawControl(Rectangle rect)
        {
            Renderer.DrawLayer(this, SkinInformation.Layers[0], rect);
            Renderer.DrawString(this, SkinInformation.Layers[0], Text, rect, true);
        } // DrawControl
Example #11
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
Example #12
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
Example #13
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