الســلام عليكم جميعــاً
أحتاج لمســاعدة في تصميم وبرمجة شريط أخبار افقي كالذي يظهر في القنوات الفضائية يقرأ من ملف نصــي،
(.txt)
وطبعــاً بإستخدام لغة
C#.net
الاتي هو تطبيق لما قمت به، ولكن واجهتني مشــاكل مثل ترتيب الأحرف.
أرجو المســـاعدة ممن لديه أي فكرة عن الموضوع .
الكود الذي استخدمته هو كالاتي ( ومن لديه أي كود أخر يرجى ارساله)
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO.IsolatedStorage;
using System.IO;
using System.Configuration ;
using System.Text ;
namespace TextScroll
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private Timer timer1;
private IContainer components;
StreamReader sr;
private Label label2;
StringBuilder sb;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
Application.ExitThread();
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.components = new System.ComponentModel.Container();
this.label1 = new System.Windows.Forms.Label();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.label2 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.BackColor = System.Drawing.Color.Azure;
this.label1.Font = new System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.ForeColor = System.Drawing.Color.MidnightBlue;
this.label1.Location = new System.Drawing.Point(38, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(0, 19);
this.label1.TabIndex = 0;
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// timer1
//
this.timer1.Interval = 500;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(39, 42);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(0, 13);
this.label2.TabIndex = 1;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(648, 116);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[sTAThread]
static void Main()
{
Application.Run(new Form1());
}
string s_line;
private void Form1_Load(object sender, System.EventArgs e)
{
timer1.Start();
readNews();
}
private void readNews()
{
try
{
sr = new StreamReader("news.txt");
s_line = sr.ReadToEnd();
sb = new System.Text.StringBuilder(s_line);
sb.Replace("\r\n", "");
label1.Text = sb.ToString();
label2.Text = sb.ToString();
label1.Left = 0 - label1.Width;
label2.Left = this.Width;
}
catch (Exception)
{
throw;
}
}
private void timer1_Tick(object sender, EventArgs e)
{
if (label1.Left >= this.Width)
label1.Left = 0 - label1.Width;
else
label1.Left += 10;
if (label2.Left <=0- this.Width)
label2.Left = this.Width;
else
label2.Left -= 10;
}
}
}