public MetricValueControl(WriteToLogDelegate writeToLog, 
                      Action closeAction, 
                      IEnumerable<MetricValue> metricValues, 
                      MetricDataPoint metricDataPoint,  
                      MetricInfo metricInfo)
 {
     this.writeToLog = writeToLog;
     this.closeAction = closeAction;
     this.metricDataPoint = metricDataPoint;
     this.metricInfo = metricInfo;
     InitializeComponent();
     metricList = metricValues as IList<MetricValue> ?? metricValues.ToList();
     bindingList = metricValues != null ?
                   new BindingList<MetricValue>(metricList)
                     {
                         AllowNew = true,
                         AllowEdit = true,
                         AllowRemove = true
                     } : 
                   new BindingList<MetricValue>
                     {
                         AllowNew = true,
                         AllowEdit = true,
                         AllowRemove = true
                     };
     InitializeControls();
 } 
Ejemplo n.º 2
0
 public MetricValueControl(WriteToLogDelegate writeToLog,
                           Action closeAction,
                           IEnumerable <MetricValue> metricValues,
                           MetricDataPoint metricDataPoint,
                           MetricInfo metricInfo)
 {
     this.writeToLog      = writeToLog;
     this.closeAction     = closeAction;
     this.metricDataPoint = metricDataPoint;
     this.metricInfo      = metricInfo;
     InitializeComponent();
     metricList  = metricValues as IList <MetricValue> ?? metricValues.ToList();
     bindingList = metricValues != null ?
                   new BindingList <MetricValue>(metricList)
     {
         AllowNew    = true,
         AllowEdit   = true,
         AllowRemove = true
     } :
     new BindingList <MetricValue>
     {
         AllowNew    = true,
         AllowEdit   = true,
         AllowRemove = true
     };
     InitializeControls();
 }
