コード例 #1
0
ファイル: NuGenGroupBox.cs プロジェクト: carlhuth/GenXSource
        /*
         * 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);
        }
コード例 #2
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);
        }
コード例 #3
0
            /*
             * OnPaint
             */

            /// <summary>
            /// Raises the <see cref="System.Windows.Forms.Control.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)
            {
                NuGenPaintParams paintParams = new NuGenPaintParams(this, e.Graphics, this.ClientRectangle, NuGenControlState.Normal);

                this.Renderer.DrawBackground(paintParams);
                this.Renderer.DrawBorder(paintParams);
            }
コード例 #4
0
		/// <summary>
		/// </summary>
		/// <param name="paintParams"></param>
		/// <exception cref="ArgumentNullException">
		/// <para><paramref name="paintParams"/> is <see langword="null"/>.</para>
		/// </exception>
		public void DrawExtendedBackground(NuGenPaintParams paintParams)
		{
			if (paintParams == null)
			{
				throw new ArgumentNullException("paintParams");
			}

			this.DrawBackground(paintParams);
			Color borderColor = this.ColorManager.GetBorderColor(paintParams.State);
			Graphics g = paintParams.Graphics;
			Rectangle bounds = paintParams.Bounds;

			int ellipseWidth = 2 * bounds.Width;
			int ellipseHeight = 2 * bounds.Height;

			int ellipseStart = 0;
			int ellipseStep = 50;

			using (SolidBrush sb = new SolidBrush(Color.FromArgb(20, borderColor)))
			{
				g.FillEllipse(sb, ellipseStart, ellipseStart, ellipseWidth, ellipseHeight);
				g.FillEllipse(sb, ellipseStart + ellipseStep, ellipseStart + ellipseStep, ellipseWidth, ellipseHeight);
				g.FillEllipse(sb, ellipseStart + ellipseStep * 2, ellipseStart + ellipseStep * 2, ellipseWidth, ellipseHeight);
			}
		}
コード例 #5
0
		/// <summary>
		/// </summary>
		/// <param name="paintParams"></param>
		public void DrawShadow(NuGenPaintParams paintParams)
		{
			if (paintParams == null)
			{
				throw new ArgumentNullException("paintParams");
			}

			Graphics g = paintParams.Graphics;
			Rectangle bounds = paintParams.Bounds;

			int alpha = 0;
			Color baseColor = Color.Black;
			int alphaStep = 5;
			Padding deflatePadding = new Padding(1);

			using (NuGenGrfxMode mode = new NuGenGrfxMode(g))
			{
				NuGenControlPaint.SetGraphicsVeryHighQuality(g);

				using (Pen pen = new Pen(Color.FromArgb(alpha, baseColor)))
				{
					for (int i = 0; i <= _shadowStepCount; i++)
					{
						g.DrawRectangle(pen, bounds);
						pen.Color = Color.FromArgb(alpha += alphaStep, baseColor);
						bounds = NuGenControlPaint.DeflateRectangle(bounds, deflatePadding);

						if (i == 1)
						{
							alphaStep = 10;
						}
					}
				}
			}
		}
コード例 #6
0
		/// <summary>
		/// </summary>
		/// <param name="paintParams"></param>
		/// <exception cref="ArgumentNullException">
		/// <para><paramref name="paintParams"/> is <see langword="null"/>.</para>
		/// </exception>
		public void DrawDoubleScrollButton(NuGenPaintParams paintParams)
		{
			if (paintParams == null)
			{
				throw new ArgumentNullException("paintParams");
			}

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

			Rectangle bounds = paintParams.Bounds;

			paintParams.Bounds = new Rectangle(
				bounds.Left
				, bounds.Top - 3
				, bounds.Width
				, bounds.Height
			);
			this.DrawScrollButtonBody(paintParams);

			paintParams.Bounds = new Rectangle(
				bounds.Left
				, bounds.Top + 3
				, bounds.Width
				, bounds.Height
			);
			this.DrawScrollButtonBody(paintParams);
		}
			protected override void OnPaint(PaintEventArgs e)
			{
				NuGenPaintParams paintParams = new NuGenPaintParams(e.Graphics);
				paintParams.Bounds = this.ClientRectangle;
				paintParams.State = this.StateTracker.GetControlState();
				this.Renderer.DrawToolBarSeparator(paintParams);
			}
コード例 #8
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)
			{
				NuGenPaintParams paintParams = new NuGenPaintParams(e.Graphics);
				paintParams.Bounds = this.Bounds;
				paintParams.State = this.ButtonStateTracker.GetControlState();
				this.Renderer.DrawDropDownButton(paintParams);
			}
コード例 #9
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);
				}
			}
		}
コード例 #10
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;
			}
		}
コード例 #11
0
		/// <summary>
		/// </summary>
		/// <param name="paintParams"></param>
		/// <exception cref="ArgumentNullException">
		/// <para><paramref name="paintParams"/> is <see langword="null"/>.</para>
		/// </exception>
		public void DrawCCWRotateButton(NuGenPaintParams paintParams)
		{
			if (paintParams == null)
			{
				throw new ArgumentNullException("paintParams");
			}

			NuGenImagePaintParams imagePaintParams = new NuGenImagePaintParams(paintParams);

			switch (imagePaintParams.State)
			{
				case NuGenControlState.Hot:
				case NuGenControlState.Pressed:
				{
					imagePaintParams.Image = res.RotateCCW_Hot;
					break;
				}
				default:
				{
					imagePaintParams.Image = res.RotateCCW_Normal;
					break;
				}
			}

			this.DrawImage(imagePaintParams);
		}
コード例 #12
0
		/// <summary>
		/// </summary>
		/// <param name="paintParams"></param>
		public void DrawBorder(NuGenPaintParams paintParams)
		{
			base.DrawBorder(
				paintParams.Graphics
				, NuGenControlPaint.BorderRectangle(paintParams.Bounds)
				, paintParams.State
			);
		}
コード例 #13
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)
            {
                NuGenPaintParams paintParams = new NuGenPaintParams(e.Graphics);

                paintParams.Bounds = this.Bounds;
                paintParams.State  = this.ButtonStateTracker.GetControlState();
                this.Renderer.DrawDropDownButton(paintParams);
            }
