コード例 #1
0
        private void gridPanel_MouseClick(object sender, MouseEventArgs e)
        {
            int?newRow    = RowFromY(e.Y);
            int?newColumn = ColFromX(e.X);

            SetCurrentCell(newRow, newColumn, e.X, e.Y);
            if (newColumn == 0 && newRow != null)
            {
                Bottle    bottle = evnt.bottles[(int)newRow];
                Rectangle rect   = GetGridRectangle((int)newRow, (int)newColumn);
                rect = new Rectangle(rect.Right - deleteIconSize, rect.Top, deleteIconSize, deleteIconSize);
                if (new Region(rect).IsVisible(e.Location)) // delete button pressed
                {
                    evnt.bottles.Remove(bottle);
                    if (currentRow >= evnt.bottles.Count)
                    {
                        currentRow = evnt.bottles.Count > 0 ? (int?)evnt.bottles.Count - 1 : null;
                    }
                    RefreshGrid();
                }
                else
                {
                    BottleDetailForm bottleDetailForm = new BottleDetailForm(trip, bottle, RefreshGrid, this);
                    bottleDetailForm.ShowDialog(this);
                }
            }
        }
コード例 #2
0
        private void buttonAddBottle_Click(object sender, EventArgs e)
        {
            Bottle bottle = new Bottle();

            evnt.bottles.Add(bottle);
            CalcRowHeights(headerColumnWidth);
            BottleDetailForm bottleDetailForm = new BottleDetailForm(trip, bottle, RefreshGrid, this);

            bottleDetailForm.ShowDialog();
        }