private void contentchap_MouseDown(object sender, MouseEventArgs e) { if (!string.IsNullOrWhiteSpace(contentchap.Text)) { //get index of nearest character var index = contentchap.GetCharIndexFromPosition(e.Location); //check if mouse is above a word (non-whitespace character) if (!Controller.Rhythm.isSeparator(contentchap.Text[index])) { var start = index; while (start > 0 && !Controller.Rhythm.isSeparator(contentchap.Text[start - 1])) { start--; } var end = index; while (end < contentchap.Text.Length - 1 && !Controller.Rhythm.isSeparator(contentchap.Text[end + 1])) { end++; } string strHover = contentchap.Text.Substring(start, end - start + 1); long tryparse; if (!Int64.TryParse(strHover, out tryparse)) { if (!strHover.Equals(string.Empty) && !Controller.MyRule.IsValid(strHover)) { DialogResult dialogResult; switch (e.Button) { case MouseButtons.Right: dialogResult = MessageBox.Show("Bạn có muốn xóa từ này không?", "", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { MessageBox.Show("Đã xóa từ"); } break; case MouseButtons.Left: dialogResult = MessageBox.Show("Bạn có muốn sửa từ này không?", "", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { Form form = new EditErrorWord(idt, idh, start, end, contentchap.Text, strHover); DialogResult result = form.ShowDialog(this); if (result == DialogResult.OK) { Model.Chapter chap = (Model.Chapter)listchap.SelectedItem; chap.content = Model.MyDatabase.getContentChap(idh); contentchap.Text = chap.content.Replace("\r\n", "\n"); MarkWrongRhythm(); contentchap.Select(start, end - start + 1); } } break; } } } } } }
/// <summary> /// perform download item /// </summary> /// <param name="chapter"></param> public void Download(Model.Chapter chapter) { try { this.Chapter = chapter; this.browser.Navigate(this.Chapter.URL); } catch (Exception) { throw; } }
private void listchap_SelectedIndexChanged(object sender, EventArgs e) { Model.Chapter chap = (Model.Chapter)listchap.SelectedItem; idh = chap.idh; lbChapName.Text = chap.name; contentchap.Text = " " + chap.content.Replace("\r\n", "\n "); MarkWrongRhythm(); //contentchap.SelectionStart = 0; //contentchap.SelectionIndent = 100; //contentchap.SelectionHangingIndent = -70; //contentchap.SelectionRightIndent = 30; }
public void SelectChap() { Model.Chapter chap = null; listchap.Invoke((MethodInvoker) delegate() { chap = (Model.Chapter)listchap.SelectedItem; chapautoscroll = listchap.SelectedIndex; }); if (chap != null) { idh = chap.idh; contentchap.Invoke((MethodInvoker) delegate() { contentchap.Text = chap.content; // contentchap.Text = "kien kiem trumg lung ling lang lieng tuing taing yen yến yên yện yển"; }); MarkWrongRhythm(posautoscroll, poslen); posautoscroll = 0; poslen = 0; } }