C#怎么利用panel和Picturebox做进度条?还要改变播放过的背景,有没有具体一点的。

2025-02-25 07:41:48
推荐回答(5个)
回答1:

WPF完全满足你要求,首先进度条这东西就有现成的,当然样式有可能不一样,那你可以重写一些,不难的,然后两个事件就是lable,背景的颜色你弄一个渐变的画刷就OK啦

回答2:

分诱人,可惜只做过小例子,没真正实现过

回答3:

GDI就可以了,虽然比较难,但非常漂亮。

回答4:

可以根据panel的值调节Picturebox的透明度~!

回答5:

可参考下面的两段代码:
//进度条效果
private void drawGraphicsPath()
{
Graphics g = this.pictureBox7.CreateGraphics();
g.Clear(this.pictureBox7.BackColor );
//消除锯齿
g.SmoothingMode = SmoothingMode.AntiAlias;
//高质量,低速度绘制
g.CompositingQuality = CompositingQuality.HighQuality;
StringFormat mySF = new StringFormat();
mySF.Alignment = StringAlignment.Near;
mySF.LineAlignment = StringAlignment.Center;
mySF.FormatFlags = StringFormatFlags.NoWrap;
SizeF strSize = g.MeasureString(PercentStr, PercFont, new PointF(), mySF);
int strWidth = (int)(strSize.Width + 10);

GraphicsPath myPath = new GraphicsPath();
int fontStyle = (int)FontStyle.Bold;
int x = (int)((this.pictureBox7.Width - strWidth) / 2);
int y = (int)((this.pictureBox7.Height - strSize.Height) / 2);
Point origin = new Point(x, y + 5);
StringFormat format = StringFormat.GenericDefault;
// Add the string to the path.
myPath.AddString(PercentStr,
family2,
fontStyle,
emSize2,
origin,
format);
GraphicsPath stringPath = myPath;
CurrentX += this.pictureBox7.Width / 10;
Rectangle blotoutRect = new Rectangle(0, 0, CurrentX, this.pictureBox7.Height);
myPath.AddRectangle(blotoutRect);
//Draw the path to the screen.
g.FillPath(Brushes.Green, myPath);
}

// 绘 制图片,文字
private void DrawFlowingString()
{
Graphics g = this.pictureBox2.CreateGraphics();
//消除锯齿
g.SmoothingMode = SmoothingMode.AntiAlias;
//高质量,低速度绘制
g.CompositingQuality = CompositingQuality.HighQuality;
StringFormat mySF = new StringFormat();
mySF.Alignment = StringAlignment.Near;
mySF.LineAlignment = StringAlignment.Center;
mySF.FormatFlags = StringFormatFlags.NoWrap;
SizeF strSize = g.MeasureString(myDrawingStr, myFont, new PointF(), mySF);
int width = (int)(strSize.Width + 30.0f);
g.Clear(Color.Black);

dx -= steep;
if (dx <= (width * -1))
{
dx = this.pictureBox2.Width - steep;
}
g.TranslateTransform(dx, 0);//水平平移坐标

//dy += steep;
//if (dy >= this.pictureBox5.Height)
//{
// dy = (strSize.Height * -1);
//}
//g.TranslateTransform(0, dy);//垂直平移坐标
Rectangle myRect = new Rectangle(myBitmap.Width + 10, 0, width, (int)this.pictureBox2.Height);
g.DrawString(myDrawingStr, myFont, Brushes.Red, myRect, mySF);
int y = (this.pictureBox2.Height - this.myBitmap.Height) / 2;
g.DrawImage(myBitmap, new Point(0, y));
//g.DrawPie(Pens.Red, myRect, 0, 360);
//g.FillPie(Brushes.Red, myRect, 0, 360);
//g.DrawRectangle(Pens.Red, myRect);
//g.FillRectangle(Brushes.Red, myRect);
}