コード例 #14
0
ファイル: NuGenButton.cs プロジェクト: carlhuth/GenXSource
        /*
         * 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);
        }
コード例 #15
0
		/*
		 * DrawBackground
		 */

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

			base.DrawRoundBackground(paintParams);
		}
コード例 #16
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)
        {
            NuGenPaintParams paintParams = new NuGenPaintParams(e.Graphics);

            paintParams.Bounds = this.ClientRectangle;
            paintParams.State  = this.StateTracker.GetControlState();
            this.Renderer.DrawBackground(paintParams);
            this.Renderer.DrawNavigationPaneBorder(paintParams);
        }
コード例 #17
0
		/*
		 * DrawComboBoxButton
		 */

		/// <summary>
		/// </summary>
		/// <param name="paintParams"></param>
		/// <exception cref="ArgumentNullException">
		/// <para><paramref name="paintParams"/> is <see langword="null"/>.</para>
		/// </exception>
		/// <exception cref="InvalidOperationException">
		/// <para>
		///		Border should return an array containing at least 1 element.
		/// </para>
		/// </exception>
		public void DrawComboBoxButton(NuGenPaintParams paintParams)
		{
			if (paintParams == null)
			{
				throw new ArgumentNullException("paintParams");
			}

			this.DrawScrollButton(paintParams);
		}
コード例 #18
0
		/// <summary>
		/// </summary>
		/// <param name="paintParams"></param>
		/// <exception cref="ArgumentNullException"><paramref name="paintParams"/> is <see langword="null"/>.</exception>
		public void DrawBorder(NuGenPaintParams paintParams)
		{
			if (paintParams == null)
			{
				throw new ArgumentNullException("paintParams");
			}

			base.DrawBorder(paintParams.Graphics, paintParams.Bounds, paintParams.State);
		}
コード例 #19
0
		/// <summary>
		/// </summary>
		/// <param name="paintParams"></param>
		/// <exception cref="ArgumentNullException"><para><paramref name="paintParams"/> is <see langword="null"/>.</para></exception>
		public void DrawDropDownButton(NuGenPaintParams paintParams)
		{
			if (paintParams == null)
			{
				throw new ArgumentNullException("paintParams");
			}

			this.DrawScrollButtonBody(paintParams);
		}
コード例 #20
0
		/*
		 * DrawShadow
		 */

		/// <summary>
		/// </summary>
		/// <param name="paintParams"></param>
		public void DrawShadow(NuGenPaintParams paintParams)
		{
			if (paintParams == null)
			{
				throw new ArgumentNullException("paintParams");
			}

			this.DrawShadow(paintParams.Graphics, NuGenSmoothButtonRenderer.GetBorderRectangle(paintParams.Bounds), paintParams.State);
		}
コード例 #21
0
		/// <summary>
		/// </summary>
		/// <param name="paintParams"></param>
		/// <exception cref="ArgumentNullException">
		/// <para>
		///		<paramref name="paintParams"/> is <see langword="null"/>.
		/// </para>
		/// </exception>
		public void DrawBorder(NuGenPaintParams paintParams)
		{
			if (paintParams == null)
			{
				throw new ArgumentNullException("paintParams");
			}

			this.DrawBorder(paintParams.Graphics, NuGenControlPaint.BorderRectangle(paintParams.Bounds), paintParams.State);
		}
コード例 #22
0
		void INuGenPanelExRenderer.DrawBackground(NuGenPaintParams paintParams)
		{
			if (paintParams == null)
			{
				throw new ArgumentNullException("paintParams");
			}

			base.DrawBackground(paintParams);
			RendererUtils.DrawBackground(this.ServiceProvider, paintParams);
		}
コード例 #23
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;
        }
コード例 #24
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");

            NuGenPaintParams paintParams = new NuGenPaintParams(e.Graphics);

            paintParams.Bounds = this.ClientRectangle;
            paintParams.State  = this.ButtonStateTracker.GetControlState();

            this.Renderer.DrawCloseButton(paintParams);
        }
コード例 #25
0
        private void doccomment_Paint(object sender, PaintEventArgs e)
        {
            Debug.Assert(this.Renderer != null, "this.Renderer != null");

            NuGenPaintParams paintParams = new NuGenPaintParams(e.Graphics);

            paintParams.Bounds = _doccomment.Properties["ClientRectangle"].GetValue <Rectangle>();
            paintParams.State  = this.StateTracker.GetControlState();

            this.Renderer.DrawDocComment(paintParams);
        }
コード例 #26
0
		/// <summary>
		/// </summary>
		/// <param name="paintParams"></param>
		/// <exception cref="ArgumentNullException">
		/// <para><paramref name="paintParams"/> is <see langword="null"/>.</para>
		/// </exception>
		public void DrawButtonBorder(NuGenPaintParams paintParams)
		{
			if (paintParams == null)
			{
				throw new ArgumentNullException("paintParams");
			}

			Rectangle borderRectangle = paintParams.Bounds;
			borderRectangle.Width--;
			this.DrawBorder(paintParams.Graphics, borderRectangle, paintParams.State);
		}
コード例 #27
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
			);
		}
コード例 #28
0
		void INuGenButtonRenderer.DrawBackground(NuGenPaintParams paintParams)
		{
			if (paintParams == null)
			{
				throw new ArgumentNullException("paintParams");
			}

			this.DrawBackground(
				paintParams.Graphics,
				Rectangle.Inflate(paintParams.Bounds, -2, -2),
				paintParams.State
			);
		}
コード例 #29
0
		/// <summary>
		/// </summary>
		/// <param name="paintParams"></param>
		/// <exception cref="ArgumentNullException">
		/// <para>
		///		<paramref name="paintParams"/> is <see langword="null"/>.
		/// </para>
		/// </exception>
		public void DrawDocComment(NuGenPaintParams paintParams)
		{
			if (paintParams == null)
			{
				throw new ArgumentNullException("paintParams");
			}

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

			this.DrawBackground(paintParams);
			this.DrawBorder(g, NuGenControlPaint.BorderRectangle(bounds), state);
		}
