示例#1
0
        public override void PaintControl(RichTextBox control, ControlPaintArgs args)
        {
            INode    controlNode = new ControlNode(control);
            IRuleset ruleset     = args.StyleSheet.GetRuleset(controlNode);

            RenderUtilities.ApplyColorProperties(control, ruleset);

            Rectangle clientRect = control.ClientRectangle;
            Rectangle borderRect = new Rectangle(clientRect.X - 3, clientRect.Y - 3, clientRect.Width + 6, clientRect.Height + 6);

            ScrollBars visibleScrollbars = ControlUtilities.GetVisibleScrollBars(control);

            if (visibleScrollbars.HasFlag(ScrollBars.Vertical))
            {
                borderRect = new Rectangle(borderRect.X, borderRect.Y, borderRect.Width + SystemInformation.VerticalScrollBarWidth, borderRect.Height);
            }

            if (visibleScrollbars.HasFlag(ScrollBars.Horizontal))
            {
                borderRect = new Rectangle(borderRect.X, borderRect.Y, borderRect.Width, borderRect.Height + SystemInformation.HorizontalScrollBarHeight);
            }

            args.PaintBackground(borderRect);
            args.PaintBorder(borderRect);
        }
        // Public members

        public override void PaintControl(GroupBox control, ControlPaintArgs e)
        {
            IRuleset ruleset = e.StyleSheet.GetRuleset(control);

            IRuleset textBackgroundRuleset = new Ruleset();

            textBackgroundRuleset.AddProperty(ruleset.BackgroundColor);

            SizeF textSize = e.Graphics.MeasureString(control.Text, control.Font);

            Rectangle clientRect         = control.ClientRectangle;
            Rectangle backgroundRect     = new Rectangle(clientRect.X, clientRect.Y + (int)textSize.Height / 2, clientRect.Width, clientRect.Height - (int)textSize.Height / 2);
            Rectangle textRect           = new Rectangle(clientRect.X + 6, clientRect.Y, (int)textSize.Width, (int)textSize.Height);
            Rectangle textBackgroundRect = new Rectangle(textRect.X, backgroundRect.Y, textRect.Width, textRect.Height - (int)textSize.Height / 2);

            e.Clear();

            e.StyleRenderer.PaintBackground(e.Graphics, backgroundRect, ruleset);
            e.StyleRenderer.PaintBorder(e.Graphics, backgroundRect, ruleset);

            e.StyleRenderer.PaintBackground(e.Graphics, textBackgroundRect, textBackgroundRuleset);
            e.StyleRenderer.PaintBorder(e.Graphics, textBackgroundRect, textBackgroundRuleset);

            e.StyleRenderer.PaintText(e.Graphics, textRect, ruleset, control.Text, control.Font, TextFormatFlags.Top);
        }
        // Private members

        private void PaintItems(ListBox control, ControlPaintArgs e)
        {
            for (int i = 0; i < control.Items.Count; ++i)
            {
                PaintItem(control, e, i);
            }
        }
        // Private members

        private void PaintDropDownArrow(ComboBox control, ControlPaintArgs e)
        {
            INode    controlNode       = new ControlNode(control);
            UserNode dropDownArrowNode = new UserNode(string.Empty, new[] { "DropDownArrow" });

            dropDownArrowNode.SetParent(controlNode);
            dropDownArrowNode.SetStates(controlNode.States);

            IRuleset ruleset = e.StyleSheet.GetRuleset(dropDownArrowNode);

            // Create the arrow rectangle to match the bounds of the default control.

            Rectangle clientRect = control.ClientRectangle;
            Rectangle arrowRect  = new Rectangle(clientRect.Right - 12, clientRect.Y + 9, 7, 6);

            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;

            using (Pen pen = new Pen(ruleset.Color?.Value ?? SystemColors.ControlText)) {
                pen.Width     = 2.0f;
                pen.Alignment = PenAlignment.Center;
                pen.StartCap  = LineCap.Flat;
                pen.EndCap    = LineCap.Flat;

                PointF bottomMidpoint = new PointF(arrowRect.Left + arrowRect.Width / 2.0f, arrowRect.Bottom - 1);

                e.Graphics.DrawLine(pen, new PointF(arrowRect.Left, arrowRect.Top), bottomMidpoint);
                e.Graphics.DrawLine(pen, new PointF(arrowRect.Right, arrowRect.Top), bottomMidpoint);
            }
        }
