/// <summary> /// Add the pre-defined test lists defined in the <c>TESTLISTS</c> table of the data dictionary to the specified <c>ComboBox</c> control. /// </summary> /// <param name="comboBox">The <c>ComboBox</c> control that it to be processed.</param> private void ComboBoxAddTestLists(ComboBox comboBox) { // Skip, if the Dispose() method has been called. if (IsDisposed) { return; } Debug.Assert(comboBox != null, "FormTestListDefine.ComboBoxAddTestLists() - [comboBox != null]"); comboBox.Items.Clear(); // Get the pre-configured test lists. TestListRecord testListRecord; for (int testListIndex = 0; testListIndex < Lookup.TestListTable.RecordList.Count; testListIndex++) { if (Lookup.TestListTable.RecordList[testListIndex] != null) { testListRecord = Lookup.TestListTable.RecordList[testListIndex]; comboBox.Items.Add(testListRecord); } } // If the user defined test list record hasn't been defined, create an empty, user defined test list record. if (m_UserDefinedTestListRecord == null) { m_UserDefinedTestListRecord = ConstructEmptyUserDefinedTestListRecord(); } // Add the user defined test list record. comboBox.Items.Add(m_UserDefinedTestListRecord); }
/// <summary> /// Add the self tests defined in the specified test list the specified <c>ListBox</c> control. /// </summary> /// <param name="listBox">The <c>ListBox</c> to which the items are to be added.</param> /// <param name="testListRecord">The test list that is to be added to the <c>ListBox</c> control.</param> private void TestItemAddRange(ListBox listBox, TestListRecord testListRecord) { // Skip, if the Dispose() method has been called. if (IsDisposed) { return; } Cursor = Cursors.WaitCursor; listBox.Items.Clear(); listBox.SuspendLayout(); TestItem_t testItem; short selfTestIdentifier, selfTestNumber; for (int index = 0; index < testListRecord.SelfTestRecordList.Count; index++) { testItem = new TestItem_t(); selfTestIdentifier = testListRecord.SelfTestRecordList[index].Identifier; selfTestNumber = testListRecord.SelfTestRecordList[index].SelfTestNumber; testItem.SelfTestIdentifier = selfTestIdentifier; testItem.SelfTestNumber = selfTestNumber; testItem.Added = true; listBox.Items.Add(testItem); } listBox.PerformLayout(); Cursor = Cursors.Default; }
/// <summary> /// Construct an empty, user defined test list record. /// </summary> /// <returns>An empty user defined test list record.</returns> private TestListRecord ConstructEmptyUserDefinedTestListRecord() { TestListRecord testListRecord; testListRecord = new TestListRecord(); testListRecord.Identifier = short.MaxValue; testListRecord.HelpIndex = CommonConstants.NotDefined; testListRecord.Description = Resources.TextUserDefined; testListRecord.Attribute = 0; testListRecord.SelfTestRecordList = new List<SelfTestRecord>(); return (testListRecord); }
/// <summary> /// Event handler for the <c>DataUpdate</c> event raised by the FormWorksetDefine class. This event is raised if the current test list is modified. /// </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 FormWorksetDefine_DataUpdate(object sender, EventArgs e) { // Skip, if the Dispose() method has been called. if (IsDisposed) { return; } // Check whether the current test list is one of the pre-defined test lists. if (m_TestListRecord.Identifier != short.MaxValue) { // Yes, change the Text property of the ComboBox control to reflect that the user has changed the tests associated with the current pre defined // test list, however, leave the currently defined tests as they are. // Detach and then re-attach the 'SelectedIndexChanged' event handler to ensure that the event handler is not called when the Text property is modified. m_ComboBoxTestList.SelectedIndexChanged -= new System.EventHandler(m_ComboBoxTestList_SelectedIndexChanged); m_ComboBoxTestList.Text = m_UserDefinedTestListRecord.Description; m_ComboBoxTestList.SelectedIndexChanged += new System.EventHandler(m_ComboBoxTestList_SelectedIndexChanged); // Copy the fields of the user defined TestListRecord to the active test list record. m_TestListRecord = m_UserDefinedTestListRecord; // Display the name of the test list in the TabPage header. m_TabPageColumn1.Text = m_UserDefinedTestListRecord.Description; } // Keep the SelfTestRecordList properties of the TestListRecords up to date. m_UserDefinedTestListRecord.SelfTestRecordList = ConvertToSelfTestRecordList(m_ListBox1); m_TestListRecord.SelfTestRecordList = ConvertToSelfTestRecordList(m_ListBox1); WinHlp32.HideHelpWindow(Handle.ToInt32()); }
/// <summary> /// Event handler for the <c>SelectedIndexChanged</c> event associated with the <c>ComboBox</c> control used to select one of the pre-defined test lists. /// </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_ComboBoxTestList_SelectedIndexChanged(object sender, EventArgs e) { // Skip, if the Dispose() method has been called. if (IsDisposed) { return; } Cursor = Cursors.WaitCursor; TestListRecord testListRecord = (TestListRecord)m_ComboBoxTestList.SelectedItem; m_TestListRecord = testListRecord; // Display the name of the selected test list in the TabPage header. m_TabPageColumn1.Text = m_TestListRecord.Description; LoadTestList(m_TestListRecord); // If the help window is open then hide it. WinHlp32.HideHelpWindow(Handle.ToInt32()); Cursor = Cursors.Default; }
/// <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 { // Close the help window if one is open. WinHlp32.HideHelpWindow(Handle.ToInt32()); if (disposing) { // Cleanup managed objects by calling their Dispose() methods. if (components != null) { components.Dispose(); } // Detach the event handlers. TabPage tabPage; ListBox listBox; for (int tabPageIndex = 0; tabPageIndex < m_TabControlAvailable.TabPages.Count; tabPageIndex++) { tabPage = m_TabControlAvailable.TabPages[tabPageIndex]; listBox = (ListBox)tabPage.Controls[KeyListBoxAvailable + tabPage.Tag.ToString()]; listBox.SelectedIndexChanged -= new EventHandler(this.ListBoxAvailable_SelectedIndexChanged); listBox.DoubleClick -= new System.EventHandler(this.m_ButtonAdd_Click); listBox.MouseDown -= new System.Windows.Forms.MouseEventHandler(this.m_ListBoxSource_MouseDown); listBox.MouseMove -= new System.Windows.Forms.MouseEventHandler(this.m_ListBoxSource_MouseMove); listBox.MouseUp -= new System.Windows.Forms.MouseEventHandler(this.m_ListBoxSource_MouseUp); listBox.Items.Clear(); } m_TabControlAvailable.TabPages.Clear(); // De-register the event handler for the DataUpdate event. DataUpdate -= new EventHandler(FormWorksetDefine_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_TestItems = null; m_TestListRecord = null; m_UserDefinedTestListRecord = 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 an new instance of the form. /// </summary> /// <param name="testListRecord">Reference to the currently selected test list record.</param> public FormTestListDefine(TestListRecord testListRecord) { InitializeComponent(); // Move the position of the OK and Cancel buttons as the Apply button is not required. m_ButtonOK.Location = m_ButtonCancel.Location; m_ButtonCancel.Location = m_ButtonApply.Location; // Only one column is required for this form so delete the tab pages associated with columns 2 and 3. m_TabControlColumn.TabPages.Remove(m_TabPageColumn2); m_TabControlColumn.TabPages.Remove(m_TabPageColumn3); m_TextBoxName.Visible = false; // Register the event handler for the DataUpdate event. This is raised whenever the current list of tests is modified. DataUpdate += new EventHandler(FormWorksetDefine_DataUpdate); m_TestListRecord = testListRecord; // Check whether the specified test list record was the user defined test list record and, if so, update the user defined test list record. if (m_TestListRecord.Identifier == short.MaxValue) { m_UserDefinedTestListRecord = ConstructEmptyUserDefinedTestListRecord(); m_UserDefinedTestListRecord.SelfTestRecordList = m_TestListRecord.SelfTestRecordList; } ComboBoxAddTestLists(m_ComboBoxTestList); // Display the name of the selected test list record in the TabPage header. m_TabPageColumn1.Text = m_TestListRecord.Description; // Display the name of the current test list record on the ComboBox control. // Ensure that the SelectionChanged event is not triggered as a result of specifying the Text property of the ComboBox control. m_ComboBoxTestList.SelectedIndexChanged -= new EventHandler(m_ComboBoxTestList_SelectedIndexChanged); m_ComboBoxTestList.Text = m_TestListRecord.Description; m_ComboBoxTestList.SelectedIndexChanged += new EventHandler(m_ComboBoxTestList_SelectedIndexChanged); m_TestItems = ConstructTestItemArray(); UpdateListBoxAvailable(); TabPage selectedTabPage = m_TabControlAvailable.TabPages[0]; m_ListBoxAvailable = (ListBox)selectedTabPage.Controls[KeyListBoxAvailable + selectedTabPage.Tag.ToString()]; m_ListBoxSelected = m_ListBox1; LoadTestList(m_TestListRecord); }
/// <summary> /// Load the specified test list into the <c>ListBox</c> control used to display the selected self tests. /// </summary> /// <param name="testListRecord">The test list that is to be loaded.</param> private void LoadTestList(TestListRecord testListRecord) { // Skip, if the Dispose() method has been called. if (IsDisposed) { return; } m_ListItemCount = testListRecord.SelfTestRecordList.Count; m_TestItems = ConstructTestItemArray(); SelfTestRecord selfTestRecord; for (int testIndex = 0; testIndex < m_ListItemCount; testIndex++) { selfTestRecord = testListRecord.SelfTestRecordList[testIndex]; m_TestItems[selfTestRecord.Identifier].Added = true; } TestItemAddRange(m_ListBox1, testListRecord); UpdateCount(); }