コード例 #30
0
        /*
         * OnPaint
         */

        /// <summary>
        /// Raises the <see cref="M:System.Windows.Forms.ButtonBase.OnPaint(System.Windows.Forms.PaintEventArgs)"></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;

            /* Translate e.Graphics to render different scroll-button styles. */

            switch (this.Style)
            {
            case NuGenScrollButtonStyle.Left:
            {
                bounds = new Rectangle(bounds.Top, bounds.Left, bounds.Height, bounds.Width);
                NuGenControlPaint.Make90CWGraphics(g, bounds);
                break;
            }

            case NuGenScrollButtonStyle.Right:
            {
                NuGenControlPaint.Make90CCWGraphics(g, bounds);
                bounds = new Rectangle(bounds.Top, bounds.Left, bounds.Height, bounds.Width);
                break;
            }

            case NuGenScrollButtonStyle.Up:
            {
                NuGenControlPaint.Make180CCWGraphics(g, bounds);
                break;
            }
            }

            if (
                bounds.Width > 0 &&
                bounds.Height > 0
                )
            {
                NuGenPaintParams paintParams = new NuGenPaintParams(g);
                paintParams.Bounds = bounds;
                paintParams.State  = this.ButtonStateTracker.GetControlState();

                if (this.DoubleArrow)
                {
                    this.Renderer.DrawDoubleScrollButton(paintParams);
                }
                else
                {
                    this.Renderer.DrawScrollButton(paintParams);
                }
            }
        }
コード例 #31
0
		/// <summary>
		/// </summary>
		/// <exception cref="ArgumentNullException"><paramref name="paintParams"/> is <see langword="null"/>.</exception>
		public void DrawFisheyeExpander(NuGenPaintParams paintParams)
		{
			if (paintParams == null)
			{
				throw new ArgumentNullException("paintParams");
			}

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

			if (state == NuGenControlState.Hot)
			{
				using (SolidBrush sb = new SolidBrush(Color.FromArgb(30, this.ColorManager.GetBorderColor(expanderState))))
				{
					g.FillRectangle(sb, bounds);
				}

				this.DrawBorder(g, bounds, expanderState);
			}
			else if (state == NuGenControlState.Normal)
			{
				this.DrawBorder(g, NuGenControlPaint.BorderRectangle(bounds), expanderState);
			}

			NuGenPaintParams arrowPaintParams = new NuGenPaintParams(paintParams);
			arrowPaintParams.State = expanderState;
			arrowPaintParams.Bounds = Rectangle.FromLTRB(
				bounds.Left
				, bounds.Bottom - 20
				, bounds.Right
				, bounds.Bottom
			);

			this.DrawScrollButtonBody(arrowPaintParams);

			arrowPaintParams.Bounds = Rectangle.FromLTRB(
				bounds.Left
				, bounds.Top
				, bounds.Right
				, bounds.Top + 30
			);

			g.RotateTransform(180);
			g.TranslateTransform(-(bounds.Width * 2 + bounds.Left + 3), -(24 + bounds.Y * 2));
			this.DrawScrollButtonBody(arrowPaintParams);
			g.ResetTransform();
		}
コード例 #32
0
        /*
         * DrawDropDown
         */

        private void DrawDropDown(Graphics g)
        {
            Debug.Assert(g != null, "g != null");
            NuGenControlState state = this.StateTracker.GetControlState();

            if (_dropDownHovering)
            {
                state = NuGenControlState.Hot;
            }

            NuGenPaintParams dropDownPaintParams = new NuGenPaintParams(this, g, this.GetDropDownRectangle(), state);

            this.Renderer.DrawBackground(dropDownPaintParams);
            this.Renderer.DrawDropDownArrow(dropDownPaintParams);
        }
コード例 #33
0
		/// <summary>
		/// </summary>
		/// <param name="paintParams"></param>
		/// <exception cref="ArgumentNullException"><para><paramref name="paintParams"/> is <see langword="null"/>.</para></exception>
		public void DrawBorder(NuGenPaintParams paintParams)
		{
			if (paintParams == null)
			{
				throw new ArgumentNullException("paintParams");
			}

			Graphics g = paintParams.Graphics;

			using (NuGenGrfxMode mode = new NuGenGrfxMode(g))
			{
				g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
				this.DrawRoundBorder(g, NuGenControlPaint.BorderRectangle(paintParams.Bounds), paintParams.State);
			}
		}
コード例 #34
0
		/// <summary>
		/// </summary>
		/// <param name="paintParams"></param>
		/// <exception cref="ArgumentNullException">
		/// <para><paramref name="paintParams"/> is <see langword="null"/>.</para>
		/// </exception>
		public void DrawSplitLine(NuGenPaintParams paintParams)
		{
			if (paintParams == null)
			{
				throw new ArgumentNullException("paintParams");
			}

			Rectangle bounds = paintParams.Bounds;

			this.DrawLine(
				paintParams.Graphics
				, NuGenControlPaint.RectTLCorner(bounds)
				, NuGenControlPaint.RectBLCorner(bounds)
				, paintParams.State
			);
		}
コード例 #35
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)
			{
				base.OnPaint(e);

				if (
					this.ClientRectangle.Width > 0
					&& this.ClientRectangle.Height > 0
					)
				{
					NuGenPaintParams paintParams = new NuGenPaintParams(e.Graphics);
					paintParams.Bounds = NuGenControlPaint.OrientationAgnosticRectangle(this.ClientRectangle, this.Orientation);
					paintParams.State = this.ButtonStateTracker.GetControlState();
					
					this.Renderer.DrawSizeBox(paintParams);
				}
			}
コード例 #36
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)
            {
                base.OnPaint(e);

                if (
                    this.ClientRectangle.Width > 0 &&
                    this.ClientRectangle.Height > 0
                    )
                {
                    NuGenPaintParams paintParams = new NuGenPaintParams(e.Graphics);
                    paintParams.Bounds = NuGenControlPaint.OrientationAgnosticRectangle(this.ClientRectangle, this.Orientation);
                    paintParams.State  = this.ButtonStateTracker.GetControlState();

                    this.Renderer.DrawSizeBox(paintParams);
                }
            }
