private void reLayoutItem(int i) { CheckTypeInputPanel item = (CheckTypeInputPanel)checkPanel.Controls[i]; CheckTypeInputPanel preItem = (CheckTypeInputPanel)checkPanel.Controls[i - 1]; item.Location = new Point(checkPanel.Width / 2 - item.Width / 2, preItem.Location.Y + preItem.Height); }
private void layoutBottomInputPanel(ref CheckTypeInputPanel inputPanel) { int controlsLoactionX = checkPanel.Width / 2 - inputPanel.Width / 2; int bottomPanelIndex = checkPanel.Controls.Count - 1; CheckTypeInputPanel bottomInputPanel = (CheckTypeInputPanel)checkPanel.Controls[checkPanel.Controls.Count - 1]; inputPanel.Location = new Point(controlsLoactionX, bottomInputPanel.Location.Y + bottomInputPanel.Height); }
/* ---- Delete ---- */ private void checkTypeInputPanel_Delete(CheckTypeInputPanel sender) { for (int i = 0; i < checkPanel.Controls.Count; i++) { if (i == 0) { reLayoutFirstItem(); } else { reLayoutItem(i); } } }
/* ---- Add a item ---- */ private void checkTypeAddButton_Click(object sender, EventArgs e) { CheckTypeInputPanel checkTypeInputPanel = new CheckTypeInputPanel(); if (checkPanel.Controls.Count == 0) { layoutFirstInputPanel(ref checkTypeInputPanel); } else { layoutBottomInputPanel(ref checkTypeInputPanel); } checkTypeInputPanel.afterDelete += checkTypeInputPanel_Delete; addInputPanel(ref checkTypeInputPanel); }
private void reLayoutFirstItem() { CheckTypeInputPanel item = (CheckTypeInputPanel)checkPanel.Controls[0]; item.Location = new Point(checkPanel.Width / 2 - item.Width / 2, 0); }
private void addInputPanel(ref CheckTypeInputPanel inputPanel) { checkPanel.Controls.Add(inputPanel); inputPanel.resizeSelf(); }
private void layoutFirstInputPanel(ref CheckTypeInputPanel inputPanel) { int controlsLoactionX = checkPanel.Width / 2 - inputPanel.Width / 2; inputPanel.Location = new Point(controlsLoactionX, 0); }