Пример #1
0
 public static void ControlloInChiusura(ref bool flag_modified, RichTextBoxEx RTBText, ref string FileName, ref bool flag_saved)
 {
     if (flag_modified)
     {
         System.Windows.Forms.DialogResult mboxres;
         mboxres = MessageBox.Show("Vuoi Salvare?", "File non Salvato", MessageBoxButtons.YesNoCancel);
         if (mboxres == System.Windows.Forms.DialogResult.Yes)
         {
             Salva(RTBText.Lines, ref FileName, ref flag_saved);
         }
         else if (mboxres == System.Windows.Forms.DialogResult.Cancel)
         {
             throw new OperationCanceledException("Operazione annullata");
         }
     }
 }
Пример #2
0
        public static void ColoraTesto(RichTextBoxEx rtb, List <ColorConfig> color)
        {
            if (color == null)
            {
                color = Leggifile();
            }
            int             selIndx     = rtb.SelectionStart;                   //salvo le coordinate di un eventuale selezione
            int             selLeght    = rtb.SelectionLength;
            Color           col         = rtb.ForeColor;                        //salvo il colore iniziale del font
            string          rex         = @"[\w]+[.\s]($)?";
            MatchCollection Collections = Regex.Matches(rtb.Text, rex);         //prendo tutte le parole

            foreach (ColorConfig i in color)
            {
                if (i.RegexOption != -1)
                {
                    MatchCollection rexres = Regex.Matches(rtb.Text, i.Value, (RegexOptions)i.RegexOption);
                    foreach (Match n in rexres)
                    {
                        rtb.Select(n.Index, n.Length);                              // seleziono il match
                        rtb.SelectionColor = i.color;                               // coloro
                    }
                }
                else
                {
                    foreach (Match m in Collections)
                    {
                        if (i.Value.ToLower() == m.ToString().Trim().ToLower() + " ") //guardo se la parola corrisponde
                        {
                            rtb.Select(m.Index, m.Length);                            //seleziono la parola
                            rtb.SelectionColor = i.color;                             //coloro
                        }
                    }
                }
            }
            rtb.Select(selIndx, 0);                                     //riporto la selezione allo stato iniziale
            rtb.SelectionStart  = selIndx;
            rtb.SelectionLength = selLeght;
            rtb.SelectionColor  = col;
        }
Пример #3
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);
        }