Пример #1
0
        internal override void Render(Graphics graphics, SizeF minimumSize, PointF location)
        {
            var text = string.Empty;

            if (Items != null &&
                SelectedIndex >= 0 && SelectedIndex < Items.Length)
            {
                text = Items[SelectedIndex];
            }

            var size = Measure(graphics);

            size.Width  = Math.Max(minimumSize.Width, size.Width);
            size.Height = Math.Max(minimumSize.Height, size.Height);

            var path = GraphRenderer.CreateRoundedRectangle(size, location);

            location.Y += 1;
            location.X += 1;

            if ((state & RenderState.Hover) == RenderState.Hover)
            {
                graphics.DrawPath(Pens.White, path);
                graphics.DrawString(text, SystemFonts.MenuFont, Brushes.Black, new RectangleF(location, size), GraphConstants.LeftTextStringFormat);
            }
            else
            {
                graphics.DrawPath(Pens.Black, path);
                graphics.DrawString(text, SystemFonts.MenuFont, Brushes.Black, new RectangleF(location, size), GraphConstants.LeftTextStringFormat);
            }
        }
Пример #2
0
        public override void RenderContent(Graphics graphics)
        {
            var size = ContentBounds.Size;

            using (var path = GraphRenderer.CreateRoundedRectangle(size, ContentBounds.Location))
            {
                var rect = ContentBounds;
                if (this.Checked)
                {
                    using (var brush = new SolidBrush(Color.FromArgb(128 + 32, Color.White)))
                    {
                        graphics.FillPath(brush, path);
                    }
                }
                else
                {
                    using (var brush = new SolidBrush(Color.FromArgb(64, Color.Black)))
                    {
                        graphics.FillPath(brush, path);
                    }
                }
                graphics.DrawString(this.Text, SystemFonts.MenuFont, Node.TextColor, rect, GraphConstants.CenterTextStringFormat);

                if ((state & RenderState.Hover) != 0)
                {
                    graphics.DrawPath(Pens.White, path);
                }
                else
                {
                    graphics.DrawPath(Pens.Black, path);
                }
            }
        }
Пример #3
0
        public override void RenderContent(Graphics graphics)
        {
            var text = string.Empty;

            if (Items != null &&
                SelectedIndex >= 0 && SelectedIndex < Items.Length)
            {
                text = Items[SelectedIndex];
            }



            var path = GraphRenderer.CreateRoundedRectangle(ContentBounds.Size, ContentBounds.Location);

            var location = ContentBounds.Location;

            location.Y += 1;
            location.X += 1;

            if ((state & RenderState.Hover) == RenderState.Hover)
            {
                graphics.DrawPath(Pens.White, path);
                graphics.DrawString(text, SystemFonts.MenuFont, Node.TextColor, new RectangleF(location, ContentBounds.Size), GraphConstants.LeftTextStringFormat);
            }
            else
            {
                graphics.DrawPath(Pens.Black, path);
                graphics.DrawString(text, SystemFonts.MenuFont, Node.TextColor, new RectangleF(location, ContentBounds.Size), GraphConstants.LeftTextStringFormat);
            }
        }
Пример #4
0
        internal override void Render(Graphics graphics, SizeF minimumSize, PointF location)
        {
            var size = Measure(graphics);

            size.Width  = Math.Max(minimumSize.Width, size.Width);
            size.Height = Math.Max(minimumSize.Height, size.Height);

            var path = GraphRenderer.CreateRoundedRectangle(size, location);

            graphics.FillPath(background, path);

            location.Y += 1;
            location.X += 1;

            if ((state & RenderState.Hover) == RenderState.Hover)
            {
                graphics.DrawPath(Pens.White, path);
                graphics.DrawString(this.FormattedText, SystemFonts.MenuFont, Brushes.Black, new RectangleF(location, size), GraphConstants.LeftTextStringFormat);
            }
            else
            {
                graphics.DrawPath(Pens.Black, path);
                graphics.DrawString(this.FormattedText, SystemFonts.MenuFont, Brushes.Black, new RectangleF(location, size), GraphConstants.LeftTextStringFormat);
            }
        }