コード例 #37
0
ファイル: NuGenButton.cs プロジェクト: carlhuth/GenXSource
        /*
         * 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(this.ClientRectangle);

            NuGenPaintParams paintParams = new NuGenPaintParams(this, g, bounds, 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(
                    this,
                    g,
                    imageBounds = this.LayoutManager.GetImageBounds(new NuGenImageBoundsParams(contentBounds, image, imageAlign)),
                    currentState,
                    image
                    );

                this.Renderer.DrawImage(imagePaintParams);
            }

            NuGenTextPaintParams textPaintParams = new NuGenTextPaintParams(
                this,
                g,
                this.LayoutManager.GetTextBounds(new NuGenTextBoundsParams(contentBounds, imageBounds, imageAlign)),
                currentState,
                this.Text
                );

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

            this.Renderer.DrawText(textPaintParams);
        }
コード例 #38
0
            /*
             * DrawButton
             */

            private void DrawButton(Graphics g, NuGenNavigationButton button)
            {
                Debug.Assert(g != null, "g != null");
                Debug.Assert(button != null, "button != null");

                NuGenControlState buttonState = this.StateTracker.GetControlState();

                if (button == _hoveringButton)
                {
                    buttonState = button == _selectedButton ? NuGenControlState.Pressed : NuGenControlState.Hot;
                }
                else
                {
                    if (button == _selectedButton)
                    {
                        buttonState = NuGenControlState.Pressed;
                    }
                }

                NuGenPaintParams paintParams = new NuGenPaintParams(g);

                paintParams.Bounds = button.Bounds;
                paintParams.State  = buttonState;

                this.Renderer.DrawBackground(paintParams);

                if (button.IsLarge)
                {
                    NuGenItemPaintParams itemPaintParams = new NuGenItemPaintParams(paintParams);

                    itemPaintParams.ContentAlign = ContentAlignment.MiddleLeft;
                    itemPaintParams.Font         = this.Font;
                    itemPaintParams.ForeColor    = this.ForeColor;
                    itemPaintParams.Image        = button.Image;
                    itemPaintParams.Text         = button.Text;

                    this.Renderer.DrawLargeButtonBody(itemPaintParams);
                    this.Renderer.DrawButtonBorder(paintParams);
                }
                else
                {
                    NuGenImagePaintParams imagePaintParams = new NuGenImagePaintParams(paintParams);
                    imagePaintParams.Image = button.Image;

                    this.Renderer.DrawSmallButtonBody(imagePaintParams);
                }
            }
コード例 #39
0
            /*
             * OnPaint
             */

            protected override void OnPaint(PaintEventArgs e)
            {
                Graphics g          = e.Graphics;
                Size     shadowSize = this.LayoutManager.GetShadowSize();

                Rectangle bodyBounds = new Rectangle(
                    this.ClientRectangle.Left,
                    this.ClientRectangle.Top,
                    this.ClientRectangle.Width - shadowSize.Width,
                    this.ClientRectangle.Height - shadowSize.Height
                    );

                NuGenPaintParams bodyPaintParams = new NuGenPaintParams(this, g, bodyBounds, NuGenControlState.Normal);

                this.Renderer.DrawBackground(bodyPaintParams);
                this.Renderer.DrawBorder(bodyPaintParams);
            }
コード例 #40
0
		/*
		 * DrawBackground
		 */

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

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

			using (NuGenGrfxMode mode = new NuGenGrfxMode(g))
			{
				g.SmoothingMode = SmoothingMode.AntiAlias;
				g.PixelOffsetMode = PixelOffsetMode.HighQuality;
				this.DrawRoundBackground(g, bounds, state);
			}
		}
コード例 #41
0
ファイル: NuGenPanelEx.cs プロジェクト: carlhuth/GenXSource
        /// <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)
        {
            NuGenPaintParams paintParams = new NuGenPaintParams(e.Graphics);

            paintParams.Bounds = this.ClientRectangle;
            paintParams.State  = this.StateTracker.GetControlState();

            if (this.DrawShadow)
            {
                this.Renderer.DrawShadow(paintParams);
            }

            paintParams.Bounds = this.DisplayRectangle;
            this.Renderer.DrawBackground(paintParams);
            this.Renderer.DrawBorder(paintParams);

            base.OnPaint(e);
        }
コード例 #42
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)
        {
            Graphics g = e.Graphics;

            Debug.Assert(this.StateTracker != null, "this.StateTracker != null");

            NuGenPaintParams paintParams = new NuGenPaintParams(
                this,
                e.Graphics,
                this.ClientRectangle,
                this.StateTracker.GetControlState()
                );

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

            base.OnPaint(e);
        }
コード例 #43
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)
        {
            Rectangle        clientRect  = this.ClientRectangle;
            NuGenPaintParams paintParams = new NuGenPaintParams(e.Graphics);

            paintParams.Bounds = clientRect;
            paintParams.State  = this.StateTracker.GetControlState();
            NuGenPaintParams borderPaintParams = new NuGenPaintParams(paintParams);

            borderPaintParams.Bounds = new Rectangle(
                clientRect.Left,
                clientRect.Top - 1,
                clientRect.Width - 1,
                clientRect.Height
                );
            this.Renderer.DrawBackground(paintParams);
            this.Renderer.DrawBorder(borderPaintParams);
            base.OnPaint(e);
        }
コード例 #44
0
		/*
		 * DrawForeground
		 */

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

			Graphics g = paintParams.Graphics;
			Rectangle bounds = paintParams.Bounds;

			if (bounds.Height > 0 && bounds.Width > 0)
			{
				using (NuGenGrfxMode mode = new NuGenGrfxMode(g))
				{
					g.SmoothingMode = SmoothingMode.AntiAlias;
					this.DrawBackground(paintParams.Graphics, bounds, NuGenControlState.Pressed);
				}
			}
		}
