using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; using System.Drawing.Drawing2D; namespace Mesnac.Controls.Sulf { public partial class WorkProgress : SulfControl { bool bNewPic = false; string _statusName; public string StatusName { get { return _statusName; } set { _statusName = value; } } string[] sImages; public WorkProgress():base() { InitializeComponent(); Init(); } /// /// 初始化 /// protected override void Init() { base.Init(); this.pictureBox1.Left = 0; this.pictureBox1.Top = 0; this.pictureBox1.Height = this.Height; this.pictureBox1.Width = 0; _imageStream = null; this.label1.Left = this.Width / 2 - this.label1.Width / 2; this.label1.Top = this.Height / 2 - this.label1.Height / 2; sImages = new string[2]; sImages[0] = "Mesnac.Controls.Sulf.Resources.workpBG.jpg";//rgNull sImages[1] = "Mesnac.Controls.Sulf.Resources.workpFG.jpg";//rgNull } protected override void OnPaint(PaintEventArgs e) { this.label1.Left = this.Width / 2 - this.label1.Width / 2; this.label1.Top = this.Height / 2 - this.label1.Height / 2; ReloadStream(); } float _allTotal = 0; string _allTotalName; public string AllTotalName { get { return _allTotalName; } set { _allTotalName = value; } } /// /// 总硫化时间 /// public float AllTotal { get { return _allTotal; } set { _allTotal = value; } } float _sulfTime = 0; string _sulfTimeName; public string SulfTimeName { get { return _sulfTimeName; } set { _sulfTimeName = value; } } /// /// 已经硫化时间 /// public float SulfTime { get { return _sulfTime; } set { _sulfTime = value; ReloadStream(); this.Refresh(); } } void ReloadStream() { if (_allTotal != 0) { int progress = Convert.ToInt32(_sulfTime / _allTotal * 100); this.pictureBox1.Width = Convert.ToInt32(this.Width*(Convert.ToDecimal(progress)/100)); this._statusName = progress.ToString() + "%"; //this.label1.Text = this._statusName; RegionControl(this.label1, this._statusName); } } private void RegionControl(Control control, string txt) { GraphicsPath gp = new GraphicsPath(); gp.AddString(txt, new FontFamily("宋体"), (int)FontStyle.Bold, 19, control.ClientRectangle, new StringFormat(StringFormatFlags.NoWrap)); control.Region = new Region(gp); control.ForeColor = Color.Blue; } } }