示例#1
0
        private void menuItem_File_OpenProject_Click(object sender, EventArgs e)
        {
            if (AskSaveSourceCode() == false)
            {
                return;
            }

            openFileDialog1.CheckFileExists = true;
            openFileDialog1.DefaultExt      = "gmacproj";
            openFileDialog1.Filter          = @"GMac Project Files (*.gmacproj)|*.gmacproj";
            openFileDialog1.Multiselect     = false;
            openFileDialog1.SupportMultiDottedExtensions = true;
            openFileDialog1.Title = @"Open GMac Project File";

            if (openFileDialog1.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            InitializeProject(
                GMacProject.CreateFromXmlFile(openFileDialog1.FileName)
                );

            UpdateInterface_SourceFilesList();

            UpdateInterface_EnableControls();
        }
示例#2
0
        private void menuItem_File_NewProject_Click(object sender, EventArgs e)
        {
            if (AskSaveSourceCode() == false)
            {
                return;
            }

            saveFileDialog1.DefaultExt      = "gmacproj";
            saveFileDialog1.Filter          = @"GMac Projects (*.gmacproj)|*.gmacproj";
            saveFileDialog1.OverwritePrompt = true;
            saveFileDialog1.SupportMultiDottedExtensions = true;
            saveFileDialog1.Title = @"New GMac Project File";

            if (saveFileDialog1.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            InitializeProject(
                GMacProject.CreateNew(saveFileDialog1.FileName)
                );

            UpdateInterface_SourceFilesList();

            UpdateInterface_EnableControls();
        }
示例#3
0
        private void InitializeProject(GMacProject gmacDslProject)
        {
            _dslProject  = gmacDslProject;
            _dslCompiler = new GMacProjectCompiler();
            _astRoot     = null;

            ResetCompilationInterface();

            ChangeOpenedSourceFile(null);
        }
示例#4
0
        /// <summary>
        /// This class automatically creates a dsl code file on disk, adds it to a project file,
        /// and compiles the project returning a GMacProjectCompiler object holding all this information.
        /// </summary>
        /// <param name="dslCode"></param>
        /// <param name="mainFolder"></param>
        /// <param name="baseFileName"></param>
        /// <returns></returns>
        public static GMacProjectCompiler CompileDslCode(string dslCode, string mainFolder, string baseFileName)
        {
            var compiler = new GMacProjectCompiler();

            if (compiler.SetProgressRunning() == false)
            {
                return(compiler);
            }

            try
            {
                var projectFilePath = Path.Combine(mainFolder, baseFileName + ".gmacproj");

                var codeFilePath = Path.Combine(mainFolder, baseFileName + ".gmac");

                File.WriteAllText(codeFilePath, dslCode, Encoding.Unicode);

                var project = GMacProject.CreateNew(projectFilePath);

                project.AddSourceFile(codeFilePath, Encoding.Unicode);

                project.SaveProjectToXmlFile();

                compiler.Compile(project);
            }
            catch (Exception e)
            {
                compiler.ReportError(e);
            }
            finally
            {
                compiler.SetProgressNotRunning();
            }

            return(compiler);
        }