Пример #1
0
        /// <summary>
        /// </summary>
        /// <exception cref="ArgumentNullException">
        /// <para>
        ///		<paramref name="g"/> is <see langword="null"/>.
        /// </para>
        /// -or-
        /// <para>
        ///		<paramref name="font"/> is <see langword="null"/>.
        /// </para>
        /// -or-
        /// <para>
        ///		<paramref name="sf"/> is <see langword="null"/>.
        /// </para>
        /// </exception>
        public virtual void DrawText(
            Graphics g,
            Rectangle bounds,
            NuGenControlState state,
            string text,
            Font font,
            Color foreColor,
            StringFormat sf
            )
        {
            if (g == null)
            {
                throw new ArgumentNullException("g");
            }

            if (font == null)
            {
                throw new ArgumentNullException("font");
            }

            if (sf == null)
            {
                throw new ArgumentNullException("sf");
            }

            using (SolidBrush sb = new SolidBrush(state == NuGenControlState.Disabled ? SystemColors.ControlDark : foreColor))
            {
                g.DrawString(text, font, sb, bounds, sf);
            }
        }
Пример #2
0
        /// <summary>
        /// </summary>
        /// <exception cref="ArgumentNullException">
        /// <para>
        ///		<paramref name="g"/> is <see langword="null"/>.
        /// </para>
        /// -or-
        /// <para>
        ///		<paramref name="text"/> is <see langword="null"/>.
        /// </para>
        /// -or-
        /// <para>
        ///		<paramref name="font"/> is <see langword="null"/>.
        /// </para>
        /// </exception>
        public void DrawText(
            Graphics g,
            Rectangle bounds,
            NuGenControlState state,
            string text,
            Font font,
            Color foreColor,
            ContentAlignment textAlignment
            )
        {
            if (g == null)
            {
                throw new ArgumentNullException("g");
            }

            if (text == null)
            {
                throw new ArgumentNullException("text");
            }

            if (font == null)
            {
                throw new ArgumentNullException("font");
            }

            using (StringFormat sf = NuGenControlPaint.ContentAlignmentToStringFormat(textAlignment))
            {
                sf.HotkeyPrefix = HotkeyPrefix.Show;
                sf.Trimming     = StringTrimming.EllipsisCharacter;
                sf.FormatFlags  = StringFormatFlags.NoWrap;

                this.DrawText(g, bounds, state, text, font, foreColor, sf);
            }
        }
Пример #3
0
        /// <summary>
        /// </summary>
        /// <exception cref="ArgumentNullException">
        /// <para>
        ///		<paramref name="g"/> is <see langword="null"/>.
        /// </para>
        /// -or-
        /// <para>
        ///		<paramref name="image"/> is <see langword="null"/>.
        /// </para>
        /// </exception>
        public void DrawImage(Graphics g, Rectangle bounds, NuGenControlState state, Image image)
        {
            if (g == null)
            {
                throw new ArgumentNullException("g");
            }

            if (image == null)
            {
                throw new ArgumentNullException("image");
            }

            switch (state)
            {
            case NuGenControlState.Disabled:
            {
                g.DrawImage(
                    image,
                    bounds,
                    0, 0, image.Width, image.Height,
                    GraphicsUnit.Pixel,
                    NuGenControlPaint.GetDesaturatedImageAttributes()
                    );
                break;
            }

            default:
            {
                g.DrawImage(image, bounds);
                break;
            }
            }
        }
Пример #4
0
        /*
         * OnPaint
         */

        /// <summary>
        /// Raises the paint event.
        /// </summary>
        /// <param name="e">The <see cref="System.Windows.Forms.PaintEventArgs"/> instance containing the event data.</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics          g            = e.Graphics;
            Rectangle         bounds       = this.ClientRectangle;
            NuGenControlState currentState = this.ButtonStateTracker.GetControlState();
            Image             image        = this.Image;
            ContentAlignment  imageAlign   = this.ImageAlign;
            Rectangle         imageBounds  = Rectangle.Empty;

            if (image != null)
            {
                imageBounds = this.LayoutManager.GetImageBounds(new NuGenImageBoundsParams(bounds, image, imageAlign));
                this.Renderer.DrawImage(new NuGenImagePaintParams(this, g, imageBounds, currentState, image));
            }

            Rectangle textBounds = NuGenControlPaint.TextBoundsFromImageBounds(
                bounds,
                imageBounds,
                imageAlign
                );

            NuGenTextPaintParams textPaintParams = new NuGenTextPaintParams(this, g, textBounds, currentState, this.Text);

            textPaintParams.Font      = this.Font;
            textPaintParams.ForeColor = this.ForeColor;
            textPaintParams.TextAlign = this.TextAlign;

            this.Renderer.DrawText(textPaintParams);
        }
        /// <summary>
        /// </summary>
        /// <param name="paintParams"></param>
        /// <exception cref="ArgumentNullException">
        /// <para><paramref name="paintParams"/> is <see langword="null"/>.</para>
        /// </exception>
        public void DrawTrack(NuGenTrackBarPaintParams paintParams)
        {
            if (paintParams == null)
            {
                throw new ArgumentNullException("paintParams");
            }

            Graphics           g            = paintParams.Graphics;
            Rectangle          bounds       = paintParams.Bounds;
            NuGenControlState  state        = paintParams.State;
            TickStyle          tickStyle    = paintParams.TickStyle;
            INuGenValueTracker valueTracker = paintParams.ValueTracker;

            /* Track */

            Rectangle valueRect = new Rectangle(
                bounds.Left,
                bounds.Top,
                (int)(NuGenSmoothTrackBarRenderer.GetStep(bounds, valueTracker) * (valueTracker.Value - valueTracker.Minimum)),
                bounds.Height
                );

            if (
                valueRect.Width > 0 &&
                valueRect.Height > 0
                )
            {
                this.DrawBackground(
                    g,
                    valueRect,
                    state == NuGenControlState.Normal || state == NuGenControlState.Focused ? NuGenControlState.Hot : state
                    );
            }

            this.DrawBorder(g, bounds, state);

            /* TickLines */

            if ((tickStyle & TickStyle.BottomRight) > 0)
            {
                this.DrawTickLines(
                    g,
                    NuGenSmoothTrackBarRenderer.GetTickLinesBounds(bounds, TickStyle.BottomRight),
                    state,
                    TickStyle.BottomRight,
                    valueTracker
                    );
            }

            if ((tickStyle & TickStyle.TopLeft) > 0)
            {
                this.DrawTickLines(
                    g,
                    NuGenSmoothTrackBarRenderer.GetTickLinesBounds(bounds, TickStyle.TopLeft),
                    state,
                    TickStyle.TopLeft,
                    valueTracker
                    );
            }
        }
