Beispiel #1
0
		/// -----------------------------------------------------------------------------------
		/// <summary>
		/// Paint method for steps. This is shared between WizardDialog and WizardStepPanel.
		/// </summary>
		/// -----------------------------------------------------------------------------------
		internal static void PanStepsPaint(IWizardPaintPanSteps steps, PaintEventArgs e)
		{
			if (steps.StepNames == null || steps.LastStepNumber == -1)
				return;

			// This is the minimum height a single step text line will occupy.
			// (Note: this doesn't include the spacing between step text lines.)
			int dyStepHeight = Math.Max(steps.StepsFont.Height, kdypStepSquareHeight);

			// This is the rectangle for the text of step one. Each subsequent step's
			// text rectangle will be calculated by increasing the rectangle's Y
			// property accordingly. 3 is added as the number of horizontal pixels
			// between the text and the colored square.
			Rectangle rcText =
				new Rectangle(kdxpStepListSpacing + kdxpStepSquareWidth + 3,
				kdypStepListSpacing,
				steps.PanSteps.Width - (kdxpStepListSpacing + kdxpStepSquareWidth + 3),
				dyStepHeight);

			// This is the distance between the top of a step text's rectangle
			// and the top of the colored square's rectangle. However, if the step
			// text's rectangle is shorter than the height of the square, the
			// padding will be zero.
			int dySquarePadding = (dyStepHeight > kdypStepSquareHeight) ?
				(dyStepHeight - kdypStepSquareHeight) / 2 : 0;

			// This is the rectangle for step one's colored square.
			Rectangle rcSquare = new Rectangle(kdxpStepListSpacing,
				kdypStepListSpacing + dySquarePadding,
				kdxpStepSquareWidth, kdypStepSquareHeight);

			using (var sf = new StringFormat(StringFormat.GenericTypographic))
			{
				sf.Alignment = StringAlignment.Near;
				sf.LineAlignment = StringAlignment.Center;
				sf.Trimming = StringTrimming.EllipsisCharacter;

				// Calculate the horizontal position for the vertical connecting
				// line. (Subtracting 1 puts it just off center because the line
				// will be 2 pixels thick.)
				int xpConnectingLine = rcSquare.X + (kdxpStepSquareWidth / 2) - 1;

				// Create brushes for the colored squares and the step text.
				using (SolidBrush brSquare = new SolidBrush(kclrPendingStep),
					brText = new SolidBrush(steps.TextColor))
				{
					for (int i = 0; i <= steps.LastStepNumber; i++)
					{
						e.Graphics.DrawString(steps.StepNames[i], steps.StepsFont, brText, rcText, sf);
						rcText.Y += dyStepHeight + kdypStepListSpacing;

						// Determine what color the square should be.
						if (i == steps.LastStepNumber)
							brSquare.Color = kclrLastStep;
						else if (i == steps.CurrentStepNumber)
							brSquare.Color = kclrCurrentStep;
						else if (i < steps.CurrentStepNumber)
							brSquare.Color = kclrCompletedStep;
						else
							brSquare.Color = kclrPendingStep;

						// Draw the square next to the step text label.
						e.Graphics.FillRectangle(brSquare, rcSquare);
						rcSquare.Y += (dyStepHeight + kdypStepListSpacing);

						// Draw the vertical line connecting each step's square.
						if (i < steps.LastStepNumber)
						{
							using (var line = new LineDrawing(e.Graphics))
							{
								line.LineType = LineTypes.Solid;

								line.Draw(xpConnectingLine,
									rcSquare.Y - kdypStepListSpacing,
									xpConnectingLine, rcSquare.Y, kclrCompletedStep);

								line.Draw(xpConnectingLine + 1,
									rcSquare.Y - kdypStepListSpacing,
									xpConnectingLine + 1, rcSquare.Y, kclrPendingStep);
							}
						}
					}
				}
			}
		}
        /// -----------------------------------------------------------------------------------
        /// <summary>
        /// Paint method for steps. This is shared between WizardDialog and WizardStepPanel.
        /// </summary>
        /// -----------------------------------------------------------------------------------
        internal static void PanStepsPaint(IWizardPaintPanSteps steps, PaintEventArgs e)
        {
            if (steps.StepNames == null || steps.LastStepNumber == -1)
            {
                return;
            }

            // This is the minimum height a single step text line will occupy.
            // (Note: this doesn't include the spacing between step text lines.)
            int dyStepHeight = Math.Max(steps.StepsFont.Height, kdypStepSquareHeight);

            // This is the rectangle for the text of step one. Each subsequent step's
            // text rectangle will be calculated by increasing the rectangle's Y
            // property accordingly. 3 is added as the number of horizontal pixels
            // between the text and the colored square.
            Rectangle rcText =
                new Rectangle(kdxpStepListSpacing + kdxpStepSquareWidth + 3,
                              kdypStepListSpacing,
                              steps.PanSteps.Width - (kdxpStepListSpacing + kdxpStepSquareWidth + 3),
                              dyStepHeight);

            // This is the distance between the top of a step text's rectangle
            // and the top of the colored square's rectangle. However, if the step
            // text's rectangle is shorter than the height of the square, the
            // padding will be zero.
            int dySquarePadding = (dyStepHeight > kdypStepSquareHeight) ?
                                  (dyStepHeight - kdypStepSquareHeight) / 2 : 0;

            // This is the rectangle for step one's colored square.
            Rectangle rcSquare = new Rectangle(kdxpStepListSpacing,
                                               kdypStepListSpacing + dySquarePadding,
                                               kdxpStepSquareWidth, kdypStepSquareHeight);

            using (var sf = new StringFormat(StringFormat.GenericTypographic))
            {
                sf.Alignment     = StringAlignment.Near;
                sf.LineAlignment = StringAlignment.Center;
                sf.Trimming      = StringTrimming.EllipsisCharacter;

                // Calculate the horizontal position for the vertical connecting
                // line. (Subtracting 1 puts it just off center because the line
                // will be 2 pixels thick.)
                int xpConnectingLine = rcSquare.X + (kdxpStepSquareWidth / 2) - 1;

                // Create brushes for the colored squares and the step text.
                using (SolidBrush brSquare = new SolidBrush(kclrPendingStep),
                       brText = new SolidBrush(steps.TextColor))
                {
                    for (int i = 0; i <= steps.LastStepNumber; i++)
                    {
                        e.Graphics.DrawString(steps.StepNames[i], steps.StepsFont, brText, rcText, sf);
                        rcText.Y += dyStepHeight + kdypStepListSpacing;

                        // Determine what color the square should be.
                        if (i == steps.LastStepNumber)
                        {
                            brSquare.Color = kclrLastStep;
                        }
                        else if (i == steps.CurrentStepNumber)
                        {
                            brSquare.Color = kclrCurrentStep;
                        }
                        else if (i < steps.CurrentStepNumber)
                        {
                            brSquare.Color = kclrCompletedStep;
                        }
                        else
                        {
                            brSquare.Color = kclrPendingStep;
                        }

                        // Draw the square next to the step text label.
                        e.Graphics.FillRectangle(brSquare, rcSquare);
                        rcSquare.Y += (dyStepHeight + kdypStepListSpacing);

                        // Draw the vertical line connecting each step's square.
                        if (i < steps.LastStepNumber)
                        {
                            using (var line = new LineDrawing(e.Graphics))
                            {
                                line.LineType = LineTypes.Solid;

                                line.Draw(xpConnectingLine,
                                          rcSquare.Y - kdypStepListSpacing,
                                          xpConnectingLine, rcSquare.Y, kclrCompletedStep);

                                line.Draw(xpConnectingLine + 1,
                                          rcSquare.Y - kdypStepListSpacing,
                                          xpConnectingLine + 1, rcSquare.Y, kclrPendingStep);
                            }
                        }
                    }
                }
            }
        }