示例#1
0
 private void button3_Click(object sender, EventArgs e)
 {
     o2Mate.Compilateur comp = new o2Mate.Compilateur();
     comp.Compilation(@"C:\Documents and Settings\Olivier\Mes documents\Visual Studio 2005\Projects\o2Mate\Editeur\outil_texte.xml",
                      @"C:\Documents and Settings\Olivier\Mes documents\Visual Studio 2005\Projects\o2Mate\Editeur\dicttest.xml",
                      @"C:\Documents and Settings\Olivier\Mes documents\Visual Studio 2005\Projects\o2Mate\Editeur\result.txt", null);
 }
示例#2
0
        void DictExecute_Exec(object sender, System.Windows.Forms.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();
            comp.LoadTemplates(Documents.TemplatesDirectory);
            comp.LoadSkeletons(Documents.SkeletonsDirectory);
            string outputFinalFile = Documents.BuildDirectory + Path.GetFileNameWithoutExtension(fi.Name) + ".txt";

            try
            {
                comp.Compilation(this.fileNameSrc, fileNameDict, outputFinalFile, null);
                Process proc = new Process();
                proc.StartInfo.FileName = outputFinalFile;
                proc.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            if (this.Close != null)
            {
                this.Close(this, new EventArgs());
            }
        }
示例#3
0
        public string ExecuteAndRead()
        {
            string   result       = String.Empty;
            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();
            comp.LoadTemplates(Documents.TemplatesDirectory);
            comp.LoadSkeletons(Documents.SkeletonsDirectory);
            string outputFinalFile = Documents.BuildDirectory + Path.GetFileNameWithoutExtension(fi.Name) + ".txt";

            try
            {
                comp.Compilation(this.fileNameSrc, fileNameDict, outputFinalFile, null);
                StreamReader sr = new StreamReader(outputFinalFile);
                result = sr.ReadToEnd();
                sr.Close();
                sr.Dispose();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            if (this.Close != null)
            {
                this.Close(this, new EventArgs());
            }
            return(result);
        }
示例#4
0
        private void btnRefresh_Click(object sender, EventArgs e)
        {
            List <ListViewItem> list = new List <ListViewItem>();

            this.lvFiles.Items.Clear();
            DirectoryInfo di = new DirectoryInfo(this._directorySource);

            foreach (FileInfo fi in di.GetFiles("*.xml"))
            {
                try
                {
                    ListViewItem lvi = new ListViewItem();
                    lvi.Text = fi.Name;
                    string             cd, md, rev;
                    o2Mate.Compilateur comp = new o2Mate.Compilateur();
                    comp.GetHeader(fi.FullName, out cd, out md, out rev);
                    lvi.SubItems.Add(cd);
                    lvi.SubItems.Add(md);
                    lvi.SubItems.Add(rev);
                    list.Add(lvi);
                }
                catch { }
            }
            list.Sort(new Comparison <ListViewItem>(delegate(ListViewItem l1, ListViewItem l2)
            {
                int res = 0;
                try
                {
                    if (this.columnSorter == 0)
                    {
                        res = String.Compare(l1.Text, l2.Text);
                    }
                    else if (this.columnSorter == 1)
                    {
                        DateTime dt1 = DateTime.Parse(l1.SubItems[1].Text);
                        DateTime dt2 = DateTime.Parse(l2.SubItems[1].Text);
                        res          = DateTime.Compare(dt1, dt2);
                    }
                    else if (this.columnSorter == 2)
                    {
                        DateTime dt1 = DateTime.Parse(l1.SubItems[2].Text);
                        DateTime dt2 = DateTime.Parse(l2.SubItems[2].Text);
                        res          = DateTime.Compare(dt1, dt2);
                    }
                    else
                    {
                        Int32 i1 = Int32.Parse(l1.SubItems[3].Text);
                        Int32 i2 = Int32.Parse(l2.SubItems[3].Text);
                        res      = i1.CompareTo(i2);
                    }
                }
                catch { }
                return(res);
            }));
            foreach (ListViewItem item in list)
            {
                this.lvFiles.Items.Add(item);
            }
        }
示例#5
0
        public void Load()
        {
            o2Mate.Dictionnaire IHMdict = new o2Mate.Dictionnaire();
            string fileNameDict         = Path.Combine(Documents.TempDirectory, Documents.BienvenuePage + ".xml");

            IHMdict.Save(fileNameDict);
            o2Mate.Compilateur comp = new o2Mate.Compilateur();
            comp.LoadTemplates(Documents.GeneratedDictionariesTemplatesDirectory);
            comp.Compilation(Documents.BienvenuePage, fileNameDict, this.fileNameFinal, null);
        }
示例#6
0
        private void btnNew_Click(object sender, EventArgs e)
        {
            FileInfo fi = new FileInfo(this._directorySource + "\\" + this.SearchNewFileName() + ".xml");

            // we create the file now with the correct format
            o2Mate.Compilateur comp = new o2Mate.Compilateur();
            comp.CreateFile(fi.FullName);
            this._fileName    = fi.Name;
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
示例#7
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());
            }
        }
 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);
 }
