LED广告预览效果
来源:互联网 发布:js字符串双引号转义 编辑:程序博客网 时间:2024/04/28 06:27
自己写的LED广告预览~
namespace TaxiADSystem
{
partial class ADPreviewForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label_back = new DevExpress.XtraEditors.LabelControl();
this.panelControl1 = new DevExpress.XtraEditors.PanelControl();
this.panelControl2 = new DevExpress.XtraEditors.PanelControl();
this.labelControl1 = new DevExpress.XtraEditors.LabelControl();
this.panelControl3 = new DevExpress.XtraEditors.PanelControl();
this.Memo_top = new DevExpress.XtraEditors.MemoEdit();
this.label_font = new DevExpress.XtraEditors.LabelControl();
this.panelControl4 = new DevExpress.XtraEditors.PanelControl();
((System.ComponentModel.ISupportInitialize)(this.panelControl1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.panelControl2)).BeginInit();
this.panelControl2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.panelControl3)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.Memo_top.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.panelControl4)).BeginInit();
this.SuspendLayout();
//
// label_back
//
this.label_back.Appearance.BackColor = System.Drawing.Color.Black;
this.label_back.Appearance.Font = new System.Drawing.Font("Tahoma", 40F);
this.label_back.Appearance.ForeColor = System.Drawing.Color.Red;
this.label_back.AutoSizeMode = DevExpress.XtraEditors.LabelAutoSizeMode.None;
this.label_back.Location = new System.Drawing.Point(29, 63);
this.label_back.Name = "label_back";
this.label_back.Size = new System.Drawing.Size(486, 80);
this.label_back.TabIndex = 1;
//
// panelControl1
//
this.panelControl1.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
this.panelControl1.Location = new System.Drawing.Point(-40, 143);
this.panelControl1.Name = "panelControl1";
this.panelControl1.Size = new System.Drawing.Size(670, 232);
this.panelControl1.TabIndex = 4;
//
// panelControl2
//
this.panelControl2.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
this.panelControl2.Controls.Add(this.labelControl1);
this.panelControl2.Location = new System.Drawing.Point(16, -81);
this.panelControl2.Name = "panelControl2";
this.panelControl2.Size = new System.Drawing.Size(534, 144);
this.panelControl2.TabIndex = 5;
//
// labelControl1
//
this.labelControl1.Appearance.Font = new System.Drawing.Font("Tahoma", 20F);
this.labelControl1.Appearance.ForeColor = System.Drawing.Color.Purple;
this.labelControl1.Location = new System.Drawing.Point(165, 97);
this.labelControl1.Name = "labelControl1";
this.labelControl1.Size = new System.Drawing.Size(162, 33);
this.labelControl1.TabIndex = 0;
this.labelControl1.Text = "模拟显示效果";
//
// panelControl3
//
this.panelControl3.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
this.panelControl3.Location = new System.Drawing.Point(515, 34);
this.panelControl3.Name = "panelControl3";
this.panelControl3.Size = new System.Drawing.Size(49, 129);
this.panelControl3.TabIndex = 6;
//
// Memo_top
//
this.Memo_top.EditValue = "wwzswwww趋利七八\r\ne巧伪趋利123122\r\nqweou3o1233333\r\n44444444444444\r\n5555555555555\r\n6666666" +
"66666666\r\n77777777777777";
this.Memo_top.Location = new System.Drawing.Point(27, -436);
this.Memo_top.Name = "Memo_top";
this.Memo_top.Properties.AllowFocused = false;
this.Memo_top.Properties.Appearance.BackColor = System.Drawing.Color.Black;
this.Memo_top.Properties.Appearance.Font = new System.Drawing.Font("Tahoma", 38F);
this.Memo_top.Properties.Appearance.ForeColor = System.Drawing.Color.Red;
this.Memo_top.Properties.Appearance.Options.UseBackColor = true;
this.Memo_top.Properties.Appearance.Options.UseFont = true;
this.Memo_top.Properties.Appearance.Options.UseForeColor = true;
this.Memo_top.Properties.Appearance.Options.UseTextOptions = true;
this.Memo_top.Properties.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Near;
this.Memo_top.Properties.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
this.Memo_top.Properties.ReadOnly = true;
this.Memo_top.Properties.ScrollBars = System.Windows.Forms.ScrollBars.None;
this.Memo_top.Size = new System.Drawing.Size(482, 496);
this.Memo_top.TabIndex = 15;
//
// label_font
//
this.label_font.Appearance.BackColor = System.Drawing.Color.Black;
this.label_font.Appearance.Font = new System.Drawing.Font("Tahoma", 40F);
this.label_font.Appearance.ForeColor = System.Drawing.Color.Red;
this.label_font.AutoSizeMode = DevExpress.XtraEditors.LabelAutoSizeMode.None;
this.label_font.Location = new System.Drawing.Point(28, -22);
this.label_font.Name = "label_font";
this.label_font.Size = new System.Drawing.Size(486, 80);
this.label_font.TabIndex = 16;
this.label_font.Text = "label_font";
//
// panelControl4
//
this.panelControl4.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
this.panelControl4.Location = new System.Drawing.Point(-20, 34);
this.panelControl4.Name = "panelControl4";
this.panelControl4.Size = new System.Drawing.Size(49, 129);
this.panelControl4.TabIndex = 7;
//
// ADPreviewForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 14F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(543, 169);
this.Controls.Add(this.panelControl2);
this.Controls.Add(this.panelControl1);
this.Controls.Add(this.panelControl3);
this.Controls.Add(this.panelControl4);
this.Controls.Add(this.label_font);
this.Controls.Add(this.Memo_top);
this.Controls.Add(this.label_back);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "ADPreviewForm";
this.Opacity = 0.86D;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "ADPreviewForm";
this.Load += new System.EventHandler(this.ADPreviewForm_Load);
((System.ComponentModel.ISupportInitialize)(this.panelControl1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.panelControl2)).EndInit();
this.panelControl2.ResumeLayout(false);
this.panelControl2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.panelControl3)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.Memo_top.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.panelControl4)).EndInit();
this.ResumeLayout(false);
}
#endregion
private DevExpress.XtraEditors.LabelControl label_back;
private DevExpress.XtraEditors.PanelControl panelControl1;
private DevExpress.XtraEditors.PanelControl panelControl2;
private DevExpress.XtraEditors.MemoEdit Memo_top;
private DevExpress.XtraEditors.LabelControl labelControl1;
private DevExpress.XtraEditors.PanelControl panelControl3;
private DevExpress.XtraEditors.LabelControl label_font;
private DevExpress.XtraEditors.PanelControl panelControl4;
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.Utils;
using DevExpress.XtraEditors;
using System.Text.RegularExpressions;
namespace TaxiADSystem
{
public partial class ADPreviewForm : DevExpress.XtraEditors.XtraForm
{
public ADPreviewForm()
{
InitializeComponent();
}
private int _ledlength;
private int _effect;
private int _rollspeed; 滚动速度
private int _staytime; 停留时间
private string _content; 广告内容
private string _contentclone;
private int _contentlength; 广告长度
readonly Timer _timer1 = new Timer();
readonly Timer _timer2 = new Timer();
private Point _pointTop;
private Point _pointBottom;
public ADPreviewForm(int effect,int rollspeed,int staytime,string content)
{
InitializeComponent();
_effect = effect;
_rollspeed = rollspeed;
_staytime = staytime;
_content = content;
_contentclone = content;
_ledlength = 16;
foreach (char c in content)
{
// 判断是否为汉字
if (Regex.IsMatch(c.ToString(), @"^[\u4e00-\u9fa5]+$") == true)
{
_contentlength++;
_contentlength++;
}
else _contentlength++;
}
_pointTop = new Point(label_back.Location.X,
label_back.Location.Y - label_back.Height);
_pointBottom = new Point(label_back.Location.X,
label_back.Location.Y+label_back.Height);
DisplayEffect();
}
private void ADPreviewForm_Load(object sender, EventArgs e)
{
}
private void DisplayEffect( )
{
if (_effect == 0)//翻页
{
_timer1.Tick += Flip;
_timer1.Enabled = true;
_timer1.Start();
}
else if(_effect ==1)//上覆盖
{
label_font.Location = _pointBottom;
label_font.Text = ShowingString();
_timer1.Tick += UpCover;
_timer1.Enabled = true;
_timer1.Start();
}
else if(_effect ==2)//下覆盖
{
label_font.Location = _pointTop;
label_font.Text = ShowingString();
_timer1.Tick += DownCover;
_timer1.Enabled = true;
_timer1.Start();
}
else if(_effect==3) // 左覆盖
{
label_font.Location = new Point(label_back.Location.X + label_back.Width,
label_back.Location.Y);
label_font.Text = ShowingString();
_timer1.Tick += LeftCover;
_timer1.Enabled = true;
_timer1.Start();
}
else if (_effect == 4) // 右覆盖
{
label_back.Appearance.TextOptions.HAlignment = HorzAlignment.Far;
label_font.Location = new Point(label_back.Location.X - label_back.Width,
label_back.Location.Y);
label_font.Text = ShowingString();
string strTurn = "";
for (int i = label_font.Text.Length - 1; i >= 0; i--)
{
strTurn += label_font.Text[i];
}
label_font.Text = strTurn;
label_font.Appearance.TextOptions.HAlignment = HorzAlignment.Far;
_timer1.Tick += RightCover;
_timer1.Enabled = true;
_timer1.Start();
}
else if (_effect == 5)//向上移动
{
this.Opacity = 100;
string contentTurn = "";
//计算出广告字符长度能够显示多少行广告
int rows = int.Parse(Math.Ceiling((double)_contentlength / _ledlength).ToString());
//将广告按每行显示的长度划分后 反向排列
string[] s = new string[rows];
for (int i = 0; i < rows; i++)
{
contentTurn += ShowingString();
contentTurn += "\r\n";
}
//根据光谷行数缩小Memo_top控件的高度 默认Memo_top默认高度为496 显示7行数据
Memo_top.Size = new Size(Memo_top.Size.Width, Memo_top.Size.Height - 70 * (7 - rows));
Memo_top.Text = contentTurn;
Memo_top.Location = new Point(Memo_top.Location.X, _pointBottom.Y);
_timer1.Tick += UpMoving;
_timer1.Enabled = true;
_timer1.Interval = 50 / _rollspeed;
_timer1.Start();
}
else if (_effect == 6)//向下移动
{
this.Opacity = 100;
string contentTurn = "";
//计算出广告字符长度能够显示多少行广告
int rows = int.Parse(Math.Ceiling((double)_contentlength / _ledlength).ToString());
//算出最后一行广告(反向排列后为第一行)缺少多少个字符补满
int lack = _ledlength - _contentlength % _ledlength;
string strEmp = "";
for (int i = 0; i < lack; i++)
{
strEmp += " ";
}
//将广告按每行显示的长度划分后 反向排列
string[] s = new string[rows];
for (int i = rows - 1; i >= 0; i--)
{
s[i] = ShowingString();
}
s[0] += strEmp;
//将数组中的广告重新组合为新字符串
for (int i = 0; i < rows; i++)
{
contentTurn += s[i];
contentTurn += "\r\n";
}
//根据光谷行数缩小Memo_top控件的高度 默认Memo_top默认高度为410 显示7行数据
Memo_top.Size = new Size(Memo_top.Size.Width, Memo_top.Size.Height - 58 * (7 - rows));
Memo_top.Text = contentTurn;
Memo_top.Location = new Point(Memo_top.Location.X, label_back.Location.Y - Memo_top.Height);
_timer1.Tick += DownMoving;
_timer1.Enabled = true;
_timer1.Interval = 50 / _rollspeed;
_timer1.Start();
}
else if (_effect == 7)//向左移动
{
for (int i = 0; i < _ledlength; i++)
{
_content = _content.Insert(0, " ");
}
label_back.Text = _content;
_timer1.Tick += LeftMoving;
_timer1.Enabled = true;
_timer1.Interval = 1000 / _rollspeed;
_timer1.Start();
}
else if (_effect == 8) // 向右移动
{
label_back.Appearance.TextOptions.HAlignment = HorzAlignment.Far;
string contentTurn = "";
for (int i = _content.Length - 1; i >= 0; i--)
{
contentTurn += _content[i];
}
for (int i = 0; i < _ledlength; i++)
{
contentTurn = contentTurn + " ";
}
_content = contentTurn;
label_back.Text = _content;
_timer1.Tick += RighttMoving;
_timer1.Enabled = true;
_timer1.Start();
}
else if (_effect == 9) // 垂直百叶窗
{
label_font.Location = new Point(label_back.Location.X,
label_back.Location.Y+label_back.Height/2) ;
label_font.Text = ShowingString();
label_font.Size = new Size(label_font.Width,0);
_timer1.Tick += Blinds;
_timer1.Enabled = true;
_timer1.Start();
}
else if (_effect == 10)//闪烁
{
_timer1.Tick += Flip;
_timer1.Enabled = true;
_timer1.Start();
//闪烁效果
_timer2.Tick += Glisten;
_timer2.Enabled = true;
_timer2.Start();
}
}
private void Blinds(object sender, EventArgs eventArgs) //垂直百叶窗
{
_timer1.Interval = 100/(_rollspeed+1);
if(label_font.Text.Length>0)
{
if (label_font.Location.Y > label_back.Location.Y)
{
_timer1.Interval = 100 / (_rollspeed + 1);
label_font.Size = new Size(label_font.Size.Width, label_font.Size.Height+2);
label_font.Location = new Point(label_back.Location.X,label_font.Location.Y-1);
}
else
{
label_font.Location = new Point(label_back.Location.X,
label_back.Location.Y + label_back.Height / 2 +1);
label_back.Text = label_font.Text;
label_font.Text = ShowingString();
label_font.Size = new Size(label_font.Width, 0);
_timer1.Interval = 500 * _staytime;
}
}
else
{
Close();
}
}
private void Glisten(object sender, EventArgs eventArgs) //闪烁
{
_timer2.Interval = 400;
if (label_back.ForeColor == Color.Red)
{
label_back.ForeColor = Color.Yellow;
}
else
{
label_back.ForeColor = Color.Red;
}
}
private void Flip(object sender, EventArgs eventArgs) //翻页
{
_timer1.Interval = _staytime * 500;
if (_contentlength >= 0)
{
label_back.Text = ShowingString();
if (_contentlength == 0)
_contentlength = -1;
}
else
Close();
}
private void UpCover(object sender, EventArgs eventArgs) //向上覆盖
{
_timer1.Interval = 10 / (_rollspeed + 1);
if (label_font.Text.Length > 0)
{
if (label_font.Location.Y > label_back.Location.Y)
{
_timer1.Interval = 10 / (_rollspeed + 1);
label_font.Location = new Point(label_font.Location.X,
label_font.Location.Y-1);
}
else
{
_timer1.Interval = _staytime * 300;
label_back.Text = label_font.Text;
label_font.Text = ShowingString();
label_font.Location = _pointBottom;
}
}
else Close();
}
private void DownCover(object sender, EventArgs eventArgs) //向下覆盖
{
_timer1.Interval = 10 / (_rollspeed + 1);
if (label_font.Text.Length > 0)
{
if (label_font.Location.Y < label_back.Location.Y)
{
_timer1.Interval = 10 / (_rollspeed + 1);
label_font.Location = new Point(label_font.Location.X,
label_font.Location.Y + 1);
}
else
{
_timer1.Interval = _staytime * 300;
label_back.Text = label_font.Text;
label_font.Text = ShowingString();
label_font.Location = _pointTop;
}
}
else Close();
}
private void LeftCover(object sender, EventArgs eventArgs) //左覆盖
{
_timer1.Interval = 10 / (_rollspeed + 1);
if (label_font.Text.Length > 0)
{
if (label_font.Location.X > label_back.Location.X)
{
_timer1.Interval = 10 / (_rollspeed + 1);
label_font.Location = new Point(label_font.Location.X - 2,
label_font.Location.Y);
}
else
{
_timer1.Interval = _staytime * 300;
label_back.Text = label_font.Text;
label_font.Text = ShowingString();
label_font.Location = new Point(label_back.Location.X + label_back.Width,
label_back.Location.Y);
}
}
else Close();
}
private void RightCover(object sender, EventArgs eventArgs) //右覆盖
{
_timer1.Interval = 10 / (_rollspeed + 1);
if (label_font.Text.Length > 0)
{
if (label_font.Location.X < label_back.Location.X)
{
_timer1.Interval = 10 / (_rollspeed + 1);
label_font.Location = new Point(label_font.Location.X + 2,
label_font.Location.Y);
}
else
{
_timer1.Interval = _staytime * 300;
label_back.Text = label_font.Text;
label_font.Text = ShowingString();
string strTurn = "";
for (int i = label_font.Text.Length-1; i>= 0; i--)
{
strTurn += label_font.Text[i];
}
label_font.Text = strTurn;
label_font.Location = new Point(label_back.Location.X - label_back.Width,
label_back.Location.Y);
}
}
else Close();
}
private string ShowingString() //返回当前_content的前16位置的字符 并将这些字符从_content中删除
{
if (_contentlength > _ledlength)
{
int i = 0;
int j = 0;
foreach (char c in _content)
{
if (i < _ledlength)
{
j++;
if (Regex.IsMatch(c.ToString(), @"^[\u4e00-\u9fa5]+$") == true)
{
i = i + 2;
}
else i++;
}
}
string s1 = _content.Substring(0, j);
_content = _content.Substring(j);
_contentlength = _contentlength - i;
return s1;
}
string s2 = _content;
_content = "";
_contentlength = 0;
return s2;
}
private void UpMoving(object sender, EventArgs eventArgs) //向上移动
{
if (Memo_top.Location.Y > label_back.Location.Y-Memo_top.Height)
{
label_back.Focus();
Memo_top.Location = new Point(Memo_top.Location.X, Memo_top.Location.Y - 1);
}
else Close();
}
private void DownMoving(object sender, EventArgs eventArgs) //向下移动
{
if (Memo_top.Location.Y <_pointBottom.Y)
{
label_back.Focus();
Memo_top.Location =new Point(Memo_top.Location.X,Memo_top.Location.Y+1);
}
else Close();
}
private void LeftMoving(object sender, EventArgs eventArgs) //向左移动
{
if (_content.Length > 0)
{
_content = _content.Substring(1);
label_back.Text = _content;
}
else
Close();
}
private void RighttMoving(object sender, EventArgs eventArgs) //向右移动
{
_timer1.Interval = 1000 / _rollspeed;
if (_content.Length > 0)
{
_content = _content.Remove(_content.Length-1);
label_back.Text = _content;
}
else
Close();
}
private void simpleButton_play_Click_1(object sender, EventArgs e)
{
_timer1.Dispose();
_content = _contentclone;
DisplayEffect();
}
}
}
- LED广告预览效果
- LED广告屏
- 广告效果
- LED跑马灯效果
- 效果预览代码
- 预览图ajax效果
- 图片上传预览效果
- 上传图片 预览效果
- 上传图片 预览效果
- JavaScript 图片预览效果
- JavaScript 图片预览效果
- JavaScript 图片预览效果
- JavaScript 图片预览效果
- JavaScript 图片预览效果
- JavaScript 图片预览效果
- js图片预览效果
- U3Ditween easetype 效果预览
- HTML 幻灯片预览效果
- 中国著名的傍名牌
- 嵌入式学习步骤
- [转]如何生成swc库文件
- Android编译过程详解
- Javascript技巧几则
- LED广告预览效果
- 得到数据库的类型以及版本
- 802.11n来龙去脉
- SQL server2000安装图解
- web.config 配置
- 如何:在 Visual Studio 中添加或移除引用自己的程序集
- flash 3D 学习资料收集
- Python编码时应该注意的一些事情
- 查看数据库的最大连接数和字符集