コード例 #45
0
		/// <summary>
		/// </summary>
		/// <param name="serviceProvider">
		/// <para>Requires:</para>
		/// <para><see cref="INuGenSmoothColorManager"/></para>
		/// </param>
		/// <param name="paintParams"></param>
		/// <exception cref="ArgumentNullException">
		/// <para><paramref name="serviceProvider"/> is <see langword="null"/>.</para>
		/// -or-
		/// <para><paramref name="paintParams"/> is <see langword="null"/>.</para>
		/// </exception>
		/// <exception cref="NuGenServiceNotFoundException"/>
		public static void DrawBackground(INuGenServiceProvider serviceProvider, NuGenPaintParams paintParams)
		{
			if (serviceProvider == null)
			{
				throw new ArgumentNullException("serviceProvider");
			}

			if (paintParams == null)
			{
				throw new ArgumentNullException("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)
			{
				INuGenSmoothColorManager colorManager = serviceProvider.GetService<INuGenSmoothColorManager>();

				if (colorManager == null)
				{
					throw new NuGenServiceNotFoundException<INuGenSmoothColorManager>();
				}

				Color beginColor = Color.FromArgb(60, colorManager.GetBorderColor(state));
				Color endColor = Color.FromArgb(10, colorManager.GetBackgroundGradientEnd(state));

				using (Brush brush = new LinearGradientBrush(ellipseBounds, beginColor, endColor, 0.0f))
				{
					g.SetClip(bounds, CombineMode.Replace);
					g.FillEllipse(brush, ellipseBounds);
				}
			}
		}
コード例 #46
0
ファイル: NuGenComboBox.cs プロジェクト: carlhuth/GenXSource
        /*
         * DrawComboBox
         */

        private void DrawComboBox(Graphics g)
        {
            if (g == null)
            {
                throw new ArgumentNullException("g");
            }

            Debug.Assert(this.ButtonStateTracker != null, "this.ButtonStateTracker != null");
            Debug.Assert(this.Renderer != null, "this.Renderer != null");

            NuGenControlState currentState = this.ButtonStateTracker.GetControlState();

            NuGenPaintParams paintParams = new NuGenPaintParams(g);

            paintParams.State = currentState;

            paintParams.Bounds = NuGenControlPaint.DropDownButtonBounds(this.ClientRectangle, this.RightToLeft);
            this.Renderer.DrawComboBoxButton(paintParams);

            paintParams.Bounds = this.ClientRectangle;
            this.Renderer.DrawBorder(paintParams);
        }
コード例 #47
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)
        {
            NuGenItemPaintParams titlePaintParams = new NuGenItemPaintParams(e.Graphics);

            titlePaintParams.Bounds = new Rectangle(
                this.ClientRectangle.Left
                , this.ClientRectangle.Top
                , this.ClientRectangle.Width
                , this.TitleHeight
                );

            titlePaintParams.ContentAlign = this.RightToLeft == RightToLeft.Yes
                                ? ContentAlignment.MiddleRight
                                : ContentAlignment.MiddleLeft
            ;
            titlePaintParams.Font      = this.Font;
            titlePaintParams.ForeColor = this.ForeColor;
            titlePaintParams.State     = this.StateTracker.GetControlState();
            titlePaintParams.Text      = this.Text;

            NuGenPaintParams bkgndPaintParams = new NuGenPaintParams(titlePaintParams);

            bkgndPaintParams.Bounds = this.DisplayRectangle;

            NuGenBorderPaintParams borderPaintParams = new NuGenBorderPaintParams(bkgndPaintParams);

            borderPaintParams.Bounds     = this.ClientRectangle;
            borderPaintParams.DrawBorder = this.DrawBorder;

            this.PanelRenderer.DrawBackground(bkgndPaintParams);
            this.PanelRenderer.DrawBorder(borderPaintParams);

            this.TitleRenderer.DrawBackground(titlePaintParams);
            this.TitleRenderer.DrawBody(titlePaintParams);
            this.TitleRenderer.DrawBorder(titlePaintParams);

            base.OnPaint(e);
        }
コード例 #48
0
		/*
		 * DrawBevel
		 */

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

			Graphics g = paintParams.Graphics;
			Point pt1 = paintParams.Bounds.Location;
			Point pt2 = (Point)paintParams.Bounds.Size;
			NuGenControlState state = paintParams.State;

			using (Pen topBevelPen = this.GetBorderPen(state))
			using (Pen bottomBevelPen = new Pen(this.ColorManager.GetBackgroundGradientBegin(state)))
			{
				g.DrawLine(topBevelPen, pt1, pt2);

				pt1.Offset(0, 1);
				pt2.Offset(0, 1);

				g.DrawLine(bottomBevelPen, pt1, pt2);
			}
		}
コード例 #49
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);
			}
コード例 #50
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);
		}