Пример #5
0
        internal override void Render(Graphics graphics, SizeF minimumSize, PointF location)
        {
            var size = Measure(graphics);

            size.Width  = Math.Max(minimumSize.Width, size.Width);
            size.Height = Math.Max(minimumSize.Height, size.Height);

            var sliderOffset = Spacing + this.textSize.Width;
            var sliderWidth  = size.Width - (Spacing + this.textSize.Width);

            var textRect   = new RectangleF(location, size);
            var sliderBox  = new RectangleF(location, size);
            var sliderRect = new RectangleF(location, size);

            sliderRect.X      = sliderRect.Right - sliderWidth;
            sliderRect.Y     += ((sliderRect.Bottom - sliderRect.Top) - SliderHeight) / 2.0f;
            sliderRect.Width  = sliderWidth;
            sliderRect.Height = SliderHeight;
            textRect.Width   -= sliderWidth + Spacing;

            var valueSize = (this.MaxValue - this.MinValue);

            this.sliderRect        = sliderRect;
            this.sliderRect.Width -= SliderBoxSize;
            this.sliderRect.X     += SliderBoxSize / 2.0f;

            sliderBox.Width = SliderBoxSize;
            sliderBox.X     = sliderRect.X + (this.Value * this.sliderRect.Width) / valueSize;

            graphics.DrawString(this.Text, SystemFonts.MenuFont, Brushes.Black, textRect, GraphConstants.LeftTextStringFormat);

            using (var path = GraphRenderer.CreateRoundedRectangle(sliderRect.Size, sliderRect.Location))
            {
                if ((state & (RenderState.Hover | RenderState.Dragging)) != 0)
                {
                    graphics.DrawPath(Pens.White, path);
                }
                else
                {
                    graphics.DrawPath(Pens.Black, path);
                }
            }

            graphics.FillRectangle(Brushes.LightGray, sliderBox.X, sliderBox.Y, sliderBox.Width, sliderBox.Height);

            if ((state & (RenderState.Hover | RenderState.Dragging)) != 0)
            {
                graphics.DrawRectangle(Pens.White, sliderBox.X, sliderBox.Y, sliderBox.Width, sliderBox.Height);
            }
            else
            {
                graphics.DrawRectangle(Pens.Black, sliderBox.X, sliderBox.Y, sliderBox.Width, sliderBox.Height);
            }
        }
Пример #6
0
        public override void Render(Graphics graphics, SizeF minimumSize, PointF location, object context)
        {
            var text = string.Empty;

            if (Items != null &&
                SelectedIndex >= 0 && SelectedIndex < Items.Length)
            {
                text = Items[SelectedIndex];
            }

            var size = Measure(graphics);

            size.Width  = Math.Max(minimumSize.Width, size.Width);
            size.Height = Math.Max(minimumSize.Height, size.Height);

            var path = GraphRenderer.CreateRoundedRectangle(size, location);

            var stringRect = new RectangleF(new PointF(location.X + 1, location.Y + 1), new SizeF(size.Width - 2, size.Height - 2));
            var arrowRect  = stringRect;

            float sep        = 2.0f;
            float arrowWidth = Math.Min(arrowRect.Height, stringRect.Width - sep);

            arrowRect.X      += arrowRect.Width - arrowWidth;
            arrowRect.Width   = arrowWidth;
            stringRect.Width -= arrowWidth - sep;
            arrowRect.X      += 6; arrowRect.Width -= 12;
            arrowRect.Y      += 6; arrowRect.Height -= 12;

            bool highlight = (state & RenderState.Hover) == RenderState.Hover;

            graphics.FillPath(BackgroundBrush, path);
            graphics.DrawPath(highlight ? Pens.White : Pens.LightGray, path);
            graphics.DrawString(text, SystemFonts.MenuFont, Brushes.White, stringRect, GraphConstants.CenterTextStringFormat);

            // draw a little arrow to indicate that it is a drop down list
            graphics.FillPolygon(
                highlight ? Brushes.White : Brushes.LightGray,
                new Point[]
            {
                new Point((int)arrowRect.Left, (int)arrowRect.Top),
                new Point((int)arrowRect.Right, (int)arrowRect.Top),
                new Point((int)(.5f * (arrowRect.Left + arrowRect.Right)), (int)arrowRect.Bottom)
            });
        }