Ejemplo n.º 3
0
        private void InitializeControls()
        {
            // Set Grid style
            partitionsDataGridView.EnableHeadersVisualStyles = false;

            // Set the selection background color for all the cells.
            partitionsDataGridView.DefaultCellStyle.SelectionBackColor = Color.FromArgb(92, 125, 150);
            partitionsDataGridView.DefaultCellStyle.SelectionForeColor = SystemColors.Window;

            // Set RowHeadersDefaultCellStyle.SelectionBackColor so that its default
            // value won't override DataGridView.DefaultCellStyle.SelectionBackColor.
            partitionsDataGridView.RowHeadersDefaultCellStyle.SelectionBackColor = Color.FromArgb(153, 180, 209);

            // Set the background color for all rows and for alternating rows.
            // The value for alternating rows overrides the value for all rows.
            partitionsDataGridView.RowsDefaultCellStyle.BackColor = SystemColors.Window;
            partitionsDataGridView.RowsDefaultCellStyle.ForeColor = SystemColors.ControlText;
            //filtersDataGridView.AlternatingRowsDefaultCellStyle.BackColor = Color.White;
            //filtersDataGridView.AlternatingRowsDefaultCellStyle.ForeColor = SystemColors.ControlText;

            // Set the row and column header styles.
            partitionsDataGridView.RowHeadersDefaultCellStyle.BackColor    = Color.FromArgb(215, 228, 242);
            partitionsDataGridView.RowHeadersDefaultCellStyle.ForeColor    = SystemColors.ControlText;
            partitionsDataGridView.ColumnHeadersDefaultCellStyle.BackColor = Color.FromArgb(215, 228, 242);
            partitionsDataGridView.ColumnHeadersDefaultCellStyle.ForeColor = SystemColors.ControlText;

            // Initialize the DataGridView.
            partitionsDataGridView.AutoGenerateColumns = true;
            partitionsDataGridView.AutoSize            = true;
            partitionsDataGridView.ForeColor           = SystemColors.WindowText;

            // Set Grid style
            dataPointDataGridView.EnableHeadersVisualStyles = false;

            // Set the selection background color for all the cells.
            dataPointDataGridView.DefaultCellStyle.SelectionBackColor = Color.FromArgb(92, 125, 150);
            dataPointDataGridView.DefaultCellStyle.SelectionForeColor = SystemColors.Window;

            // Set RowHeadersDefaultCellStyle.SelectionBackColor so that its default
            // value won't override DataGridView.DefaultCellStyle.SelectionBackColor.
            dataPointDataGridView.RowHeadersDefaultCellStyle.SelectionBackColor = Color.FromArgb(153, 180, 209);

            // Set the background color for all rows and for alternating rows.
            // The value for alternating rows overrides the value for all rows.
            dataPointDataGridView.RowsDefaultCellStyle.BackColor = SystemColors.Window;
            dataPointDataGridView.RowsDefaultCellStyle.ForeColor = SystemColors.ControlText;
            //filtersDataGridView.AlternatingRowsDefaultCellStyle.BackColor = Color.White;
            //filtersDataGridView.AlternatingRowsDefaultCellStyle.ForeColor = SystemColors.ControlText;

            // Set the row and column header styles.
            dataPointDataGridView.RowHeadersDefaultCellStyle.BackColor    = Color.FromArgb(215, 228, 242);
            dataPointDataGridView.RowHeadersDefaultCellStyle.ForeColor    = SystemColors.ControlText;
            dataPointDataGridView.ColumnHeadersDefaultCellStyle.BackColor = Color.FromArgb(215, 228, 242);
            dataPointDataGridView.ColumnHeadersDefaultCellStyle.ForeColor = SystemColors.ControlText;

            // Initialize the DataGridView.
            dataPointBindingSource.DataSource         = dataPointBindingList;
            dataPointDataGridView.AutoGenerateColumns = false;
            dataPointDataGridView.AutoSize            = true;
            dataPointDataGridView.DataSource          = dataPointBindingSource;
            dataPointDataGridView.ForeColor           = SystemColors.WindowText;

            if (consumerGroupDescription != null)
            {
                MetricInfo.GetMetricInfoListAsync(serviceBusHelper.Namespace,
                                                  ConsumerGroupEntity,
                                                  string.Format(ConsumerGroupPathFormat,
                                                                consumerGroupDescription.EventHubPath,
                                                                consumerGroupDescription.Name)).ContinueWith(t => metricsManualResetEvent.Set());
            }

            if (dataPointDataGridView.Columns.Count == 0)
            {
                // Create the Metric column
                var metricColumn = new DataGridViewComboBoxColumn
                {
                    DataSource = MetricInfo.EntityMetricDictionary.ContainsKey(ConsumerGroupEntity) ?
                                 MetricInfo.EntityMetricDictionary[ConsumerGroupEntity] :
                                 null,
                    DataPropertyName = MetricProperty,
                    DisplayMember    = DisplayNameProperty,
                    ValueMember      = NameProperty,
                    Name             = MetricProperty,
                    Width            = 144,
                    DropDownWidth    = 250,
                    FlatStyle        = FlatStyle.Flat,
                    DisplayStyle     = DataGridViewComboBoxDisplayStyle.DropDownButton
                };
                dataPointDataGridView.Columns.Add(metricColumn);

                // Create the Time Granularity column
                var timeGranularityColumn = new DataGridViewComboBoxColumn
                {
                    DataSource       = timeGranularityList,
                    DataPropertyName = GranularityProperty,
                    Name             = GranularityProperty,
                    Width            = 72,
                    FlatStyle        = FlatStyle.Flat
                };
                dataPointDataGridView.Columns.Add(timeGranularityColumn);

                // Create the Time Operator 1 column
                var operator1Column = new DataGridViewComboBoxColumn
                {
                    DataSource       = operators,
                    DataPropertyName = TimeFilterOperator1Name,
                    HeaderText       = TimeFilterOperator,
                    Name             = TimeFilterOperator1Name,
                    Width            = 72,
                    FlatStyle        = FlatStyle.Flat
                };
                dataPointDataGridView.Columns.Add(operator1Column);

                // Create the Time Value 1 column
                var value1Column = new DataGridViewDateTimePickerColumn
                {
                    DataPropertyName = TimeFilterValue1Name,
                    HeaderText       = TimeFilterValue,
                    Name             = TimeFilterValue1Name,
                    Width            = 136
                };
                dataPointDataGridView.Columns.Add(value1Column);

                // Create the Time Operator 1 column
                var operator2Column = new DataGridViewComboBoxColumn
                {
                    DataSource       = operators,
                    DataPropertyName = TimeFilterOperator2Name,
                    HeaderText       = TimeFilterOperator,
                    Name             = TimeFilterOperator2Name,
                    Width            = 72,
                    FlatStyle        = FlatStyle.Flat
                };
                dataPointDataGridView.Columns.Add(operator2Column);

                // Create the Time Value 1 column
                var value2Column = new DataGridViewDateTimePickerColumn
                {
                    DataPropertyName = TimeFilterValue2Name,
                    HeaderText       = TimeFilterValue,
                    Name             = TimeFilterValue2Name,
                    Width            = 136
                };
                dataPointDataGridView.Columns.Add(value2Column);

                // Create delete column
                var deleteButtonColumn = new DataGridViewButtonColumn
                {
                    Name         = DeleteName,
                    CellTemplate = new DataGridViewDeleteButtonCell(),
                    HeaderText   = string.Empty,
                    Width        = 22
                };
                deleteButtonColumn.CellTemplate.ToolTipText    = DeleteTooltip;
                deleteButtonColumn.UseColumnTextForButtonValue = true;
                dataPointDataGridView.Columns.Add(deleteButtonColumn);
            }

            DisablePage(PartitionsTabPage);

            if (consumerGroupDescription != null)
            {
                // Tab pages
                if (serviceBusHelper.IsCloudNamespace)
                {
                    EnablePage(MetricsTabPage);
                }
                else
                {
                    DisablePage(MetricsTabPage);
                }

                // Initialize buttons
                btnCreateDelete.Text     = DeleteText;
                btnCancelUpdate.Text     = UpdateText;
                btnRefresh.Visible       = true;
                btnMetrics.Visible       = true;
                btnCloseTabs.Visible     = true;
                btnGetPartitions.Visible = true;

                // Initialize textboxes
                txtName.ReadOnly  = true;
                txtName.BackColor = SystemColors.Window;
                txtName.GotFocus += textBox_GotFocus;

                // Initialize Data
                InitializeData();

                toolTip.SetToolTip(txtName, NameTooltip);
                toolTip.SetToolTip(txtUserMetadata, UserMetadataTooltip);

                propertyListView.ContextMenuStrip = entityInformationContextMenuStrip;
            }
            else
            {
                // Tab pages
                DisablePage(MetricsTabPage);

                // Initialize buttons
                btnCreateDelete.Text     = CreateText;
                btnCancelUpdate.Text     = CancelText;
                btnRefresh.Visible       = false;
                btnMetrics.Visible       = false;
                btnCloseTabs.Visible     = false;
                btnGetPartitions.Visible = false;
            }
        }