private void DeleteBottle(BottleRowHeaderControl bottleControl) { if (evnt.bottles.Contains(bottleControl.bottle)) // should always be there.. { evnt.bottles.Remove(bottleControl.bottle); } CreateGrid(); }
private void NewBottleRow(Bottle bottle, bool canDelete = true) { BottleRowHeaderControl bottleControl = new BottleRowHeaderControl(bottle); rowHeaderLayoutPanel.Controls.Add(bottleControl); bottleControl.Dock = DockStyle.Top; bottleControl.canDelete = canDelete; }
private void BottleTextChanged(BottleRowHeaderControl bottleControl) { if (!evnt.bottles.Contains(bottleControl.bottle)) // if the name of a bottle changes and its not part of the collection, add it { evnt.bottles.Add(bottleControl.bottle); bottleControl.canDelete = true; // its part of the collection now, so it can be deleted NewBottleRow(new Bottle(), false); } }
private void gridPanel_MouseClick(object sender, MouseEventArgs e) { if (currentRow != null && currentColumn != null) { bool buttonPressed = false; int i = 0; while (!buttonPressed && i < orderFocusButtons.Count()) { RoundButton button = orderFocusButtons[i]; if (button.GetButtonRegion(new Rectangle(currentColumn.Left, currentRow.Top, currentColumn.Width, currentRow.Height), buttonSize).IsVisible(e.Location)) { buttonPressed = true; button.Invoke(); } i++; } if (buttonPressed) // we handled a button press, nothing else to do here { return; } gridPanel.Invalidate(new Rectangle(currentColumn.Left - buttonSize, currentRow.Top, currentColumn.Width + buttonSize * 2, currentRow.Height)); } Control columnCtrl = columnHeaderLayoutPanel.GetChildAtPoint(new Point(e.X, 0)); Control rowCtrl = rowHeaderLayoutPanel.GetChildAtPoint(new Point(0, e.Y)); if (rowCtrl is BottleRowHeaderControl && columnCtrl is UserHeaderControl && (rowCtrl != currentRow || columnCtrl != currentColumn)) { currentRow = (BottleRowHeaderControl)rowCtrl; currentColumn = (UserHeaderControl)columnCtrl; } else { currentRow = null; currentColumn = null; } if (currentRow != null && currentColumn != null) { gridPanel.Invalidate(new Rectangle(currentColumn.Left - buttonSize, currentRow.Top, currentColumn.Width + buttonSize * 2, currentRow.Height)); } }