Ejemplo n.º 1
0
        private void buttonLoadFIle_Click(object sender, EventArgs e)
        {
            if (buttonLoadFIle.Text == "Load File")
            {
                DialogResult result = openFileDialog.ShowDialog();
                fileLoc = openFileDialog.FileName;
                if (result == DialogResult.OK) // Test result.
                {
                    string ext = Path.GetExtension(openFileDialog.FileName);
                    if (ext == ".xml")
                    {
                        labelFile.Text = fileLoc;
                        string xmlRawText = string.Empty;
                        try
                        {
                            try
                            {
                                textBoxSource.Text      = XmlOperation.LoadFileToXML(fileLoc, out newDocument);
                                textBoxSource.ForeColor = Color.Black;
                                buttonLoadFIle.Text     = "UnLoad File";
                                fileLoadStatus          = true;
                            }
                            catch { }
                        }
                        catch
                        {
                            textBoxSource.Text      = xmlRawText;
                            textBoxSource.ForeColor = Color.Red;
                        }
                    }
                    else
                    {
                        UtilityOperations.ShowMessageBox("File Format Not Supported. (I.E. .XML or .TXT)", MessageBoxIcon.Error);
                    }

                    if (ext == ".xml")
                    {
                        textBoxElement.Enabled = true;
                    }
                    else
                    {
                        textBoxElement.Enabled = false;
                    }
                }
            }
            else
            {
                buttonLoadFIle.Text    = "Load File";
                labelFile.Text         = "File Location";
                fileLoadStatus         = false;
                textBoxSource.Text     = "";
                textBoxElement.Enabled = true;
            }
        }
Ejemplo n.º 2
0
        private void buttonGenerate_Click(object sender, EventArgs e)
        {
            propertyList = new List <string>();
            if (comboBoxAM.SelectedIndex == -1 || comboBoxProperty.SelectedIndex == -1 || comboBoxReturn.SelectedIndex == -1 || labelFile.Text == "" || textBoxClass.Text == "" || textBoxElement.Text == "")
            {
                UtilityOperations.ShowMessageBox("Please load a file using load file or fill source text area. Also select \"Access Specifier, Return Type, Property Type, Class Name & Element for Property\" for the same.", MessageBoxIcon.Warning);
            }
            else
            {
                if (fileLoadStatus)
                {
                    try
                    {
                        XmlDocument docIn = new XmlDocument();
                        docIn.Load(fileLoc);

                        XmlNodeList headerNodeList = docIn.SelectSingleNode("/ROOT").ChildNodes;
                        if (headerNodeList != null)
                        {
                            foreach (XmlNode headerAttribute in headerNodeList)
                            {
                                processXMLNodes(headerAttribute);
                            }
                        }
                    }
                    catch { }
                    generateProperty();
                    textBoxDestination.Text = textBoxDestination.Text + "\r\n" + "}";
                }
                else
                {
                    if (string.IsNullOrEmpty(textBoxSource.Text))
                    {
                        UtilityOperations.ShowMessageBox("Please load a file using load file or fill source text area.", MessageBoxIcon.Warning);
                    }
                    else
                    {
                        string[] lines = Regex.Split(textBoxSource.Text, "\r\n");
                        for (int i = 0; i < lines.Length; i++)
                        {
                            propertyList.Add(lines[i].ToString());
                        }

                        generateProperty();
                        textBoxDestination.Text = textBoxDestination.Text + "\r\n" + "}";
                    }
                }
            }
        }