コード例 #1
0
        /// <summary>
        /// Handles the event raised when a recent file menu option is clicked
        /// </summary>
        /// <param name="sender">Object raising the event</param>
        /// <param name="e">Event-specific parameters</param>
        private void recentFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem menuItem = sender as ToolStripMenuItem;

            if (menuItem != null)
            {
                FileHistoryItem item = menuItem.Tag as FileHistoryItem;
                if (item != null)
                {
                    // Check if the item exists
                    if (!FileHelper.Instance.FileExists(item.FilePath))
                    {
                        MessageBox.Show(this, string.Format("The file {0} does not exist", item.FilePath), "File does not exist", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        // Remove the file from the list
                        ConfigPersistenceHelper.Instance.Settings.XmlFiles.Remove(item);
                        // Rebuild the menu
                        PopulateRecentlyUsedXmlFileList();
                    }
                    else
                    {
                        OpenFile(item.FilePath);
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Handles the event raised when the Validate button is clicked
        /// </summary>
        /// <param name="sender">Object raising the event</param>
        /// <param name="e">Event-specific parameters</param>
        private void btnValidate_Click(object sender, EventArgs e)
        {
            FileHistoryItem item    = cboXsdFile.SelectedItem as FileHistoryItem;
            string          xsdPath = cboXsdFile.Text;

            if (item != null)
            {
                xsdPath = item.FilePath;
            }

            // Check that the file exists
            if (!FileHelper.Instance.FileExists(xsdPath))
            {
                MessageBox.Show(this, string.Format("The file '{0}' does not exist, or the path is invalid", xsdPath), "File does not exist", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            ConfigPersistenceHelper.Instance.Settings.XsdFiles.AddItem(xsdPath);
            txtValidationEvents.Clear();
            XsdValidationResult result = XsdValidationHelper.Instance.ValidateInstance(xsdPath, _doc);

            txtValidationEvents.Text = result.Results.ToString();
            switch (result.State)
            {
            case ValidationState.Success:
            {
                txtValidationEvents.ForeColor = Color.Black;
                break;
            }

            case ValidationState.OtherError:
            {
                txtValidationEvents.ForeColor = Color.Red;
                break;
            }

            case ValidationState.ValidationError:
            {
                txtValidationEvents.ForeColor = Color.Green;
                break;
            }

            case ValidationState.Warning:
            {
                txtValidationEvents.ForeColor = Color.Brown;
                break;
            }
            }

            // Refresh the combo box
            string currentPath = cboXsdFile.Text;

            LoadXSDComboBox();
            cboXsdFile.Text = currentPath;
        }
コード例 #3
0
        /// <summary>
        /// Handles the event raised when the GenerateBizUnitTestCase menu item is clicked
        /// </summary>
        /// <param name="sender">Object raising the event</param>
        /// <param name="e">Event-specific parameters</param>
        private void generateBizUnitTestCaseToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FileHistoryItem item    = cboXsdFile.SelectedItem as FileHistoryItem;
            string          xsdPath = cboXsdFile.Text;

            if (item != null)
            {
                xsdPath = item.FilePath;
            }
            new BizUnitTestCase().ShowDialog(_rootNode, _currentFileName, xsdPath);
        }
コード例 #4
0
        /// <summary>
        /// Handles the event raised when the SelectXSD button is clicked
        /// </summary>
        /// <param name="sender">Object raising the event</param>
        /// <param name="e">Event-specific parameters</param>
        private void btnSelectXSD_Click(object sender, EventArgs e)
        {
            dlgOpenFile.Filter = "Xsd Files (*.xsd)|*.xsd";
            dlgOpenFile.Title  = "Select an Xsd File to open";
            if ((string.IsNullOrEmpty(cboXsdFile.Text)) || (!FileHelper.Instance.FileExists(cboXsdFile.Text)))
            {
                dlgOpenFile.FileName = null;
            }
            else
            {
                dlgOpenFile.FileName = cboXsdFile.Text;
            }

            if (dlgOpenFile.ShowDialog() == DialogResult.OK)
            {
                if (string.Compare(cboXsdFile.Text, dlgOpenFile.FileName, true) != 0)
                {
                    FileHistoryItem item = new FileHistoryItem(dlgOpenFile.FileName);
                    cboXsdFile.Items.Add(item);
                    cboXsdFile.SelectedItem = item;
                }
            }
        }