//чатик public void RunListenPort() { byte[] bytes = new byte[1024]; int bytesRec1 = client.Receive(bytes); string Adder = String.Format(Encoding.UTF8.GetString(bytes, 0, bytesRec1)); if (Adder.Length > 1) { string SubAdder = Adder.Substring(0, 2); if (SubAdder == "#D") { string[] SubSubAdder = Adder.Substring(2, Adder.Length - 2).Split(Convert.ToChar("-")); foreach (string keker in SubSubAdder) { RTB1.AppendText(keker + "_"); } FileConnectForm.tet(SubSubAdder); } else { infoPole.Items.Add(Adder); } } else { infoPole.Items.Add(Adder); } }
void OnDestroy() { RTA1.Release(); RTA2.Release(); RTB1.Release(); RTB2.Release(); }
private void TVQuestions_BeforeSelect(object sender, TreeViewCancelEventArgs e) { RTBText.Clear(); CB1.Checked = CB2.Checked = CB3.Checked = CB4.Checked = false; RTB1.Clear(); RTB2.Clear(); RTB3.Clear(); RTB4.Clear(); }
private void LoadVerse(string _name, int _chap, int _verse) { // load specific verse RTB1.Clear(); RTB1.SelectionFont = new Font(RTB1.Font.FontFamily, 14, FontStyle.Bold); RTB1.AppendText("Name: " + _name + Environment.NewLine + "Chapter: " + _chap.ToString() + Environment.NewLine); RTB1.AppendText("______________________________________" + Environment.NewLine); RTB1.SelectionFont = new Font(RTB1.Font.FontFamily, RTB1.Font.Size, FontStyle.Bold); RTB1.SelectionFont = new Font(RTB1.Font.FontFamily, RTB1.Font.Size, FontStyle.Regular); RTB1.AppendText("Verse " + _verse.ToString() + " : " + controller.GetVerse(_name, _chap, _verse)); }
//Просмотреть код файла, потом ликвидировать private void SendButton01_Click(object sender, EventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); if (dialog.ShowDialog() == DialogResult.OK) { a = File.ReadAllBytes(dialog.FileName); for (int i = 0; i < a.Length; i++) { RTB1.AppendText(Convert.ToString(a[i] + " ")); } } }
private void searchBTN_Click(object sender, EventArgs e) { RTB1.SelectAll(); RTB1.SelectionBackColor = Color.White; RTB1.DeselectAll(); RTB1.Update(); string srcText = searchText.Text.Trim(); if (!"".Equals(srcText)) { HighlightWords(srcText); } }
private void TVQuestions_BeforeSelect(object sender, TreeViewCancelEventArgs e) { RTBText.Clear(); CB1.Checked = CB2.Checked = CB3.Checked = CB4.Checked = false; RTB1.Clear(); RTB2.Clear(); RTB3.Clear(); RTB4.Clear(); if (TVQuestions.SelectedNode != null) { TVQuestions.SelectedNode.BackColor = Color.Transparent; TVQuestions.SelectedNode.ForeColor = SystemColors.ControlText; } }
// change RichTextBox font private void fontToolStripMenuItem_Click(object sender, EventArgs e) { fontDialog1.Font = RTB1.Font; if (fontDialog1.ShowDialog() == DialogResult.OK) { // set new font RTB1.Font = fontDialog1.Font; Properties.Settings.Default.font = RTB1.Font; Properties.Settings.Default.Save(); bookComboBox.PerformClick(); RTB1.Update(); itemChanged(); } }
private void itemChanged() { if (selectedItem == null || selectedItem.Equals("")) { return; } string bookName; int chapter; int verse; string[] sArr = selectedItem.Split(':'); bookName = sArr[0]; chapter = int.Parse(sArr[1]); verse = int.Parse(sArr[2]); string bookPath = Properties.Settings.Default.JSONBiblePath; bookPath += controller.GetBookPath(bookName); bookTitle = bookName; RTB1.Text = bookPath; if (verseRB.Checked) { // load verse LoadVerse(bookName, chapter, verse); } else { // load book LoadChapters(bookPath); } //!currentBook.Equals(bookName) && if (!isHighlighted) { HighlightWords(searchText.Text.Trim()); currentBook = bookName; isHighlighted = true; } if (chapterRB.Checked) { string srchT = chapter.ToString() + ":" + verse.ToString(); int idx = RTB1.Find(srchT, 0, RTB1.Text.Length, RichTextBoxFinds.WholeWord); RTB1.ScrollToCaret(); } }
// load and format chapter text private void LoadChapters(string bookPath) { RTB1.Clear(); if (Properties.Settings.Default.font != null) { RTB1.Font = Properties.Settings.Default.font; } int chapter; int oldchapter = 0; try { // load chapters from {book}.json file texts = controller.GetChapters(bookPath); RTB1.SelectionFont = new Font(RTB1.Font.FontFamily, 14, FontStyle.Bold); RTB1.AppendText("Book: " + controller.GetBookTitle(bookTitle) + Environment.NewLine + Environment.NewLine); foreach (BookText text in texts) { chapter = text.chapter; if (chapter > oldchapter) { RTB1.SelectionFont = new Font(RTB1.Font.FontFamily, 14, FontStyle.Bold); RTB1.AppendText("Chapter: " + text.chapter.ToString() + Environment.NewLine); RTB1.AppendText("______________________________________" + Environment.NewLine); } RTB1.SelectionFont = new Font(RTB1.Font.FontFamily, RTB1.Font.Size, FontStyle.Bold); RTB1.AppendText(text.chapter.ToString() + ":" + text.verse.ToString()); RTB1.SelectionFont = new Font(RTB1.Font.FontFamily, RTB1.Font.Size, FontStyle.Regular); RTB1.AppendText("\t" + text.text + Environment.NewLine + Environment.NewLine); oldchapter = text.chapter; } }catch (Exception ex) { MessageBox.Show(bookPath + Environment.NewLine + ex.Message, bookTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void HighlightWords(string words) { StatusWin swin = new StatusWin(); swin.setLabel("Locating"); swin.Show(); swin.setVal(0); Application.DoEvents(); RTB1.SelectionStart = 0; RTB1.SelectionLength = 0; RTB1.ScrollToCaret(); int startSearch = 0; // bool first = true; int index = -1; int incr = 0; int matches = 0; // Search text in RichTextBox and highlight them with color. while ((index = RTB1.Find(words, startSearch, RichTextBoxFinds.None)) > -1) { matches++; slabel1.Text = "Matches = " + matches.ToString(); RTB1.SelectionBackColor = Color.GreenYellow; // Continue after the one we searched startSearch = index + 1; incr += 1; swin.setVal(incr); Application.DoEvents(); } swin.Close(); }