ProgressBar显示滚动的文字的问题?最好有代码。我怎么实验都不行呀,郁闷呀。
谢谢啦
谢谢啦
解决方案 »
- 用ArcEngine开发一个地图,我想获得某个点的信息怎么获得啊?
- 一段下载代码。这是什么意思搞不懂。希望大神来帮忙
- 使用C#代码下载的应用程序文件会报错,而文本文件正常.
- 超级菜鸟初来乍到想自己做一个用户名登陆的程序,最简单的那种
- vs.net2003打包framework1.1和mdac2.7问题???请大家指教!!
- win form activated事件的问题
- 水晶报表如何找印DataGridView中的数据
- 不好意思,"C#"英文怎么读?
- 如何把若干个TEXTBOX中的内容作为一条记录INSERTI 回数据库
- 为什么我找不到在winform中的datagrid的属性生成器?
- 继承窗体菜单不能使用的问题?急救!!!!
- 请问下 怎么在.net 2005 的 form窗体中 嵌入一个flash?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;namespace GameProcessBar
{
public partial class GameProcessBar : UserControl
{
public GameProcessBar()
{
InitializeComponent();
} int min = 0;
int max = 100;
int val = 0;
Image im;
protected override void OnResize(EventArgs e)
{
this.Invalidate();
} protected override void OnPaint(PaintEventArgs e)
{
if (im == null)
im = BackImage.BackgroundImage; this.BackgroundImage = im; SolidBrush myBrush = new SolidBrush(Color.GhostWhite);
Graphics g = e.Graphics;
float percent = (float)(val - min) / (max - min);
Rectangle rect = this.ClientRectangle; rect.Width = (int)((float)rect.Width * percent); //g.DrawImage(im,rect,rect,GraphicsUnit.Pixel);
g.FillRectangle(myBrush, rect); //int mini = (max - val) / 60;
//int sec = (max - val) % 60;
//string text = string.Format("{0} 分 {1} 秒", mini, sec);
//Font font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
//g.DrawString(text, font, Brushes.Black, 140, 5);
Draw3DBorder(g); myBrush.Dispose();
g.Dispose();
} public int Minimum
{
get
{
return min;
}
set
{
if (value < 0)
{
min = 0;
}
if (value > max)
{
max = value;
}
min = value;
if (val < min)
{
val = min;
}
this.Invalidate();
}
} public int Maximum
{
get
{
return max;
}
set
{
if (value < min)
{
min = value;
}
max = value;
if (val > max)
{
val = max;
}
this.Invalidate();
}
} public int Value
{
get
{
return val;
}
set
{
int oldVal = val;
if (val < min)
{
val = min;
}
else if (val > max)
{
val = max;
}
else
{
val = value;
} float percent; Rectangle newValueRect = this.ClientRectangle;
Rectangle oldValueRect = this.ClientRectangle; percent = (float)(val - min) / (max - min);
newValueRect.Width = (int)((float)newValueRect.Width * percent); percent = (float)(oldVal - min) / (float)(max - min);
oldValueRect.Width = (int)((float)oldValueRect.Width * percent); Rectangle updateRect = new Rectangle(); if (newValueRect.Width > oldValueRect.Width)
{
updateRect.X = oldValueRect.Size.Width;
updateRect.Width = newValueRect.Width - oldValueRect.Width;
}
else
{
updateRect.X = newValueRect.Size.Width;
updateRect.Width = oldValueRect.Width - newValueRect.Width;
} updateRect.Height = this.Height; this.Invalidate(updateRect); int mini = (max - val) / 60;
int sec = (max - val) % 60;
label1.Text = string.Format("{0} 分 {1} 秒", mini, sec);
}
} private void Draw3DBorder(Graphics g)
{
int PenWidth = (int)Pens.White.Width; g.DrawLine(Pens.DarkGray, new Point(this.ClientRectangle.Left, this.ClientRectangle.Top),
new Point(this.ClientRectangle.Width - PenWidth, this.ClientRectangle.Top));
g.DrawLine(Pens.DarkGray, new Point(this.ClientRectangle.Left, this.ClientRectangle.Top), new Point(this.ClientRectangle.Left, this.ClientRectangle.Height - PenWidth));
g.DrawLine(Pens.White, new Point(this.ClientRectangle.Left, this.ClientRectangle.Height - PenWidth),
new Point(this.ClientRectangle.Width - PenWidth, this.ClientRectangle.Height - PenWidth));
g.DrawLine(Pens.White, new Point(this.ClientRectangle.Width - PenWidth, this.ClientRectangle.Top),
new Point(this.ClientRectangle.Width - PenWidth, this.ClientRectangle.Height - PenWidth));
}
}
}