示例#5
0
        private void PaintGenericControl(ControlPaintArgs e)
        {
            IRuleset ruleset = e.StyleSheet.GetRuleset(new ControlNode(e.Control));

            RenderUtilities.ApplyColorProperties(e.Control, ruleset);

            e.PaintBackground();
            e.PaintBorder();
        }
        // Public members

        public override void PaintControl(ProgressBar control, ControlPaintArgs args)
        {
            args.PaintBackground();
            args.PaintBorder();

            args.ClipToBorder();

            PaintProgress(control, args);
        }
示例#7
0
        private void PaintLines(TreeView control, TreeNodeCollection nodes, ControlPaintArgs args)
        {
            const int buttonWidth = 9;

            if (control.ShowLines && control.Nodes.Count > 0)
            {
                if (control.ShowRootLines || nodes[0].Level != 0)
                {
                    UserNode lineNode = new UserNode(string.Empty, new[] { "Lines" });

                    lineNode.SetParent(new ControlNode(control));

                    IRuleset lineRuleset = args.StyleSheet.GetRuleset(lineNode);

                    Color lineColor = lineRuleset.Color?.Value ?? Color.Black;

                    using (Pen linePen = new Pen(lineColor)) {
                        linePen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;

                        // Draw a line from the first node down to the last node.

                        TreeNode firstNode = nodes[0];
                        TreeNode lastNode  = nodes[nodes.Count - 1];

                        int x1 = firstNode.Bounds.X - 8;
                        int x2 = x1;
                        int y1 = firstNode.Bounds.Y + (firstNode.Nodes.Count > 0 ? buttonWidth - 1 : 2);
                        int y2 = lastNode.Bounds.Y + (firstNode.Nodes.Count > 0 ? buttonWidth - 1 : 13);

                        args.Graphics.DrawLine(linePen, new Point(x1, y1), new Point(x2, y2));

                        // Draw horizontal lines connecting the vertical line to each of the nodes.

                        foreach (TreeNode childNode in nodes)
                        {
                            x1 = firstNode.Bounds.X - buttonWidth + 1;
                            x2 = childNode.Bounds.X + 2;
                            y1 = childNode.Bounds.Y + 12;
                            y2 = y1;

                            args.Graphics.DrawLine(linePen, new Point(x1, y1), new Point(x2, y2));
                        }
                    }
                }

                // Draw lines for the child nodes.

                foreach (TreeNode node in nodes)
                {
                    if (node.IsExpanded)
                    {
                        PaintLines(control, node.Nodes, args);
                    }
                }
            }
        }
示例#8
0
        public override void PaintControl(PictureBox control, ControlPaintArgs args)
        {
            args.PaintBackground();

            if (control.Image != null)
            {
                args.Graphics.DrawImage(control.Image, new Rectangle(0, 0, control.Width, control.Height), (ImageSizeMode)control.SizeMode);
            }

            args.PaintBorder();
        }
        // Private members

        private void PaintButton(ControlPaintArgs e, Rectangle clientRect, TriangleOrientation arrowOrientation, IRuleset ruleset)
        {
            e.StyleRenderer.PaintBackground(e.Graphics, clientRect, ruleset);
            e.StyleRenderer.PaintBorder(e.Graphics, clientRect, ruleset);

            clientRect.Inflate(new Size(-5, -3));
            clientRect.Offset(1, 0);

            using (Brush brush = new SolidBrush(ruleset.Color?.Value ?? Color.Black))
                e.Graphics.FillTriangle(brush, clientRect, arrowOrientation);
        }
示例#10
0
        // Public members

        public override void PaintControl(TabControl control, ControlPaintArgs e)
        {
            // Paint the background.

            e.PaintBackground();
            e.PaintBorder();

            // Paint the tabs.

            PaintTabs(control, e);
        }