コード例 #51
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)
            {
                int bottomContainerHeight = this.GetBottomContainerRectangle().Height;
                int buttonHeight          = this.GetButtonHeight();
                int gripHeight            = this.GetGripRectangle().Height;

                _maxLargeButtonCount = (int)Math.Floor(
                    (double)((this.Height - bottomContainerHeight - gripHeight) / buttonHeight)
                    );

                int visibleCount = _buttons.GetVisibleCount();

                if (visibleCount < _maxLargeButtonCount)
                {
                    _maxLargeButtonCount = visibleCount;
                }

                _canShrink = _maxLargeButtonCount != 0;
                _canGrow   = _maxLargeButtonCount < visibleCount;

                this.Height = _maxLargeButtonCount * buttonHeight + gripHeight + bottomContainerHeight;

                int bottomContainerLeftMargin = this.GetBottomContainerLeftMargin();
                int dropDownWidth             = this.GetDropDownRectangle().Width;
                int smallButtonWidth          = this.GetSmallButtonWidth();

                _maxSmallButtonCount = (int)Math.Floor(
                    (double)((this.Width - dropDownWidth - bottomContainerLeftMargin) / smallButtonWidth)
                    );

                if (visibleCount - _maxLargeButtonCount <= 0)
                {
                    _maxSmallButtonCount = 0;
                }

                if (_maxSmallButtonCount > (visibleCount - _maxLargeButtonCount))
                {
                    _maxSmallButtonCount = visibleCount - _maxLargeButtonCount;
                }

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

                paintParams.State = currentState;

                /* Border */

                paintParams.Bounds = bounds;
                this.Renderer.DrawBorder(paintParams);

                /* Grip */

                paintParams.Bounds = this.GetGripRectangle();
                this.Renderer.DrawGrip(paintParams);

                /* Large buttons */

                int syncLargeButtons = 0;
                int iterateLargeButtons;

                for (iterateLargeButtons = 0; iterateLargeButtons < _buttons.Count; iterateLargeButtons++)
                {
                    NuGenNavigationButton button = _buttons[iterateLargeButtons];

                    if (button.Visible)
                    {
                        Rectangle rect = new Rectangle(0, syncLargeButtons * this.GetButtonHeight() + this.GetGripHeight(), this.ClientRectangle.Width, this.GetButtonHeight());
                        button.Bounds  = rect;
                        button.IsLarge = true;
                        this.DrawButton(g, button);

                        if (syncLargeButtons == _maxLargeButtonCount)
                        {
                            break;
                        }

                        syncLargeButtons++;
                    }
                }

                /* Bottom container */

                paintParams.Bounds = this.GetBottomContainerRectangle();
                this.Renderer.DrawBackground(paintParams);

                /* Small buttons */

                int startX           = this.ClientRectangle.Width - this.GetDropDownRectangle().Width - _maxSmallButtonCount * this.GetSmallButtonWidth();
                int syncSmallButtons = 0;
                int iterateSmallButtons;

                for (iterateSmallButtons = iterateLargeButtons; iterateSmallButtons < _buttons.Count; iterateSmallButtons++)
                {
                    if (syncSmallButtons == _maxSmallButtonCount)
                    {
                        break;
                    }

                    NuGenNavigationButton button = _buttons[iterateSmallButtons];

                    if (button.Visible)
                    {
                        Rectangle rect = new Rectangle(startX + (syncSmallButtons * this.GetSmallButtonWidth()), this.GetBottomContainerRectangle().Y, this.GetSmallButtonWidth(), this.GetBottomContainerRectangle().Height);
                        button.Bounds  = rect;
                        button.IsLarge = false;
                        this.DrawButton(g, button);
                        syncSmallButtons++;
                    }
                }

                for (int i = iterateSmallButtons; i < _buttons.Count; i++)
                {
                    _buttons[i].Bounds = Rectangle.Empty;
                }

                /* DropDown */

                this.DrawDropDown(g);

                /* Bottom container border */

                this.Renderer.DrawBorder(paintParams);
            }
コード例 #52
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NuGenItemPaintParams"/> class.
 /// </summary>
 /// <exception cref="ArgumentNullException">
 /// <para><paramref name="initializeFrom"/> is <see langword="null"/>.</para>
 /// </exception>
 public NuGenItemPaintParams(NuGenPaintParams initializeFrom)
     : base(initializeFrom)
 {
 }
