private void richTextBox1_MouseMove(object sender, MouseEventArgs e) { int index = richTextBox1.GetCharIndexFromPosition(e.Location); if (previousIndex == index) { return; } int selectStart = richTextBox1.SelectionStart, selectLength = richTextBox1.SelectionLength; if (previousIndex != -1) { richTextBox1.Select(previousIndex, 1); richTextBox1.SelectionColor = Color.Black; } richTextBox1.Select(index, 1); richTextBox1.SelectionColor = Color.DarkOrange; previousIndex = index; richTextBox1.Select(selectStart, selectLength); Chat.Invalidate(); }
private void richTextBox1_MouseLeave(object sender, EventArgs e) { if (previousIndex == -1) { return; } int selectStart = richTextBox1.SelectionStart, selectLength = richTextBox1.SelectionLength; richTextBox1.Select(previousIndex, 1); richTextBox1.SelectionColor = Color.Black; richTextBox1.Select(selectStart, selectLength); previousIndex = -1; Chat.Invalidate(); }
private void button1_Click_1(object sender, EventArgs e) { cg.UpdateScreen(); Bitmap chatbox = cg.Capture.CloneAsBitmap(Rectangles.LOBBY_CHATBOX); using (Graphics g = Graphics.FromImage(chatbox)) { g.InterpolationMode = InterpolationMode.NearestNeighbor; } if (this.Chatbox != null) { this.Chatbox.Dispose(); } this.Chatbox = chatbox; Chat.Invalidate(); }
private void pictureBox1_MouseMove(object sender, MouseEventArgs e) { if (Chatbox == null) { return; } Point selectLocation = ContainerToChatbox(e.Location); selectLocation.Offset(1, 0); selectLocation.X = Math.Min(Math.Max(selectLocation.X, 0), Chatbox.Width); selectLocation.Y = Math.Min(Math.Max(selectLocation.Y, 0), Chatbox.Height); cursorLocation.Text = $"{selectLocation.X}, {selectLocation.Y}. Line location: {SetLineRect.Y}"; if (!SetLineMode) { if (e.Button != MouseButtons.Left) { return; } SelectRect.Location = new Point( Math.Min(SelectStartPoint.X, selectLocation.X), Math.Min(SelectStartPoint.Y, selectLocation.Y)); SelectRect.Size = new Size( Math.Abs(SelectStartPoint.X - selectLocation.X), Math.Abs(SelectStartPoint.Y - selectLocation.Y)); Chat.Invalidate(); } else { SetLineRect = new Rectangle(0, selectLocation.Y, Chat.Width, 1); Chat.Invalidate(); } }