public void PintarNotesDeBlau() { MatchCollection matches = Regex.Matches(QuadernBitacoles_richTextBox.Text, ".*Nota:.*\n"); //Apply color to all matching text foreach (Match match in matches) { // Posar tota la línia del terapeuta de color blau QuadernBitacoles_richTextBox.Select(match.Index, match.Length); QuadernBitacoles_richTextBox.SelectionColor = Color.SteelBlue; // Posar "Nota:" en negreta Match match2 = Regex.Match(match.Value, "Nota:"); QuadernBitacoles_richTextBox.Select(match.Index + match2.Index, match2.Length); // Línia + columna per trobar la nota de cada línia QuadernBitacoles_richTextBox.SelectionFont = new Font(QuadernBitacoles_richTextBox.Font, FontStyle.Bold); } }
public void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { if (Connexio_Singleton.getInstance().portObert()) { QuadernBitacoles_richTextBox.Invoke(new MethodInvoker(delegate() { QuadernBitacoles_richTextBox.AppendText(DateTime.Now.ToLongTimeString() + " " + TEXT_ENVIAR + Environment.NewLine); PintarNotesDeBlau(); })); //QuadernModel q = new QuadernModel(); //q.Missatge = DateTime.Now.ToLongTimeString() + " " + TEXT_ENVIAR; //SqliteDataAccess.DesaQuadern(q); } else { MessageBox.Show("Error: Arduino no connectat."); } backgroundWorker1.CancelAsync(); }