Пример #6
0
        /*
         * OnPaint
         */

        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Control.Paint"></see> event.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs"></see> that contains the event data.</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            Debug.Assert(this.Renderer != null, "this.Renderer != null");
            Debug.Assert(this.StateTracker != null, "this.StateTracker != null");

            NuGenControlState state      = this.StateTracker.GetControlState();
            Rectangle         bounds     = this.ClientRectangle;
            Rectangle         foreBounds = Rectangle.Empty;

            switch (this.Style)
            {
            case NuGenProgressBarStyle.Marquee:
            {
                if (this.Enabled && !this.DesignMode)
                {
                    foreBounds = this.GetMarqueeRectangle(this.ClientRectangle);
                }
                break;
            }

            default:
            {
                foreBounds = this.GetContinuousRectangle(this.ClientRectangle);
                break;
            }
            }

            Graphics g = e.Graphics;

            this.Renderer.DrawForeground(new NuGenProgressBarPaintParams(this, g, foreBounds, state, this.Style));
            this.Renderer.DrawBorder(new NuGenPaintParams(this, g, bounds, state));
        }
Пример #7
0
		/// <summary>
		/// </summary>
		/// <exception cref="ArgumentNullException">
		/// <para>
		///		<paramref name="g"/> is <see langword="null"/>.
		/// </para>
		/// -or-
		/// <para>
		///		<paramref name="image"/> is <see langword="null"/>.
		/// </para>
		/// </exception>
		public void DrawImage(Graphics g, Rectangle bounds, NuGenControlState state, Image image)
		{
			if (g == null)
			{
				throw new ArgumentNullException("g");
			}

			if (image == null)
			{
				throw new ArgumentNullException("image");
			}

			switch (state)
			{
				case NuGenControlState.Disabled:
				{
					g.DrawImage(
						image,
						bounds,
						0, 0, image.Width, image.Height,
						GraphicsUnit.Pixel,
						NuGenControlPaint.GetDesaturatedImageAttributes()
					);
					break;
				}
				default:
				{
					g.DrawImage(image, bounds);
					break;
				}
			}
		}
Пример #8
0
        void INuGenRoundedPanelRenderer.DrawBackground(NuGenPaintParams paintParams)
        {
            if (paintParams == null)
            {
                throw new ArgumentNullException("paintParams");
            }

            base.DrawRoundBackground(paintParams);

            Graphics          g      = paintParams.Graphics;
            Rectangle         bounds = paintParams.Bounds;
            NuGenControlState state  = paintParams.State;

            RectangleF ellipseBounds = new RectangleF(
                bounds.Left - bounds.Width * 0.2f
                , bounds.Top + bounds.Height * 0.6f
                , bounds.Width * 2
                , bounds.Height
                );

            if (ellipseBounds.Width > 0 && ellipseBounds.Height > 0)
            {
                Color beginColor = Color.FromArgb(60, this.ColorManager.GetBorderColor(state));
                Color endColor   = Color.FromArgb(10, this.ColorManager.GetBackgroundGradientEnd(state));

                using (Brush brush = new LinearGradientBrush(ellipseBounds, beginColor, endColor, 0.0f))
                {
                    g.SetClip(bounds, CombineMode.Replace);
                    g.FillEllipse(brush, ellipseBounds);
                }
            }
        }
Пример #9
0
            /// <summary>
            /// Add custom logic before the <see cref="E:Genetibase.Shared.Windows.NuGenWndLessControl.Paint"/> event will be raised.
            /// </summary>
            /// <param name="e"></param>
            protected override void OnPaint(PaintEventArgs e)
            {
                NuGenControlState currentState = this.ButtonStateTracker.GetControlState();
                NuGenPaintParams  paintParams  = new NuGenPaintParams(e.Graphics);

                paintParams.Bounds = this.Bounds;
                paintParams.State  = currentState;

                switch (this.Style)
                {
                case ImageRotationStyle.CCW:
                {
                    this.Renderer.DrawCCWRotateButton(paintParams);
                    break;
                }

                default:
                {
                    this.Renderer.DrawCWRotateButton(paintParams);
                    break;
                }
                }

                base.OnPaint(e);
            }
        /// <summary>
        /// </summary>
        public static TabItemState FromControlState(NuGenControlState ctrlState)
        {
            switch (ctrlState)
            {
            case NuGenControlState.Disabled:
            {
                return(TabItemState.Disabled);
            }

            case NuGenControlState.Hot:
            {
                return(TabItemState.Hot);
            }

            case NuGenControlState.Pressed:
            {
                return(TabItemState.Selected);
            }

            default:
            {
                return(TabItemState.Normal);
            }
            }
        }
Пример #11
0
        /*
         * DrawCheckBox
         */

        /// <summary>
        /// </summary>
        /// <param name="paintParams"></param>
        /// <exception cref="ArgumentNullException">
        /// <para><paramref name="paintParams"/> is <see langword="null"/>.</para>
        /// </exception>
        public void DrawCheckBox(NuGenCheckBoxPaintParams paintParams)
        {
            if (paintParams == null)
            {
                throw new ArgumentNullException("paintParams");
            }

            Graphics          g            = paintParams.Graphics;
            Rectangle         bounds       = paintParams.Bounds;
            NuGenControlState currentState = paintParams.State;
            CheckState        checkState   = paintParams.CheckState;

            if (checkState == CheckState.Indeterminate && currentState != NuGenControlState.Disabled)
            {
                this.DrawBackground(g, bounds, NuGenControlState.Pressed);
            }
            else
            {
                this.DrawBackground(paintParams);
            }

            this.DrawBorder(g, bounds, currentState);

            if (checkState == CheckState.Checked)
            {
                this.DrawCheck(g, bounds, currentState);
            }
        }
Пример #12
0
        /*
         * DrawBackground
         */

        /// <summary>
        /// </summary>
        private void DrawItemBackground(
            Graphics g,
            Rectangle bounds,
            NuGenControlState state,
            Color defaultBackColor
            )
        {
            Debug.Assert(g != null, "g != null");
            Rectangle borderBounds = new Rectangle(
                bounds.Left,
                bounds.Top,
                bounds.Width - 1,
                bounds.Height
                );

            if (state == NuGenControlState.Normal ||
                state == NuGenControlState.Disabled
                )
            {
                using (SolidBrush sb = new SolidBrush(defaultBackColor))
                    using (Pen pen = new Pen(sb))
                    {
                        g.FillRectangle(sb, bounds);
                        g.DrawRectangle(pen, borderBounds);
                    }
            }
            else
            {
                this.DrawBackground(g, bounds, state);
                this.DrawBorder(g, borderBounds, state);
            }
        }
