/// <summary>
        /// Load the specified workset.
        /// </summary>
        /// <param name="workset">The workset that is to be processed.</param>
        protected override void LoadWorkset(Workset_t workset)
        {
            // Skip, if the Dispose() method has been called.
            if (IsDisposed)
            {
                return;
            }

            // Ensure that the TextChanged event is not triggered as a result of specifying the Text property of the TextBox control.
            m_TextBoxName.TextChanged -= new EventHandler(m_TextBoxName_TextChanged);
            m_TextBoxName.Text         = workset.Name;
            m_TextBoxName.TextChanged += new EventHandler(m_TextBoxName_TextChanged);

            m_TextBoxHeader1.Text = workset.Column[0].HeaderText;
            m_TextBoxHeader2.Text = workset.Column[1].HeaderText;
            m_TextBoxHeader3.Text = workset.Column[2].HeaderText;

            m_ListItemCount = workset.Count;

            m_WatchItems = new WatchItem_t[workset.WatchItems.Length];
            Array.Copy(workset.WatchItems, m_WatchItems, workset.WatchItems.Length);

            UpdateListBoxAvailable(m_WatchItems);

            // ------------------------------------
            // Update the 'Column' ListBox control.
            // -------------------------------------
            WatchItemAddRange(m_ListBox1, workset.Column[0]);
            WatchItemAddRange(m_ListBox2, workset.Column[1]);
            WatchItemAddRange(m_ListBox3, workset.Column[2]);
            UpdateCount();

            m_TextBoxSecurityLevel.Text = Security.GetSecurityDescription(workset.SecurityLevel);
        }
        /// <summary>
        /// Event handler for the Apply button <c>Click</c> event. Apply the changes.
        /// </summary>
        /// <param name="sender">Reference to the object that raised the event.</param>
        /// <param name="e">Parameter passed from the object that raised the event.</param>
        protected override void m_ButtonApply_Click(object sender, EventArgs e)
        {
            // Skip, if the Dispose() method has been called.
            if (IsDisposed)
            {
                return;
            }

            // Skip, if the ICheckBoxUInt32 interface has not yet been instantiated.
            if (m_ICheckBoxUInt32 == null)
            {
                return;
            }

            WatchItem_t selectedWatchItem = (WatchItem_t)m_ListBox.SelectedItem;

            m_DisplayMask = m_ICheckBoxUInt32.ToValue();
            if (m_DisplayMask != selectedWatchItem.DisplayMask)
            {
                selectedWatchItem.DisplayMask            = m_DisplayMask;
                m_ListBox.Items[m_ListBox.SelectedIndex] = selectedWatchItem;

                // Let the calling form know that the display mask value has been modified.
                DialogResult = DialogResult.Yes;
            }
        }
Beispiel #3
0
        /// <summary>
        /// Add the watch variables defined in the specified list of old identifiers to the specified <c>ListBox</c> control.
        /// </summary>
        /// <param name="listBox">The <c>ListBox</c> to which the items are to be added.</param>
        /// <param name="plotTabPage">The plot tab page of the workset that is to be added to the <c>ListBox</c> control.</param>
        protected void WatchItemAddRange(ListBox listBox, PlotTabPage_t plotTabPage)
        {
            // Skip, if the Dispose() method has been called.
            if (IsDisposed)
            {
                return;
            }

            Cursor = Cursors.WaitCursor;
            List <short> oldIdentifierList = plotTabPage.OldIdentifierList;
            List <uint>  displayMaskList   = plotTabPage.DisplayMaskList;

            Debug.Assert(oldIdentifierList.Count == displayMaskList.Count, "FormPlotDefine.WatchItemAddRange() - oldIdentifierList.Count == displayMaskList.Count[]");

            listBox.Items.Clear();
            listBox.SuspendLayout();

            WatchItem_t watchItem;
            short       oldIdentifier;
            uint        displayMask;

            for (int index = 0; index < oldIdentifierList.Count; index++)
            {
                watchItem               = new WatchItem_t();
                oldIdentifier           = oldIdentifierList[index];
                displayMask             = displayMaskList[index];
                watchItem.OldIdentifier = oldIdentifier;

                // The DisplayMask field is only applicable to bitmask watch variables and is used to define which bits of the bitmask watch variable.
                watchItem.DisplayMask = displayMask;
                watchItem.Added       = true;
                listBox.Items.Add(watchItem);
            }

            listBox.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="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;
        }