示例#11
0
        // Public members

        public override void PaintControl(NumericUpDown control, ControlPaintArgs e)
        {
            IRuleset ruleset = e.StyleSheet.GetRuleset(control);

            // Update the color of the NumericUpdateDown, which updates the color of the UpDownEdit (inheriting from TextBox).

            RenderUtilities.ApplyColorProperties(control, ruleset);

            // Like TextBoxes, NumericUpDowns are 23 pixels high.
            // Because the NumericUpDown has BorderStyle.None, we need to adjust it to look like a bordered control.

            Rectangle clientRect = control.ClientRectangle;

            int x = clientRect.X - 2;
            int y = clientRect.Y - 2;
            int w = clientRect.Width + 3;
            int h = clientRect.Height + 4;

            double topWidth    = ruleset.BorderTopWidth?.Value ?? 0;
            double rightWidth  = ruleset.BorderRightWidth?.Value ?? 0;
            double bottomWidth = ruleset.BorderBottomWidth?.Value ?? 0;
            double leftWidth   = ruleset.BorderLeftWidth?.Value ?? 0;

            if (topWidth <= 1)
            {
                topWidth = 0;
            }

            if (rightWidth <= 1)
            {
                rightWidth = 0;
            }

            if (bottomWidth <= 1)
            {
                bottomWidth = 0;
            }

            if (leftWidth <= 1)
            {
                leftWidth = 0;
            }

            x -= (int)leftWidth;
            y -= (int)topWidth;
            w += (int)leftWidth + (int)rightWidth;
            h += (int)topWidth + (int)bottomWidth;

            Rectangle drawRect = new Rectangle(x, y, w, h);

            e.StyleRenderer.PaintBackground(e.Graphics, drawRect, ruleset);
            e.StyleRenderer.PaintBorder(e.Graphics, drawRect, ruleset);
        }
        private void PaintProgress(ProgressBar control, ControlPaintArgs args)
        {
            double progress = (double)control.Value / control.Maximum;

            IRuleset progressRuleset = GetProgressRuleset(control, args);

            Rectangle clientRect   = control.ClientRectangle;
            Rectangle progressRect = new Rectangle(clientRect.X, clientRect.Y, (int)Math.Floor(clientRect.Width * progress), clientRect.Height);

            args.StyleRenderer.PaintBackground(args.Graphics, progressRect, progressRuleset);
            args.StyleRenderer.PaintBorder(args.Graphics, progressRect, progressRuleset);
        }
示例#13
0
        // Private members

        private void PaintTabs(TabControl control, ControlPaintArgs e)
        {
            if (control.TabPages.Count > 0)
            {
                for (int i = 0; i < control.TabPages.Count; ++i)
                {
                    TabPage   tabPage = control.TabPages[i];
                    Rectangle tabRect = control.GetTabRect(i);
                    UserNode  tabNode = new UserNode(tabRect, control.PointToClient(Cursor.Position));

                    tabNode.SetParent(new ControlNode(control));
                    tabNode.AddClass("tab");

                    if (i == 0)
                    {
                        tabRect = new Rectangle(tabRect.X + 2, tabRect.Y, tabRect.Width - 2, tabRect.Height);
                    }

                    if (control.SelectedIndex == i)
                    {
                        // Draw selected tab.

                        tabNode.AddState(NodeStates.Checked);

                        IRuleset tabRuleset = e.StyleSheet.GetRuleset(tabNode);

                        Rectangle drawRect = new Rectangle(tabRect.X - 2, tabRect.Y - 2, tabRect.Width + 2, tabRect.Height + 4);
                        Rectangle textRect = new Rectangle(tabRect.X, tabRect.Y - 2, tabRect.Width, tabRect.Height);

                        if (i == 0)
                        {
                            drawRect = new Rectangle(drawRect.X + 2, drawRect.Y, drawRect.Width - 2, drawRect.Height);
                        }

                        e.StyleRenderer.PaintBackground(e.Graphics, drawRect, tabRuleset);
                        e.StyleRenderer.PaintBorder(e.Graphics, drawRect, tabRuleset);
                        e.StyleRenderer.PaintText(e.Graphics, textRect, tabRuleset, tabPage.Text, control.Font, textFormatFlags: TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter);
                    }
                    else
                    {
                        // Draw unselected tab.

                        IRuleset tabRuleset = e.StyleSheet.GetRuleset(tabNode);

                        Rectangle drawRect = new Rectangle(tabRect.X, tabRect.Y, tabRect.Width, tabRect.Height + 2);

                        e.StyleRenderer.PaintBackground(e.Graphics, drawRect, tabRuleset);
                        e.StyleRenderer.PaintBorder(e.Graphics, drawRect, tabRuleset);
                        e.StyleRenderer.PaintText(e.Graphics, tabRect, tabRuleset, tabPage.Text, control.Font, textFormatFlags: TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter);
                    }
                }
            }
        }
