/// <summary> /// 동적 카테고리와 동적 메뉴 전체 제거하기 /// </summary> private void CategoriesAndMenusClearAll() { // panel_MenuPageLayout > FlowLayoutPanel > UCMenuButton // 메뉴 동적 콘트롤 제거 int categoryCount = this.panel_MenuPageLayout.Controls.Count; while (this.panel_MenuPageLayout.Controls.Count > 0) { while (this.panel_MenuPageLayout.Controls[0].Controls.Count > 0) { UCMenuButton control = this.panel_MenuPageLayout.Controls[0].Controls[0] as UCMenuButton; // 메뉴 이벤트 제거 control.Click -= _menuButton_Click; // 메뉴 객체 제거 this.panel_MenuPageLayout.Controls[0].Controls.RemoveAt(0); // 메뉴 객체 릴리즈 control.Dispose(); } FlowLayoutPanel flp = this.panel_MenuPageLayout.Controls[0] as FlowLayoutPanel; this.panel_MenuPageLayout.Controls.RemoveAt(0); flp.Dispose(); } // 카테고리 동적 콘트롤 제거 while (this.flowLayoutPanel_Category.Controls.Count > 0) { Control control = this.flowLayoutPanel_Category.Controls[0]; // 카테고리 이벤트 제거 control.Click -= _categoryButton_Click; // 카테고리 객체 제거 this.flowLayoutPanel_Category.Controls.RemoveAt(0); // 카테고리 객체 릴리즈 control.Dispose(); } // 카테고리 페이지 맵핑 제거 dicMenuPages.Clear(); }
/// <summary> /// 카테고리별 페이지에 메뉴 추가 /// </summary> /// <param name="aCategoryName"></param> /// <param name="aCategoryCode"></param> /// <param name="aMenuCode"></param> /// <param name="aEventName"></param> /// <param name="aMenuName"></param> /// <param name="aSize"></param> /// <param name="aType"></param> /// <param name="aPrice"></param> /// <param name="aDCDigicap"></param> /// <param name="aDCCovision"></param> private void AddMenu( string aCategoryName, int aCategoryCode, int aMenuCode, string aEventName, string aMenuName, string aSize, string aType, int aPrice, //int aDCDigicap, //int aDCCovision Dictionary <string, int> aDiscounts ) { UCMenuButton _menuButton = new UCMenuButton(); { _menuButton.BackColor = System.Drawing.Color.WhiteSmoke; _menuButton.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; _menuButton.Font = new System.Drawing.Font("SpoqaHanSans-Regular", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129))); _menuButton.ForeColor = System.Drawing.Color.DimGray; _menuButton.Size = new System.Drawing.Size(250, 250); _menuButton.XBorderColor = System.Drawing.Color.Gainsboro; _menuButton.XOnHoverBackColor = System.Drawing.Color.DarkOrchid; //---------------------------------------------------------- _menuButton.XCategoryCode = aCategoryCode; _menuButton.XMenuCode = aMenuCode; _menuButton.XEventName = aEventName; _menuButton.XMenuNameKR = aMenuName; _menuButton.XMenuNameEN = "Product Name"; _menuButton.XMenuSize = aSize; _menuButton.XMenuType = aType; _menuButton.XMenuPrice = aPrice; } // 해당 카테고리 페이지에 메뉴 추가 FlowLayoutPanel flp; this.dicMenuPages.TryGetValue(aCategoryName, out flp); flp.Controls.Add(_menuButton); // 클릭 이벤트 _menuButton.Click += _menuButton_Click; }
/// <summary> /// 카테고리 메뉴 버튼 클릭 이벤트 처리 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void _menuButton_Click(object sender, EventArgs e) { UCMenuButton obj = sender as UCMenuButton; OrderCartAdd(obj, obj.XMenuNameKR, obj.XMenuSize, obj.XMenuType, obj.XMenuPrice); }
/// <summary> /// NAME, SIZE, TYPE 조합으로 주문 카트 내역 추가 /// CartOrderItem.Name = aItemName+aItemSize+aItemType 으로 CartOrderItem 객체 식별 /// </summary> /// <param name="aMenuButtonObj"></param> /// <param name="aMenuNameKR"></param> /// <param name="aMenuSize"></param> /// <param name="aMenuType"></param> /// <param name="aMenuUnitPrice"></param> /// <param name="aMenuAmount"></param> private void OrderCartAdd(UCMenuButton aMenuButtonObj, string aMenuNameKR, string aMenuSize, string aMenuType, int aMenuUnitPrice, int aMenuAmount = 1) { // 타입이 "BOTH"이면 "메시지 박스 출력 선택 if ((aMenuType.ToUpper()).CompareTo("BOTH") == 0) { using (FormMessageBox dlg = new FormMessageBox()) { { dlg.Left = 450; dlg.Top = this.Location.X + (ClientSize.Height / 2) - 100; } DialogResult dlgResult = dlg.ShowDialog("추가 옵션을 선택하세요.", "추가 옵션 선택", CustomMessageBoxButtons.HotIced); { if (dlgResult == DialogResult.OK) { aMenuType = "HOT"; } else if (dlgResult == DialogResult.Cancel) { aMenuType = "ICED"; } } } } // 카트 콘트롤 이름 string keyName = string.Format("{0}{1}{2}", aMenuNameKR, aMenuSize, aMenuType); // 카트에 주문이 있으면 추가 하지 않고, 주문 개수 증가 시킴 if (this.flowLayoutPanel_OrderCartLayout.Controls.ContainsKey(keyName) == true) { UCOrderItem control = this.flowLayoutPanel_OrderCartLayout.Controls[keyName] as UCOrderItem; control.XMenuAmount++; // 총액 업데이트 OrderCartUpdateTotalPrice(); return; } // 주문 추가 UCOrderItem _OrderItem = new UCOrderItem(); { _OrderItem.Name = keyName; //---------------------------------------------------------- _OrderItem.BackColor = System.Drawing.Color.Transparent; _OrderItem.Font = new System.Drawing.Font("SpoqaHanSans-Regular", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129))); _OrderItem.Size = new System.Drawing.Size(539, 50); _OrderItem.XForeTextColor = System.Drawing.Color.White; //---------------------------------------------------------- _OrderItem.XMenuNameKR = aMenuNameKR; _OrderItem.XMenuSize = aMenuSize; _OrderItem.XMenuType = aMenuType; _OrderItem.XMenuUnitPrice = aMenuUnitPrice; //---------------------------------------------------------- _OrderItem.XMenuAmount = aMenuAmount; _OrderItem.XMenuTotalAmount = aMenuUnitPrice * aMenuAmount; //---------------------------------------------------------- _OrderItem.XMenuButtonObject = aMenuButtonObj; //---------------------------------------------------------- _OrderItem.OnMinusButtonClicked += UcOrderItem_OnMinusButtonClicked; _OrderItem.OnPlusButtonClicked += UcOrderItem_OnPlusButtonClicked; } this.flowLayoutPanel_OrderCartLayout.Controls.Add(_OrderItem); // 총액 업데이트 OrderCartUpdateTotalPrice(); }