コード例 #53
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)
        {
            if (!_shouldRender)
            {
                return;
            }

            int i;
            int x;
            int y;
            int space;
            int size;
            int width  = this.Width;
            int height = this.Height;

            Graphics g = e.Graphics;

            g.TextRenderingHint = TextRenderingHint.AntiAlias;

            /*
             * Fisheye
             */

            y = _borderY;
            int  y1 = 0;
            int  y2 = height - _borderY;
            bool start;

            size = 0;

            if (_focusLock)
            {
                start = true;
                y     = _flFocusPosition;
                for (i = _focusIndex - 1; i >= 0; i--)
                {
                    size  = _flSizeLUT[i];
                    space = _flSpaceLUT[i];

                    if (size == _minFontSize)
                    {
                        y1 = y + size + space;
                        break;
                    }

                    y -= size + space;
                }

                y = _flFocusPosition;

                for (i = _focusIndex; i < this.Items.Count; i++)
                {
                    size  = _flSizeLUT[i];
                    space = _flSpaceLUT[i];

                    if (size == _minFontSize)
                    {
                        y2 = y;
                        break;
                    }

                    y += size + space;
                }

                if (y1 < _borderY)
                {
                    y1 = _borderY;
                }
            }
            else
            {
                start = true;

                for (i = 0; i < this.Items.Count; i++)
                {
                    size  = _sizeLUT[_focusIndex][i];
                    space = _spaceLUT[_focusIndex][i];

                    if (start)
                    {
                        if (size > _minFontSize)
                        {
                            y1    = y;
                            start = false;
                        }
                    }
                    else
                    {
                        if (size == _minFontSize)
                        {
                            y2 = y - size;
                            break;
                        }
                    }

                    y += size + space;
                }
            }

            if (this.Items.Count > 0 && !_noFishEye)
            {
                int expanderLeft   = width / 2;
                int expanderTop    = y1;
                int expanderWidth  = width / 2 - _borderRight;
                int expanderHeight = y2 - y1;

                if (expanderWidth > 0 && expanderHeight > 0)
                {
                    NuGenPaintParams expanderPaintParams = new NuGenPaintParams(g);
                    expanderPaintParams.Bounds = new Rectangle(
                        expanderLeft
                        , expanderTop
                        , expanderWidth
                        , expanderHeight
                        );

                    if (_focusLock)
                    {
                        expanderPaintParams.State = NuGenControlState.Hot;
                    }
                    else
                    {
                        expanderPaintParams.State = NuGenControlState.Normal;
                    }

                    this.Renderer.DrawFisheyeExpander(expanderPaintParams);
                }
            }

            /*
             * Items
             */

            x = _borderLeft;
            y = _borderY;

            NuGenTextPaintParams itemPaintParams = new NuGenTextPaintParams(g);

            itemPaintParams.ForeColor = this.ForeColor;
            itemPaintParams.State     = this.StateTracker.GetControlState();
            itemPaintParams.TextAlign = ContentAlignment.MiddleLeft;

            List <string> sortedItems = this.GetSortedItems(this.Items);

            Debug.Assert(sortedItems != null, "sortedItems != null");

            if (!_focusLock /* Normal mode. */)
            {
                for (i = 0; i < sortedItems.Count; i++)
                {
                    size  = _sizeLUT[_focusIndex][i];
                    space = _spaceLUT[_focusIndex][i];

                    // Draw focused element with a background hilight
                    if (_selectedIndex == i)
                    {
                        NuGenPaintParams selPaintParams = new NuGenPaintParams(itemPaintParams);
                        selPaintParams.Bounds = this.LayoutManager.GetSelectionFrameBounds(
                            _borderLeft, y, width - (_borderLeft + _borderRight) - 1, size + space
                            );
                        selPaintParams.State = NuGenControlState.Hot;

                        this.Renderer.DrawSelectionFrame(selPaintParams);
                    }                     // if

                    itemPaintParams.Text   = sortedItems[i];
                    itemPaintParams.Font   = _fonts[size - 1];
                    itemPaintParams.Bounds = this.GetTextBounds(g, itemPaintParams.Text, itemPaintParams.Font, x, y);

                    this.Renderer.DrawText(itemPaintParams);
                    y += space + size;
                }                 // for

                foreach (KeyValuePair <string, int> pair in _labelLUT)
                {
                    itemPaintParams.Text   = pair.Key;
                    itemPaintParams.Font   = _boldFonts[_maxFontSize - 1];
                    itemPaintParams.Bounds = this.GetTextBounds(
                        g
                        , itemPaintParams.Text
                        , itemPaintParams.Font
                        , _labelBorderLeft
                        , pair.Value - _sizeLUT[0][0]
                        );

                    this.Renderer.DrawText(itemPaintParams);
                }            // foreach
            }
            else             /* Fisheye mode. */
            {
                if (_focusIndex > 0 /* First render from focus up. */)
                {
                    y = _flFocusPosition - _flSizeLUT[_focusIndex - 1] - _flSpaceLUT[_focusIndex - 1];

                    for (i = _focusIndex - 1; i >= 0; i--)
                    {
                        if (y < _borderY)
                        {
                            break;
                        }

                        size  = _flSizeLUT[i];
                        space = _flSpaceLUT[i];

                        // Draw focused element with a background hilight.
                        if (_selectedIndex == i)
                        {
                            NuGenPaintParams selPaintParams = new NuGenPaintParams(itemPaintParams);
                            selPaintParams.Bounds = this.LayoutManager.GetSelectionFrameBounds(
                                _borderLeft, y, width - (_borderLeft + _borderRight), size + space
                                );
                            selPaintParams.State = NuGenControlState.Hot;

                            this.Renderer.DrawSelectionFrame(selPaintParams);
                        }                         // if

                        itemPaintParams.Text   = sortedItems[i];
                        itemPaintParams.Font   = _fonts[size - 1];
                        itemPaintParams.Bounds = this.GetTextBounds(g, itemPaintParams.Text, itemPaintParams.Font, x, y);

                        this.Renderer.DrawText(itemPaintParams);

                        if (i > 0)
                        {
                            y -= _flSizeLUT[i - 1] + _flSpaceLUT[i - 1];
                        }
                    }             // for
                }                 // if

                /* Then render from focus down. */

                y = _flFocusPosition;

                for (i = _focusIndex; i < sortedItems.Count; i++)
                {
                    if (y > height - _borderY)
                    {
                        break;
                    }

                    size  = _flSizeLUT[i];
                    space = _flSpaceLUT[i];

                    // Draw focused element with a background hilight
                    if (_selectedIndex == i)
                    {
                        NuGenPaintParams selPaintParams = new NuGenPaintParams(itemPaintParams);
                        selPaintParams.Bounds = this.LayoutManager.GetSelectionFrameBounds(
                            _borderLeft, y, width - (_borderLeft + _borderRight), size + space
                            );
                        selPaintParams.State = NuGenControlState.Hot;

                        this.Renderer.DrawSelectionFrame(selPaintParams);
                    }

                    itemPaintParams.Text   = sortedItems[i];
                    itemPaintParams.Font   = _fonts[size - 1];
                    itemPaintParams.Bounds = this.GetTextBounds(g, itemPaintParams.Text, itemPaintParams.Font, x, y);

                    this.Renderer.DrawText(itemPaintParams);

                    y += space + size;
                }                 // for
            }

            base.OnPaint(e);
        }
コード例 #54
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NuGenBorderPaintParams"/> class.
 /// </summary>
 /// <exception cref="ArgumentNullException">
 /// <para><paramref name="initializeFrom"/> is <see langword="null"/>.</para>
 /// </exception>
 public NuGenBorderPaintParams(NuGenPaintParams initializeFrom)
     : base(initializeFrom)
 {
 }
