Exemplo n.º 1
0
 private void dataGridViewFilter_CellValueChanged(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex < 0)
     {
         return;
     }
     if (e.ColumnIndex == 0)
     {
         DataGridViewCell operationCell   = dataGridViewFilter.Rows[e.RowIndex].Cells[1];
         object           oldSelectedItem = operationCell.Value;
         operationCell.Value = string.Empty;
         DataGridViewCell      fieldCell  = dataGridViewFilter.Rows[e.RowIndex].Cells[0];
         string                filterName = fieldCell.Value.ToString();
         IILStubEventFilterDef filterDef  =
             ILStubEventFilterManager.GetInstance().GetFilterDef(filterName);
         if (filterDef != null)
         {
             List <string>            operations            = filterDef.Operations;
             DataGridViewComboBoxCell comboBoxOperationCell =
                 operationCell as DataGridViewComboBoxCell;
             comboBoxOperationCell.Items.Clear();
             comboBoxOperationCell.Items.AddRange(operations.ToArray());
             if (oldSelectedItem != null &&
                 comboBoxOperationCell.Items.Contains(oldSelectedItem))
             {
                 comboBoxOperationCell.Value = oldSelectedItem;
             }
         }
     }
 }
Exemplo n.º 2
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            ILStubDiagnosticSessionController controller =
                ILStubDiagnosticSessionController.GetInstance();

            controller.EnableKernelSession();
            controller.ILStubEventHandler += ILStubEventListener;

            // For ILStubEvents DataGridView
            dataGridViewILStubEvents.AutoGenerateColumns = false;
            for (int i = 0; i < columnNames.Length; i++)
            {
                dataGridViewILStubEvents.Columns.Add(columnNames[i], columnNames[i]);
                dataGridViewILStubEvents.Columns[i].DataPropertyName = dataPropertyNames[i];
                dataGridViewILStubEvents.Columns[i].Visible          = false;
            }
            // Add the last padding column.
            dataGridViewILStubEvents.Columns.Add("", "");
            dataGridViewILStubEvents.Columns[columnNames.Length].Visible      = true;
            dataGridViewILStubEvents.Columns[columnNames.Length].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            // Bind to the event list.
            dataGridViewILStubEvents.DataSource = m_viewEventList;

            // For Filter DataGridView
            DataGridViewComboBoxColumn fieldColumn =
                dataGridViewFilter.Columns[0] as DataGridViewComboBoxColumn;

            fieldColumn.Items.Clear();
            List <IILStubEventFilterDef> filterDefList =
                ILStubEventFilterManager.GetInstance().FilterDefList;

            for (int i = 0; i < filterDefList.Count; i++)
            {
                fieldColumn.Items.Add(filterDefList[i].FilterName);
            }
            UpdateFilterMessage();

            // For contextMenuStripOnEventsColumnHeader
            for (int i = 0; i < columnNames.Length; i++)
            {
                ToolStripMenuItem item = new ToolStripMenuItem();
                item.Text         = columnNames[i];
                item.CheckOnClick = true;
                item.Click       += ItemOfContextMenuStripOnEventsColumnHeader_Click;
                contextMenuStripOnEventsColumnHeader.Items.Add(item);
                if (initialColumnCheckedStatus[i])
                {
                    item.PerformClick();
                }
            }
            // We can not hide the first column.
            contextMenuStripOnEventsColumnHeader.Items[0].Enabled = false;
        }
Exemplo n.º 3
0
 private void toolStripButtonRefresh_Click(object sender, EventArgs e)
 {
     try
     {
         this.Cursor = Cursors.WaitCursor;
         ILStubEventFilterList listFilter = new ILStubEventFilterList();
         int rowCount = dataGridViewFilter.Rows.Count;
         for (int i = 0; i < rowCount; i++)
         {
             DataGridViewRow dataGridViewRow = dataGridViewFilter.Rows[i];
             if (dataGridViewRow.IsNewRow)
             {
                 continue;
             }
             if (dataGridViewRow.Cells[0].Value == null)
             {
                 MessageBox.Show("The field of row " + (i + 1) + " is empty.");
                 return;
             }
             string filterName = dataGridViewRow.Cells[0].Value.ToString();
             IILStubEventFilterDef filterDef =
                 ILStubEventFilterManager.GetInstance().GetFilterDef(filterName);
             Debug.Assert(filterDef != null);
             if (dataGridViewRow.Cells[1].Value == null)
             {
                 MessageBox.Show("The operation of row '" + filterName + "' is empty.");
                 return;
             }
             string operaton = dataGridViewRow.Cells[1].Value.ToString();
             if (dataGridViewRow.Cells[2].Value == null)
             {
                 MessageBox.Show("The value of row '" + filterName + "' is empty.");
                 return;
             }
             string value = dataGridViewRow.Cells[2].Value.ToString();
             try
             {
                 IILStubEventFilter filter = filterDef.CreateFilter(operaton, value);
                 listFilter.Add(filter);
             }
             catch (FilterOperationIsNullException ex)
             {
                 MessageBox.Show(String.Format(
                                     Resource.ResourceManager.GetString("Wrn_FilterOperationIsNull"), ex.FilterName));
                 return;
             }
             catch (FilterOperationNotSupportException ex)
             {
                 MessageBox.Show(String.Format(
                                     Resource.ResourceManager.GetString("Wrn_FilterOperationNotSupport"),
                                     ex.Operation, ex.FilterName));
                 return;
             }
             catch (FilterValueIsNullException ex)
             {
                 MessageBox.Show(String.Format(
                                     Resource.ResourceManager.GetString("Wrn_FilterValueIsNull"), ex.FilterName));
                 return;
             }
             catch (FilterValueNotIntegerException ex)
             {
                 MessageBox.Show(String.Format(
                                     Resource.ResourceManager.GetString("Wrn_FilterValueNotInteger"),
                                     ex.Value, ex.FilterName));
                 return;
             }
         }
         m_filterList = listFilter;
         UpdateFilterMessage();
         UpdateEventList();
     }
     finally
     {
         this.Cursor = Cursors.Default;
     }
 }