コード例 #1
0
        /// <summary>
        /// Event handled for the 'Stream Triggered' context menu. Toggle the state of the StreamTriggered property of the event flag associated with the selected record.
        /// </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 m_MenuItemStreamTriggered_Click(object sender, EventArgs e)
        {
            // Skip, if the Dispose() method has been called.
            if (IsDisposed)
            {
                return;
            }

            Cursor = Cursors.WaitCursor;

            EventStatus_t   eventStatus;
            DataGridViewRow dataGridViewRow;

            if (GetEventStatusElement(out eventStatus, out dataGridViewRow) == true)
            {
                // Toggle the state of the StreamTriggered property of the event flag.
                eventStatus.StreamTriggered = !eventStatus.StreamTriggered;
                eventStatus.Modified        = true;

                // Get the index of the matched event flag in the list and replace the entry with the modified value.
                int index = eventStatus.Index;
                EventStatusList.RemoveAt(index);
                EventStatusList.Insert(index, eventStatus);

                // Update the 'Stream Triggered' column of the DataGridView control.
                if (eventStatus.StreamTriggered == true)
                {
                    dataGridViewRow.Cells[ColumnIndexStreamTriggered].Value = (object)m_TextTrue;
                }
                else
                {
                    dataGridViewRow.Cells[ColumnIndexStreamTriggered].Value = (object)m_TextFalse;
                }
            }

            Cursor = Cursors.Default;
        }
コード例 #2
0
        /// <summary>
        /// Event handler for the OK button <c>Click</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>
        protected void m_ButtonOK_Click(object sender, EventArgs e)
        {
            // Skip, if the Dispose() method has been called.
            if (IsDisposed)
            {
                return;
            }

            Cursor = Cursors.WaitCursor;

            List <EventStatus_t> modifiedEventFlagList = new List <EventStatus_t>();

            // Check which of the event status structure elements have been modified.
            modifiedEventFlagList = EventStatusList.FindAll(delegate(EventStatus_t eventStatus)
            {
                return(eventStatus.Modified == true);
            });

            if (modifiedEventFlagList.Count >= 1)
            {
                DialogResult dialogResult = MessageBox.Show(Resources.MBTEventFlagsChanged, Resources.MBCaptionInformation, MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                Update();
                if (dialogResult == DialogResult.Yes)
                {
                    // Update the VCU with the latest modifications.
                    for (int index = 0; index < modifiedEventFlagList.Count; index++)
                    {
                        EventRecord eventRecord;
                        try
                        {
                            eventRecord = Lookup.EventTable.RecordList[modifiedEventFlagList[index].Identifier];
                            if (eventRecord == null)
                            {
                                continue;
                            }
                        }
                        catch (Exception)
                        {
                            continue;
                        }

                        // Update the VCU.
                        short enabledFlag;
                        if (modifiedEventFlagList[index].Enabled == true)
                        {
                            enabledFlag = CommonConstants.True;
                        }
                        else
                        {
                            enabledFlag = 0;
                        }

                        short streamTriggeredFlag;
                        if (modifiedEventFlagList[index].StreamTriggered == true)
                        {
                            streamTriggeredFlag = CommonConstants.True;
                        }
                        else
                        {
                            streamTriggeredFlag = 0;
                        }

                        try
                        {
                            CommunicationInterface.SetFaultFlags((short)eventRecord.TaskIdentifier, (short)eventRecord.EventIdentifier, enabledFlag, streamTriggeredFlag);
                        }
                        catch (Exception)
                        {
                            MessageBox.Show(string.Format(Resources.MBTSetFaultFlagsFailed, eventRecord.Description), Resources.MBCaptionWarning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                }
            }

            Cursor = Cursors.Default;
        }