コード例 #55
0
            /*
             * OnPaint
             */

            protected override void OnPaint(PaintEventArgs e)
            {
                Graphics g = e.Graphics;

                Rectangle bounds       = this.ClientRectangle;
                Size      shadowSize   = this.LayoutManager.GetShadowSize();
                Rectangle shadowBounds = new Rectangle(
                    bounds.Left + shadowSize.Width,
                    bounds.Top + shadowSize.Height,
                    bounds.Width - shadowSize.Width,
                    bounds.Height - shadowSize.Height
                    );
                Rectangle bodyBounds = new Rectangle(
                    bounds.Left,
                    bounds.Top,
                    bounds.Width - shadowSize.Width,
                    bounds.Height - shadowSize.Height
                    );

                NuGenPaintParams paintParams = new NuGenPaintParams(g);

                paintParams.State = _state;

                paintParams.Bounds = shadowBounds;
                this.Renderer.DrawShadow(paintParams);

                paintParams.Bounds = bodyBounds;
                this.Renderer.DrawBackground(paintParams);
                this.Renderer.DrawBorder(paintParams);

                if (_tooltipInfo != null)
                {
                    NuGenTextPaintParams textPaintParams = new NuGenTextPaintParams(paintParams);
                    textPaintParams.TextAlign = ContentAlignment.MiddleLeft;
                    textPaintParams.ForeColor = this.ForeColor;

                    NuGenImagePaintParams imagePaintParams = new NuGenImagePaintParams(paintParams);

                    if (_tooltipInfo.IsHeaderVisible)
                    {
                        textPaintParams.Bounds = _layoutDescriptor.HeaderBounds;
                        textPaintParams.Font   = _headerFont;
                        textPaintParams.Text   = _tooltipInfo.Header;

                        this.Renderer.DrawHeaderText(textPaintParams);
                    }

                    if (_tooltipInfo.IsTextVisible)
                    {
                        textPaintParams.Bounds = _layoutDescriptor.TextBounds;
                        textPaintParams.Font   = _textFont;
                        textPaintParams.Text   = _tooltipInfo.Text;

                        this.Renderer.DrawText(textPaintParams);
                    }

                    if (_tooltipInfo.IsImageVisible)
                    {
                        imagePaintParams.Bounds = _layoutDescriptor.ImageBounds;
                        imagePaintParams.Image  = _tooltipInfo.Image;

                        this.Renderer.DrawImage(imagePaintParams);
                    }

                    if (_tooltipInfo.IsRemarksHeaderVisible)
                    {
                        textPaintParams.Bounds = _layoutDescriptor.RemarksHeaderBounds;
                        textPaintParams.Font   = _headerFont;
                        textPaintParams.Text   = _tooltipInfo.RemarksHeader;

                        this.Renderer.DrawHeaderText(textPaintParams);

                        if (_tooltipInfo.IsRemarksVisible)
                        {
                            textPaintParams.Bounds = _layoutDescriptor.RemarksBounds;
                            textPaintParams.Font   = _textFont;
                            textPaintParams.Text   = _tooltipInfo.Remarks;

                            this.Renderer.DrawText(textPaintParams);
                        }

                        if (_tooltipInfo.IsRemarksImageVisible)
                        {
                            imagePaintParams.Bounds = _layoutDescriptor.RemarksImageBounds;
                            imagePaintParams.Image  = _tooltipInfo.RemarksImage;

                            this.Renderer.DrawImage(imagePaintParams);
                        }

                        paintParams.Bounds = _layoutDescriptor.BevelBounds;
                        this.Renderer.DrawBevel(paintParams);
                    }
                }
            }
コード例 #56
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NuGenTextPaintParams"/> class.
 /// </summary>
 /// <exception cref="ArgumentNullException">
 /// <para><paramref name="paintParams"/> is <see langword="null"/>.</para>
 /// </exception>
 public NuGenTextPaintParams(NuGenPaintParams paintParams)
     : base(paintParams)
 {
 }
コード例 #57
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;

            if (this.Orientation == NuGenOrientationStyle.Horizontal)
            {
                bounds.X++;
                bounds.Width -= 2;
            }
            else
            {
                bounds.Y++;
                bounds.Height -= 2;
            }

            Rectangle         contentBounds = this.LayoutManager.GetContentRectangle(bounds);
            NuGenControlState currentState  = this.ButtonStateTracker.GetControlState();

            NuGenPaintParams paintParams = new NuGenPaintParams(e.Graphics);

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

            if (currentState != NuGenControlState.Normal)
            {
                this.Renderer.DrawBackground(paintParams);

                NuGenPaintParams borderPaintParams = new NuGenPaintParams(paintParams);
                borderPaintParams.Bounds = NuGenControlPaint.BorderRectangle(borderPaintParams.Bounds);
                this.Renderer.DrawBorder(borderPaintParams);
            }

            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);
        }
コード例 #58
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)
        {
            Graphics          g            = e.Graphics;
            Rectangle         bounds       = this.ClientRectangle;
            NuGenControlState currentState = this.StateTracker.GetControlState();

            /* Border */

            NuGenPaintParams borderPaintParams = new NuGenPaintParams(this, g, bounds, currentState);

            this.Renderer.DrawBorder(borderPaintParams);

            /* Grip */

            NuGenPaintParams gripPaintParams = new NuGenPaintParams(this, g, this.GetGripRectangle(), currentState);

            this.Renderer.DrawGrip(gripPaintParams);

            /* Large buttons */

            int syncLargeButtons = 0;
            int iterateLargeButtons;

            for (iterateLargeButtons = 0; iterateLargeButtons < this.Buttons.Count; iterateLargeButtons++)
            {
                NuGenNavigationButton button = this.Buttons[iterateLargeButtons];

                if (button.Visible)
                {
                    Rectangle rect = new Rectangle(0, syncLargeButtons * this.GetButtonHeight() + this.GetGripHeight(), this.ClientRectangle.Width, this.GetButtonHeight());
                    button.Bounds  = rect;
                    button.IsLarge = true;
                    this.DrawButton(g, button);

                    if (syncLargeButtons == _maxLargeButtonCount)
                    {
                        break;
                    }

                    syncLargeButtons++;
                }
            }

            /* Bottom container */

            NuGenPaintParams bottomContainerPaintParams = new NuGenPaintParams(this, g, this.GetBottomContainerRectangle(), currentState);

            this.Renderer.DrawBackground(bottomContainerPaintParams);

            /* Small buttons */

            int startX           = this.ClientRectangle.Width - this.GetDropDownRectangle().Width - _maxSmallButtonCount * this.GetSmallButtonWidth();
            int syncSmallButtons = 0;
            int iterateSmallButtons;

            for (iterateSmallButtons = iterateLargeButtons; iterateSmallButtons < this.Buttons.Count; iterateSmallButtons++)
            {
                if (syncSmallButtons == _maxSmallButtonCount)
                {
                    break;
                }

                NuGenNavigationButton button = this.Buttons[iterateSmallButtons];

                if (button.Visible)
                {
                    Rectangle rect = new Rectangle(startX + (syncSmallButtons * this.GetSmallButtonWidth()), this.GetBottomContainerRectangle().Y, this.GetSmallButtonWidth(), this.GetBottomContainerRectangle().Height);
                    button.Bounds  = rect;
                    button.IsLarge = false;
                    this.DrawButton(g, button);
                    syncSmallButtons++;
                }
            }

            for (int i = iterateSmallButtons; i < this.Buttons.Count; i++)
            {
                this.Buttons[i].Bounds = Rectangle.Empty;
            }

            /* DropDown */

            this.DrawDropDown(g);

            /* Bottom container border */

            this.Renderer.DrawBorder(bottomContainerPaintParams);
        }