Ejemplo n.º 1
0
        /// <summary>
        /// Initialize a new instance of the form.
        /// </summary>
        /// <param name="variableControl">Reference to the user control that called this form.</param>
        public FormShowFlagsSelfTest(VariableControl variableControl)
        {
            InitializeComponent();

            m_VariableControl = variableControl;

            // Add this form to the list of opened dialog forms associated with the client form.
            m_ClientAsFormPTU = m_VariableControl.ClientForm as FormPTU;
            if (m_ClientAsFormPTU != null)
            {
                m_ClientAsFormPTU.OpenedDialogBoxList.Add(this);
            }

            m_SelfTestVariableIdentifier = (short)m_VariableControl.Identifier;
            m_SelfTestVariableName = m_VariableControl.VariableNameFieldText;

            // Get a list of the current state of each flag and keep a record to determine if there is a change in state.
            List<FlagState_t> flagStateList = Lookup.SelfTestVariableTable.GetFlagStateList(m_SelfTestVariableIdentifier, m_PreviousValue = GetValue());

            m_TableLayoutPanel = ConstructLayoutPanel();
            m_PanelFlagList.Controls.Add(m_TableLayoutPanel);
            ConfigureTableLayoutPanel(m_TableLayoutPanel, flagStateList);

            UpdateTitle(m_SelfTestVariableName, GetValue());
            UpdateFlagStates(m_TableLayoutPanel.Controls, flagStateList);
            CheckHeight();
            PositionTheForm(m_VariableControl);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the form. (1) Positions the form; (2) displays the watch variable and current value; (3) displays the flag state
        /// corresponding to the current value of the watch variable.
        /// </summary>
        /// <param name="bitmaskControl">Reference to the bit mask control that called this form.</param>
        public FormShowFlags(VariableControl bitmaskControl)
        {
            InitializeComponent();

            m_VariableControl = bitmaskControl;

            // Add this form to the list of opened dialog forms associated with the client form.
            m_ClientAsFormPTU = m_VariableControl.ClientForm as FormPTU;
            if (m_ClientAsFormPTU != null)
            {
                m_ClientAsFormPTU.OpenedDialogBoxList.Add(this);
            }

            // Register the event handler for the data update event.
            m_ClientAsIDataUpdate = m_VariableControl.ClientForm as IDataUpdate;
            if (m_ClientAsIDataUpdate != null)
            {
                m_ClientAsIDataUpdate.DataUpdate += new EventHandler(DataUpdate);
            }

            m_OldIdentifier = (short)m_VariableControl.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_VariableControl.VariableNameFieldText;

            // Get a list of the current state of each flag and keep a record to determine if there is a change in state.
            List <FlagState_t> flagStateList = Lookup.WatchVariableTableByOldIdentifier.GetFlagStateList(m_OldIdentifier, m_PreviousValue = GetValue());

            m_TableLayoutPanel = ConstructLayoutPanel();
            m_PanelFlagList.Controls.Add(m_TableLayoutPanel);
            ConfigureTableLayoutPanel(m_TableLayoutPanel, flagStateList);

            UpdateTitle(m_WatchVariableName, GetValue());
            UpdateFlagStates(m_TableLayoutPanel.Controls, flagStateList);
            CheckHeight();
            PositionTheForm(m_VariableControl);
        }
Ejemplo n.º 3
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();
                    }

                    if (m_ClientAsIDataUpdate != null)
                    {
                        // De-register the event handler for the data update event.
                        m_ClientAsIDataUpdate.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_TableLayoutPanel = null;
                m_VariableControl  = null;
                m_ClientAsFormPTU  = 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);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Position the form relative to the position of the bitmask control that called the form.
        /// </summary>
        /// <param name="bitmaskControl">The bitmask user control that alled this form.</param>
        protected void PositionTheForm(VariableControl bitmaskControl)
        {
            // Work out the preferred location where the form is to be positioned, this is to the right of the bit mask control so that it is aligned with the
            // selected control.

            // Get the location of the bitmask control in screen coordinates.
            Point preferredLocation = m_VariableControl.PointToScreen(bitmaskControl.ClientForm.Location);

            // Offset this by the width of the control plus a few minor X and Y adjustments.
            preferredLocation.Offset(new Point(bitmaskControl.Size.Width + AdjustX, AdjustY));

            int xCoordinate = preferredLocation.X;
            int yCoordinate = preferredLocation.Y;
            int formWidth = this.Size.Width;
            int formHeight = this.Size.Height;

            // Ensure that the form remains within the bounds of the screen.
            if ((yCoordinate + formHeight) > Screen.PrimaryScreen.WorkingArea.Height)
            {
                yCoordinate = Screen.PrimaryScreen.WorkingArea.Height - formHeight;
            }

            // Check whether the whole form can still fit on the screen and, if not, flip over to the other side of the control.
            if ((xCoordinate + formWidth) > Screen.PrimaryScreen.WorkingArea.Width)
            {
                // Flip over to the other side of the control.
                xCoordinate -= (formWidth + m_VariableControl.Size.Width + AdjustXFlipForm);
            }

            this.Location = new Point(xCoordinate, yCoordinate);
        }
Ejemplo n.º 5
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();
                    }

                    if (m_ClientAsIDataUpdate != null)
                    {
                        // De-register the event handler for the data update event.
                        m_ClientAsIDataUpdate.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_TableLayoutPanel = null;
                m_VariableControl = null;
                m_ClientAsFormPTU = 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);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Initializes a new instance of the form. (1) Positions the form; (2) displays the watch variable and current value; (3) displays the flag state 
        /// corresponding to the current value of the watch variable.
        /// </summary>
        /// <param name="bitmaskControl">Reference to the bit mask control that called this form.</param>
        public FormShowFlags(VariableControl bitmaskControl)
        {
            InitializeComponent();

            m_VariableControl = bitmaskControl;

            // Add this form to the list of opened dialog forms associated with the client form.
            m_ClientAsFormPTU = m_VariableControl.ClientForm as FormPTU;
            if (m_ClientAsFormPTU != null)
            {
                m_ClientAsFormPTU.OpenedDialogBoxList.Add(this);
            }

            // Register the event handler for the data update event.
            m_ClientAsIDataUpdate = m_VariableControl.ClientForm as IDataUpdate;
            if (m_ClientAsIDataUpdate != null)
            {
                m_ClientAsIDataUpdate.DataUpdate += new EventHandler(DataUpdate);
            }

            m_OldIdentifier = (short)m_VariableControl.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_VariableControl.VariableNameFieldText;
            
            // Get a list of the current state of each flag and keep a record to determine if there is a change in state.
            List<FlagState_t> flagStateList = Lookup.WatchVariableTableByOldIdentifier.GetFlagStateList(m_OldIdentifier, m_PreviousValue = GetValue());

            m_TableLayoutPanel = ConstructLayoutPanel();
            m_PanelFlagList.Controls.Add(m_TableLayoutPanel);
            ConfigureTableLayoutPanel(m_TableLayoutPanel, flagStateList);

            UpdateTitle(m_WatchVariableName, GetValue());
            UpdateFlagStates(m_TableLayoutPanel.Controls, flagStateList);
            CheckHeight();
            PositionTheForm(m_VariableControl);
        }