Beispiel #1
0
        private void InitFoodMenu(GroupBox grBox, int menuId, out Label [,] FoodName)
        {
            SuspendLayout();
            string mark    = "F" + menuId.ToString() + DateTime.Now.Ticks.ToString(); //避免多次進入,label重名了
            int    WidthX  = (grBox.Width - MyLayout.OffsetX) / MyLayout.NoX;
            int    HeightY = (grBox.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;
                    BasicDataSet.ProductRow 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.MiddleLeft;
                    l.BorderStyle = BorderStyle.None;
                    l.AllowDrop   = true;
                    grBox.Controls.Add(l);
                }
            }

            ResumeLayout();
            PerformLayout();
        }
Beispiel #2
0
 public override string ToString()
 {
     if (row == null)
     {
         return("");
     }
     if (row.IsNameNull())
     {
         return("");
     }
     return(row.Name);
 }