Esempio n. 1
0
 private void RefreshPreview()
 {
     if (enablePreviewToolStripMenuItem.Checked)
     {
         try
         {
             string output =
                 new TemplateEngine().ParseFile(
                 Path.Combine(Application.StartupPath, "Templates", "Default.template"),
                     treeView1.Nodes[0].Tag as Menu).TrimStart();
             txtPreview.Text = output;
         }
         catch (Exception ex)
         {
             txtPreview.Text = ex.Message;
         }
     }
 }
Esempio n. 2
0
        private void generateToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (SaveFileDialog sfd = new SaveFileDialog())
            {
                sfd.Filter = "Papyrus script (*.psc)|*.psc";
                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    if (File.Exists(sfd.FileName))
                        File.Delete(sfd.FileName);

                    try
                    {
                        string output =
                        new TemplateEngine().ParseFile(
                        Path.Combine(Application.StartupPath, "Templates", "Default.template"),
                            treeView1.Nodes[0].Tag as Menu).TrimStart();

                        //ScriptTemplate st = new ScriptTemplate
                        //{
                        //    Menu = treeView1.Nodes[0].Tag as Menu
                        //};
                        //File.AppendAllText(sfd.FileName, st.TransformText());
                        File.AppendAllText(sfd.FileName, output);
                    }
                    catch (Exception)
                    {

                        throw;
                    }
                    //using (var fs = File.OpenWrite(sfd.FileName))
                    //{
                    //    MenuWriter sw = new MenuWriter(fs);
                    //    sw.AutoFlush = true;
                    //    sw.Write(treeView1.Nodes[0].Tag as Menu);
                    //}
                }
            }
        }