WinForm完成仿視頻播放器左下角轉動消息後果的辦法。本站提示廣大學習愛好者:(WinForm完成仿視頻播放器左下角轉動消息後果的辦法)文章只能為提供參考,不一定能成為您想要的結果。以下是WinForm完成仿視頻播放器左下角轉動消息後果的辦法正文
本文實例講述了WinForm完成仿視頻播放器左下角轉動消息後果的辦法。分享給年夜家供年夜家參考。詳細完成辦法以下:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Drawing.Imaging; using System.IO; using System.Xml.Linq; namespace App { public partial class Form7 : Form { private int Index { get; set; } private DataTable dataTable { get; set; } private System.Timers.Timer timer { get; set; } public Form7() { InitializeComponent(); dataTable = new DataTable(); dataTable.Columns.AddRange(new DataColumn[] { new DataColumn("Id",typeof(System.Int32)), new DataColumn("DisplayName",typeof(System.String)), new DataColumn("URL",typeof(System.String)) }); DataRow row = dataTable.NewRow(); row["Id"] = 1; row["DisplayName"] = "百度百科迎接你!"; row["URL"] = "http://www.百度.com"; dataTable.Rows.Add(row); row = dataTable.NewRow(); row["Id"] = 2; row["DisplayName"] = "劉XX明星曾經現身搜狐網站,趕緊去圍不雅!"; row["URL"] = "http://www.sohu.com"; dataTable.Rows.Add(row); row = dataTable.NewRow(); row["Id"] = 3; row["DisplayName"] = "新浪消息湧現嚴重消息,點我疾速檢查!"; row["URL"] = "http://www.sina.com.cn"; dataTable.Rows.Add(row); row = dataTable.NewRow(); row["Id"] = 4; row["DisplayName"] = "網易客戶端湧現新版本啦,趕緊去體驗把!"; row["URL"] = "http://www.126.com"; dataTable.Rows.Add(row); label1.Text = lblContent.Top.ToString(); timer = new System.Timers.Timer(2000); timer.Elapsed += delegate { CharsMouse(); }; timer.Start(); button1.Click += delegate { CharsMouse(); }; button2.Click += delegate { timer.Dispose(); }; lblContent.LinkClicked += delegate { label2.Text = dataTable.Rows[Index]["URL"].ToString(); }; } void CharsMouse() { this.lblContent.Invoke(new MethodInvoker(delegate { if (Index >= dataTable.Rows.Count) Index = 0; while (lblContent.Top > -lblContent.Height) { lblContent.Top = lblContent.Top - 2; label1.Text = "1.Top=" + lblContent.Top.ToString(); System.Threading.Thread.Sleep(100); Application.DoEvents(); } lblContent.Text = dataTable.Rows[Index]["DisplayName"].ToString(); lblContent.Top = 2; timer.Enabled = false; Application.DoEvents(); System.Threading.Thread.Sleep(2000); timer.Enabled = true; Index++; })); } } }
願望本文所述對年夜家的C#法式設計有所贊助。