/// <summary> /// DrawProgressText method. /// </summary> /// <param name="graphics">Graphics instance.</param> private void DrawProgressText(Graphics graphics) { if (!this.ShowText && !this.ShowPercentText) { return; } Color foreColor = this.Enabled ? ModernPaint.ForeColor.ProgressBar.Normal(this.ThemeStyle) : ModernPaint.ForeColor.ProgressBar.Disabled(this.ThemeStyle); if (this.ShowText) { TextRenderer.DrawText(graphics, this.Text, ModernFonts.ProgressBar(this.FontSize, this.FontWeight), this.ClientRectangle, foreColor, ModernPaint.GetTextFormatFlags(this.TextAlign)); } if (this.ShowPercentText) { TextRenderer.DrawText(graphics, this.ProgressPercentText, ModernFonts.ProgressBar(this.FontSize, this.FontWeight), this.ClientRectangle, foreColor, ModernPaint.GetTextFormatFlags(this.PercentTextAlign)); } }
/// <summary> /// Get preferred size. /// </summary> /// <param name="proposedSize">Proposed size.</param> /// <returns>Preferred size.</returns> public override Size GetPreferredSize(Size proposedSize) { Size preferredSize; base.GetPreferredSize(proposedSize); using (Graphics g = this.CreateGraphics()) { proposedSize = new Size(int.MaxValue, int.MaxValue); preferredSize = TextRenderer.MeasureText(g, this.ProgressPercentText, ModernFonts.ProgressBar(this.FontSize, this.FontWeight), proposedSize, ModernPaint.GetTextFormatFlags(this.PercentTextAlign)); } return(preferredSize); }