Esempio n. 1
0
        /// <summary>
        /// Clean up the resources used by the form.
        /// </summary>
        /// <param name="disposing">True to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
        protected override void Cleanup(bool disposing)
        {
            try
            {
                if (disposing)
                {
                    // Cleanup managed objects by calling their Dispose() methods.
                    if (components != null)
                    {
                        components.Dispose();
                    }
                }

                // Whether called by consumer code or the garbage collector free all unmanaged resources and set the value of managed data members to null.
                m_WatchVariable = null;
                m_IChartScale   = null;
                m_CalledFromAsFormConfigureChartRecorder = null;

                #region --- Windows Form Designer Variables ---
                // Detach the event handler delegates.

                // Set the Windows Form Designer Variables to null.

                #endregion --- Windows Form Designer Variables ---
            }
            catch (Exception)
            {
                // Don't do anything, just ensure that an exception isn't thrown.
            }
            finally
            {
                base.Cleanup(disposing);
            }
        }
        /// <summary>
        /// Event handler for the form <c>Shown</c> event.
        /// </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>
        private void FormChangeChartScale_Shown(object sender, EventArgs e)
        {
            m_IChartScale = CalledFrom as IChartScale;
            Debug.Assert(m_IChartScale != null, "FormChargeChartScale.FormChangeChartScale_Shown() - [m_CalledFromAsFormWorksetDefineChartRecorder != null]");

            string chartScaleLowerLimitText = (string)m_IChartScale.ListBoxChartScaleLowerLimit.Items[m_SelectedIndex];
            string chartScaleUpperLimitText = (string)m_IChartScale.ListBoxChartScaleUpperLimit.Items[m_SelectedIndex];

            CultureInfo provider = new CultureInfo(CommonConstants.CultureInfoString);
            bool successfulParse;
            if (m_HexFormat == true)
            {
                uint lowerLimitAsUInt32;
                uint upperLimitAsUInt32;
                string strippedChartScaleLowerLimitText, strippedChartScaleUpperLimitText;

                // Strip out the leading HexValueIdentifier.
                Debug.Assert(chartScaleLowerLimitText.Contains(CommonConstants.HexValueIdentifier), "FormChangeChartScale.FormChangeChartScale_Shown() - [chartScaleLowerLimitText.Contains(HexValueIdentifier)]");
                Debug.Assert(chartScaleUpperLimitText.Contains(CommonConstants.HexValueIdentifier), "FormChangeChartScale.FormChangeChartScale_Shown() - [chartScaleUpperLimitText.Contains(HexValueIdentifier)]");

                strippedChartScaleLowerLimitText = chartScaleLowerLimitText.Remove(0, CommonConstants.HexValueIdentifier.Length);
                strippedChartScaleUpperLimitText = chartScaleUpperLimitText.Remove(0, CommonConstants.HexValueIdentifier.Length);

                // Check that the value entered is a valid 32 bit hexadecimal value.
                successfulParse = UInt32.TryParse(strippedChartScaleLowerLimitText, NumberStyles.HexNumber, provider, out lowerLimitAsUInt32);
                if (successfulParse == false)
                {
                    m_ChartScaleLowerLimit = double.NaN;
                }
                else
                {
                    m_ChartScaleLowerLimit = lowerLimitAsUInt32;
                }

                successfulParse = UInt32.TryParse(strippedChartScaleUpperLimitText, NumberStyles.HexNumber, provider, out upperLimitAsUInt32);
                if (successfulParse == false)
                {
                    m_ChartScaleUpperLimit = double.NaN;
                }
                else
                {
                    m_ChartScaleUpperLimit = upperLimitAsUInt32;
                }
            }
            else
            {
                double lowerLimitAsDouble;
                double upperLimitAsDouble;

                // Check that the value entered is a valid 32 bit decimal value.
                successfulParse = double.TryParse(chartScaleLowerLimitText, out lowerLimitAsDouble);
                if (successfulParse == false)
                {
                    m_ChartScaleLowerLimit = double.NaN;
                }
                else
                {
                    m_ChartScaleLowerLimit = lowerLimitAsDouble;
                }

                successfulParse = double.TryParse(chartScaleUpperLimitText, out upperLimitAsDouble);
                if (successfulParse == false)
                {
                    m_ChartScaleUpperLimit = double.NaN;
                }
                else
                {
                    m_ChartScaleUpperLimit = upperLimitAsDouble;
                }
            }
            
            if ((m_ChartScaleLowerLimit.Equals(double.NaN)) || (m_ChartScaleUpperLimit.Equals(double.NaN)))
            {
                MessageBox.Show(Resources.MBTChartScaleLimitsInvalid, Resources.MBCaptionWarning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                m_ChartScaleLowerLimit = m_WatchVariable.MinChartScale;
                m_ChartScaleUpperLimit = m_WatchVariable.MaxChartScale;
            }
            
            if (m_HexFormat == true)
            {
                m_TextBoxNewChartScaleMin.Text = ((uint)m_ChartScaleLowerLimit).ToString(CommonConstants.FormatStringHex);
                m_TextBoxNewChartScaleMax.Text = ((uint)m_ChartScaleUpperLimit).ToString(CommonConstants.FormatStringHex);
                m_LabelDataFormat.Text = Resources.LegendFormatHex;
            }
            else
            {
                m_TextBoxNewChartScaleMin.Text = m_ChartScaleLowerLimit.ToString(CommonConstants.FormatStringNumeric);
                m_TextBoxNewChartScaleMax.Text = m_ChartScaleUpperLimit.ToString(CommonConstants.FormatStringNumeric);
                m_LabelDataFormat.Text = string.Empty;
            }

            m_TextBoxNewChartScaleMax.SelectAll();
        }
        /// <summary>
        /// Clean up the resources used by the form.
        /// </summary>
        /// <param name="disposing">True to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
        protected override void Cleanup(bool disposing)
        {
            try
            {
                if (disposing)
                {
                    // Cleanup managed objects by calling their Dispose() methods.
                    if (components != null)
                    {
                        components.Dispose();
                    }
                }

                // Whether called by consumer code or the garbage collector free all unmanaged resources and set the value of managed data members to null.
                m_WatchVariable = null;
                m_IChartScale = null;
                m_CalledFromAsFormConfigureChartRecorder = null;

                #region --- Windows Form Designer Variables ---
                // Detach the event handler delegates.

                // Set the Windows Form Designer Variables to null.

                #endregion --- Windows Form Designer Variables ---
            }
            catch (Exception)
            {
                // Don't do anything, just ensure that an exception isn't thrown.
            }
            finally
            {
                base.Cleanup(disposing);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Event handler for the form <c>Shown</c> event.
        /// </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>
        private void FormChangeChartScale_Shown(object sender, EventArgs e)
        {
            m_IChartScale = CalledFrom as IChartScale;
            Debug.Assert(m_IChartScale != null, "FormChargeChartScale.FormChangeChartScale_Shown() - [m_CalledFromAsFormWorksetDefineChartRecorder != null]");

            string chartScaleLowerLimitText = (string)m_IChartScale.ListBoxChartScaleLowerLimit.Items[m_SelectedIndex];
            string chartScaleUpperLimitText = (string)m_IChartScale.ListBoxChartScaleUpperLimit.Items[m_SelectedIndex];

            CultureInfo provider = new CultureInfo(CommonConstants.CultureInfoString);
            bool        successfulParse;

            if (m_HexFormat == true)
            {
                uint   lowerLimitAsUInt32;
                uint   upperLimitAsUInt32;
                string strippedChartScaleLowerLimitText, strippedChartScaleUpperLimitText;

                // Strip out the leading HexValueIdentifier.
                Debug.Assert(chartScaleLowerLimitText.Contains(CommonConstants.HexValueIdentifier), "FormChangeChartScale.FormChangeChartScale_Shown() - [chartScaleLowerLimitText.Contains(HexValueIdentifier)]");
                Debug.Assert(chartScaleUpperLimitText.Contains(CommonConstants.HexValueIdentifier), "FormChangeChartScale.FormChangeChartScale_Shown() - [chartScaleUpperLimitText.Contains(HexValueIdentifier)]");

                strippedChartScaleLowerLimitText = chartScaleLowerLimitText.Remove(0, CommonConstants.HexValueIdentifier.Length);
                strippedChartScaleUpperLimitText = chartScaleUpperLimitText.Remove(0, CommonConstants.HexValueIdentifier.Length);

                // Check that the value entered is a valid 32 bit hexadecimal value.
                successfulParse = UInt32.TryParse(strippedChartScaleLowerLimitText, NumberStyles.HexNumber, provider, out lowerLimitAsUInt32);
                if (successfulParse == false)
                {
                    m_ChartScaleLowerLimit = double.NaN;
                }
                else
                {
                    m_ChartScaleLowerLimit = lowerLimitAsUInt32;
                }

                successfulParse = UInt32.TryParse(strippedChartScaleUpperLimitText, NumberStyles.HexNumber, provider, out upperLimitAsUInt32);
                if (successfulParse == false)
                {
                    m_ChartScaleUpperLimit = double.NaN;
                }
                else
                {
                    m_ChartScaleUpperLimit = upperLimitAsUInt32;
                }
            }
            else
            {
                double lowerLimitAsDouble;
                double upperLimitAsDouble;

                // Check that the value entered is a valid 32 bit decimal value.
                successfulParse = double.TryParse(chartScaleLowerLimitText, out lowerLimitAsDouble);
                if (successfulParse == false)
                {
                    m_ChartScaleLowerLimit = double.NaN;
                }
                else
                {
                    m_ChartScaleLowerLimit = lowerLimitAsDouble;
                }

                successfulParse = double.TryParse(chartScaleUpperLimitText, out upperLimitAsDouble);
                if (successfulParse == false)
                {
                    m_ChartScaleUpperLimit = double.NaN;
                }
                else
                {
                    m_ChartScaleUpperLimit = upperLimitAsDouble;
                }
            }

            if ((m_ChartScaleLowerLimit.Equals(double.NaN)) || (m_ChartScaleUpperLimit.Equals(double.NaN)))
            {
                MessageBox.Show(Resources.MBTChartScaleLimitsInvalid, Resources.MBCaptionWarning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                m_ChartScaleLowerLimit = m_WatchVariable.MinChartScale;
                m_ChartScaleUpperLimit = m_WatchVariable.MaxChartScale;
            }

            if (m_HexFormat == true)
            {
                m_TextBoxNewChartScaleMin.Text = ((uint)m_ChartScaleLowerLimit).ToString(CommonConstants.FormatStringHex);
                m_TextBoxNewChartScaleMax.Text = ((uint)m_ChartScaleUpperLimit).ToString(CommonConstants.FormatStringHex);
                m_LabelDataFormat.Text         = Resources.LegendFormatHex;
            }
            else
            {
                m_TextBoxNewChartScaleMin.Text = m_ChartScaleLowerLimit.ToString(CommonConstants.FormatStringNumeric);
                m_TextBoxNewChartScaleMax.Text = m_ChartScaleUpperLimit.ToString(CommonConstants.FormatStringNumeric);
                m_LabelDataFormat.Text         = string.Empty;
            }

            m_TextBoxNewChartScaleMax.SelectAll();
        }