示例#14
0
        // Public members

        public override void PaintControl(Control control, ControlPaintArgs e)
        {
            IControlRenderer renderer = GetRenderer(control);

            if (renderer is null)
            {
                PaintGenericControl(e);
            }
            else
            {
                renderer.PaintControl(control, e);
            }
        }
示例#15
0
        // Protected members

        protected virtual void PaintBackground(TreeView control, ControlPaintArgs args)
        {
            IRuleset  ruleset    = args.StyleSheet.GetRuleset(control);
            Rectangle borderRect = RenderUtilities.GetOuterBorderRectangle(control, ruleset);

            if (ruleset.BackgroundColor.HasValue() && ruleset.BackgroundColor.Value != control.BackColor)
            {
                control.BackColor = ruleset.BackgroundColor.Value;
            }

            args.PaintBackground(borderRect);
            args.PaintBorder(borderRect);
        }
        // Public members

        public override void PaintControl(CheckBox control, ControlPaintArgs e)
        {
            e.PaintBackground();
            e.PaintBorder();

            PaintCheck(control, e);

            IRuleset ruleset = e.StyleSheet.GetRuleset(control);

            Rectangle clientRect = control.ClientRectangle;
            Rectangle drawRect   = new Rectangle(clientRect.X + CheckWidth + 3, clientRect.Y - 1, clientRect.Width, clientRect.Height);

            e.StyleRenderer.PaintText(e.Graphics, drawRect, ruleset, control.Text, control.Font, ControlUtilities.GetTextFormatFlags(control.TextAlign));
        }
        public override void PaintControl(DataGridView control, ControlPaintArgs args)
        {
            // Draw the background/border of the control.

            IRuleset  ruleset    = args.StyleSheet.GetRuleset(control);
            Rectangle borderRect = RenderUtilities.GetOuterBorderRectangle(control, ruleset);

            if (ruleset.BackgroundColor.HasValue() && ruleset.BackgroundColor.Value != control.BackColor)
            {
                control.BackgroundColor = ruleset.BackgroundColor.Value;
            }

            args.PaintBackground(borderRect);
            args.PaintBorder(borderRect);
        }
        private void PaintItem(ListBox control, ControlPaintArgs e, int itemindex)
        {
            Rectangle clientRect = control.ClientRectangle;
            Rectangle itemRect   = control.GetItemRectangle(itemindex);

            object item = control.Items[itemindex];

            if (itemRect.IntersectsWith(clientRect))
            {
                IRuleset itemRuleset = GetItemRuleset(control, e, itemindex);

                e.StyleRenderer.PaintBackground(e.Graphics, itemRect, itemRuleset);
                e.StyleRenderer.PaintBorder(e.Graphics, itemRect, itemRuleset);
                e.StyleRenderer.PaintText(e.Graphics, itemRect, itemRuleset, control.GetItemText(item), control.Font);
            }
        }
示例#19
0
        public override void PaintControl(TreeView control, ControlPaintArgs args)
        {
            PaintBackground(control, args);

            if (!args.ParentDraw)
            {
                PaintLines(control, control.Nodes, args);

                int visibleIndex = 0;

                foreach (TreeNode node in control.Nodes)
                {
                    visibleIndex = PaintNodeAndChildNodes(control, node, visibleIndex, args);
                }
            }
        }
