Пример #1
0
 private void InitializerSeatMap()
 {
     System.Threading.Thread t = new System.Threading.Thread(() =>
     {
         this.Invoke(new Action(() => { FLPMap.SuspendLayout(); }));
         Label lblSeat = new Label();
         for (int row = 1; row <= Program.AuditoriumSeatRowsCount; ++row)
         {
             for (int col = 1; col <= Program.AuditoriumSeatColumnsCount; ++col)
             {
                 lblSeat          = new Label();
                 lblSeat.Text     = string.Format("{0:00}-{1:00}", row, col);
                 lblSeat.Name     = lblSeat.Text;
                 lblSeat.AutoSize = true;
                 lblSeat.Margin   = new Padding(6);
                 lblSeat.Tag      = new Point(row, col);
                 lblSeat.Cursor   = Cursors.Hand;
                 lblSeat.Click   += LblSeat_Click;
                 this.Invoke(new Action(() => { FLPMap.Controls.Add(lblSeat); }));
             }
             this.Invoke(new Action(() => { FLPMap.SetFlowBreak(lblSeat, true); }));
         }
         this.isInit = true;
         this.Invoke(new Action(() => { FLPMap.ResumeLayout(); }));
     });
     t.Start();
 }
Пример #2
0
        /// <summary>
        /// 设置座位值
        /// </summary>
        /// <param name="soldList">售出的座位</param>
        /// <param name="max">总数量</param>
        public void SetValue(List <Point> soldList, int max)
        {
            while (!this.isInit)
            {
                ; // 等待初始化完毕
            }
            FLPMap.SuspendLayout();
            for (int i = 0; i < this.FLPMap.Controls.Count; ++i)
            {
                Label lblSeat = FLPMap.Controls[i] as Label;
                if (i < max)
                {
                    lblSeat.Cursor    = Cursors.Hand;
                    lblSeat.ForeColor = Color.FromArgb(0x00, 0x00, 0x00);
                    lblSeat.BackColor = Color.FromArgb(0x66, 0xFF, 0xCC);
                }
                else
                {
                    // 如果是无法选择的座位,则取消事件
                    lblSeat.Cursor    = Cursors.Default;
                    lblSeat.ForeColor = Color.FromArgb(0x99, 0x99, 0x99);
                    lblSeat.BackColor = Color.FromArgb(0xcc, 0xcc, 0xcc);
                }
            }

            foreach (var p in soldList)
            {
                string name = string.Format("{0:00}-{1:00}", p.X, p.Y);
                var    c    = FLPMap.Controls.Find(name, false);
                if (c != null && c.Length > 0)
                {
                    Label lblSeat = c[0] as Label;
                    // 如果是无法选择的座位,则取消事件
                    lblSeat.Cursor    = Cursors.Default;
                    lblSeat.ForeColor = Color.FromArgb(0x00, 0x00, 0x00);
                    lblSeat.BackColor = Color.FromArgb(0xFF, 0xCC, 0x66);
                }
            }
            FLPMap.ResumeLayout();
        }