📄 sourcecodechildform.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace PLX
{
public partial class SourceCodeChildForm : Form
{
public SourceCodeChildForm()
{
InitializeComponent();
}
private void rtxtSourceCode_KeyPress(object sender, KeyPressEventArgs e)
{
//判读回车符,增加行号
if (e.KeyChar == 13)
{
ChangeLineNum();
}
//判断Delete,Backspace,减少行号
if (e.KeyChar == 46 || e.KeyChar == 8)
{
ChangeLineNum();
}
}
private void ChangeLineNum()
{
//Get first LineNum of current textbox
Point pos = new Point(0,rtxtSourceCode.Font.Height);
int firstIndex = rtxtSourceCode.GetCharIndexFromPosition(pos);
int firstLineNum = rtxtSourceCode.GetLineFromCharIndex(firstIndex) + 1;
//Get last lineNum of current textbox
pos.X = ClientRectangle.Width;
pos.Y = ClientRectangle.Height;
int lastIndex = rtxtSourceCode.GetCharIndexFromPosition(pos);
int lastLineNum = rtxtSourceCode.GetLineFromCharIndex(lastIndex) + 1;
Form1.BuildLineNum(firstLineNum , lastLineNum);
}
private void rtxtSourceCode_TextChanged(object sender, EventArgs e)
{
ChangeLineNum();
}
private void rtxtSourceCode_VScroll(object sender, EventArgs e)
{
ChangeLineNum();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -