/// <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(); } if (m_IDataUpdate != null) { // De-register the event handler for the data update event. m_IDataUpdate.DataUpdate -= new EventHandler(DataUpdate); } } // 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_ICheckBoxUInt32 = 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> /// Initialize a new instance of the class. /// </summary> /// <param name="bitmaskControl">The <c>WatchControl</c> derived user control that called this form.</param> public FormChangeBitmask(WatchBitmaskControl bitmaskControl) { InitializeComponent(); m_WatchControl = bitmaskControl; // Use the communication interface associated with the client form. m_ICommunicationInterface = m_WatchControl.ClientForm as ICommunicationInterface<ICommunicationWatch>; Debug.Assert(m_ICommunicationInterface != null); // Register the event handler for the data update event. m_IDataUpdate = m_WatchControl.ClientForm as IDataUpdate; if (m_IDataUpdate != null) { m_IDataUpdate.DataUpdate += new EventHandler(DataUpdate); } m_IPollTarget = m_WatchControl.ClientForm as IPollTarget; Debug.Assert(m_IPollTarget != null); m_OldIdentifier = (short)m_WatchControl.Identifier; try { m_WatchVariable = Lookup.WatchVariableTableByOldIdentifier.Items[m_OldIdentifier]; if (m_WatchVariable == null) { throw new ArgumentException(Resources.MBTWatchVariableNotDefined); } } catch(Exception) { throw new ArgumentException(Resources.MBTWatchVariableNotDefined); } Debug.Assert(m_WatchVariable.VariableType == VariableType.Bitmask, "FormChangeBitmask.Ctor() - [m_WatchVariable.VariableType == VariableType.Bitmask]"); Text = m_WatchVariable.Name; #region - [Units] - string units = m_WatchVariable.Units; m_LabelCurrentValueUnits.Text = units; m_LabelNewValueUnits.Text = units; #endregion - [Units] - #region - [NumericUpDown] - m_NumericUpDownNewValue.Hexadecimal = m_RadioButtonHex.Checked; m_NumericUpDownNewValue.DecimalPlaces = 0; m_NumericUpDownNewValue.Increment = 1; m_NumericUpDownNewValue.Maximum = (decimal)m_WatchVariable.MaxModifyValue; m_NumericUpDownNewValue.Minimum = (decimal)m_WatchVariable.MinModifyValue; // Initialize the NumericUpDown control Value property. try { m_NumericUpDownNewValue.Value = (decimal)m_WatchControl.Value; } catch (Exception) { // The specified initial value is outside of the limits, set to the minimum value. m_NumericUpDownNewValue.Value = m_NumericUpDownNewValue.Minimum; } #endregion - [NumericUpDown] - #region - [ICheckBoxUInt32] - m_ICheckBoxUInt32 = new CheckBoxUInt32(); CheckBox[] checkBoxes; ConfigureCheckBoxes(out checkBoxes); m_ICheckBoxUInt32.CheckBoxes = checkBoxes; m_ICheckBoxUInt32.SetText(m_OldIdentifier); m_ICheckBoxUInt32.SetChecked((uint)m_WatchControl.Value); #endregion - [ICheckBoxUInt32] - // Update the display by calling the DataUpdate event handler. DataUpdate(this, new EventArgs()); // Now that the display has been initialized, disable the apply button. This will only be re-enabled when the user has specified a new watch value. m_ButtonApply.Enabled = false; }
/// <summary> /// Initialize a new instance of the class. /// </summary> /// <param name="bitmaskControl">The <c>WatchControl</c> derived user control that called this form.</param> public FormChangeBitmask(WatchBitmaskControl bitmaskControl) { InitializeComponent(); m_WatchControl = bitmaskControl; // Use the communication interface associated with the client form. m_ICommunicationInterface = m_WatchControl.ClientForm as ICommunicationInterface <ICommunicationWatch>; Debug.Assert(m_ICommunicationInterface != null); // Register the event handler for the data update event. m_IDataUpdate = m_WatchControl.ClientForm as IDataUpdate; if (m_IDataUpdate != null) { m_IDataUpdate.DataUpdate += new EventHandler(DataUpdate); } m_IPollTarget = m_WatchControl.ClientForm as IPollTarget; Debug.Assert(m_IPollTarget != null); m_OldIdentifier = (short)m_WatchControl.Identifier; try { m_WatchVariable = Lookup.WatchVariableTableByOldIdentifier.Items[m_OldIdentifier]; if (m_WatchVariable == null) { throw new ArgumentException(Resources.MBTWatchVariableNotDefined); } } catch (Exception) { throw new ArgumentException(Resources.MBTWatchVariableNotDefined); } Debug.Assert(m_WatchVariable.VariableType == VariableType.Bitmask, "FormChangeBitmask.Ctor() - [m_WatchVariable.VariableType == VariableType.Bitmask]"); Text = m_WatchVariable.Name; #region - [Units] - string units = m_WatchVariable.Units; m_LabelCurrentValueUnits.Text = units; m_LabelNewValueUnits.Text = units; #endregion - [Units] - #region - [NumericUpDown] - m_NumericUpDownNewValue.Hexadecimal = m_RadioButtonHex.Checked; m_NumericUpDownNewValue.DecimalPlaces = 0; m_NumericUpDownNewValue.Increment = 1; m_NumericUpDownNewValue.Maximum = (decimal)m_WatchVariable.MaxModifyValue; m_NumericUpDownNewValue.Minimum = (decimal)m_WatchVariable.MinModifyValue; // Initialize the NumericUpDown control Value property. try { m_NumericUpDownNewValue.Value = (decimal)m_WatchControl.Value; } catch (Exception) { // The specified initial value is outside of the limits, set to the minimum value. m_NumericUpDownNewValue.Value = m_NumericUpDownNewValue.Minimum; } #endregion - [NumericUpDown] - #region - [ICheckBoxUInt32] - m_ICheckBoxUInt32 = new CheckBoxUInt32(); CheckBox[] checkBoxes; ConfigureCheckBoxes(out checkBoxes); m_ICheckBoxUInt32.CheckBoxes = checkBoxes; m_ICheckBoxUInt32.SetText(m_OldIdentifier); m_ICheckBoxUInt32.SetChecked((uint)m_WatchControl.Value); #endregion - [ICheckBoxUInt32] - // Update the display by calling the DataUpdate event handler. DataUpdate(this, new EventArgs()); // Now that the display has been initialized, disable the apply button. This will only be re-enabled when the user has specified a new watch value. m_ButtonApply.Enabled = false; }