Пример #1
0
 internal void Compilation(string fileName)
 {
     o2Mate.Compilateur comp = new o2Mate.Compilateur();
     comp.LoadTemplates(Documents.TemplatesDirectory);
     comp.LoadSkeletons(Documents.SkeletonsDirectory);
     o2Mate.Dictionnaire dict = comp.OutputDictionary(fileName);
     dict.Save(Documents.TempDictFile);
     // le fichier de sortie n'est pas important
     comp.Debug(Documents.TempDictFile, Documents.UnusedFile, null);
     o2Mate.Compilateur compProject = new o2Mate.Compilateur();
     compProject.LoadTemplates(Documents.TemplatesDirectory);
     o2Mate.Dictionnaire dictProject = comp.Threads.Dictionary;
     dictProject.Save(Documents.TempDictFile);
     compProject.Compilation(Documents.ProjectSourceCode, Documents.TempDictFile, Documents.ProjectPage, null);
 }
Пример #2
0
        void VBScript_Click(object sender, HtmlElementEventArgs e)
        {
            FileInfo fi           = new FileInfo(this.fileNameSrc);
            string   fileNameDict = Path.Combine(Documents.TempDirectory, Path.GetFileNameWithoutExtension(fi.Name) + ".xml");

            this.outputDict.Save(fileNameDict);
            o2Mate.Compilateur comp            = new o2Mate.Compilateur();
            string             outputFinalFile = Documents.BuildDirectory + Path.GetFileNameWithoutExtension(fi.Name) + ".vbs";

            try
            {
                comp.UnderConversion   = true;
                comp.ConvertedLanguage = new Converters.VBScriptConverter();
                comp.LoadTemplates(Documents.TemplatesDirectory);
                comp.LoadSkeletons(Documents.SkeletonsDirectory);
                comp.Convert(comp.ConvertedLanguage, this.fileNameSrc, fileNameDict, outputFinalFile);

                Process proc = new Process();
                if (global::CodeCommander.Properties.Settings.Default.AcceptExecutingPrograms)
                {
                    proc.StartInfo.Verb = "Open";
                }
                else
                {
                    proc.StartInfo.Verb = "Edit";
                }
                proc.StartInfo.FileName = outputFinalFile;
                proc.Start();
                proc.WaitForExit();

                // ouvrir le document résultat
                if (global::CodeCommander.Properties.Settings.Default.AcceptExecutingPrograms)
                {
                    proc = new Process();
                    proc.StartInfo.Verb     = "Open";
                    proc.StartInfo.FileName = Documents.BuildDirectory + Path.GetFileNameWithoutExtension(fi.Name) + ".txt";
                    proc.Start();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            if (this.Close != null)
            {
                this.Close(this, new EventArgs());
            }
        }
Пример #3
0
        void WindowsCPP_Click(object sender, HtmlElementEventArgs e)
        {
            // fermer la dialog box pour lancer le message d'attente
            if (this.Close != null)
            {
                this.Close(this, new EventArgs());
            }
            FileInfo fi             = new FileInfo(this.fileNameSrc);
            string   solutionPath   = Path.Combine(Documents.BuildDirectory, Path.GetFileNameWithoutExtension(fi.Name) + "_wincpp");
            string   projectPath    = Path.Combine(solutionPath, Path.GetFileNameWithoutExtension(fi.Name));
            string   executablePath = Path.Combine(solutionPath, @"x64\Debug");
            string   fileNameDict   = Path.Combine(Documents.DictionariesDirectory, Path.GetFileNameWithoutExtension(fi.Name) + ".xml");

            this.outputDict.Save(fileNameDict);
            o2Mate.Compilateur comp            = new o2Mate.Compilateur();
            string             outputFinalFile = Path.Combine(Documents.BuildDirectory, Path.GetFileNameWithoutExtension(fi.Name) + ".txt");

            try
            {
                comp.UnderConversion   = true;
                comp.ConvertedLanguage = new Converters.MicrosoftCPPConverter();
                comp.LoadTemplates(Documents.TemplatesDirectory);
                comp.LoadSkeletons(Documents.SkeletonsDirectory);
                comp.Convert(comp.ConvertedLanguage, this.fileNameSrc, fileNameDict, outputFinalFile);

                #region Start Progress Bar
                PopupProgress pp = new PopupProgress(false, ProgressBarStyle.Marquee);
                pp.Start(false);
                #endregion

                #region compile and execute C++ Windows generated app
                bool         compiled = false;
                ThreadObject to       = new ThreadObject(new object[] { comp, pp });
                if (System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(delegate(object param)
                {
                    ThreadObject d = param as ThreadObject;
                    try
                    {
                        compiled = comp.ConvertedLanguage.CompileAndExecute(Path.Combine(solutionPath, Path.GetFileNameWithoutExtension(fi.Name) + ".sln"),
                                                                            Path.Combine(projectPath, Path.GetFileNameWithoutExtension(fi.Name) + ".vcxproj"),
                                                                            Path.Combine(executablePath, Path.GetFileNameWithoutExtension(fi.Name) + ".exe"),
                                                                            global::CodeCommander.Properties.Settings.Default.AcceptExecutingPrograms);
                        (d.Datas[1] as PopupProgress).IsFinished = true;
                    }
                    catch (Exception ex)
                    {
                        (d.Datas[1] as PopupProgress).GiveException(ex);
                        (d.Datas[1] as PopupProgress).IsFinished = true;
                    }
                }), to))
                {
                    to.Wait.WaitOne(2000);
                    if (!pp.IsFinished)
                    {
                        pp.ShowDialog();
                    }

                    #region Copy dict file into the source directory
                    if (compiled)
                    {
                        File.Copy(fileNameDict, Path.Combine(solutionPath, Path.GetFileName(fileNameDict)), true);

                        #region Open result file
                        Process proc = new Process();
                        if (global::CodeCommander.Properties.Settings.Default.AcceptExecutingPrograms)
                        {
                            proc.StartInfo.Verb     = "Open";
                            proc.StartInfo.FileName = outputFinalFile;
                        }
                        else
                        {
                            proc.StartInfo.Verb     = "Edit";
                            proc.StartInfo.FileName = Path.Combine(projectPath, "compiled.cpp");
                        }
                        proc.Start();
                        #endregion
                    }
                    else
                    {
                        MessageBox.Show("La compilation a échouée.", "Erreur à la compilation", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    #endregion
                }
                #endregion
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }