private void UpdatePositions(RealTimePositionObject pos)
        {
            try
            {
                if (pos != null)
                {
                    //find the position
                    int i = AllRealTimePositions.Find("Cusip", pos.Cusip);

                    if (i != -1)
                    {
                        //position already exists, remove it and add new one
                        pos.Notes = AllRealTimePositions[i].Notes;

                        AllRealTimePositions.RemoveAt(i);
                        RealTimeOccPositionObject r = new RealTimeOccPositionObject(pos);
                        AllRealTimePositions.Add(r);
                    }
                    else
                    {
                        //new position. add it
                        RealTimeOccPositionObject r = new RealTimeOccPositionObject(pos);
                        AllRealTimePositions.Add(r);
                    }
                    AllRealTimePositions.Sort("SortField", ListSortDirection.Descending);
                    ColorRows();

                    dgvRealTimePosition.Refresh();
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
        private void buttonRevert_Click(object sender, EventArgs e)
        {
            //IndividualSighting currentIS = (IndividualSighting)dataGridViewNotSeen.SelectedRows[0].DataBoundItem;
            int currentIndex = dataGridViewNotSeen.SelectedRows[0].Index;

            if (RowChecked(currentIndex))
            {
                // We want to go back to initial value, or remove
                // if there was none
                if (currentIndex > initialNotSeen.Count - 1)
                {
                    currentNotSeen.RemoveAt(currentIndex);
                }
                else
                {
                    // Get the old value;
                    currentNotSeen[currentIndex] = initialNotSeen[currentIndex];
                    // Uncheck the box
                    ((DataGridViewCheckBoxCell)this.dataGridViewNotSeen["sightedCheckBoxColumn", currentIndex])
                    .Value = sightedCheckBoxColumn.FalseValue;
                }
            }

            this.CheckComplete();
        }
Пример #3
0
 private void RemoveSourceDirectory_Click(object sender, RoutedEventArgs e)
 {
     if (SourcesView.SelectedIndex >= 0)
     {
         sources.RemoveAt(SourcesView.SelectedIndex);
     }
 }
 public void DeleteButton_Handler(object sender, EventArgs e)
 {
     if (_personList.Count > 0)
     {
         _personList.RemoveAt(_dataGridView.CurrentRow.Index);
         Console.WriteLine("Person object deleted!");
     }
 }
Пример #5
0
        /// <summary>
        ///   Handle Key input on the Grid
        /// </summary>
        /// <param name = "msg"></param>
        /// <param name = "keyData"></param>
        /// <returns></returns>
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            switch (keyData)
            {
            case Keys.Delete:
                for (int i = dataGridViewBurn.Rows.Count - 1; i > -1; i--)
                {
                    if (!dataGridViewBurn.Rows[i].Selected)
                    {
                        continue;
                    }

                    bindingList.RemoveAt(i);
                }
                return(true);
            }
            return(base.ProcessCmdKey(ref msg, keyData));
        }
 public void RemoveSecurityData(OpenPositionItem monitorItem)
 {
     for (int i = _securityDataSource.Count - 1; i >= 0; i--)
     {
         var secuItem = _securityDataSource[i];
         if (secuItem.MonitorId == monitorItem.MonitorId)
         {
             _securityDataSource.RemoveAt(i);
         }
     }
 }
Пример #7
0
        public void RemoveExplicit()
        {
            var coll = new SortableBindingList <int>(new List <int> {
                1, 2, 3, 2, 1
            })
            {
                CheckConsistency = false
            };

            coll.ApplySort(ListSortDirection.Ascending);
            coll.Remove(1);   // first 1
            coll.RemoveAt(1); // 2
            coll.Remove(1);   // last 1 (1st element)
            AssertConsistency(coll);
        }
Пример #8
0
 public void DeleteButton_Handler(object sender, EventArgs e)
 {
     if (_listBox.SelectedIndex > -1)
     {
         DialogResult result = MessageBox.Show("Are you sure you want to delete this person?",
                                               "Delete Warning", MessageBoxButtons.OK,
                                               MessageBoxIcon.Exclamation);
         if (result == DialogResult.OK)
         {
             _personList.RemoveAt(_listBox.SelectedIndex);
         }
         ClearEntryControls();
     }
     else
     {
         MessageBox.Show("There are no items to delete!", "No Items Alert",
                         MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
 }
        private void buttonRevert_Click(object sender, EventArgs e)
        {
            if (currentIndex >= 0)
            {
                // Remove the selected value, replacing it with the old
                // value if there is one
                int index = initialReproductiveStates.FindIndex(
                    new Predicate <IndividualReproductiveState>(x =>
                                                                x.Individual.ID == currentIrs.Individual.ID));

                if (index >= 0)
                {
                    boundReproductiveStates[currentIndex] = initialReproductiveStates[index];
                }
                else
                {
                    boundReproductiveStates.RemoveAt(currentIndex);
                }
            }
        }
Пример #10
0
        public void RemoveInner()
        {
            var inner = new List <string> {
                "1", "2", "3", "2", "1"
            };
            var coll = new SortableBindingList <string>(inner)
            {
                CheckConsistency = false
            };

            coll.ApplySort(ListSortDirection.Ascending);

            // causing inconsistency
            inner.RemoveAt(2);
            inner.Add("a"); // making sure inner length does not change; otherwise, inconsistency is detected and fixed in Assert
            Throws <AssertionException>(() => AssertConsistency(coll));

            // inconsistency detected and fixed on next remove
            coll.CheckConsistency = true;
            coll.RemoveAt(0);
            AssertConsistency(coll);
        }
        private void ButtonContainer_ButtonClick(object sender, EventArgs e)
        {
            if (!(sender is Button))
            {
                return;
            }

            Button button = sender as Button;

            switch (button.Name)
            {
            case "SelectAll":
            {
                dataGridView.SelectAll(true);
            }
            break;

            case "UnSelect":
            {
                dataGridView.SelectAll(false);
            }
            break;

            case "Add":
            {
                _monitorType = MonitorType.New;
                MonitorUnitDialog dialog = new MonitorUnitDialog();
                dialog.Owner         = this;
                dialog.StartPosition = FormStartPosition.CenterParent;
                //dialog.OnLoadFormActived(json);
                //dialog.Visible = true;
                dialog.OnLoadControl(dialog, null);
                dialog.OnLoadData(dialog, null);
                dialog.SaveData += new FormSaveHandler(Dialog_SaveData);
                dialog.ShowDialog();

                if (dialog.DialogResult == System.Windows.Forms.DialogResult.OK)
                {
                    dialog.Dispose();
                }
                else
                {
                    dialog.Dispose();
                }
            }
            break;

            case "Delete":
            {
                List <int> selectIndex = TSDataGridViewHelper.GetSelectRowIndex(dataGridView);
                if (selectIndex == null && selectIndex.Count == 0)
                {
                    MessageDialog.Warn(this, msgDeleteSelect);
                    return;
                }

                string format = ConfigManager.Instance.GetLabelConfig().GetLabelText(msgDeleteConfirm);
                string msg    = string.Format(format, selectIndex.Count);
                if (MessageDialog.Warn(this, msg, MessageBoxButtons.YesNo) != System.Windows.Forms.DialogResult.Yes)
                {
                    return;
                }

                for (int i = selectIndex.Count - 1; i >= 0; i--)
                {
                    int rowIndex = selectIndex[i];
                    if (rowIndex >= 0 && rowIndex < _dataSource.Count)
                    {
                        MonitorUnit monitorUnit = _dataSource[rowIndex];
                        int         ret         = _monitorUnitBLL.Delete(monitorUnit.MonitorUnitId);
                        if (ret > 0)
                        {
                            _dataSource.RemoveAt(rowIndex);
                        }
                    }
                }
            }
            break;

            case "Modify":
            {
                _monitorType = MonitorType.Modify;
                if (dataGridView.CurrentRow == null)
                {
                    return;
                }

                int index = dataGridView.CurrentRow.Index;
                if (index < 0 || index > _dataSource.Count)
                {
                    return;
                }

                MonitorUnit monitorUnit = _dataSource[index];

                MonitorUnitDialog dialog = new MonitorUnitDialog();
                dialog.Owner         = this;
                dialog.StartPosition = FormStartPosition.CenterParent;
                //dialog.OnLoadFormActived(json);
                //dialog.Visible = true;
                dialog.OnLoadControl(dialog, null);
                dialog.OnLoadData(dialog, monitorUnit);
                dialog.SaveData += new FormSaveHandler(Dialog_SaveData);
                dialog.ShowDialog();

                if (dialog.DialogResult == System.Windows.Forms.DialogResult.OK)
                {
                    dialog.Close();
                    dialog.Dispose();
                }
                else
                {
                    dialog.Close();
                    dialog.Dispose();
                }
            }
            break;

            case "Refresh":
            {
                _dataSource.Clear();
                var monitorUnits = _monitorUnitBLL.GetAll();
                if (monitorUnits != null)
                {
                    foreach (var item in monitorUnits)
                    {
                        _dataSource.Add(item);
                    }
                }
            }
            break;

            case "Confirm":
            {
                List <int> selectIndex = TSDataGridViewHelper.GetSelectRowIndex(dataGridView);
                if (selectIndex == null && selectIndex.Count == 0)
                {
                    MessageDialog.Warn(this, msgSelectSetting);
                    return;
                }

                for (int rowIndex = 0; rowIndex < _dataSource.Count; rowIndex++)
                {
                    MonitorUnit monitorUnit = _dataSource[rowIndex];
                    if (selectIndex.Contains(rowIndex))
                    {
                        int ret = _monitorUnitBLL.Active(monitorUnit.MonitorUnitId, MonitorUnitStatus.Active);
                    }
                    else
                    {
                        int ret = _monitorUnitBLL.Active(monitorUnit.MonitorUnitId, MonitorUnitStatus.Inactive);
                    }
                }
            }
            break;

            case "Cancel":
                break;
            }
        }