// 輸出的Label[,] 放到tabPage.Tag去 private void InitFoodMenu(TabPage tabPage, int menuId, out Label[,] FoodName) { SuspendLayout(); string mark = "F" + menuId.ToString() + DateTime.Now.Ticks.ToString(); //避免多次進入,label重名了 int WidthX = (tabPage.Width - MyLayout.OffsetX) / MyLayout.NoX; int HeightY = (tabPage.Height - MyLayout.OffsetY) / MyLayout.NoY; FoodName = new Label[MyLayout.NoX, MyLayout.NoY]; int x, y; for (x = 0; x < MyLayout.NoX; x++) { for (y = 0; y < MyLayout.NoY; y++) { int xx, yy; xx = MyLayout.OffsetX + x * WidthX; yy = MyLayout.OffsetY + y * HeightY; Label l = new Label(); // Create Name Label l = new Label(); FoodName[x, y] = l; l.AutoSize = false; l.Location = new System.Drawing.Point(xx, yy); l.Name = mark + "X" + x.ToString() + "Y" + y.ToString(); l.Size = new System.Drawing.Size(WidthX - MyLayout.NoWidth - 2, HeightY - 2); l.TabIndex = 0; MyProductRow Row = GetFoodMenuItem(menuId, x, y); if (Row != null) { l.Tag = Row; if (Row.IsNameNull()) { l.Text = ""; } else { l.Text = Row.Name.ToString(); } } else { l.Tag = null; l.Text = ""; } l.DragEnter += new DragEventHandler(this.LabelDragEnter); l.DragLeave += new EventHandler(this.LabelDragLeave); l.DragDrop += new DragEventHandler(LabelDragDrop); l.MouseDown += new MouseEventHandler(LabelMouseDown); l.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; l.BorderStyle = BorderStyle.Fixed3D; l.AllowDrop = true; tabPage.Controls.Add(l); } } ResumeLayout(); PerformLayout(); }
public override string ToString() { if (row == null) { return(""); } if (row.IsNameNull()) { return(""); } return(row.Name); }