Example #1
0
        private void ConvertTemplates()
        {
            if (IsFormValid)
            {
                Cursor.Current = Cursors.WaitCursor;

                string        filename, tmp;
                List <string> templates = new List <string>();
                foreach (string file in this.checkedListBoxTemplates.CheckedItems)
                {
                    StreamWriter writer = null;
                    try
                    {
                        CstParser      parser   = new CstParser(this);
                        CstTemplate    template = parser.Parse(this.textBoxCSTFile.Text + "\\" + file);
                        LanguageHelper h        = LanguageHelper.CreateInstance(template.Language);

                        tmp      = h.BuildTemplate(template, this);
                        filename = this.textBoxOutFolder.Text + "\\" + file.Substring(0, file.LastIndexOf(".")) + ".zeus";

                        writer = File.CreateText(filename);
                        writer.Write(tmp);
                        writer.Flush();
                        writer.Close();
                        writer = null;

                        templates.Add(filename);
                    }
                    catch (Exception ex)
                    {
                        if (writer != null)
                        {
                            writer.Close();
                            writer = null;
                        }
                        this.AddEntry(ex);
                    }
                }

                if (templates.Count > 0)
                {
                    string fileList = string.Empty;
                    foreach (string fname in templates)
                    {
                        if (fileList.Length > 0)
                        {
                            fileList += " ";
                        }

                        fileList += "\"" + fname + "\"";
                    }

                    if (this.checkBoxLaunch.Checked)
                    {
                        try
                        {
                            this.mdi.OpenDocuments(templates.ToArray());

                            /*FileInfo finfo = new FileInfo(textBoxMyGenAppPath.Text);
                             * ProcessStartInfo info = new ProcessStartInfo(finfo.FullName, fileList);
                             * info.WorkingDirectory = finfo.DirectoryName;
                             * System.Diagnostics.Process.Start(info);*/
                        }
                        catch {}
                    }
                }

                Cursor.Current = Cursors.Default;
            }
        }