winform下一个编辑框
1,实现gif动画显示 类似qq 输入框(目前用的 能显示jpg,gif显示的是第一帧的richtextbox)
2,有没有牛叉(高效率)的代码高亮的 编辑框,最好是继承自richtextbox(现在着色用的 select ,那个效率啊!)
3,想要个 把 1,2功能 给 和起来 控件 过几天还会散分的
1,实现gif动画显示 类似qq 输入框(目前用的 能显示jpg,gif显示的是第一帧的richtextbox)
2,有没有牛叉(高效率)的代码高亮的 编辑框,最好是继承自richtextbox(现在着色用的 select ,那个效率啊!)
3,想要个 把 1,2功能 给 和起来 控件 过几天还会散分的
http://www.codeproject.com/KB/edit/MyExtRichTextBox.aspxhttp://stackoverflow.com/questions/165735/how-do-you-show-animated-gifs-on-a-windows-form-c
位置不好确定
而且不像是 嵌在文本里面
using System.Windows.Forms;
using System.Drawing;namespace WindowsFormsApplication1
{
class MyGifBox : Control
{
Image img;
string path;
public string Path
{
get { return path; }
set { path = value; UpdatePath(); }
} public MyGifBox() : base() { }
public MyGifBox(string src)
: base()
{
Path = src;
} void UpdatePath()
{
img = Bitmap.FromFile(path);
if (img != null)
{
this.Width = img.Width;
this.Height = img.Height;
}
} bool currentlyAnimating = false; public void AnimateImage()
{
if (!currentlyAnimating)
{
ImageAnimator.Animate(img, new EventHandler(this.OnFrameChanged));
currentlyAnimating = true;
}
} private void OnFrameChanged(object o, EventArgs e)
{
Invalidate();
} protected override void OnPaint(PaintEventArgs e)
{
if (img == null)
return;
AnimateImage();
ImageAnimator.UpdateFrames();
e.Graphics.DrawImage(img, new Point(0, 0));
}
}
}接下来把这个控件插入到刚才那个扩展的RichTextBox中,如下 private void Form1_Shown(object sender, EventArgs e)
{
for (int i = 0; i < 10; i++)
myExtRichTextBox1.InsertControl(new MyGifBox(@"E:\My Documents\My Pictures\39.gif"));
}
大功告成!当然期待高人们想一些更好的方法!我感觉我这个方法效率上不怎么高,欠缺很多优化。