示例#20
0
        protected virtual void PaintNodeButton(TreeView control, TreeNode node, ControlPaintArgs args)
        {
            const int buttonWidth   = 9;
            const int detailPadding = 2;

            UserNode nodeButtonNode = new UserNode(string.Empty, new[] { "Button" });

            nodeButtonNode.SetParent(new ControlNode(control));

            if (node.IsSelected)
            {
                nodeButtonNode.AddState(NodeStates.Checked);
            }

            IRuleset nodeButtonRuleset = args.StyleSheet.GetRuleset(nodeButtonNode);

            Rectangle nodeRect   = node.Bounds;
            Rectangle buttonRect = new Rectangle(nodeRect.X - buttonWidth - 3, nodeRect.Y + nodeRect.Height - buttonWidth - 1, buttonWidth, buttonWidth);

            args.StyleRenderer.PaintBackground(args.Graphics, buttonRect, nodeButtonRuleset);
            args.StyleRenderer.PaintBorder(args.Graphics, buttonRect, nodeButtonRuleset);

            if (PaintNodeButtonContent)
            {
                Color detailColor = nodeButtonRuleset.Color?.Value ?? Color.Black;

                buttonRect.Inflate(-detailPadding, -detailPadding);

                int x    = buttonRect.X;
                int y    = buttonRect.Y;
                int x2   = x + buttonRect.Width - 1;
                int y2   = y + buttonRect.Height - 1;
                int midX = x + (buttonRect.Width / 2);
                int midY = y + (buttonRect.Height / 2);

                using (Pen detailPen = new Pen(detailColor)) {
                    args.Graphics.DrawLine(detailPen, new Point(x, midY), new Point(x2, midY));

                    if (!node.IsExpanded)
                    {
                        args.Graphics.DrawLine(detailPen, new Point(midX, y), new Point(midX, y2));
                    }
                }
            }
        }
