Click here to Skip to main content
15,880,972 members
Home / Discussions / C#
   

C#

 
AnswerRe: Custom progressbar doesn't update Pin
teknolog12322-Sep-09 4:02
teknolog12322-Sep-09 4:02 
GeneralRe: Custom progressbar doesn't update Pin
Programm3r22-Sep-09 21:21
Programm3r22-Sep-09 21:21 
GeneralRe: Custom progressbar doesn't update Pin
teknolog12323-Sep-09 9:26
teknolog12323-Sep-09 9:26 
QuestionBinary Serialization of Dictionary Pin
FJJCENTU22-Sep-09 1:28
FJJCENTU22-Sep-09 1:28 
AnswerRe: Binary Serialization of Dictionary Pin
Henry Minute22-Sep-09 1:44
Henry Minute22-Sep-09 1:44 
QuestionText over Progressbar - Question Pin
Programm3r22-Sep-09 1:25
Programm3r22-Sep-09 1:25 
AnswerRe: Text over Progressbar - Question Pin
Programm3r22-Sep-09 1:36
Programm3r22-Sep-09 1:36 
AnswerRe: Text over Progressbar - Question Pin
firda-cze18-Apr-10 22:21
firda-cze18-Apr-10 22:21 
public class ProgressLabel: ProgressBar {
	private static StringFormat sfCenter = new StringFormat() {
		Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center };
	private Color textColor = DefaultTextColor;
	private string progressString;
	public ProgressLabel() { SetStyle(ControlStyles.AllPaintingInWmPaint, true); }
	protected override void OnCreateControl() {
		progressString = null;
		base.OnCreateControl();
	}
	protected override void WndProc(ref Message m) {
		switch(m.Msg) {
		case 15: if(HideBar) base.WndProc(ref m);
			else {
				ProgressBarStyle style = Style;
				if(progressString == null) {
					progressString = Text;
					if(!HideBar && style != ProgressBarStyle.Marquee) {
						int range = Maximum-Minimum;
						int value = Value;
						if(range > 42949672) { value = (int)((uint)value>>7); range = (int)((uint)range>>7); }
						if(range > 0) progressString = string.Format(progressString.Length == 0 ? "{0}%" : "{1}: {0}%",
						value*100/range, progressString);
					}
				}
				if(progressString.Length == 0) base.WndProc(ref m);
				else using(Graphics g = CreateGraphics()) {
					base.WndProc(ref m);
					OnPaint(new PaintEventArgs(g, ClientRectangle));
				}
			}
			break;
		case 0x402: goto case 0x406;
		case 0x406: progressString = null;
			base.WndProc(ref m);
			break;
		default:
			base.WndProc(ref m);
			break;
		}
	}
	protected override void OnPaint(PaintEventArgs e) {
		Rectangle cr = ClientRectangle;
		RectangleF crF = new RectangleF(cr.Left, cr.Top, cr.Width, cr.Height);
		using(Brush br = new SolidBrush(TextColor))
			e.Graphics.DrawString(progressString, Font, br, crF, sfCenter);
		base.OnPaint(e);
	}
	public bool HideBar {
		get { return GetStyle(ControlStyles.UserPaint); }
		set { if(HideBar != value) { SetStyle(ControlStyles.UserPaint, value); Refresh(); } }
	}
	public static Color DefaultTextColor {
		get { return SystemColors.ControlText; }
	}
	public Color TextColor {
		get { return textColor; }
		set { textColor = value; }
	}
	public override string Text {
		get { return base.Text; }
		set { if(value != Text) { base.Text = value; progressString = null; } }
	}
	public override Font Font {
		get { return base.Font; }
		set { base.Font = value; }
	}
}

GeneralRe: Text over Progressbar - Question Pin
Scott Sherin28-May-10 4:15
Scott Sherin28-May-10 4:15 
Questionhow to use a macro in c# Pin
Ajithevn22-Sep-09 0:58
Ajithevn22-Sep-09 0:58 
AnswerRe: how to use a macro in c# Pin
Programm3r22-Sep-09 1:39
Programm3r22-Sep-09 1:39 
GeneralRe: how to use a macro in c# Pin
Ajithevn22-Sep-09 2:29
Ajithevn22-Sep-09 2:29 
GeneralRe: how to use a macro in c# Pin
Programm3r22-Sep-09 2:50
Programm3r22-Sep-09 2:50 
GeneralRe: how to use a macro in c# Pin
Programm3r22-Sep-09 2:53
Programm3r22-Sep-09 2:53 
GeneralRe: how to use a macro in c# Pin
thecodedemon23-Sep-09 13:30
thecodedemon23-Sep-09 13:30 
AnswerRe: how to use a macro in c# Pin
Programm3r22-Sep-09 2:57
Programm3r22-Sep-09 2:57 
QuestionPlaying with Enumerations Pin
ezazazel22-Sep-09 0:45
ezazazel22-Sep-09 0:45 
AnswerRe: Playing with Enumerations Pin
harold aptroot22-Sep-09 0:54
harold aptroot22-Sep-09 0:54 
AnswerRe: Playing with Enumerations Pin
Gideon Engelberth22-Sep-09 2:51
Gideon Engelberth22-Sep-09 2:51 
GeneralRe: Playing with Enumerations Pin
ezazazel22-Sep-09 6:49
ezazazel22-Sep-09 6:49 
AnswerRe: Playing with Enumerations Pin
PIEBALDconsult22-Sep-09 4:07
mvePIEBALDconsult22-Sep-09 4:07 
GeneralRe: Playing with Enumerations Pin
ezazazel22-Sep-09 6:47
ezazazel22-Sep-09 6:47 
GeneralRe: Playing with Enumerations Pin
PIEBALDconsult22-Sep-09 13:52
mvePIEBALDconsult22-Sep-09 13:52 
QuestionGetting data from a Listbox controlled by WPF and XML Pin
reg.orton22-Sep-09 0:24
reg.orton22-Sep-09 0:24 
AnswerRe: Getting data from a Listbox controlled by WPF and XML Pin
vivasaayi22-Sep-09 19:37
vivasaayi22-Sep-09 19:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.