Пример #13
0
        /*
         * OnPaint
         */

        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Control.Paint"></see> event.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs"></see> that contains the event data.</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            Debug.Assert(this.Renderer != null, "this.Renderer != null");
            Debug.Assert(this.StateTracker != null, "this.StateTracker != null");

            NuGenControlState state      = this.StateTracker.GetControlState();
            Rectangle         bounds     = this.ClientRectangle;
            Rectangle         foreBounds = Rectangle.Empty;

            switch (this.Style)
            {
            case NuGenProgressBarStyle.Marquee:
            {
                if (this.Enabled && !this.DesignMode)
                {
                    foreBounds = this.LayoutManager.GetMarqueeBlockBounds(
                        bounds,
                        _marqueeOffset,
                        this.Orientation
                        );
                }
                break;
            }

            default:
            {
                foreBounds = this.LayoutManager.GetContinuousBounds(
                    bounds,
                    this.Minimum,
                    this.Maximum,
                    this.Value,
                    this.Orientation
                    );
                break;
            }
            }

            NuGenPaintParams paintParams = new NuGenPaintParams(e.Graphics);

            paintParams.State = state;

            if (this.Style == NuGenProgressBarStyle.Blocks)
            {
                Rectangle[] blocks = this.LayoutManager.GetBlocks(foreBounds, this.Orientation);

                for (int i = 0; i < blocks.Length; i++)
                {
                    paintParams.Bounds = blocks[i];
                    this.Renderer.DrawForeground(paintParams);
                }
            }
            else
            {
                paintParams.Bounds = foreBounds;
                this.Renderer.DrawForeground(paintParams);
            }

            paintParams.Bounds = bounds;
            this.Renderer.DrawBorder(paintParams);
        }
Пример #14
0
        /// <summary>
        /// </summary>
        /// <exception cref="ArgumentNullException">
        /// <para>
        ///		<paramref name="g"/> is <see langword="null"/>.
        /// </para>
        /// -or-
        /// <para>
        ///		<paramref name="font"/> is <see langword="null"/>.
        /// </para>
        /// -or-
        /// <para>
        ///		<paramref name="sf"/> is <see langword="null"/>.
        /// </para>
        /// </exception>
        public override void DrawText(
            Graphics g,
            Rectangle bounds,
            NuGenControlState state,
            string text,
            Font font,
            Color foreColor,
            StringFormat sf
            )
        {
            if (g == null)
            {
                throw new ArgumentNullException("g");
            }

            if (font == null)
            {
                throw new ArgumentNullException("font");
            }

            if (sf == null)
            {
                throw new ArgumentNullException("sf");
            }

            using (SolidBrush sb = new SolidBrush(state == NuGenControlState.Disabled ? this.ColorManager.GetBorderColor(state) : foreColor))
            {
                g.DrawString(text, font, sb, bounds, sf);
            }
        }
Пример #15
0
        /// <summary>
        /// </summary>
        /// <param name="paintParams"></param>
        /// <exception cref="ArgumentNullException">
        /// <para><paramref name="paintParams"/> is <see langword="null"/>.</para>
        /// </exception>
        public void DrawDropDownArrow(NuGenPaintParams paintParams)
        {
            if (paintParams == null)
            {
                throw new ArgumentNullException("paintParams");
            }

            Graphics          g      = paintParams.Graphics;
            Rectangle         bounds = paintParams.Bounds;
            NuGenControlState state  = paintParams.State;

            int x = bounds.Left + bounds.Width / 2;
            int y = bounds.Top + bounds.Height / 2 - 3;

            Point[] arrowPoints = new Point[] {
                new Point(x - 3, y),
                new Point(x + 2, y),
                new Point(x, y + 3)
            };

            using (SolidBrush sb = new SolidBrush(this.ColorManager.GetBorderColor(state)))
            {
                PixelOffsetMode oldPixelOffsetMode = g.PixelOffsetMode;
                g.PixelOffsetMode = PixelOffsetMode.HighQuality;
                g.FillPolygon(sb, arrowPoints);
                g.PixelOffsetMode = oldPixelOffsetMode;
            }
        }
Пример #16
0
        /*
         * BuildItemPaintParams
         */

        /// <summary>
        /// </summary>
        /// <param name="itemParams"></param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">
        /// <para>
        ///		<paramref name="itemParams"/> is <see langword="null"/>.
        /// </para>
        /// </exception>
        public static NuGenItemPaintParams BuildItemPaintParams(NuGenItemParams itemParams)
        {
            if (itemParams == null)
            {
                throw new ArgumentNullException("itemParams");
            }

            NuGenControlState currentState = NuGenControlState.Normal;

            if ((itemParams.State & DrawItemState.Selected) > 0)
            {
                currentState = NuGenControlState.Hot;
            }

            NuGenItemPaintParams itemPaintParams = new NuGenItemPaintParams(
                itemParams.Sender,
                itemParams.Graphics,
                itemParams.Bounds,
                currentState
                );

            itemPaintParams.ContentAlign = itemParams.RightToLeft == RightToLeft.No
                                ? ContentAlignment.MiddleLeft
                                : ContentAlignment.MiddleRight
            ;
            itemPaintParams.Font      = itemParams.Font;
            itemPaintParams.ForeColor = itemParams.ForeColor;
            itemPaintParams.Image     = itemParams.Image;
            itemPaintParams.Text      = itemParams.Text;

            return(itemPaintParams);
        }
Пример #17
0
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Control.Paint"></see> event.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs"></see> that contains the event data.</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics          g              = e.Graphics;
            Rectangle         bounds         = this.ClientRectangle;
            Rectangle         dropDownBounds = this.GetDropDownButtonBounds();
            Rectangle         bodyBounds     = this.GetBodyBounds(dropDownBounds);
            NuGenControlState bodyState      = this.StateTracker.GetControlState();
            NuGenControlState buttonState    = this.ButtonStateTracker.GetControlState();

            NuGenItemPaintParams paintParams = new NuGenItemPaintParams(g);

            paintParams.Bounds       = bodyBounds;
            paintParams.ContentAlign = this.RightToLeft == RightToLeft.No
                                        ? ContentAlignment.MiddleLeft
                                        : ContentAlignment.MiddleRight
            ;
            paintParams.Font      = this.Font;
            paintParams.ForeColor = this.ForeColor;
            paintParams.Image     = this.Image;
            paintParams.Text      = this.Text;
            paintParams.State     = bodyState;

            this.Renderer.DrawDropDownBody(paintParams);

            paintParams.Bounds = dropDownBounds;
            paintParams.State  = buttonState;
            this.Renderer.DrawDropDownButton(paintParams);

            paintParams.Bounds = bounds;
            this.Renderer.DrawBorder(paintParams);
        }
            /*
             * OnPaint
             */

            /// <summary>
            /// Raises the <see cref="E:System.Windows.Forms.Control.Paint"></see> event.
            /// </summary>
            /// <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs"></see> that contains the event data.</param>
            protected override void OnPaint(PaintEventArgs e)
            {
                Graphics          g      = e.Graphics;
                Rectangle         bounds = this.ClientRectangle;
                Rectangle         displayColorRectangle = Rectangle.Inflate(bounds, -1, -1);
                Rectangle         borderRectangle       = bounds;
                NuGenControlState currentState          = this.ButtonStateTracker.GetControlState();

                using (SolidBrush sb = new SolidBrush(_displayColor))
                {
                    g.FillRectangle(sb, displayColorRectangle);
                }

                if (
                    currentState == NuGenControlState.Normal ||
                    currentState == NuGenControlState.Focused
                    )
                {
                    borderRectangle = displayColorRectangle;
                }

                this.Renderer.DrawBorder(
                    new NuGenPaintParams(
                        this,
                        g,
                        borderRectangle,
                        currentState
                        )
                    );
            }