示例#21
0
        // Private members

        private void PaintNode(TreeView control, TreeNode node, int visibleIndex, ControlPaintArgs args)
        {
            // Check that the node bounds size is valid to avoid drawing in the top-left corner.
            // https://stackoverflow.com/questions/50815725/treeview-owner-draw-anomaly

            if (node.Bounds.Width > 1 && node.Bounds.Height > 1)
            {
                // Paint the node content.

                PaintNodeContent(control, node, visibleIndex, args);

                // Paint the expand/collapse button to the left of the node.

                if (control.ShowPlusMinus && node.Nodes.Count > 0)
                {
                    PaintNodeButton(control, node, args);
                }
            }
        }
        private void PaintCheck(CheckBox control, ControlPaintArgs e)
        {
            INode    controlNode = new ControlNode(control);
            UserNode checkNode   = new UserNode(string.Empty, new[] { "Check" });

            checkNode.SetParent(controlNode);
            checkNode.SetStates(controlNode.States);

            IRuleset parentRuleset = e.StyleSheet.GetRuleset(control);
            IRuleset ruleset       = e.StyleSheet.GetRuleset(checkNode, inherit: false);

            if (!ruleset.Any())
            {
                ruleset = CreateDefaultCheckRuleset();
            }

            ruleset.InheritProperties(parentRuleset);

            Rectangle clientRect = e.Control.ClientRectangle;
            Rectangle checkRect  = new Rectangle(clientRect.X, clientRect.Y + (int)(clientRect.Height / 2.0f - CheckWidth / 2.0f) - 1, CheckWidth, CheckWidth);

            e.StyleRenderer.PaintBackground(e.Graphics, checkRect, ruleset);
            e.StyleRenderer.PaintBorder(e.Graphics, checkRect, ruleset);

            // Draw the checkmark.

            if (control.Checked)
            {
                using (Pen pen = new Pen(ruleset.Color?.Value ?? SystemColors.ControlText)) {
                    e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;

                    pen.Alignment = PenAlignment.Center;
                    pen.Width     = 2.0f;
                    pen.StartCap  = LineCap.Square;
                    pen.EndCap    = LineCap.Square;

                    e.Graphics.DrawLine(pen, checkRect.X + 3, checkRect.Y + checkRect.Height / 2.0f, checkRect.X + checkRect.Width / 2.0f - 1, checkRect.Y + checkRect.Height - 5);
                    e.Graphics.DrawLine(pen, checkRect.X + checkRect.Width / 2.0f - 1, checkRect.Y + checkRect.Height - 5, checkRect.X + checkRect.Width - 4, checkRect.Y + 3);
                }
            }
        }
        // Public members

        public override void PaintControl(ComboBox control, ControlPaintArgs e)
        {
            IRuleset ruleset = e.StyleSheet.GetRuleset(control);

            RenderUtilities.ApplyColorProperties(control, ruleset);

            Rectangle clientRect = control.ClientRectangle;

            e.PaintBackground();

            // Match the foreground bounds of the default control.
            // The text is cut off behind the drop-down arrow.

            Rectangle textRect = new Rectangle(clientRect.X + 1, clientRect.Y, clientRect.Width - 21, clientRect.Height);

            e.PaintText(textRect);

            PaintDropDownArrow(control, e);

            e.PaintBorder();
        }
        // Public members

        public override void PaintControl(Control control, ControlPaintArgs e)
        {
            Rectangle clientRect = control.ClientRectangle;

            clientRect.Offset(-1, 1);

            Rectangle topButtonRect    = new Rectangle(clientRect.X, clientRect.Y, clientRect.Width, clientRect.Height / 2);
            Rectangle bottomButtonRect = new Rectangle(topButtonRect.X, clientRect.Y + clientRect.Height / 2, topButtonRect.Width, topButtonRect.Height);

            Rectangle topButtonClickRect    = topButtonRect;
            Rectangle bottomButtonClickRect = bottomButtonRect;

            topButtonClickRect.Offset(0, -1);
            bottomButtonClickRect.Offset(0, -1);

            e.Clear();

            e.Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;

            PaintButton(e, topButtonRect, TriangleOrientation.Up, e.StyleSheet.GetRuleset(new ControlNode(control, topButtonClickRect)));
            PaintButton(e, bottomButtonRect, TriangleOrientation.Down, e.StyleSheet.GetRuleset(new ControlNode(control, bottomButtonClickRect)));
        }
        // Public members

        public override void PaintControl(Button control, ControlPaintArgs e)
        {
            TextFormatFlags textFormatFlags = ControlUtilities.GetTextFormatFlags(control.TextAlign);

            e.Clear();

            e.PaintBackground();

            if (control.Image != null)
            {
                const int horizontalPadding = 4;
                const int verticalPadding   = 4;

                Rectangle imageRect = new Rectangle(horizontalPadding, verticalPadding, control.Width - horizontalPadding * 2, control.Height - verticalPadding * 2);

                e.Graphics.DrawImage(control.Image, imageRect, control.ImageAlign);
            }

            e.PaintText(textFormatFlags);

            e.PaintBorder();
        }
        private void PaintCheck(RadioButton control, ControlPaintArgs e)
        {
            INode    controlNode = new ControlNode(control);
            UserNode checkNode   = new UserNode(string.Empty, new[] { "Check" });

            checkNode.SetParent(controlNode);
            checkNode.SetStates(controlNode.States);

            IRuleset parentRuleset = e.StyleSheet.GetRuleset(control);
            IRuleset ruleset       = e.StyleSheet.GetRuleset(checkNode, inherit: false);

            if (!ruleset.Any())
            {
                ruleset = CreateDefaultCheckRuleset();
            }

            ruleset.InheritProperties(parentRuleset);

            Rectangle clientRect = control.ClientRectangle;
            Rectangle checkRect  = new Rectangle(clientRect.X, clientRect.Y + (int)(clientRect.Height / 2.0f - CheckWidth / 2.0f), CheckWidth, CheckWidth);

            e.StyleRenderer.PaintBackground(e.Graphics, checkRect, ruleset);
            e.StyleRenderer.PaintBorder(e.Graphics, checkRect, ruleset);

            // Draw the checkmark.

            if (control.Checked)
            {
                using (Brush brush = new SolidBrush(ruleset.Color?.Value ?? SystemColors.ControlText)) {
                    e.Graphics.SmoothingMode   = SmoothingMode.AntiAlias;
                    e.Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;

                    checkRect.Inflate(-3, -3);

                    e.Graphics.FillEllipse(brush, checkRect);
                }
            }
        }
        // Public members

        public override void PaintControl(ListBox control, ControlPaintArgs e)
        {
            Rectangle borderRect = RenderUtilities.GetOuterBorderRectangle(control, e.StyleSheet.GetRuleset(control));

            if (ControlUtilities.GetVisibleScrollBars(control).HasFlag(ScrollBars.Vertical))
            {
                borderRect = new Rectangle(borderRect.X, borderRect.Y, borderRect.Width + SystemInformation.VerticalScrollBarWidth, borderRect.Height);
            }

            e.PaintBackground();

            if (!e.ParentDraw)
            {
                GraphicsState graphicsState = e.Graphics.Save();

                e.ClipToBorder(borderRect);

                PaintItems(control, e);

                e.Graphics.Restore(graphicsState);
            }

            e.PaintBorder(borderRect);
        }
