/// <summary> /// Add the watch variables defined in the specified workset column to the <c>ListBox</c> controls that display the description and the chart recorder scaling /// information for each chart recorder channel. /// </summary> /// <param name="listBox">The <c>ListBox</c> to which the items are to be added.</param> /// <param name="worksetColumn">The column of the workset that is to be added to the <c>ListBox</c> control.</param> protected override void WatchItemAddRange(ListBox listBox, Column_t worksetColumn) { // Skip, if the Dispose() method has been called. if (IsDisposed) { return; } Cursor = Cursors.WaitCursor; listBox.Items.Clear(); m_ListBoxChartScaleUpperLimit.Items.Clear(); m_ListBoxChartScaleLowerLimit.Items.Clear(); m_ListBoxUnits.Items.Clear(); listBox.SuspendLayout(); m_ListBoxChartScaleLowerLimit.SuspendLayout(); m_ListBoxChartScaleUpperLimit.SuspendLayout(); m_ListBoxUnits.SuspendLayout(); bool hexFormat = false; WatchItem_t watchItem; short oldIdentifier; WatchVariable watchVariable; ChartScale_t chartScale; for (int index = 0; index < worksetColumn.OldIdentifierList.Count; index++) { watchItem = new WatchItem_t(); oldIdentifier = worksetColumn.OldIdentifierList[index]; watchItem.OldIdentifier = oldIdentifier; watchItem.Added = true; m_ListBox1.Items.Add(watchItem); // Check whether the watch variable exists. try { watchVariable = Lookup.WatchVariableTableByOldIdentifier.RecordList[oldIdentifier]; if (watchVariable == null) { throw new Exception(); } // Determine the format of the watch variable. hexFormat = (watchVariable.FormatString.ToLower().Equals(CommonConstants.DDFormatStringHex)) ? true : false; // Check whether the chart scaling for the current watch variable has been defined. try { chartScale = worksetColumn.ChartScaleList[index]; } catch (Exception) { // No - Set up the default chart scaling for the watch variable based upon the data dictionary. chartScale = new ChartScale_t(); chartScale.ChartScaleLowerLimit = watchVariable.MinChartScale; chartScale.ChartScaleUpperLimit = watchVariable.MaxChartScale; chartScale.Units = watchVariable.Units; } } catch (Exception) { // Watch variable does not exist. chartScale.ChartScaleLowerLimit = double.NaN; chartScale.ChartScaleUpperLimit = double.NaN; chartScale.Units = CommonConstants.ChartScaleUnitsNotDefinedString; } // Rather tha displaying 'NaN' if the chart scale values are undefined, display the default string used to represent a chart scale value that is not defined. if (chartScale.ChartScaleLowerLimit.Equals(double.NaN)) { m_ListBoxChartScaleLowerLimit.Items.Add(CommonConstants.ChartScaleValueNotDefinedString); } else { if (hexFormat == true) { m_ListBoxChartScaleLowerLimit.Items.Add(CommonConstants.HexValueIdentifier + ((uint)chartScale.ChartScaleLowerLimit).ToString(CommonConstants.FormatStringHex)); } else { m_ListBoxChartScaleLowerLimit.Items.Add(chartScale.ChartScaleLowerLimit.ToString(CommonConstants.FormatStringNumeric)); } } if (chartScale.ChartScaleUpperLimit.Equals(double.NaN)) { m_ListBoxChartScaleUpperLimit.Items.Add(CommonConstants.ChartScaleValueNotDefinedString); } else { if (hexFormat == true) { m_ListBoxChartScaleUpperLimit.Items.Add(CommonConstants.HexValueIdentifier + ((uint)chartScale.ChartScaleUpperLimit).ToString(CommonConstants.FormatStringHex)); } else { m_ListBoxChartScaleUpperLimit.Items.Add(chartScale.ChartScaleUpperLimit.ToString(CommonConstants.FormatStringNumeric)); } } m_ListBoxUnits.Items.Add(chartScale.Units); } listBox.PerformLayout(); m_ListBoxChartScaleLowerLimit.PerformLayout(); m_ListBoxChartScaleUpperLimit.PerformLayout(); m_ListBoxUnits.PerformLayout(); Cursor = Cursors.Default; }
/// <summary> /// Add the watch variables defined in the specified workset column to the <c>ListBox</c> controls that display the description and the chart recorder scaling /// information for each chart recorder channel. /// </summary> /// <param name="worksetColumn">The column of the workset that is to be added to the <c>ListBox</c> control.</param> protected void WatchItemAddRange(Column_t worksetColumn) { // Skip, if the Dispose() method has been called. if (IsDisposed) { return; } Cursor = Cursors.WaitCursor; m_ListBox1.Items.Clear(); m_ListBoxChartScaleMin.Items.Clear(); m_ListBoxChartScaleMax.Items.Clear(); m_ListBoxUnits.Items.Clear(); m_ListBox1.SuspendLayout(); m_ListBoxChartScaleMin.SuspendLayout(); m_ListBoxChartScaleMax.SuspendLayout(); m_ListBoxUnits.SuspendLayout(); WatchItem_t watchItem; short oldIdentifier; WatchVariable watchVariable; ChartScale_t chartScale; for (int index = 0; index < worksetColumn.OldIdentifierList.Count; index++) { watchItem = new WatchItem_t(); oldIdentifier = worksetColumn.OldIdentifierList[index]; watchItem.OldIdentifier = oldIdentifier; watchItem.Added = true; m_ListBox1.Items.Add(watchItem); // Check whether the watch variable exists. try { watchVariable = watchVariable = Lookup.WatchVariableTableByOldIdentifier.RecordList[oldIdentifier]; if (watchVariable == null) { throw new Exception(); } // Check whether the chart scaling for the current watch variable has been defined. try { chartScale = worksetColumn.ChartScaleList[index]; } catch (Exception) { // No - Set up the default chart scaling for the watch variable based upon the data dictionary. chartScale = new ChartScale_t(); chartScale.ChartScaleMax = watchVariable.MaxChartScale; chartScale.ChartScaleMin = watchVariable.MinChartScale; chartScale.Units = watchVariable.Units; } } catch (Exception) { // Watch variable does not exist. chartScale.ChartScaleMax = double.NaN; chartScale.ChartScaleMin = double.NaN; chartScale.Units = CommonConstants.VariableNotDefinedUnitsString; } m_ListBoxChartScaleMin.Items.Add(chartScale.ChartScaleMin); m_ListBoxChartScaleMax.Items.Add(chartScale.ChartScaleMax); m_ListBoxUnits.Items.Add(chartScale.Units); } m_ListBox1.PerformLayout(); m_ListBoxChartScaleMin.PerformLayout(); m_ListBoxChartScaleMax.PerformLayout(); m_ListBoxUnits.PerformLayout(); Cursor = Cursors.Default; }