/// The user may now browse to the specification and pick a clause for annotation private void btnAddAnnotation_Click(object sender, EventArgs e) { // Create an Annotation Manager object NBSAnnotationManager.AnnotationManager objAnnMan = new NBSAnnotationManager.AnnotationManager(); // Create an Annotation object for returned annotation NBSAnnotationManager.Annotation objAnnotation = default(NBSAnnotationManager.Annotation); // Get the currently selected annotation NBSAnnotationManager.Annotation objSelectedAnnotation = ReturnSelectedAnnotation(); // Show the Annotation Picker and wait until a valid annotation is returned objAnnotation = objAnnMan.SelectAnnotation(m_strSpecificationFilePath, objSelectedAnnotation); if (objAnnotation != null) { // Add annotation to list view AddAnnotationToListView(objAnnotation); } }
/// The model must be associated with a single specification, set of prelims /// or schedule of work /// The AnnotationManager object may be declared as a member variable and reused, but /// for simplicity it is used "as new" in each of the following methods. private void btnBrowseToSpecification_Click(object sender, EventArgs e) { // Create an Annotation Manager object NBSAnnotationManager.AnnotationManager objAnnMan = new NBSAnnotationManager.AnnotationManager(); // Browse to a valid NBS document string strSpecificationFilePath = objAnnMan.SelectSpecification(); if (!string.IsNullOrEmpty(strSpecificationFilePath)) { // Set the label in the UI lblSpecification.Text = strSpecificationFilePath; // Store this as a member variable m_strSpecificationFilePath = strSpecificationFilePath; // Enable further actions EnableButtons(true); // Now the specification is set, disable this button btnBrowseToSpecification.Enabled = false; } else { // no valid specification has been set EnableButtons(false); } }
// Generate validity report based on annotations object or xml file /// Show report showing the status of the annotations against the latest /// version of the project spec /// Please note, that to test this properly you should exclude and modify /// some clauses private void btnShowReport_Click(object sender, EventArgs e) { // There are two ways of doing this // and the method is overloaded // 1. Pass the annotation info as a collection of Annotations NBSAnnotationManager.AnnotationManager objAnnMan = new NBSAnnotationManager.AnnotationManager(); NBSAnnotationManager.Annotations objAnnotations = default(NBSAnnotationManager.Annotations); // Internal method that loops through the list view objAnnotations = ReturnAnnotationsFromListView(); // 2. Pass the annotation info in an XML format that verifies // against the schema // Test for XML version // objAnnMan.DisplayReport(m_strSpecificationFilePath, "c:\\doesnt really matter\\model.mdl", "C:\\NBS Documents\\destination specification.spec.nbsrpt"); objAnnMan.DisplayReport(m_strSpecificationFilePath, "c:\\doesnt really matter\\model.mdl", objAnnotations); }
// View the manufacture information of the selected annotation. If no annotation object is passed, show manufacture homepage. private void btnViewManufacturerInfo_Click(object sender, EventArgs e) { // Create an Annotation Manager object NBSAnnotationManager.Annotation objAnnotation = default(NBSAnnotationManager.Annotation); objAnnotation = ReturnSelectedAnnotation(); if (objAnnotation != null) { // If a valid item in the list view is selected then // we ask the Annotation Manager to display this in the relevant NBS Product NBSAnnotationManager.AnnotationManager objAnnMan = new NBSAnnotationManager.AnnotationManager(); objAnnMan.ShowManufacturersInfo(m_strSpecificationFilePath, objAnnotation); } }
// Returns latest NBS information to compare against annotations in the model. private void btnShowAnnotationInfo_Click(object sender, EventArgs e) { // Create an Annotation Manager object NBSAnnotationManager.AnnotationManager objAnnotationManager = new NBSAnnotationManager.AnnotationManager(); NBSAnnotationManager.Annotations objAnnotations = default(NBSAnnotationManager.Annotations); objAnnotations = ReturnAnnotationsFromListView(); objAnnotationManager.UpdateAnnotations(m_strSpecificationFilePath, ref objAnnotations); string strLatestTitles = ""; strLatestTitles = "Latest titles from specification below." + "\r" + "\r" + "The calling program should check these against what is in the model" + "\r" + "if they have been modified in the spec: " + "\r" + "\r"; NBSAnnotationManager.Annotation objAnn = default(NBSAnnotationManager.Annotation); int n = 0; for (n = 0; n <= objAnnotations.Count - 1; n++) { objAnn = objAnnotations.get_Item(n); strLatestTitles = strLatestTitles + objAnn.DisplayTitle + "\r"; } MessageBox.Show(strLatestTitles); }