Пример #19
0
        /*
         * OnPaint
         */

        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Control.Paint"></see> event.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs"></see> that contains the event data.</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            Debug.Assert(this.Renderer != null, "this.Renderer != null");

            Graphics          g            = e.Graphics;
            Rectangle         bounds       = this.ClientRectangle;
            NuGenControlState currentState = this.StateTracker.GetControlState();

            _labelRectangle = this.GetLabelRectangle(g, bounds);
            _frameRectangle = this.GetFrameRectangle(_labelRectangle, bounds);

            NuGenPaintParams paintParams = new NuGenPaintParams(g);

            paintParams.Bounds = _frameRectangle;
            paintParams.State  = currentState;

            if (this.Opaque)
            {
                this.Renderer.DrawBackground(paintParams);
            }

            this.Renderer.DrawFrame(paintParams);

            NuGenTextPaintParams textPaintParams = new NuGenTextPaintParams(g);

            textPaintParams.Bounds    = _labelRectangle;
            textPaintParams.Font      = this.Font;
            textPaintParams.ForeColor = this.ForeColor;
            textPaintParams.Text      = this.Text;
            textPaintParams.TextAlign = ContentAlignment.MiddleCenter;
            textPaintParams.State     = currentState;

            this.Renderer.DrawLabel(textPaintParams);
        }
Пример #20
0
        /// <summary>
        /// Internally called by <see cref="DrawScrollButton"/> to draw the arrow itself.
        /// </summary>
        /// <exception cref="ArgumentNullException">
        /// <para><paramref name="paintParams"/> is <see langword="null"/>.</para>
        /// </exception>
        public void DrawScrollButtonBody(NuGenPaintParams paintParams)
        {
            if (paintParams == null)
            {
                throw new ArgumentNullException("paintParams");
            }

            Graphics          g      = paintParams.Graphics;
            Rectangle         bounds = paintParams.Bounds;
            NuGenControlState state  = paintParams.State;

            using (Pen pen = this.GetBorderPen(state))
            {
                pen.Width = 2f;

                int width  = 8;
                int height = 4;

                Rectangle arrowBounds = new Rectangle(
                    bounds.Left + bounds.Width / 2 - width / 2,
                    bounds.Top + bounds.Height / 2 - height / 2,
                    width,
                    height
                    );

                Point p1 = new Point(arrowBounds.Left, arrowBounds.Top);
                Point p2 = new Point(arrowBounds.Left + arrowBounds.Width / 2, arrowBounds.Bottom);
                Point p3 = new Point(arrowBounds.Right, arrowBounds.Top);

                g.DrawLines(pen, new Point[] { p1, p2, p3 });
            }
        }
Пример #21
0
        /*
         * OnPaint
         */

        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Control.Paint"></see> event.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs"></see> that contains the event data.</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            Debug.Assert(this.ButtonStateTracker != null, "this.ButtonStateTracker != null");
            Debug.Assert(this.Renderer != null, "this.Renderer != null");

            Graphics          g             = e.Graphics;
            NuGenControlState currentState  = this.ButtonStateTracker.GetControlState();
            Rectangle         bounds        = this.ClientRectangle;
            Rectangle         contentBounds = this.LayoutManager.GetContentRectangle(bounds);

            NuGenPaintParams paintParams = new NuGenPaintParams(g);

            paintParams.Bounds = bounds;
            paintParams.State  = currentState;

            this.Renderer.DrawBackground(paintParams);
            this.Renderer.DrawShadow(paintParams);
            this.Renderer.DrawBorder(paintParams);

            Image            image       = this.Image;
            Rectangle        imageBounds = Rectangle.Empty;
            ContentAlignment imageAlign  = this.ImageAlign;

            if (image != null)
            {
                NuGenImagePaintParams imagePaintParams = new NuGenImagePaintParams(g);
                imagePaintParams.Bounds = imageBounds = this.LayoutManager.GetImageBounds(
                    new NuGenBoundsParams(
                        contentBounds
                        , imageAlign
                        , new Rectangle(Point.Empty, image.Size)
                        , this.RightToLeft
                        )
                    );
                imagePaintParams.Image = image;
                imagePaintParams.State = currentState;

                this.Renderer.DrawImage(imagePaintParams);
            }

            if (imageBounds != Rectangle.Empty)
            {
                imageBounds.Inflate(3, 3);
            }

            NuGenTextPaintParams textPaintParams = new NuGenTextPaintParams(g);

            textPaintParams.Bounds = this.LayoutManager.GetTextBounds(
                new NuGenBoundsParams(contentBounds, imageAlign, imageBounds, this.RightToLeft)
                );
            textPaintParams.Font      = this.Font;
            textPaintParams.ForeColor = this.ForeColor;
            textPaintParams.Text      = this.Text;
            textPaintParams.TextAlign = NuGenControlPaint.RTLContentAlignment(this.TextAlign, this.RightToLeft);
            textPaintParams.State     = currentState;

            this.Renderer.DrawText(textPaintParams);
        }
Пример #22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NuGenItemPaintParams"/> class.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="g"></param>
 /// <param name="bounds"></param>
 /// <param name="state"></param>
 /// <exception cref="ArgumentNullException">
 ///     <para><paramref name="g"/> is <see langword="null"/>.</para>
 /// -or-
 /// <para><paramref name="sender"/> is <see langword="null"/>.</para>
 /// </exception>
 public NuGenItemPaintParams(
     object sender,
     Graphics g,
     Rectangle bounds,
     NuGenControlState state
     )
     : base(sender, g, bounds, state)
 {
 }
Пример #23
0
 /// <summary>
 /// </summary>
 /// <returns></returns>
 public Brush GetBackgroundBrush(Rectangle bounds, NuGenControlState state)
 {
     Debug.Assert(this.ColorManager != null, "this.ColorManager != null");
     return(new LinearGradientBrush(
                bounds,
                this.ColorManager.GetBackgroundGradientBegin(state),
                this.ColorManager.GetBackgroundGradientEnd(state),
                LinearGradientMode.Vertical
                ));
 }