Пример #7
0
        public override void Render(Graphics graphics, SizeF minimumSize, PointF location, object context)
        {
            var size = Measure(graphics);

            size.Width  = Math.Max(minimumSize.Width, size.Width);
            size.Height = Math.Max(minimumSize.Height, size.Height);

            using (var path = GraphRenderer.CreateRoundedRectangle(size, location))
            {
                using (var brush = new SolidBrush(Color.FromArgb(64, Color.Black)))
                    graphics.FillPath(brush, path);

                var rect = new RectangleF(location, size);
                graphics.DrawString(
                    "+", SystemFonts.MenuFont,
                    ((GetState() & RenderState.Hover) != 0) ? Brushes.White : Brushes.Black, rect,
                    GraphConstants.CenterTextStringFormat);
            }
        }
Пример #8
0
        public override void RenderContent(Graphics graphics)
        {
            var path     = GraphRenderer.CreateRoundedRectangle(ContentBounds.Size, ContentBounds.Location);
            var location = ContentBounds.Location;

            location.Y += 1;
            location.X += 1;

            if ((state & RenderState.Hover) == RenderState.Hover)
            {
                graphics.DrawPath(Pens.White, path);
                graphics.DrawString(this.Text, SystemFonts.MenuFont, Node.TextColor, new RectangleF(location, ContentBounds.Size), GraphConstants.LeftTextStringFormat);
            }
            else
            {
                graphics.DrawPath(Pens.Black, path);
                graphics.DrawString(this.Text, SystemFonts.MenuFont, Node.TextColor, new RectangleF(location, ContentBounds.Size), GraphConstants.LeftTextStringFormat);
            }
        }
Пример #9
0
        public override void Render(Graphics graphics, SizeF minimumSize, PointF location, object context)
        {
            var size = Measure(graphics);

            size.Width  = Math.Max(minimumSize.Width, size.Width);
            size.Height = Math.Max(minimumSize.Height, size.Height);

            using (var path = GraphRenderer.CreateRoundedRectangle(size, location))
            {
                var rect = new RectangleF(location, size);
                if (this.Checked)
                {
                    using (var brush = new SolidBrush(Color.FromArgb(128 + 32, Color.White)))
                    {
                        graphics.FillPath(brush, path);
                    }
                }
                else
                {
                    using (var brush = new SolidBrush(Color.FromArgb(64, Color.Black)))
                    {
                        graphics.FillPath(brush, path);
                    }
                }
                graphics.DrawString(this.Text, SystemFonts.MenuFont, Brushes.Black, rect, GraphConstants.CenterTextStringFormat);

                if ((state & RenderState.Hover) != 0)
                {
                    graphics.DrawPath(Pens.White, path);
                }
                else
                {
                    graphics.DrawPath(Pens.Black, path);
                }
            }
        }
