/// <summary> /// Initialize a new instance of the class. /// </summary> /// <param name="watchControl">The watch control derived user control that called this form.</param> /// <exception cref="Exception">Thrown if the old Identifier associated with the control that called this form is not defined in the current data dictionary.</exception> public FormChangeWatch(WatchControl watchControl) { InitializeComponent(); m_WatchControl = watchControl; // 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); } m_WatchVariableName = m_WatchControl.VariableNameFieldText; Text = m_WatchVariableName; #region - [Units] - string units = m_WatchVariable.Units; m_LabelCurrentValueUnits.Text = units; m_LabelAllowableRangeUnits.Text = units; m_LabelNewValueUnits.Text = units; #endregion - [Units] - // Update the display by calling the DataUpdate event handler. DataUpdate(this, new EventArgs()); }
/// <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="watchControl">The watch control derived user control that called this form.</param> /// <exception cref="Exception">Thrown if the old Identifier associated with the control that called this form is not defined in the current data dictionary.</exception> public FormChangeWatch(WatchControl watchControl) { InitializeComponent(); m_WatchControl = watchControl; // 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); } m_WatchVariableName = m_WatchControl.VariableNameFieldText; Text = m_WatchVariableName; #region - [Units] - string units = m_WatchVariable.Units; m_LabelCurrentValueUnits.Text = units; m_LabelAllowableRangeUnits.Text = units; m_LabelNewValueUnits.Text = units; #endregion - [Units] - // Update the display by calling the DataUpdate event handler. DataUpdate(this, new EventArgs()); }
/// <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; }