////业务绘制 //void pbu_Paint(object sender, PaintEventArgs e) //{ // PictureBox pb = sender as PictureBox; // TBusinessModel busy = pb.Tag as TBusinessModel; // Font font = new Font("黑体", 22, FontStyle.Bold); // e.Graphics.DrawString(busy.busiName, font, new SolidBrush(Color.White), 10, 7); //} //按下图标显示 void pb_MouseDown(object sender, MouseEventArgs e) { BusyCard pb = sender as BusyCard; pb.Image = Properties.Resources.银色_点击后1; pb.Brush = new SolidBrush(Color.Black); pb.Refresh(); this.lastCard = pb; }
void pbu_Click(object sender, EventArgs e) { BusyCard pb = sender as BusyCard; TBusinessModel busy = pb.Tag as TBusinessModel; selectBusy = busy; if (SelectedBusy != null) { SelectedBusy(); } }
//动态创建业务 public void CreateBusiness( ) { this.pnBusiness.ClearControl(); int rowCount = 6;//一行 int count = 0; //int sX = 25;//起始坐标 int sY = 25; //起始坐标 int height = 105; //一行高度 int width = 206; int currY = 0; int currX = 25; int yGAP = 19; //行间距 int xGAP = 81; //列间距 var list = bList.Skip(pageCount * cureentPage).Take(pageCount); this.pnBusiness.MouseUp += this.pb_MouseUp; foreach (var u in list) { BusyCard pb = new BusyCard(); pb.Name = "pb_b_" + count; pb.Tag = u; pb.MouseEnter += (s, e) => { this.Cursor = Cursors.Hand; }; pb.MouseLeave += (s, e) => { this.Cursor = Cursors.Default; }; pb.Image = Properties.Resources.蓝色_点击前1; pb.Rectangle.Size = new Size(width, height); pb.MouseClick += pbu_Click; pb.MouseDown += pb_MouseDown; pb.Rectangle.Location = new Point(currX, currY + sY); currX = currX + width + xGAP; if (count % rowCount == rowCount - 1) { currY += (sY + height + yGAP); currX = 25; } pnBusiness.AddControl(pb); count++; } pnBusiness.Draw(); }