コード例 #1
0
        void pbu_click(object sender)
        {
            ucBusyCard     pb   = sender as ucBusyCard;
            TBusinessModel busy = pb.Tag as TBusinessModel;

            selectBusy = busy;
            if (SelectedBusy != null)
            {
                SelectedBusy();
            }
        }
コード例 #2
0
        public int cureentPage = 0; //页码。从1开始
        //动态创建业务
        public void CreateBusiness()
        {
            this.pnBusiness.ClearControl();
            int count = 0;
            int sY    = 0;//起始坐标
            int sX    = 0;
            var list  = bList.Skip(pageCount * cureentPage).Take(pageCount);

            foreach (var u in list)
            {
                ucBusyCard pb = new ucBusyCard();
                pb.Name                     = "pb_b_" + count;
                pb.Tag                      = u;
                pb.unitSeq                  = u.unitSeq;
                pb.busiSeq                  = u.busiSeq;
                pb.busiName                 = u.busiName;
                pb.action                  += new Action <object>(pbu_click);
                pb.Rectangle.Location       = new Point(sX, sY);
                pb.Rectangle.Size           = new Size(429, 737);
                pb.ButtonRectangle.Location = new Point(sX + 60, sY + 5);
                pb.ButtonRectangle.Size     = new Size(280, 50);
                pnBusiness.AddControl(pb);
                count++;
                sX += pb.Rectangle.Width;
            }
            pnBusiness.MouseMove += (s, e) =>
            {
                var ctl = pnBusiness.controls.Find(m => ((ucBusyCard)m).ButtonRectangle.Contains(e.Location)) as ucBusyCard;
                if (ctl != null)
                {
                    this.Cursor = Cursors.Hand;
                }
                else
                {
                    this.Cursor = Cursors.Default;
                }
            };
            pnBusiness.MouseClick += (s, e) =>
            {
                var ctl = pnBusiness.controls.Find(m => ((ucBusyCard)m).ButtonRectangle.Contains(e.Location)) as ucBusyCard;
                if (ctl != null)
                {
                    ctl.OnButtonClick();
                }
            };
            pnBusiness.Draw();
        }