Ejemplo n.º 1
0
 public FormBase()
 {
     InitializeComponent();
     ApplicaConfigurazioni();
     size = RTBText.Font.Size;
     FormFunctions.PopulateTreeView(TWfiles, FileName);
 }
Ejemplo n.º 2
0
 private void apriToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (openFD.ShowDialog() == DialogResult.OK)
     {
         try
         {
             FormFunctions.ControlloInChiusura(ref flag_modified, RTBText, ref FileName, ref flag_saved);
             RTBText.Lines = File.ReadAllLines(openFD.FileName);
             FileName      = openFD.FileName;
             FormFunctions.PopulateTreeView(TWfiles, FileName);
         }
         #region Catches
         catch (OperationCanceledException) { return; }
         catch (IOException)
         {
             if (MessageBox.Show("Errore in Lettura\n\nRiprovare?", "Errore", MessageBoxButtons.YesNo) == DialogResult.Yes)
             {
                 apriToolStripMenuItem_Click(sender, e);
             }
             else
             {
                 return;
             }
         }
         catch (UnauthorizedAccessException) { MessageBox.Show("Accesso al file negato"); return; }
         catch (System.Security.SecurityException) { MessageBox.Show("accesso al file negato"); return; }
         #endregion
     }
     flag_saved    = true;
     flag_modified = false;
     undoList.Clear();
     redoList.Clear();
 }
Ejemplo n.º 3
0
 private void FormBase_FormClosing(object sender, FormClosingEventArgs e)
 {
     try
     {
         FormFunctions.ControlloInChiusura(ref flag_modified, RTBText, ref FileName, ref flag_saved);
     }
     catch (OperationCanceledException) { e.Cancel = true; }
 }//chiusura form
Ejemplo n.º 4
0
 private void salvaToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (FormFunctions.Salva(RTBText.Lines, ref FileName, ref flag_saved))
     {
         undoList.Clear();
         redoList.Clear();
     }
     FormFunctions.PopulateTreeView(TWfiles, FileName);
 }
Ejemplo n.º 5
0
        private void nuovoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                FormFunctions.ControlloInChiusura(ref flag_modified, RTBText, ref FileName, ref flag_saved);
            }
            catch (OperationCanceledException) { return; };
            flag_modified = false;
            flag_saved    = false;

            undoList.Clear();
            redoList.Clear();
            //RTBText.Text = "|Scrivi il tuo codice qui|";
        }
Ejemplo n.º 6
0
 private void pacchettoToolStripMenuItem_Click(object sender, EventArgs e)
 {
     string[] errori;
     if (FormFunctions.Salva(RTBText.Lines, ref FileName, ref flag_saved))
     {
         undoList.Clear();
         redoList.Clear();
     }
     FormFunctions.PopulateTreeView(TWfiles, FileName);
     if (flag_saved)
     {
         if (FormFunctions.CompilaPacchetto(RTBText, FileName, out errori))
         {
             RTBLog.Lines = errori;
             errorConsoleToolStripMenuItem.Checked = true;
         }
     }
 }
Ejemplo n.º 7
0
 private void tsbCompila_Click(object sender, EventArgs e)
 {
     string [] errori;
     if (FormFunctions.Salva(RTBText.Lines, ref FileName, ref flag_saved))
     {
         undoList.Clear();
         redoList.Clear();
     }
     FormFunctions.PopulateTreeView(TWfiles, FileName);
     if (flag_saved)
     {
         if (sender == tsbCompila)
         {
             if (toolStripComboBox1.SelectedIndex == 0)
             {
                 if (!FormFunctions.CompilaProgramma(RTBText, FileName, out errori))
                 {
                     RTBLog.Lines = errori;
                     errorConsoleToolStripMenuItem.Checked = true;
                 }
             }
             else
             {
                 if (!FormFunctions.CompilaPacchetto(RTBText, FileName, out errori))
                 {
                     RTBLog.Lines = errori;
                     errorConsoleToolStripMenuItem.Checked = true;
                 }
             }
         }
         else
         {
             if (!FormFunctions.CompilaProgramma(RTBText, FileName, out errori))
             {
                 RTBLog.Lines = errori;
                 errorConsoleToolStripMenuItem.Checked = true;
             }
         }
     }
 }
Ejemplo n.º 8
0
        public static bool CompilaProgramma(RichTextBoxEx RTBText, string FileName, out string[] errors)
        {
            LogManager errori     = new LogManager();
            Translator traduttore = new Translator(errori);

            string[]        pacccccccchetttttttu;
            string          rex     = "aggiungi";
            MatchCollection matches = Regex.Matches(RTBText.Text, rex);
            int             j       = 0;

            pacccccccchetttttttu = new string[matches.Count + 1];
            foreach (Match i in matches)
            {
                int    index = i.Index + i.Length;
                string line  = RTBText.Lines[RTBText.GetLineFromCharIndex(index)];
                RTBText.Select(index, line.Length - i.Length);
                string res = RTBText.SelectedText.Trim();
                if (!string.IsNullOrWhiteSpace(res))
                {
                    pacccccccchetttttttu[j] = FormFunctions.GetPathByFileName(FileName) + "/" + res + ".lmp";
                }
                else
                {
                    pacccccccchetttttttu[j] = "";
                }
                j++;
            }
            pacccccccchetttttttu[j] = "./LEGGERMENTE.lmp";

            ResultCode risultato = traduttore.Translate(CodeType.Program, RTBText.Text, pacccccccchetttttttu, FormFunctions.GetPathByFileName(FileName) + "/result.cs");

            if (!errori.WithOutError)
            {
                errors = errori.LogList;
                return(false);
            }
            errors = null;
            return(true);
        }