Пример #10
0
        internal override void Render(Graphics graphics, SizeF minimumSize, PointF location)
        {
            var size = Measure(graphics);

            size.Width  = Math.Max(minimumSize.Width, size.Width);
            size.Height = Math.Max(minimumSize.Height, size.Height);

            var alignment = HorizontalAlignment.Center;
            var format    = GraphConstants.CenterTextStringFormat;

            if (this.Input.Enabled != this.Output.Enabled)
            {
                if (this.Input.Enabled)
                {
                    alignment = HorizontalAlignment.Left;
                    format    = GraphConstants.LeftTextStringFormat;
                }
                else
                {
                    alignment = HorizontalAlignment.Right;
                    format    = GraphConstants.RightTextStringFormat;
                }
            }

            var rect     = new RectangleF(location, size);
            var colorBox = new RectangleF(location, size);

            colorBox.Width = ColorBoxSize;
            switch (alignment)
            {
            case HorizontalAlignment.Left:
                rect.Width -= ColorBoxSize + Spacing;
                rect.X     += ColorBoxSize + Spacing;
                break;

            case HorizontalAlignment.Right:
                colorBox.X  = rect.Right - colorBox.Width;
                rect.Width -= ColorBoxSize + Spacing;
                break;

            case HorizontalAlignment.Center:
                rect.Width -= ColorBoxSize + Spacing;
                rect.X     += ColorBoxSize + Spacing;
                break;
            }

            graphics.DrawString(this.Text, SystemFonts.MenuFont, Brushes.Black, rect, format);

            using (var path = GraphRenderer.CreateRoundedRectangle(colorBox.Size, colorBox.Location))
            {
                using (var brush = new SolidBrush(this.Color))
                {
                    graphics.FillPath(brush, path);
                }
                if ((state & RenderState.Hover) != 0)
                {
                    graphics.DrawPath(Pens.White, path);
                }
                else
                {
                    graphics.DrawPath(Pens.Black, path);
                }
            }
            //using (var brush = new SolidBrush(this.Color))
            //{
            //	graphics.FillRectangle(brush, colorBox.X, colorBox.Y, colorBox.Width, colorBox.Height);
            //}
            //graphics.DrawRectangle(Pens.Black, colorBox.X, colorBox.Y, colorBox.Width, colorBox.Height);
        }
Пример #11
0
        public override void RenderContent(Graphics graphics)
        {
            var alignment = HorizontalAlignment.Center;
            var format    = GraphConstants.CenterTextStringFormat;

            if (ItemType == NodeItemType.Input)
            {
                alignment = HorizontalAlignment.Left;
                format    = GraphConstants.LeftTextStringFormat;
            }
            else
            {
                alignment = HorizontalAlignment.Right;
                format    = GraphConstants.RightTextStringFormat;
            }


            var rect     = ContentBounds;
            var colorBox = ContentBounds;

            colorBox.Width = ColorBoxSize;
            switch (alignment)
            {
            case HorizontalAlignment.Left:
                rect.Width -= ColorBoxSize + Spacing;
                rect.X     += ColorBoxSize + Spacing;
                break;

            case HorizontalAlignment.Right:
                colorBox.X  = rect.Right - colorBox.Width;
                rect.Width -= ColorBoxSize + Spacing;
                break;

            case HorizontalAlignment.Center:
                rect.Width -= ColorBoxSize + Spacing;
                rect.X     += ColorBoxSize + Spacing;
                break;
            }

            graphics.DrawString(this.Text, SystemFonts.MenuFont, Node.TextColor, rect, format);

            using (var path = GraphRenderer.CreateRoundedRectangle(colorBox.Size, colorBox.Location))
            {
                using (var brush = new SolidBrush(this.Color))
                {
                    graphics.FillPath(brush, path);
                }
                if ((state & RenderState.Hover) != 0)
                {
                    graphics.DrawPath(Pens.White, path);
                }
                else
                {
                    graphics.DrawPath(Pens.Black, path);
                }
            }
            //using (var brush = new SolidBrush(this.Color))
            //{
            //	graphics.FillRectangle(brush, colorBox.X, colorBox.Y, colorBox.Width, colorBox.Height);
            //}
            //graphics.DrawRectangle(Pens.Black, colorBox.X, colorBox.Y, colorBox.Width, colorBox.Height);
        }