Esempio n. 1
0
 /// <summary>
 /// Fired when the user clicks the delete menu item
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void delete_Click(object sender, EventArgs e)
 {
     // Note that the event itself doesn't give us the cell or row
     // where it was clicked - we have to ask the Table for its SelectedRows
     // Bit of a faff to get our Table...
     if (sender is MenuItem)
     {
         MenuItem item = (MenuItem)sender;
         if (item.Parent is ContextMenu)
         {
             ContextMenu menu = (ContextMenu)item.Parent;
             // SourceControl is automatically set to be the Table when
             // the menu is added to the Table in Setup()
             if (menu.SourceControl is Table)
             {
                 Table         t    = (Table)menu.SourceControl;
                 RowCollection rows = t.TableModel.Rows;
                 // Its possible more than one is selected
                 foreach (Row row in t.SelectedItems)
                 {
                     rows.Remove(row);
                 }
             }
         }
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Fired when any key up happens
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void table_CellKeyUp(object sender, CellKeyEventArgs e)
 {
     if (e.KeyCode == Keys.Delete)
     {
         RowCollection rows = e.Table.TableModel.Rows;
         rows.Remove(rows[e.Row]);
     }
 }
Esempio n. 3
0
        public void Remove_WhenRowIsNull_ShouldTHrowArgumentNullException()
        {
            var matrix = new Matrix <int>(new int[][]
            {
                new int [] { 0, 1, 2, 3 },
                new int [] { 1, -2, 3, 10 }
            });
            var collection = new RowCollection <int>(matrix);

            Assert.Throws <ArgumentNullException>(() => collection.Remove(null));
        }
Esempio n. 4
0
        public void Remove_WhenRowNotExists_ShouldReturnFalse()
        {
            var matrix = new Matrix <int>(new int[][]
            {
                new int [] { 0, 1, 2, 3 },
                new int [] { 1, -2, 3, 10 }
            });
            var collection = new RowCollection <int>(matrix);

            Assert.False(collection.Remove(new int[] { 0, 1 }));
            Assert.Equal(2, collection.Count);
            Assert.Equal(2, collection.LongCount);
        }
Esempio n. 5
0
        public void Remove_WhenRowExists_ShouldReturnTrueAndRemoveRow()
        {
            var matrix = new Matrix <int>(new int[][]
            {
                new int [] { 0, 1, 2, 3 },
                new int [] { 1, -2, 3, 10 }
            });
            var collection = new RowCollection <int>(matrix);

            Assert.True(collection.Remove(new int[] { 0, 1, 2, 3 }));

            Assert.Equal(1, collection.Count);
            Assert.Equal(1, collection.LongCount);
        }
Esempio n. 6
0
 private void delete_Click(object sender, EventArgs e)
 {
     if (sender is MenuItem)
     {
         MenuItem item = (MenuItem)sender;
         if (item.Parent is ContextMenu)
         {
             ContextMenu menu = (ContextMenu)item.Parent;
             if (menu.SourceControl is Table)
             {
                 Table         t    = (Table)menu.SourceControl;
                 RowCollection rows = t.TableModel.Rows;
                 foreach (Row row in t.SelectedItems)
                 {
                     rows.Remove(row);
                 }
             }
         }
     }
 }