“我的作品:文华”的版本间的差异
| 第23行: | 第23行: | ||
string[] lines = { "hellow world", "nihao", "line3", "line4", "line5", "end" }; | string[] lines = { "hellow world", "nihao", "line3", "line4", "line5", "end" }; | ||
int currentLine = 0; | int currentLine = 0; | ||
| + | |||
| + | ---- | ||
| + | |||
public Form1() | public Form1() | ||
| 第40行: | 第43行: | ||
} | } | ||
} | } | ||
| + | ---- | ||
| + | string[] lines;//所有文字,每行都有回车 | ||
| + | int nextLine; //下一行 | ||
| + | private void button2_Click(object sender, EventArgs e) | ||
| + | { | ||
| + | richTextBox1.Text =Resources.String1; | ||
| + | lines=richTextBox1.Lines; | ||
| + | richTextBox1.Text = ""; | ||
| + | timer1.Interval = 1000; | ||
| + | timer1.Tick += new EventHandler(timer1_Tick); | ||
| + | timer1.Start(); | ||
| + | } | ||
| + | |||
| + | void timer1_Tick(object sender, EventArgs e) | ||
| + | { | ||
| + | StringBuilder sb = new StringBuilder(richTextBox1.Text); | ||
| + | if (richTextBox1.Text != "") | ||
| + | { | ||
| + | sb.Append("\r\n"); | ||
| + | } | ||
| + | sb.Append(lines[nextLine]); //添加下一行文字 | ||
| + | richTextBox1.Text = sb.ToString(); | ||
| + | richTextBox1.Select(); | ||
| + | richTextBox1.SelectionStart = richTextBox1.Text.Length; | ||
| + | nextLine++; | ||
| + | if (nextLine >= lines.Length) | ||
| + | { | ||
| + | timer1.Enabled = false; | ||
| + | } | ||
| + | } | ||
2019年11月25日 (一) 11:15的版本
Graphics gdi(this->GetDC()->m_hDC); //构造一个GDI+对象
Pen red(Color(255,255,0,0),3); //构造一个画笔 画笔透明度是255 gdi.DrawLine(&red,10,10,50,10); //画线
FontFamily m_font(L"宋体"); Font font(&m_font,24); //构造字体 SolidBrush brush(Color(255,0,0,255)); //输出字符串要构造一个画刷 CRect rect; this->GetClientRect(&rect); //得到客户区大小 PointF point(rect.right/2,rect.bottom/2);//坐标点 gdi.DrawString(L"中华",2,&font,point,&brush);//输出字符串 ———————————————— 版权声明:本文为CSDN博主「a550853006a」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。 原文链接:https://blog.csdn.net/a550853006a/article/details/45769215
public partial class Form1 : Form {
Timer timer = new Timer();
string[] lines = { "hellow world", "nihao", "line3", "line4", "line5", "end" };
int currentLine = 0;
public Form1()
{
InitializeComponent();
timer.Interval = 300;
timer.Tick += delegate { currentLine++; this.Invalidate(); };
timer.Start();
}
protected override void OnPaint(PaintEventArgs e)
{
for (int i = 0; i < currentLine % lines.Length; i++)
{
e.Graphics.DrawString(lines[i], this.Font, Brushes.Black, 10, 20 * i);
}
}
}
string[] lines;//所有文字,每行都有回车
int nextLine; //下一行
private void button2_Click(object sender, EventArgs e)
{
richTextBox1.Text =Resources.String1;
lines=richTextBox1.Lines;
richTextBox1.Text = "";
timer1.Interval = 1000;
timer1.Tick += new EventHandler(timer1_Tick);
timer1.Start();
}
void timer1_Tick(object sender, EventArgs e)
{
StringBuilder sb = new StringBuilder(richTextBox1.Text);
if (richTextBox1.Text != "")
{
sb.Append("\r\n");
}
sb.Append(lines[nextLine]); //添加下一行文字
richTextBox1.Text = sb.ToString();
richTextBox1.Select();
richTextBox1.SelectionStart = richTextBox1.Text.Length;
nextLine++;
if (nextLine >= lines.Length)
{
timer1.Enabled = false;
}
}