المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Problems with System Tray Graph ?



C# Programming
06-24-2009, 08:32 PM
Hi im building a program in C# which downloads files , Ive wrote the code to generate the download graph and it works for values 30 - 100 but anyhing below 30 and the bar flips upside down .

I basically have 14 pixals to generate a bargraph of values 0 - 100 in . i know this is vague but im sure the problem is with GDI.FillRectangle(Graph, 1, 15 - Bar, 14, Bar - 1);

Can any ofr you c# gurus help me pinpoint the problem ()

private Graphics GDI;
private Bitmap DownloadGraphic;
private Icon icon;
private int value = 5;

public void DownloadGraph()
{
int Bar = (14 * value) / 100;
DownloadGraphic = new Bitmap(16, 16);
GDI = Graphics.FromImage(DownloadGraphic);
SolidBrush BackgroundBrush = new SolidBrush(Color.Transparent);
GDI.FillRectangle(BackgroundBrush, 0, 0, 16, 16);
Pen LeftBorder = new Pen(Color.White, 1);
GDI.DrawLine(LeftBorder, 15, 0, 15, 15);
GDI.DrawLine(LeftBorder, 15, 15, 0, 15);
Pen RightBorder = new Pen(Color.Gray, 1);
GDI.DrawLine(RightBorder, 0, 16, 0, 0);
GDI.DrawLine(RightBorder, 0, 0, 16, 0);
SolidBrush Graph = new SolidBrush(Color.DarkRed);
GDI.FillRectangle(Graph, 1, 15 - Bar, 14, Bar - 1);
Pen DownloadHilight = new Pen(Color.OrangeRed, 1);
GDI.DrawLine(DownloadHilight, 1, Bar, 14, Bar);
Font PercentFont = new System.Drawing.Font("Verdana", 7, FontStyle.Italic);
Brush Percentage = new SolidBrush(Color.White);
GDI.DrawString(value.ToString(), PercentFont, Percentage, 0, 1);
this.NotifyIcon.Icon = Icon.FromHandle(DownloadGraphic.GetHicon());
}


Thanks