示例#28
0
        private int PaintNodeAndChildNodes(TreeView control, TreeNode node, int visibleIndex, ControlPaintArgs args)
        {
            if (node.IsVisible)
            {
                PaintNode(control, node, visibleIndex++, args);

                foreach (TreeNode childNode in node.Nodes)
                {
                    visibleIndex = PaintNodeAndChildNodes(control, childNode, visibleIndex, args);
                }
            }

            return(visibleIndex);
        }
示例#29
0
        // Public members

        public override void PaintControl(TextBox control, ControlPaintArgs e)
        {
            IRuleset ruleset = e.StyleSheet.GetRuleset(control);

            // Update the color of the TextBox itself.

            RenderUtilities.ApplyColorProperties(control, ruleset);

            // Draw the background the TextBox.
            // The height of regular TextBoxes is 23 pixels, with 3 pixels of horizontal padding.

            Rectangle clientRect = control.ClientRectangle;

            int x = clientRect.X - 3;
            int y = clientRect.Y - 4;
            int w = clientRect.Width + 6;
            int h = clientRect.Height + 7;

            double topWidth    = ruleset.BorderTopWidth?.Value ?? 0;
            double rightWidth  = ruleset.BorderRightWidth?.Value ?? 0;
            double bottomWidth = ruleset.BorderBottomWidth?.Value ?? 0;
            double leftWidth   = ruleset.BorderLeftWidth?.Value ?? 0;

            if (topWidth <= 1)
            {
                topWidth = 0;
            }

            if (rightWidth <= 1)
            {
                rightWidth = 0;
            }

            if (bottomWidth <= 1)
            {
                bottomWidth = 0;
            }

            if (leftWidth <= 1)
            {
                leftWidth = 0;
            }

            x -= (int)leftWidth;
            y -= (int)topWidth;
            w += (int)leftWidth + (int)rightWidth;
            h += (int)topWidth + (int)bottomWidth;

            ScrollBars visibleScrollbars = ControlUtilities.GetVisibleScrollBars(control);

            if (visibleScrollbars.HasFlag(ScrollBars.Vertical))
            {
                w += SystemInformation.VerticalScrollBarWidth;
            }

            if (visibleScrollbars.HasFlag(ScrollBars.Horizontal))
            {
                h += SystemInformation.HorizontalScrollBarHeight;
            }

            //GraphicsState graphicsState = graphics.Save();

            Rectangle drawRect = new Rectangle(x, y, w, h);

            //graphics.SetClip(drawRect);

            e.StyleRenderer.PaintBackground(e.Graphics, drawRect, ruleset);
            e.StyleRenderer.PaintBorder(e.Graphics, drawRect, ruleset);

            //graphics.Restore(graphicsState);
        }
示例#30
0
        protected virtual void PaintNodeContent(TreeView control, TreeNode node, int visibleIndex, ControlPaintArgs args)
        {
            UserNode treeNodeNode = new UserNode(string.Empty, new[] { "Node", "TreeViewNode" });

            treeNodeNode.SetParent(new ControlNode(control));

            if (node.IsSelected)
            {
                treeNodeNode.AddState(NodeStates.Checked);
            }

            if (visibleIndex % 2 == 0)
            {
                treeNodeNode.AddClass("Even");
            }
            else
            {
                treeNodeNode.AddClass("Odd");
            }

            IRuleset treeNodeRuleset = args.StyleSheet.GetRuleset(treeNodeNode);

            Rectangle nodeRect       = node.Bounds;
            Rectangle backgroundRect = new Rectangle(nodeRect.X + 2, nodeRect.Y + 1, nodeRect.Width, nodeRect.Height - 1);
            Rectangle textRect       = new Rectangle(nodeRect.X + 1, nodeRect.Y + 3, nodeRect.Width - 1, nodeRect.Height - 3);

            if (control.FullRowSelect)
            {
                backgroundRect = new Rectangle(0, backgroundRect.Y, control.Width, backgroundRect.Height);
            }

            args.StyleRenderer.PaintBackground(args.Graphics, backgroundRect, treeNodeRuleset);
            args.StyleRenderer.PaintText(args.Graphics, textRect, treeNodeRuleset, node.Text, control.Font, TextFormatFlags.Default | TextFormatFlags.VerticalCenter);
            args.StyleRenderer.PaintBorder(args.Graphics, backgroundRect, treeNodeRuleset);
        }