Пример #1
0
        private void importFromXmlToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFile = new OpenFileDialog();

            openFile.Filter = TextFilter;
            if (openFile.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            string ext = Utils.GetExtension(openFile.FileName);

            if (ext == ".xml")
            {
                StreamReader t = new StreamReader(new FileStream(openFile.FileName, FileMode.Open));
                FileFormat.BymlData = XmlByamlConverter.FromXML(t.ReadToEnd());
            }
            else
            {
                StreamReader t = new StreamReader(new FileStream(openFile.FileName, FileMode.Open));
                FileFormat.BymlData = YamlByamlConverter.FromYaml(t.ReadToEnd());
            }
            treeView1.Nodes.Clear();
            ParseBymlFirstNode();
        }
Пример #2
0
 public void ConvertFromString(string text)
 {
     if (TextFileType == TextFileType.Xml)
     {
         BymlData = XmlByamlConverter.FromXML(text);
     }
     else
     {
         BymlData = YamlByamlConverter.FromYaml(text);
     }
 }
Пример #3
0
        private void TextEditorFromYaml(object sender, EventArgs e)
        {
            string editorText = textEditor.GetText();

            if (editorText == string.Empty)
            {
                return;
            }

            try
            {
                if (FileFormat != null)
                {
                    if (IsXML)
                    {
                        FileFormat.BymlData = XmlByamlConverter.FromXML(textEditor.GetText());
                    }
                    else if (IsOldXML)
                    {
                        byte[]       TextData = Encoding.Unicode.GetBytes(textEditor.GetText());
                        StreamReader t        = new StreamReader(new MemoryStream(TextData), Encoding.GetEncoding(932));
                        FileFormat.BymlData = XmlConverter.ToByml(t.ReadToEnd());
                    }
                    else
                    {
                        FileFormat.BymlData = YamlByamlConverter.FromYaml(textEditor.GetText());
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Byaml failed to convert! " + ex.ToString());
                return;
            }

            treeView1.Nodes.Clear();
            ParseBymlFirstNode();

            MessageBox.Show("Byaml converted successfully!");
        }