Пример #24
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NuGenTextPaintParams"/> class.
        /// </summary>
        /// <exception cref="ArgumentNullException">
        /// <para><paramref name="sender"/> is <see langword="null"/>.</para>
        /// -or-
        /// <para><paramref name="g"/> is <see langword="null"/>.</para>
        /// -or-
        /// <para><paramref name="text"/> is <see langword="null"/>.</para>
        /// </exception>
        public NuGenTextPaintParams(object sender, Graphics g, Rectangle bounds, NuGenControlState state, string text)
            : base(sender, g, bounds, state)
        {
            if (text == null)
            {
                throw new ArgumentNullException("text");
            }

            _text = text;
        }
Пример #25
0
        /*
         * DrawSpinArrow
         */

        /// <summary>
        /// </summary>
        /// <param name="g"></param>
        /// <param name="state"></param>
        /// <param name="style"></param>
        /// <exception cref="ArgumentNullException">
        /// <para><paramref name="g"/> is <see langword="null"/>.</para>
        /// </exception>
        private void DrawSpinArrow(Graphics g, NuGenControlState state, NuGenSpinButtonStyle style)
        {
            if (g == null)
            {
                throw new ArgumentNullException("g");
            }

            using (Pen pen = this.GetBorderPen(state))
            {
                Point p1 = Point.Empty;
                Point p2 = Point.Empty;
                Point p3 = Point.Empty;

                switch (style)
                {
                case NuGenSpinButtonStyle.Down:
                {
                    p1 = new Point(4, 3);
                    p2 = new Point(8, 7);
                    p3 = new Point(12, 3);

                    for (int i = 0; i < 3; i++)
                    {
                        p1.X++;
                        p2.Y--;
                        p3.X--;

                        g.DrawLine(pen, p1, p2);
                        g.DrawLine(pen, p2, p3);
                    }

                    break;
                }

                default:
                {
                    p1 = new Point(4, 6);
                    p2 = new Point(8, 2);
                    p3 = new Point(12, 6);

                    for (int i = 0; i < 3; i++)
                    {
                        p1.X++;
                        p2.Y++;
                        p3.X--;

                        g.DrawLine(pen, p1, p2);
                        g.DrawLine(pen, p2, p3);
                    }

                    break;
                }
                }
            }
        }
Пример #26
0
        /// <summary>
        /// </summary>
        /// <param name="paintParams"></param>
        /// <exception cref="ArgumentNullException">
        /// <para><paramref name="paintParams"/> is <see langword="null"/>.</para>
        /// </exception>
        public void DrawScrollTrack(NuGenPaintParams paintParams)
        {
            if (paintParams == null)
            {
                throw new ArgumentNullException("paintParams");
            }

            Graphics          g      = paintParams.Graphics;
            Rectangle         bounds = paintParams.Bounds;
            NuGenControlState state  = paintParams.State;

            Color borderColor = this.ColorManager.GetBorderColor(NuGenControlState.Normal);
            Color bkgndColor;

            switch (state)
            {
            case NuGenControlState.Pressed:
            {
                bkgndColor = Color.FromArgb(130, borderColor);
                break;
            }

            case NuGenControlState.Hot:
            {
                bkgndColor = Color.FromArgb(90, borderColor);
                break;
            }

            default:
            {
                bkgndColor = Color.FromArgb(50, borderColor);
                break;
            }
            }

            using (SolidBrush sb = new SolidBrush(bkgndColor))
            {
                g.FillRectangle(sb, bounds);
            }

            Rectangle borderRectangle = NuGenControlPaint.BorderRectangle(bounds);

            this.DrawLine(
                g,
                NuGenControlPaint.RectTLCorner(borderRectangle),
                NuGenControlPaint.RectTRCorner(borderRectangle),
                NuGenControlState.Normal
                );
            this.DrawLine(
                g,
                NuGenControlPaint.RectBLCorner(borderRectangle),
                NuGenControlPaint.RectBRCorner(borderRectangle),
                NuGenControlState.Normal
                );
        }
