📄 editgoto.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace jishiben
{
public delegate void gotoEventHandler(object sender, int gotocharline);
public partial class Editgoto : Form
{
public event gotoEventHandler gotol;
private int charline = 0;
private void Ongotol()
{
gotoEventHandler handler = gotol;
if (handler != null)
{
if (handler.Target is System.ComponentModel.ISynchronizeInvoke)
{
System.ComponentModel.ISynchronizeInvoke aSynch = handler.Target as System.ComponentModel.ISynchronizeInvoke;
if (aSynch.InvokeRequired)
{
object[] args = new object[] { this, charline };
aSynch.Invoke(handler, args);
}
else
{
handler(this, charline);
}
}
else
{
handler(this, charline);
}
}
else
{
MessageBox.Show("事件为空!");
}
}
public Editgoto()
{
InitializeComponent();
}
private void btnNo_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnOk_Click(object sender, EventArgs e)
{
foreach (char c in tBline.Text)
{
int i = (int)c;
if (i < 0x30 || i > 0x39)
{
MessageBox.Show("请输入正整数");
}
else
{
int gotoline = Convert.ToInt32(tBline.Text);
int maxline = jishiben.Lines.Length;
if (gotoline > 0 && gotoline <= maxline)
{
for (int j = gotoline-1; j > 0; j--)
{
//jishiben.Selects += jishiben.Lines[j].Length + 1;
charline += jishiben.Lines[j - 1].Length + 1;
Ongotol();
this.Close();
}
}
else
{
MessageBox.Show("输入数字1到" + maxline + "之间的数字");
break;
}
}
}
}
private void Editgoto_Load(object sender, EventArgs e)
{
int j = jishiben.Selects;
for (int i = 0; i < jishiben.Lines.Length;i++ )
{
j = j - (jishiben.Lines[i].Length+1);
if (j <= 0)
{
tBline.Text = (i+1).ToString();
break;
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -