Пример #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
        private void exportJsonToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog sav = new SaveFileDialog()
            {
                Filter = TextFilter
            };

            sav.FileName   = Path.GetFileNameWithoutExtension(FileName);
            sav.DefaultExt = ".yaml";
            if (sav.ShowDialog() != DialogResult.OK)
            {
                return;
            }

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

            if (ext == ".xml")
            {
                File.WriteAllText(sav.FileName, XmlByamlConverter.ToXML(FileFormat.BymlData));
            }
            else
            {
                File.WriteAllText(sav.FileName, YamlByamlConverter.ToYaml(FileFormat.BymlData));
            }

            MessageBox.Show("Byaml converted successfully!");
        }
Пример #3
0
 public void ConvertFromString(string text)
 {
     if (TextFileType == TextFileType.Xml)
     {
         BymlData = XmlByamlConverter.FromXML(text);
     }
     else
     {
         BymlData = YamlByamlConverter.FromYaml(text);
     }
 }
Пример #4
0
 public string ConvertToString()
 {
     if (TextFileType == TextFileType.Xml)
     {
         return(XmlByamlConverter.ToXML(BymlData));
     }
     else
     {
         return(YamlByamlConverter.ToYaml(BymlData));
     }
 }
Пример #5
0
        private void UpdateTextEditor()
        {
            textEditor.IsXML  = false;
            textEditor.IsYAML = false;

            if (IsXML)
            {
                textEditor.FillEditor(XmlByamlConverter.ToXML(FileFormat.BymlData));
                textEditor.IsXML = true;
            }
            else if (IsOldXML)
            {
                textEditor.FillEditor(XmlConverter.ToXml(FileFormat.BymlData));
                textEditor.IsXML = true;
            }
            else
            {
                textEditor.FillEditor(YamlByamlConverter.ToYaml(FileFormat.BymlData));
                textEditor.IsYAML = true;
            }
        }
Пример #6
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!");
        }