예제 #1
0
        private void Save_Click(object sender, EventArgs e)
        {
            XmlDocument xmlDoc = new XmlDocument();
            int         index, index2;

            try
            {
                XmlDocument doc     = new XmlDocument();
                XmlNode     docNode = doc.CreateXmlDeclaration("1.0", "UTF-8", null);
                doc.AppendChild(docNode);

                XmlNode CommandsRoot;
                XmlNode CommandNode;
                XmlNode CommandInfoNode;

                CommandsRoot = doc.CreateElement(PluginName.Text);
                XmlAttribute CommandsSerial = doc.CreateAttribute("SerialNumber");
                CommandsSerial.Value = PluginID.Text;
                CommandsRoot.Attributes.Append(CommandsSerial);
                doc.AppendChild(CommandsRoot);


                for (index = 0; index < PluginRequestDataCounter; index++)
                {
                    CommandNode = doc.CreateElement("PluginCommandInformation");
                    CommandsRoot.AppendChild(CommandNode);

                    CommandInfoNode = doc.CreateElement("CommandNumber");
                    CommandInfoNode.AppendChild(doc.CreateTextNode(PluginRequestData[index].CommandNumber));
                    CommandNode.AppendChild(CommandInfoNode);

                    CommandInfoNode = doc.CreateElement("CommandName");
                    CommandInfoNode.AppendChild(doc.CreateTextNode(PluginRequestData[index].CommandName));
                    CommandNode.AppendChild(CommandInfoNode);

                    CommandInfoNode = doc.CreateElement("CommandComment");
                    CommandInfoNode.AppendChild(doc.CreateTextNode(PluginRequestData[index].Comments));
                    CommandNode.AppendChild(CommandInfoNode);


                    for (index2 = 0; index2 < 15; index2++)
                    {
                        switch (index2)
                        {
                        case 0:
                            if (!string.IsNullOrEmpty(PluginRequestData[index].s1))
                            {
                                CommandInfoNode = doc.CreateElement("String-S1");
                                CommandInfoNode.AppendChild(doc.CreateTextNode(PluginRequestData[index].s1));
                                CommandNode.AppendChild(CommandInfoNode);
                            }
                            break;

                        case 1:
                            if (!string.IsNullOrEmpty(PluginRequestData[index].s2))
                            {
                                CommandInfoNode = doc.CreateElement("String-S2");
                                CommandInfoNode.AppendChild(doc.CreateTextNode(PluginRequestData[index].s2));
                                CommandNode.AppendChild(CommandInfoNode);
                            }
                            break;

                        case 2:
                            if (!string.IsNullOrEmpty(PluginRequestData[index].b1))
                            {
                                CommandInfoNode = doc.CreateElement("Bool-B1");
                                CommandInfoNode.AppendChild(doc.CreateTextNode(PluginRequestData[index].b1));
                                CommandNode.AppendChild(CommandInfoNode);
                            }
                            break;

                        case 3:
                            if (!string.IsNullOrEmpty(PluginRequestData[index].b2))
                            {
                                CommandInfoNode = doc.CreateElement("Bool-B2");
                                CommandInfoNode.AppendChild(doc.CreateTextNode(PluginRequestData[index].b2));
                                CommandNode.AppendChild(CommandInfoNode);
                            }
                            break;

                        case 4:
                            if (!string.IsNullOrEmpty(PluginRequestData[index].i1))
                            {
                                CommandInfoNode = doc.CreateElement("Integer-I1");
                                CommandInfoNode.AppendChild(doc.CreateTextNode(PluginRequestData[index].i1));
                                CommandNode.AppendChild(CommandInfoNode);
                            }
                            break;

                        case 5:
                            if (!string.IsNullOrEmpty(PluginRequestData[index].i2))
                            {
                                CommandInfoNode = doc.CreateElement("Integer-I2");
                                CommandInfoNode.AppendChild(doc.CreateTextNode(PluginRequestData[index].i2));
                                CommandNode.AppendChild(CommandInfoNode);
                            }
                            break;

                        case 6:
                            if (!string.IsNullOrEmpty(PluginRequestData[index].d1))
                            {
                                CommandInfoNode = doc.CreateElement("Double-D1");
                                CommandInfoNode.AppendChild(doc.CreateTextNode(PluginRequestData[index].d1));
                                CommandNode.AppendChild(CommandInfoNode);
                            }
                            break;

                        case 7:
                            if (!string.IsNullOrEmpty(PluginRequestData[index].d2))
                            {
                                CommandInfoNode = doc.CreateElement("Double-D2");
                                CommandInfoNode.AppendChild(doc.CreateTextNode(PluginRequestData[index].d2));
                                CommandNode.AppendChild(CommandInfoNode);
                            }
                            break;

                        case 8:
                            if (!string.IsNullOrEmpty(PluginRequestData[index].c1))
                            {
                                CommandInfoNode = doc.CreateElement("Characters-C1");
                                CommandInfoNode.AppendChild(doc.CreateTextNode(PluginRequestData[index].c1));
                                CommandNode.AppendChild(CommandInfoNode);
                            }
                            break;

                        case 9:
                            if (!string.IsNullOrEmpty(PluginRequestData[index].c2))
                            {
                                CommandInfoNode = doc.CreateElement("Characters-C2");
                                CommandInfoNode.AppendChild(doc.CreateTextNode(PluginRequestData[index].c2));
                                CommandNode.AppendChild(CommandInfoNode);
                            }
                            break;

                        case 10:
                            if (!string.IsNullOrEmpty(PluginRequestData[index].c3))
                            {
                                CommandInfoNode = doc.CreateElement("Characters-C3");
                                CommandInfoNode.AppendChild(doc.CreateTextNode(PluginRequestData[index].c3));
                                CommandNode.AppendChild(CommandInfoNode);
                            }
                            break;

                        case 11:
                            if (!string.IsNullOrEmpty(PluginRequestData[index].c4))
                            {
                                CommandInfoNode = doc.CreateElement("Characters-C4");
                                CommandInfoNode.AppendChild(doc.CreateTextNode(PluginRequestData[index].c4));
                                CommandNode.AppendChild(CommandInfoNode);
                            }
                            break;

                        case 12:
                            if (!string.IsNullOrEmpty(PluginRequestData[index].Strings))
                            {
                                CommandInfoNode = doc.CreateElement("StringArray");
                                CommandInfoNode.AppendChild(doc.CreateTextNode(PluginRequestData[index].Strings));
                                CommandNode.AppendChild(CommandInfoNode);
                            }
                            break;

                        case 13:
                            if (!string.IsNullOrEmpty(PluginRequestData[index].Integers))
                            {
                                CommandInfoNode = doc.CreateElement("IntegerArray");
                                CommandInfoNode.AppendChild(doc.CreateTextNode(PluginRequestData[index].Integers));
                                CommandNode.AppendChild(CommandInfoNode);
                            }
                            break;

                        case 14:
                            if (!string.IsNullOrEmpty(PluginRequestData[index].OBJ))
                            {
                                CommandInfoNode = doc.CreateElement("Object");
                                CommandInfoNode.AppendChild(doc.CreateTextNode(PluginRequestData[index].OBJ));
                                CommandNode.AppendChild(CommandInfoNode);
                            }
                            break;
                        }
                    }
                }
                doc.Save(Path.ChangeExtension(FileToUse, "tmp"));
                try
                {
                    File.Delete(Path.ChangeExtension(FileToUse, "bak"));
                    if (File.Exists(FileToUse))
                    {
                        File.Move(FileToUse, Path.ChangeExtension(FileToUse, "bak"));
                    }
                    File.Move(Path.ChangeExtension(FileToUse, "tmp"), FileToUse);
                }
                catch
                {
                }
                MessageBox.Show(PluginName.Text + " - " + PluginID.Text, "Documentation File Updated", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Save.Enabled = false;
                Close();
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message, "Error Updating Plugin Documentation", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #2
0
        private void Save_Click(object sender, EventArgs e)
        {
            XmlDocument  xmlDoc = new XmlDocument();
            int          index, index2;
            ComboboxItem item = new ComboboxItem();

            try
            {
                XmlDocument doc     = new XmlDocument();
                XmlNode     docNode = doc.CreateXmlDeclaration("1.0", "UTF-8", null);
                doc.AppendChild(docNode);

                XmlNode      CommandsRoot;
                XmlNode      CommandNode;
                XmlNode      CommandInfoNode;
                XmlAttribute CommandAttribute;

                CommandsRoot = doc.CreateElement(DatabaseName.Text);
                doc.AppendChild(CommandsRoot);

                for (index = 0; index < Fields.Items.Count; index++)
                {
                    item        = (ComboboxItem)Fields.Items[index];
                    CommandNode = doc.CreateElement(item.Text);
                    CommandsRoot.AppendChild(CommandNode);

                    for (index2 = 0; index2 < Dimensioned; index2 = index2 + 2)
                    {
                        if (!string.IsNullOrEmpty(StoredStuff[(int)item.Value, index2]))
                        {
                            CommandInfoNode        = doc.CreateElement("Identifer");
                            CommandAttribute       = doc.CreateAttribute("Code");
                            CommandAttribute.Value = StoredStuff[(int)item.Value, index2];
                            CommandInfoNode.Attributes.Append(CommandAttribute);

                            CommandInfoNode.AppendChild(doc.CreateTextNode(StoredStuff[(int)item.Value, index2 + 1]));
                            CommandNode.AppendChild(CommandInfoNode);
                        }
                    }
                }

                doc.Save(Path.ChangeExtension(FileToUse, "tmp"));
                try
                {
                    File.Delete(Path.ChangeExtension(FileToUse, "bak"));
                    if (File.Exists(FileToUse))
                    {
                        File.Move(FileToUse, Path.ChangeExtension(FileToUse, "bak"));
                    }
                    File.Move(Path.ChangeExtension(FileToUse, "tmp"), FileToUse);
                }
                catch
                {
                }
                MessageBox.Show(DatabaseName.Text, "Database Field Documentation File Updated", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Save.Enabled = false;
                Close();
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message, "Error Updating Plugin Documentation", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }