示例#1
0
        void PowerShell_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) + ".ps1";

            try
            {
                comp.UnderConversion   = true;
                comp.ConvertedLanguage = new Converters.PowerShellConverter();
                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 && global::CodeCommander.Properties.Settings.Default.PowerShellInstalled)
                {
                    proc.StartInfo.CreateNoWindow = true;
                    proc.StartInfo.WindowStyle    = ProcessWindowStyle.Hidden;
                    proc.StartInfo.Verb           = global::CodeCommander.Properties.Settings.Default.ExecPowerShellVerb;
                }
                else
                {
                    proc.StartInfo.Verb = "Open";
                }
                proc.StartInfo.FileName = outputFinalFile;
                proc.Start();
                if (global::CodeCommander.Properties.Settings.Default.AcceptExecutingPrograms && global::CodeCommander.Properties.Settings.Default.PowerShellInstalled)
                {
                    proc.WaitForExit();
                }

                // ouvrir le document résultat
                if (global::CodeCommander.Properties.Settings.Default.AcceptExecutingPrograms && global::CodeCommander.Properties.Settings.Default.PowerShellInstalled)
                {
                    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());
            }
        }
示例#2
0
        void Java_Click(object sender, HtmlElementEventArgs e)
        {
            FileInfo fi             = new FileInfo(this.fileNameSrc);
            string   pathExecutable = Path.Combine(Documents.BuildDirectory,
                                                   Path.Combine(Path.GetFileNameWithoutExtension(fi.Name),
                                                                Path.Combine(Path.GetFileNameWithoutExtension(fi.Name), "bin\\Debug")));
            string fileNameDict = Documents.TempDictFile;

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

            try
            {
                comp.UnderConversion   = true;
                comp.ConvertedLanguage = new Converters.JavaConverter();
                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();
            }
            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());
            }
        }