示例#9
0
        private void btnExec_Click(object sender, EventArgs e)
        {
            this._dict.Save(AppDomain.CurrentDomain.BaseDirectory + "\\dict\\" + this._fileName);
            o2Mate.Compilateur comp = new o2Mate.Compilateur();
            try
            {
                comp.Compilation(AppDomain.CurrentDomain.BaseDirectory + "\\sources\\" + this._fileName, AppDomain.CurrentDomain.BaseDirectory + "\\dict\\" + this._fileName, AppDomain.CurrentDomain.BaseDirectory + "\\files\\" + System.IO.Path.GetFileNameWithoutExtension(this._fileName) + ".txt");
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); }
            Process proc = new Process();

            proc.StartInfo.FileName = AppDomain.CurrentDomain.BaseDirectory + "\\files\\" + System.IO.Path.GetFileNameWithoutExtension(this._fileName) + ".txt";
            proc.Start();
            this.Close();
        }
示例#10
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());
            }
        }
示例#11
0
        static void Main()
        {
            try
            {
                // création du fichier outils.VBS
                o2Mate.Compilateur  comp = new o2Mate.Compilateur();
                o2Mate.Dictionnaire dict = new o2Mate.Dictionnaire();
                dict.AddString("dir", Documents.EditeurDirectory);
                string fileNameDict = Documents.TempDictFile;
                dict.Save(fileNameDict);
                comp.Compilation(Documents.OutilsVBSXML, fileNameDict, Documents.OutilsVBS, null);
                // le compilateur ne peut pas etre lancé 2 fois de suite
                comp = new o2Mate.Compilateur();
                comp.Compilation(Documents.LocalesVBSXML, fileNameDict, Documents.LocalesVBS, null);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            try
            {
                DirectoryInfo di = new DirectoryInfo(Documents.CodeCommanderDirectory);
                if (!di.Exists)
                {
                    di.Create();
                }
                di = new DirectoryInfo(Documents.SourcesDirectory);
                if (!di.Exists)
                {
                    di.Create();
                    di = new DirectoryInfo(Documents.ExamplesDirectory);
                    Program.CopyXML(di, Documents.SourcesDirectory);
                }
                di = new DirectoryInfo(Documents.TemplatesDirectory);
                if (!di.Exists)
                {
                    di.Create();
                    di = new DirectoryInfo(Documents.SrcTemplatesDirectory);
                    Program.CopyXML(di, Documents.TemplatesDirectory);
                }
                di = new DirectoryInfo(Documents.SkeletonsDirectory);
                if (!di.Exists)
                {
                    di.Create();
                    di = new DirectoryInfo(Documents.SrcSkeletonsDirectory);
                    Program.CopyXML(di, Documents.SkeletonsDirectory);
                }
                di = new DirectoryInfo(Documents.SyntaxDirectory);
                if (!di.Exists)
                {
                    di.Create();
                    di = new DirectoryInfo(Documents.SrcSyntaxDirectory);
                    Program.CopyXML(di, Documents.SyntaxDirectory);
                }
                di = new DirectoryInfo(Documents.LocalesDirectory);
                if (!di.Exists)
                {
                    di.Create();
                    di = new DirectoryInfo(Documents.SrcLocalesDirectory);
                    Program.CopyTSV(di, Documents.LocalesDirectory);
                }
                di = new DirectoryInfo(Documents.DictionariesDirectory);
                if (!di.Exists)
                {
                    di.Create();
                }
                di = new DirectoryInfo(Documents.BuildDirectory);
                if (!di.Exists)
                {
                    di.Create();
                }
                di = new DirectoryInfo(Documents.TempDirectory);
                if (!di.Exists)
                {
                    di.Create();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("L'application va s'arrêter parce qu'il est impossible de créer des fichiers dans le répertoire 'Mes documents'", "Impossible de continuer", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            ComputerSettings computerSettings = new ComputerSettings();

            try
            {
                computerSettings.VerifyPowerShell();
                computerSettings.VerifyExecutingPowerShell();
                computerSettings.TestChangeParameterSettings();
                Application.Run(computerSettings);
                if (computerSettings.DialogResult == DialogResult.Cancel)
                {
                    // si cancel alors on stoppe l'application
                    return;
                }
                if (computerSettings.DialogResult == DialogResult.OK)
                {
                    Form1 form = new Form1(computerSettings);
                    try
                    {
                        // création du fichier editeur.HTM en fonction de la langue
                        o2Mate.Compilateur  comp = new o2Mate.Compilateur();
                        o2Mate.Dictionnaire dict = new o2Mate.Dictionnaire();
                        string fileNameDict      = Documents.TempDictFile;
                        dict.Save(fileNameDict);
                        comp.Compilation(Documents.EditorPageXML, fileNameDict, Documents.EditorPage, null);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                    Application.Run(form);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
            finally
            {
                computerSettings.RevertToSaved();
                // suppress all temporary files
                DirectoryInfo dir = new DirectoryInfo(Documents.TempDirectory);
                dir.EnumerateFiles().AsParallel().ForAll(a => { a.Delete(); });
            }
        }
示例#12
0
        public void Load()
        {
            o2Mate.Dictionnaire IHMdict = new o2Mate.Dictionnaire();
            string fileNameDict         = Path.Combine(Documents.TempDirectory, Path.GetFileNameWithoutExtension(new FileInfo(this.fileNameSrc).Name) + ".xml");;

            this.preferredHeight = 270;
            this.keys.Clear();
            o2Mate.Array  tabInput         = this.inputDict.GetArray(this.keyTab) as o2Mate.Array;
            o2Mate.Fields fieldsInput      = tabInput.Item(1) as o2Mate.Fields;
            o2Mate.Array  tabDefaultFields = new o2Mate.Array();
            int           fieldIndex       = 0;

            if (!this.outputDict.IsArray(this.keyTab))
            {
                this.outputDict.AddArray(this.keyTab, new o2Mate.Array());
            }
            o2Mate.Array  arrRows   = this.outputDict.GetArray(this.keyTab) as o2Mate.Array;
            o2Mate.Fields rowFields = null;
            if (index > 0)
            {
                rowFields = arrRows.Item(this.index) as o2Mate.Fields;
            }
            o2Mate.Array refArrConnections = new o2Mate.Array();
            foreach (string key in fieldsInput.Keys)
            {
                o2Mate.Fields fieldsDefault = new o2Mate.Fields();
                ++fieldIndex;
                o2Mate.ILegende leg = this.inputDict.Legendes.GetLegendeByName(key, this.keyTab);
                this.keys.Add("field" + fieldIndex.ToString(), key);
                fieldsDefault.AddString("nom", "field" + fieldIndex.ToString());
                string description = key;
                if (leg != null)
                {
                    description = leg.Description;
                }
                fieldsDefault.AddString("description", description);
                string commentaire = "";
                if (leg != null)
                {
                    commentaire = leg.Commentaire;
                }
                fieldsDefault.AddString("commentaire", commentaire);
                string myType = "String";
                if (leg != null)
                {
                    myType = leg.Type;
                    if (leg.Observe != "")
                    {
                        fieldsDefault.AddString("observe", leg.Observe);
                    }
                }
                fieldsDefault.AddString("type", myType);
                string arrName, field;
                if (this.outputDict.GetInConnection(leg, this.keyTab, this.index, out arrName, out field))
                {
                    fieldsDefault.AddString("arrayReference", arrName);
                    o2Mate.Array  arrConnection       = this.outputDict.GetArray(arrName) as o2Mate.Array;
                    o2Mate.Fields refFieldsConnection = new o2Mate.Fields();
                    refFieldsConnection.AddString("name", "field" + index.ToString());
                    refFieldsConnection.AddString("value", "");
                    refArrConnections.Add(refFieldsConnection);
                    for (int indexConnection = 1; indexConnection <= arrConnection.Count; ++indexConnection)
                    {
                        o2Mate.Fields f = arrConnection.Item(indexConnection) as o2Mate.Fields;
                        if (f.Exists(field))
                        {
                            o2Mate.Fields refFields = new o2Mate.Fields();
                            refFields.AddString("name", "field" + index.ToString());
                            refFields.AddString("value", f.GetString(field));
                            refArrConnections.Add(refFields);
                        }
                    }
                }
                if (this.index > 0)
                {
                    if (rowFields.Exists(key))
                    {
                        fieldsDefault.AddString("valeur", rowFields.GetString(key));
                    }
                    else
                    {
                        rowFields.AddString(key, "");
                        fieldsDefault.AddString("valeur", "");
                    }
                }
                tabDefaultFields.Add(fieldsDefault);
                this.preferredHeight += 40;
            }
            IHMdict.AddArray("keyTab", tabDefaultFields);
            IHMdict.AddArray("connections", refArrConnections);
            if (this.index > 0)
            {
                IHMdict.AddString("title", "Nouvel élément du tableau '" + this.keyTab + "'");
            }
            else
            {
                IHMdict.AddString("title", "Edition d'un élément du tableau '" + this.keyTab + "'");
            }
            o2Mate.ILegende legTab         = this.inputDict.Legendes.GetLegendeByName(this.keyTab);
            string          descriptionTab = this.keyTab;

            if (legTab != null)
            {
                descriptionTab = legTab.Description;
            }
            IHMdict.AddString("description", descriptionTab);
            string commentaireTab = "";

            if (legTab != null)
            {
                commentaireTab = legTab.Commentaire;
            }
            IHMdict.AddString("commentaire", commentaireTab);
            IHMdict.Save(fileNameDict);
            o2Mate.Compilateur comp = new o2Mate.Compilateur();
            comp.LoadTemplates(Documents.GeneratedDictionariesTemplatesDirectory);
            try
            {
                comp.Compilation(Documents.SaisieChampsPage, fileNameDict, this.fileNameFinal, null);
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.ToString());
            }
        }
示例#13
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());
            }
        }
        public new void Load()
        {
            o2Mate.Dictionnaire IHMdict = new o2Mate.Dictionnaire();
            string fileNameDict         = Path.Combine(Documents.TempDirectory, Path.GetFileNameWithoutExtension(new FileInfo(this.fileNameSrc).Name) + ".xml");

            o2Mate.Array arr = new o2Mate.Array();
            this.PreferredHeight = 258;
            this.keys.Clear();
            int index = 1;

            IHMdict.AddString("title", "Saisie des champs libres");
            o2Mate.Array refArrConnections = new o2Mate.Array();
            foreach (string key in this.inputDict.StringKeys)
            {
                o2Mate.Fields fields = new o2Mate.Fields();
                this.keys.Add("field" + index.ToString(), key);
                fields.AddString("nom", "field" + index.ToString());
                o2Mate.ILegende leg         = this.inputDict.Legendes.GetLegendeByName(key);
                string          description = key;
                if (leg != null)
                {
                    description = leg.Description;
                }
                fields.AddString("description", description);
                string commentaire = "";
                if (leg != null)
                {
                    commentaire = leg.Commentaire;
                }
                fields.AddString("commentaire", commentaire);
                string myType = "String";
                if (leg != null)
                {
                    myType = leg.Type;
                    if (leg.Expression != "")
                    {
                        fields.AddString("observe", leg.Expression);
                    }
                }
                fields.AddString("type", myType);
                string arrName, field;
                if (this.outputDict.GetInConnection(leg, "", 0, out arrName, out field))
                {
                    fields.AddString("arrayReference", arrName);
                    o2Mate.Array  arrConnection       = this.outputDict.GetArray(arrName) as o2Mate.Array;
                    o2Mate.Fields refFieldsConnection = new o2Mate.Fields();
                    refFieldsConnection.AddString("name", "field" + index.ToString());
                    refFieldsConnection.AddString("value", "");
                    refArrConnections.Add(refFieldsConnection);
                    for (int indexConnection = 1; indexConnection <= arrConnection.Count; ++indexConnection)
                    {
                        o2Mate.Fields f = arrConnection.Item(indexConnection) as o2Mate.Fields;
                        if (f.Exists(field))
                        {
                            o2Mate.Fields refFields = new o2Mate.Fields();
                            refFields.AddString("name", "field" + index.ToString());
                            refFields.AddString("value", f.GetString(field));
                            refArrConnections.Add(refFields);
                        }
                    }
                }
                if (this.outputDict.IsString(key))
                {
                    fields.AddString("valeur", this.outputDict.GetString(key));
                }
                else
                {
                    fields.AddString("valeur", "");
                }
                arr.Add(fields);
                this.PreferredHeight += 40;
                ++index;
            }
            IHMdict.AddArray("connections", refArrConnections);
            IHMdict.AddArray("champs", arr);
            IHMdict.Save(fileNameDict);
            o2Mate.Compilateur comp = new o2Mate.Compilateur();
            comp.LoadTemplates(Documents.GeneratedDictionariesTemplatesDirectory);
            comp.Compilation(Documents.SaisieLibrePage, fileNameDict, this.fileNameFinal, null);
            FileInfo fi = new FileInfo(Documents.GeneratedDictionariesDirectory + Documents.ImageAdd);

            fi.CopyTo(Path.GetDirectoryName(this.fileNameFinal) + Documents.ImageAdd, true);
            fi = new FileInfo(Documents.GeneratedDictionariesDirectory + Documents.ImageEdit);
            fi.CopyTo(Path.GetDirectoryName(this.fileNameFinal) + Documents.ImageEdit, true);
        }
示例#15
0
        public new void Load()
        {
            o2Mate.Dictionnaire IHMdict = new o2Mate.Dictionnaire();
            string fileNameDict         = Path.Combine(Documents.TempDirectory, Path.GetFileNameWithoutExtension(new FileInfo(this.fileNameSrc).Name) + ".xml");

            this.PreferredHeight = 270;
            this.keys.Clear();
            o2Mate.Array  tabInput         = this.inputDict.GetArray(this.keyTab) as o2Mate.Array;
            o2Mate.Fields fieldsInput      = tabInput.Item(1) as o2Mate.Fields;
            o2Mate.Array  tabDefaultFields = new o2Mate.Array();
            int           fieldIndex       = 0;

            foreach (string key in fieldsInput.Keys)
            {
                o2Mate.Fields fieldsDefault = new o2Mate.Fields();
                ++fieldIndex;
                o2Mate.ILegende leg = this.inputDict.Legendes.GetLegendeByName(key, this.keyTab);
                this.keys.Add("field" + fieldIndex.ToString(), key);
                fieldsDefault.AddString("nom", "field" + fieldIndex.ToString());
                string description = key;
                if (leg != null)
                {
                    description = leg.Description;
                }
                fieldsDefault.AddString("description", description);
                string commentaire = "";
                if (leg != null)
                {
                    commentaire = leg.Commentaire;
                }
                fieldsDefault.AddString("commentaire", commentaire);
                string myType = "String";
                if (leg != null)
                {
                    myType = leg.Type;
                    if (leg.Expression != "")
                    {
                        fieldsDefault.AddString("observe", leg.Expression);
                    }
                }
                fieldsDefault.AddString("type", myType);
                tabDefaultFields.Add(fieldsDefault);
            }
            IHMdict.AddArray("keyTab", tabDefaultFields);
            IHMdict.AddString("title", "Saisie du tableau '" + this.keyTab + "'");
            o2Mate.ILegende legTab         = this.inputDict.Legendes.GetLegendeByName(this.keyTab);
            string          descriptionTab = this.keyTab;

            if (legTab != null)
            {
                descriptionTab = legTab.Description;
            }
            IHMdict.AddString("description", descriptionTab);
            string commentaireTab = "";

            if (legTab != null)
            {
                commentaireTab = legTab.Commentaire;
            }
            IHMdict.AddString("commentaire", commentaireTab);
            if (!this.outputDict.IsArray(this.keyTab))
            {
                this.outputDict.AddArray(this.keyTab, new o2Mate.Array());
            }
            o2Mate.Array tabOutput = this.outputDict.GetArray(this.keyTab) as o2Mate.Array;
            o2Mate.Array arrRows   = new o2Mate.Array();
            o2Mate.Array arrFields = new o2Mate.Array();
            for (int index = 1; index <= tabOutput.Count; ++index)
            {
                o2Mate.Fields tabRows = new o2Mate.Fields();
                tabRows.AddString("index", index.ToString());
                arrRows.Add(tabRows);
                o2Mate.Fields tabFieldsInput = tabInput.Item(1) as o2Mate.Fields;
                o2Mate.Fields fields         = tabOutput.Item(index) as o2Mate.Fields;
                fieldIndex = 0;
                foreach (string key in tabFieldsInput.Keys)
                {
                    o2Mate.Fields tabFields = new o2Mate.Fields();
                    tabFields.AddString("rowId", index.ToString());
                    ++fieldIndex;
                    o2Mate.ILegende leg = this.inputDict.Legendes.GetLegendeByName(key, this.keyTab);
                    this.keys.Add("rowId" + index.ToString() + "_field" + fieldIndex.ToString(), key);
                    tabFields.AddString("nom", "rowId" + index.ToString() + "_field" + fieldIndex.ToString());
                    string description = key;
                    if (leg != null)
                    {
                        description = leg.Description;
                    }
                    tabFields.AddString("description", description);
                    string commentaire = "";
                    if (leg != null)
                    {
                        commentaire = leg.Commentaire;
                    }
                    tabFields.AddString("commentaire", commentaire);
                    string myType = "String";
                    if (leg != null)
                    {
                        myType = leg.Type;
                        if (leg.Expression != "")
                        {
                            tabFields.AddString("observe", leg.Expression);
                        }
                    }
                    tabFields.AddString("type", myType);
                    if (fields.Exists(key))
                    {
                        tabFields.AddString("value", fields.GetString(key));
                    }
                    else
                    {
                        tabFields.AddString("value", "");
                    }
                    arrFields.Add(tabFields);
                    this.PreferredHeight += 40;
                }
                this.PreferredHeight += 10;
            }
            IHMdict.AddArray("items", arrRows);
            IHMdict.AddArray("fields", arrFields);
            IHMdict.Save(fileNameDict);
            try
            {
                o2Mate.Compilateur comp = new o2Mate.Compilateur();
                comp.LoadTemplates(Documents.GeneratedDictionariesTemplatesDirectory);
                comp.Compilation(Documents.SaisieTableauPage, fileNameDict, this.fileNameFinal, null);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            FileInfo fi = new FileInfo(Documents.GeneratedDictionariesDirectory + Documents.ImageTabUp);

            fi.CopyTo(Path.GetDirectoryName(this.fileNameFinal) + Documents.ImageTabUp, true);
            fi = new FileInfo(Documents.GeneratedDictionariesDirectory + Documents.ImageTabDown);
            fi.CopyTo(Path.GetDirectoryName(this.fileNameFinal) + Documents.ImageTabDown, true);
        }