Пример #27
0
        /// <summary>
        /// </summary>
        /// <exception cref="ArgumentNullException">
        ///	<para>
        ///		<paramref name="g"/> is <see langword="null"/>.
        /// </para>
        /// </exception>
        public void DrawShadow(Graphics g, Rectangle bounds, NuGenControlState state)
        {
            if (g == null)
            {
                throw new ArgumentNullException("g");
            }

            /* Bottom */

            using (Pen pen = new Pen(this.ColorManager.GetShadowColorBottomBegin(state)))
            {
                g.DrawLine(pen, bounds.Left + 1, bounds.Bottom - 2, bounds.Right - 1, bounds.Bottom - 2);
            }

            using (Pen pen = new Pen(this.ColorManager.GetShadowColorBottomEnd(state)))
            {
                g.DrawLine(pen, bounds.Left + 2, bounds.Bottom - 1, bounds.Right - 2, bounds.Bottom - 1);
            }

            /* Top */

            using (Pen pen = new Pen(this.ColorManager.GetShadowColorTopBegin(state)))
            {
                g.DrawLine(pen, bounds.Left + 2, bounds.Top + 1, bounds.Right - 2, bounds.Top + 1);
            }

            using (Pen pen = new Pen(this.ColorManager.GetShadowColorTopEnd(state)))
            {
                g.DrawLine(pen, bounds.Left + 1, bounds.Top + 2, bounds.Right - 1, bounds.Top + 2);
            }

            /* Left */

            using (Pen pen = new Pen(this.ColorManager.GetShadowColorLeftBegin(state)))
            {
                g.DrawLine(pen, bounds.Left + 1, bounds.Top + 3, bounds.Left + 1, bounds.Bottom - 3);
            }

            using (Pen pen = new Pen(this.ColorManager.GetShadowColorLeftEnd(state)))
            {
                g.DrawLine(pen, bounds.Left + 2, bounds.Top + 3, bounds.Left + 2, bounds.Bottom - 3);
            }

            /* Right */

            using (Pen pen = new Pen(this.ColorManager.GetShadowColorRightBegin(state)))
            {
                g.DrawLine(pen, bounds.Right - 2, bounds.Top + 3, bounds.Right - 2, bounds.Bottom - 3);
            }

            using (Pen pen = new Pen(this.ColorManager.GetShadowColorRightEnd(state)))
            {
                g.DrawLine(pen, bounds.Right - 1, bounds.Top + 3, bounds.Right - 1, bounds.Bottom - 3);
            }
        }
        /*
         * DrawTickLine
         */

        private void DrawTickLine(Graphics g, float offset, int y1, int y2, NuGenControlState state)
        {
            Debug.Assert(g != null, "g != null");

            this.DrawLine(
                g,
                new PointF(offset, y1),
                new PointF(offset, y2),
                state
                );
        }
		/// <summary>
		/// Initializes a new instance of the <see cref="NuGenProgressBarPaintParams"/> class.
		/// </summary>
		/// <exception cref="ArgumentNullException">
		/// <para><paramref name="g"/> is <see langword="null"/>.</para>
		/// -or-
		/// <para><paramref name="sender"/> is <see langword="null"/>.</para>
		/// </exception>
		public NuGenProgressBarPaintParams(
			object sender,
			Graphics g,
			Rectangle bounds,
			NuGenControlState state,
			NuGenProgressBarStyle style
			)
			: base(sender, g, bounds, state)
		{
			_style = style;
		}
		/// <summary>
		/// Initializes a new instance of the <see cref="NuGenImagePaintParams"/> class.
		/// </summary>
		/// <exception cref="ArgumentNullException">
		/// <para><paramref name="sender"/> is <see langword="null"/>.</para>
		/// -or-
		/// <para><paramref name="g"/> is <see langword="null"/>.</para>
		/// -or-
		/// <para><paramref name="image"/> is <see langword="null"/>.</para>
		/// </exception>
		public NuGenImagePaintParams(
			object sender,
			Graphics g,
			Rectangle bounds,
			NuGenControlState state,
			Image image
			)
			: base(sender, g, bounds, state)
		{
			_image = image;
		}
 /// <summary>
 /// Initializes a new instance of the <see cref="NuGenProgressBarPaintParams"/> class.
 /// </summary>
 /// <exception cref="ArgumentNullException">
 /// <para><paramref name="g"/> is <see langword="null"/>.</para>
 /// -or-
 /// <para><paramref name="sender"/> is <see langword="null"/>.</para>
 /// </exception>
 public NuGenProgressBarPaintParams(
     object sender,
     Graphics g,
     Rectangle bounds,
     NuGenControlState state,
     NuGenProgressBarStyle style
     )
     : base(sender, g, bounds, state)
 {
     _style = style;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="NuGenSpinButtonPaintParams"/> class.
 /// </summary>
 /// <exception cref="ArgumentNullException">
 /// <para>
 ///		<paramref name="sender"/> is <see langword="null"/>.
 /// </para>
 /// -or-
 /// <para>
 ///		<paramref name="g"/> is <see langword="null"/>.
 /// </para>
 /// </exception>
 public NuGenSpinButtonPaintParams(
     object sender,
     Graphics g,
     Rectangle bounds,
     NuGenControlState state,
     NuGenSpinButtonStyle style
     )
     : base(sender, g, bounds, state)
 {
     _style = style;
 }
Пример #33
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NuGenPaintParams"/> class.
        /// </summary>
        /// <exception cref="ArgumentNullException">
        /// <para><paramref name="initializeFrom"/> is <see langword="null"/>.</para>
        /// </exception>
        public NuGenPaintParams(NuGenPaintParams initializeFrom)
        {
            if (initializeFrom == null)
            {
                throw new ArgumentNullException("initializeFrom");
            }

            _bounds   = initializeFrom.Bounds;
            _graphics = initializeFrom.Graphics;
            _state    = initializeFrom.State;
        }
		/// <summary>
		/// Initializes a new instance of the <see cref="NuGenTrackButtonPaintParams"/> class.
		/// </summary>
		/// <exception cref="ArgumentNullException">
		/// <para>
		///		<paramref name="sender"/> is <see langword="null"/>.
		/// </para>
		/// -or-
		/// <para>
		///		<paramref name="g"/> is <see langword="null"/>.
		/// </para>
		/// </exception>
		public NuGenTrackButtonPaintParams(
			object sender,
			Graphics g,
			Rectangle bounds,
			NuGenControlState state,
			TickStyle style
			)
			: base(sender,  g, bounds, state)
		{
			_style = style;
		}
Пример #35
0
		/// <summary>
		/// </summary>
		/// <exception cref="ArgumentNullException">
		/// <para>
		///		<paramref name="g"/> is <see langword="null"/>.
		/// </para>
		/// </exception>
		public void DrawBackground(Graphics g, Rectangle bounds, NuGenControlState state)
		{
			if (g == null)
			{
				throw new ArgumentNullException("g");
			}

			if (bounds.Width > 0 && bounds.Height > 0)
			{
				using (Brush brush = this.GetBackgroundBrush(bounds, state))
				{
					g.FillRectangle(brush, bounds);
				}
			}
		}
		/*
		 * DrawRadio
		 */

		/// <summary>
		/// </summary>
		/// <param name="g"></param>
		/// <param name="bounds"></param>
		/// <param name="state"></param>
		/// <exception cref="ArgumentNullException">
		/// <para>
		///		<paramref name="g"/> is <see langword="null"/>.
		/// </para>
		/// </exception>
		private void DrawRadio(Graphics g, Rectangle bounds, NuGenControlState state)
		{
			if (g == null)
			{
				throw new ArgumentNullException("g");
			}

			Debug.Assert(this.ColorManager != null, "this.ColorManager != null");
			bounds.Inflate(-3, -3);
			using (SolidBrush sb = new SolidBrush(this.ColorManager.GetBorderColor(state)))
			{
				using (NuGenGrfxMode mode = new NuGenGrfxMode(g))
				{
					g.SmoothingMode = SmoothingMode.AntiAlias;
					g.FillEllipse(sb, bounds);
				}
			}
		}
		private static void DrawItemBackground(Graphics g, Rectangle bounds, NuGenControlState state, Color defaultBackColor)
		{
			Debug.Assert(g != null, "g != null");
			Color backColor;

			if (
				state == NuGenControlState.Normal
				|| state == NuGenControlState.Disabled
				)
			{
				backColor = defaultBackColor;
			}
			else
			{
				backColor = SystemColors.Highlight;
			}

			using (SolidBrush sb = new SolidBrush(backColor))
			{
				g.FillRectangle(sb, bounds);
			}
		}
		/// <summary>
		/// </summary>
		public static TabItemState FromControlState(NuGenControlState ctrlState)
		{
			switch (ctrlState)
			{
				case NuGenControlState.Disabled:
				{
					return TabItemState.Disabled;
				}
				case NuGenControlState.Hot:
				{
					return TabItemState.Hot;
				}
				case NuGenControlState.Pressed:
				{
					return TabItemState.Selected;
				}
				default:
				{
					return TabItemState.Normal;
				}
			}
		}
		/*
		 * DrawCheck
		 */

		/// <summary>
		/// </summary>
		/// <exception cref="ArgumentNullException">
		/// <para>
		///		<paramref name="g"/> is <see langword="null"/>.
		/// </para>
		/// </exception>
		/// <exception cref="InvalidOperationException">
		/// <para>
		///		Border should return an array containing at least 1 element.
		/// </para>
		/// </exception>
		private void DrawCheck(Graphics g, Rectangle bounds, NuGenControlState state)
		{
			if (g == null)
			{
				throw new ArgumentNullException("g");
			}

			int x = bounds.X;
			int y = bounds.Y;

			x += 3;
			y += 3;

			Point p1 = new Point(x, y + 2);
			Point p2 = new Point(x + 2, y + 4);
			Point p3 = new Point(x + 6, y);

			using (Pen pen = this.GetBorderPen(state))
			{
				g.DrawLine(pen, p1, p2);
				g.DrawLine(pen, p2, p3);

				p1.Y++;
				p2.Y++;
				p3.Y++;

				g.DrawLine(pen, p1, p2);
				g.DrawLine(pen, p2, p3);

				p1.Y++;
				p2.Y++;
				p3.Y++;

				g.DrawLine(pen, p1, p2);
				g.DrawLine(pen, p2, p3);
			}
		}
Пример #40
0
		/// <summary>
		/// </summary>
		/// <exception cref="ArgumentNullException">
		///	<para>
		///		<paramref name="g"/> is <see langword="null"/>.
		/// </para>
		/// </exception>
		public void DrawRoundBorder(Graphics g, Rectangle bounds, NuGenControlState state, NuGenRoundRectangleStyle style)
		{
			if (g == null)
			{
				throw new ArgumentNullException("g");
			}

			using (Pen pen = this.GetBorderPen(state))
			{
				NuGenControlPaint.DrawRoundRectangle(g, pen, bounds, _roundRectangleRadius, style);
			}
		}
Пример #41
0
		/// <summary>
		/// </summary>
		/// <exception cref="ArgumentNullException">
		/// <para>
		///		<paramref name="g"/> is <see langword="null"/>.
		/// </para>
		/// </exception>
		public void DrawEllipseBackground(Graphics g, Rectangle bounds, NuGenControlState state)
		{
			if (g == null)
			{
				throw new ArgumentNullException("g");
			}

			using (Brush brush = this.GetBackgroundBrush(bounds, state))
			{
				g.FillEllipse(brush, bounds);
			}
		}
Пример #42
0
		/// <summary>
		/// </summary>
		/// <exception cref="ArgumentNullException">
		/// <para>
		///		<paramref name="g"/> is <see langword="null"/>.
		/// </para>
		/// </exception>
		public void DrawRoundBackground(Graphics g, Rectangle bounds, NuGenControlState state, NuGenRoundRectangleStyle style)
		{
			if (g == null)
			{
				throw new ArgumentNullException("g");
			}

			if (bounds.Width > 0 && bounds.Height > 0)
			{
				using (Brush brush = this.GetBackgroundBrush(bounds, state))
				using (GraphicsPath gp = NuGenControlPaint.GetRoundRectangleGraphicsPath(bounds, _roundRectangleRadius, style))
				{
					g.FillPath(brush, gp);
				}
			}
		}
Пример #43
0
		/// <summary>
		/// </summary>
		/// <exception cref="ArgumentNullException">
		/// <para>
		///		<paramref name="g"/> is <see langword="null"/>.
		/// </para>
		/// </exception>
		public void DrawEllipseBorder(Graphics g, Rectangle bounds, NuGenControlState state)
		{
			if (g == null)
			{
				throw new ArgumentNullException("g");
			}

			using (Pen pen = this.GetBorderPen(state))
			{
				g.DrawEllipse(pen, bounds);
			}
		}
Пример #44
0
		/// <summary>
		/// Initializes a new instance of the <see cref="NuGenPaintParams"/> class.
		/// </summary>
		/// <exception cref="ArgumentNullException">
		/// <para><paramref name="initializeFrom"/> is <see langword="null"/>.</para>
		/// </exception>
		public NuGenPaintParams(NuGenPaintParams initializeFrom)
		{
			if (initializeFrom == null)
			{
				throw new ArgumentNullException("initializeFrom");
			}

			_bounds = initializeFrom.Bounds;
			_graphics = initializeFrom.Graphics;
			_state = initializeFrom.State;
		}
		/// <summary>
		/// </summary>
		public Color GetBorderColor(NuGenControlState state)
		{
			return this.Colors[state].Border;
		}
		/// <summary>
		/// </summary>
		public Color GetShadowColorRightBegin(NuGenControlState state)
		{
			return this.Colors[state].ShadowRightBegin;
		}
Пример #47
0
		/// <summary>
		/// </summary>
		/// <exception cref="ArgumentNullException">
		/// <para>
		///		<paramref name="g"/> is <see langword="null"/>.
		/// </para>
		/// -or-
		/// <para>
		///		<paramref name="font"/> is <see langword="null"/>.
		/// </para>
		/// -or-
		/// <para>
		///		<paramref name="sf"/> is <see langword="null"/>.
		/// </para>
		/// </exception>
		public override void DrawText(
			Graphics g,
			Rectangle bounds,
			NuGenControlState state,
			string text,
			Font font,
			Color foreColor,
			StringFormat sf
			)
		{
			if (g == null)
			{
				throw new ArgumentNullException("g");
			}

			if (font == null)
			{
				throw new ArgumentNullException("font");
			}

			if (sf == null)
			{
				throw new ArgumentNullException("sf");
			}

			using (SolidBrush sb = new SolidBrush(state == NuGenControlState.Disabled ? this.ColorManager.GetBorderColor(state) : foreColor))
			{
				g.DrawString(text, font, sb, bounds, sf);
			}
		}
Пример #48
0
		/// <summary>
		/// </summary>
		/// <exception cref="ArgumentNullException">
		///	<para>
		///		<paramref name="g"/> is <see langword="null"/>.
		/// </para>
		/// </exception>
		public void DrawShadow(Graphics g, Rectangle bounds, NuGenControlState state)
		{
			if (g == null)
			{
				throw new ArgumentNullException("g");
			}

			/* Bottom */

			using (Pen pen = new Pen(this.ColorManager.GetShadowColorBottomBegin(state)))
			{
				g.DrawLine(pen, bounds.Left + 1, bounds.Bottom - 2, bounds.Right - 1, bounds.Bottom - 2);
			}

			using (Pen pen = new Pen(this.ColorManager.GetShadowColorBottomEnd(state)))
			{
				g.DrawLine(pen, bounds.Left + 2, bounds.Bottom - 1, bounds.Right - 2, bounds.Bottom - 1);
			}

			/* Top */

			using (Pen pen = new Pen(this.ColorManager.GetShadowColorTopBegin(state)))
			{
				g.DrawLine(pen, bounds.Left + 2, bounds.Top + 1, bounds.Right - 2, bounds.Top + 1);
			}

			using (Pen pen = new Pen(this.ColorManager.GetShadowColorTopEnd(state)))
			{
				g.DrawLine(pen, bounds.Left + 1, bounds.Top + 2, bounds.Right - 1, bounds.Top + 2);
			}

			/* Left */

			using (Pen pen = new Pen(this.ColorManager.GetShadowColorLeftBegin(state)))
			{
				g.DrawLine(pen, bounds.Left + 1, bounds.Top + 3, bounds.Left + 1, bounds.Bottom - 3);
			}

			using (Pen pen = new Pen(this.ColorManager.GetShadowColorLeftEnd(state)))
			{
				g.DrawLine(pen, bounds.Left + 2, bounds.Top + 3, bounds.Left + 2, bounds.Bottom - 3);
			}

			/* Right */

			using (Pen pen = new Pen(this.ColorManager.GetShadowColorRightBegin(state)))
			{
				g.DrawLine(pen, bounds.Right - 2, bounds.Top + 3, bounds.Right - 2, bounds.Bottom - 3);
			}

			using (Pen pen = new Pen(this.ColorManager.GetShadowColorRightEnd(state)))
			{
				g.DrawLine(pen, bounds.Right - 1, bounds.Top + 3, bounds.Right - 1, bounds.Bottom - 3);
			}
		}
Пример #49
0
		/// <summary>
		/// </summary>
		/// <returns></returns>
		public Brush GetBackgroundBrush(Rectangle bounds, NuGenControlState state)
		{
			Debug.Assert(this.ColorManager != null, "this.ColorManager != null");
			return new LinearGradientBrush(
				bounds, 
				this.ColorManager.GetBackgroundGradientBegin(state),
				this.ColorManager.GetBackgroundGradientEnd(state),
				LinearGradientMode.Vertical
			);
		}
Пример #50
0
		/// <summary>
		/// </summary>
		public Pen GetBorderPen(NuGenControlState state)
		{
			Debug.Assert(this.ColorManager != null, "this.ColorManager != null");
			return new Pen(this.ColorManager.GetBorderColor(state));
		}
		/// <summary>
		/// </summary>
		/// <param name="value"></param>
		protected void SetState(NuGenControlState value)
		{
			_state = value;
		}
Пример #52
0
		/*
		 * DrawBackground
		 */

		/// <summary>
		/// </summary>
		private void DrawItemBackground(
			Graphics g,
			Rectangle bounds,
			NuGenControlState state,
			Color defaultBackColor
			)
		{
			Debug.Assert(g != null, "g != null");
			Rectangle borderBounds = new Rectangle(
				bounds.Left,
				bounds.Top,
				bounds.Width - 1,
				bounds.Height
			);

			if (state == NuGenControlState.Normal
				|| state == NuGenControlState.Disabled
				)
			{
				using (SolidBrush sb = new SolidBrush(defaultBackColor))
				using (Pen pen = new Pen(sb))
				{
					g.FillRectangle(sb, bounds);
					g.DrawRectangle(pen, borderBounds);
				}
			}
			else
			{
				this.DrawBackground(g, bounds, state);
				this.DrawBorder(g, borderBounds, state);
			}
		}
		/// <summary>
		/// </summary>
		public Color GetBackgroundGradientEnd(NuGenControlState state)
		{
			return this.Colors[state].BackgroundGradientEnd;
		}
Пример #54
0
		/// <summary>
		/// </summary>
		/// <param name="g"></param>
		/// <param name="bounds"></param>
		/// <param name="state"></param>
		/// <exception cref="ArgumentNullException">
		///	<para>
		///		<paramref name="g"/> is <see langword="null"/>.
		/// </para>
		/// </exception>
		public void DrawRoundBorder(Graphics g, Rectangle bounds, NuGenControlState state)
		{
			DrawRoundBorder(g, bounds, state, NuGenRoundRectangleStyle.Default);
		}
		/// <summary>
		/// </summary>
		public Color GetShadowColorBottomEnd(NuGenControlState state)
		{
			return this.Colors[state].ShadowBottomEnd;
		}
Пример #56
0
		/// <summary>
		/// Draws an arc representing a portion of an ellipse specified by a pair of coordinates, a width, and a height.
		/// </summary>
		/// <exception cref="ArgumentNullException">
		/// <para><paramref name="g"/> is <see langword="null"/>.</para>
		/// </exception>
		public void DrawArc(
			Graphics g,
			int x,
			int y,
			int width,
			int height,
			int startAngle,
			int sweepAngle,
			NuGenControlState state
		)
		{
			if (g == null)
			{
				throw new ArgumentNullException("g");
			}

			using (Pen pen = this.GetBorderPen(state))
			{
				g.DrawArc(pen, x, y, width, height, startAngle, sweepAngle);
			}
		}
		/// <summary>
		/// </summary>
		public Color GetShadowColorTopEnd(NuGenControlState state)
		{
			return this.Colors[state].ShadowTopEnd;
		}
Пример #58
0
		/// <summary>
		/// </summary>
		/// <param name="g"></param>
		/// <param name="p1"></param>
		/// <param name="p2"></param>
		/// <param name="state"></param>
		/// <exception cref="ArgumentNullException">
		///	<para>
		///		<paramref name="g"/> is <see langword="null"/>.
		/// </para>
		/// </exception>
		public void DrawLine(Graphics g, Point p1, Point p2, NuGenControlState state)
		{
			this.DrawLine(g, (PointF)p1, (PointF)p2, state);
		}
		/// <summary>
		/// Initializes a new instance of the <see cref="NuGenTextPaintParams"/> class.
		/// </summary>
		/// <exception cref="ArgumentNullException">
		/// <para><paramref name="sender"/> is <see langword="null"/>.</para>
		/// -or-
		/// <para><paramref name="g"/> is <see langword="null"/>.</para>
		/// -or-
		/// <para><paramref name="text"/> is <see langword="null"/>.</para>
		/// </exception>
		public NuGenTextPaintParams(object sender, Graphics g, Rectangle bounds, NuGenControlState state, string text)
			: base(sender, g, bounds, state)
		{
			if (text == null)
			{
				throw new ArgumentNullException("text");
			}

			_text = text;
		}
Пример #60
0
		/// <summary>
		/// </summary>
		/// <param name="g"></param>
		/// <param name="p1"></param>
		/// <param name="p2"></param>
		/// <param name="state"></param>
		/// <exception cref="ArgumentNullException">
		///	<para>
		///		<paramref name="g"/> is <see langword="null"/>.
		/// </para>
		/// </exception>
		public void DrawLine(Graphics g, PointF p1, PointF p2, NuGenControlState state)
		{
			if (g == null)
			{
				throw new ArgumentNullException("g");
			}

			using (Pen pen = this.GetBorderPen(state))
			{
				g.DrawLine(pen, p1, p2);
			}
		}