.net C# 改变VS2005中屏保,实现字幕滚动和字体消隐技术
来源:互联网 发布:靠谱助手网络连接失败 编辑:程序博客网 时间:2024/05/16 01:03
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace test
...{
public partial class Form1 : Form
...{
public Form1()
...{
InitializeComponent();
}
private int textAlpha = 0;
private int textAlphaDelta = 4;
private int textAlphaMax = 251;
private void Form1_Paint(object sender, PaintEventArgs e)
...{
// 更改图形设置以绘制清晰的文本
e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
// 确定位于文本上方和下方的
// 线条的位置
float lineLeftX = Size.Width / 4;
float lineRightX = 3 * Size.Width / 4;
int lineVerticalBuffer = Size.Height / 50;
float lineTopY = Location.Y + lineVerticalBuffer;
float lineBottomY = Location.Y + Size.Height - lineVerticalBuffer;
// 绘制文章的文本
using (StringFormat textFormat = new StringFormat(StringFormatFlags.LineLimit))
...{
textFormat.Alignment = StringAlignment.Near;
textFormat.LineAlignment = StringAlignment.Near;
textFormat.Trimming = StringTrimming.EllipsisWord;
int textVerticalBuffer = 4 * lineVerticalBuffer;
//Rectangle textRect = new Rectangle(Location.X, Location.Y + textVerticalBuffer, Size.Width, Size.Height - (2 * textVerticalBuffer));
Rectangle textRect = new Rectangle(Location.X, textAlpha, Size.Width, Size.Height - (2 * textVerticalBuffer));
using (Brush textBrush = new SolidBrush(Color.FromArgb(textAlpha, ForeColor)))
...{
e.Graphics.DrawString("//by 闫磊 Email:Landgis@126.com,yanleigis@21cn.com 2007.10.23", this.Font, textBrush, textRect, textFormat);
}
}
}
private void timer1_Tick(object sender, EventArgs e)
...{
// 更改要绘制的文本的 alpha 值
// 逐步增加值,直至达到 textAlphaMax,然后再逐步减小值
// 当值重新为零时移动到下一文章
textAlpha += textAlphaDelta;
if (textAlpha >= textAlphaMax)
...{
textAlphaDelta *= -1;
}
else if (textAlpha <= 0)
...{
// FadingComplete(this, new EventArgs());
textAlpha = 0;
textAlphaDelta *= -1;
}
//label1.Text = textAlpha.ToString();
//label1.Refresh();
this.Refresh();
}
private void Form1_Load(object sender, EventArgs e)
...{
this.Height = 300;
this.Width = 600;
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace test
...{
public partial class Form1 : Form
...{
public Form1()
...{
InitializeComponent();
}
private int textAlpha = 0;
private int textAlphaDelta = 4;
private int textAlphaMax = 251;
private void Form1_Paint(object sender, PaintEventArgs e)
...{
// 更改图形设置以绘制清晰的文本
e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
// 确定位于文本上方和下方的
// 线条的位置
float lineLeftX = Size.Width / 4;
float lineRightX = 3 * Size.Width / 4;
int lineVerticalBuffer = Size.Height / 50;
float lineTopY = Location.Y + lineVerticalBuffer;
float lineBottomY = Location.Y + Size.Height - lineVerticalBuffer;
// 绘制文章的文本
using (StringFormat textFormat = new StringFormat(StringFormatFlags.LineLimit))
...{
textFormat.Alignment = StringAlignment.Near;
textFormat.LineAlignment = StringAlignment.Near;
textFormat.Trimming = StringTrimming.EllipsisWord;
int textVerticalBuffer = 4 * lineVerticalBuffer;
//Rectangle textRect = new Rectangle(Location.X, Location.Y + textVerticalBuffer, Size.Width, Size.Height - (2 * textVerticalBuffer));
Rectangle textRect = new Rectangle(Location.X, textAlpha, Size.Width, Size.Height - (2 * textVerticalBuffer));
using (Brush textBrush = new SolidBrush(Color.FromArgb(textAlpha, ForeColor)))
...{
e.Graphics.DrawString("//by 闫磊 Email:Landgis@126.com,yanleigis@21cn.com 2007.10.23", this.Font, textBrush, textRect, textFormat);
}
}
}
private void timer1_Tick(object sender, EventArgs e)
...{
// 更改要绘制的文本的 alpha 值
// 逐步增加值,直至达到 textAlphaMax,然后再逐步减小值
// 当值重新为零时移动到下一文章
textAlpha += textAlphaDelta;
if (textAlpha >= textAlphaMax)
...{
textAlphaDelta *= -1;
}
else if (textAlpha <= 0)
...{
// FadingComplete(this, new EventArgs());
textAlpha = 0;
textAlphaDelta *= -1;
}
//label1.Text = textAlpha.ToString();
//label1.Refresh();
this.Refresh();
}
private void Form1_Load(object sender, EventArgs e)
...{
this.Height = 300;
this.Width = 600;
}
}
}
- .net C# 改变VS2005中屏保,实现字幕滚动和字体消隐技术
- c# 滚动字幕的实现
- c# 滚动字幕的实现
- C#滚动字幕的实现
- C# 滚动字幕的实现
- 改变vs2005中代码字体的大小和颜色
- Winform实现滚动字幕
- Winform实现滚动字幕
- Android 滚动字幕实现
- Java实现滚动字幕
- Android 滚动字幕实现
- Android 滚动字幕实现
- MFC滚动字幕实现
- Qt实现滚动字幕
- c#之通过Timer控件实现字幕(label)滚动
- QT 实现在ui控件QLabel中实现滚动字幕
- C#窗体程序设计滚动字幕
- 用paint()函数实现在对话框中显示滚动字幕!
- Win Mobile利用mapirule接收短信
- Ubuntu 7.10下载列表
- Alpha颜色混合的魔法 上篇 “法术篇”
- petshop4.0 详解之二(数据访问层之数据库访问设计)(转载)
- prototype.js 1.4版开发者手册
- .net C# 改变VS2005中屏保,实现字幕滚动和字体消隐技术
- 明天开始上课!越来越难了……
- Ajax基础教程---- 1.7 设计考虑
- 最新版FreeTextBox(版本3.1.6)在ASP.Net 2.0中使用简解
- CMD命令大全
- SqlSever2005 学习笔记 (1)
- XMLHTTP---介绍
- linux export 的作用
- 1