myGully.com Boerse.SH - BOERSE.AM - BOERSE.IO - BOERSE.IM Boerse.BZ .TO Nachfolger
Zurück   myGully.com > Computer & Technik > Programmierung
Seite neu laden

VB.NET - Funktion richtig erstellen

Willkommen

myGully

Links

Forum

 
Antwort
 
Themen-Optionen Ansicht
Ungelesen 05.11.10, 18:25   #1
urga
Mitglied
 
Benutzerbild von urga
 
Registriert seit: Aug 2009
Ort: void* (*wtf[])(void **);
Beiträge: 453
Bedankt: 137
urga ist noch neu hier! | 0 Respekt Punkte
Standard

das form hat 3 elemente: textBox1, label1, timer1.
gesteuert werden die zeiten über

tickerCharMS: ms für die einzelnden buchstaben
tickerNewLineMS: ms die für eine newline gewartet werden.

tickerCharMS soll sich ja pro zeile um 1 erhöhen.
um einen effekt zu bemerken habe ich den um jeweils 50 erhöht.

Code:
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;

namespace laufschrift {
	public partial class Form1 : Form {
		public Form1 () {
			InitializeComponent ();
			this.timer1.Enabled = false;
		}

		private String[] tickerText;
		private int tickerTextIndex;
		private int tickerCharIndex;
		private int tickerCharMS;
		private int tickerNewLineMS;

		private void initTimer () {
			this.tickerText = this.textBox1.Text.Trim ().Split (new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
			this.tickerTextIndex = 0;
			this.tickerCharIndex = 0;
			this.label1.Text = "";
			this.tickerCharMS = 41;
			this.tickerNewLineMS = 1000;
			this.timer1.Interval = this.tickerCharMS;
			this.timer1.Enabled = true;
		}

		private void button1_Click (object sender, EventArgs e) {
			this.label1.Text = "";
			if (this.textBox1.Text.Trim ().Length > 0) {
				this.initTimer ();
				this.button1.Enabled = false;
			}
		}

		private bool wasNewLine = false;
		private void timer1_Tick (object sender, EventArgs e) {
			if (this.wasNewLine) {
				this.timer1.Interval = this.tickerCharMS + this.tickerTextIndex*50;
				this.wasNewLine = false;
			}

			string s = this.tickerText[this.tickerTextIndex];
			char c = s.ElementAt (this.tickerCharIndex);
			this.label1.Text += c;
			if (this.tickerCharIndex + 1 < s.Length) {
				this.tickerCharIndex++;
			}
			else {
				this.tickerCharIndex = 0;
				if (this.tickerTextIndex + 1 < this.tickerText.Length) {
					this.label1.Text += "\r\n";
					this.tickerTextIndex++;
					this.timer1.Interval = this.tickerNewLineMS;
					this.wasNewLine = true;
				}
				else {
					this.timer1.Enabled = false;
					this.button1.Enabled = true;
				}
			}
		}
	}
}
__________________
entropie erfordert keine wartung
urga ist offline   Mit Zitat antworten
Antwort


Forumregeln
Du kannst keine neue Themen eröffnen
Du kannst keine Antworten verfassen
Du kannst keine Anhänge posten
Du kannst nicht deine Beiträge editieren

BB code is An
Smileys sind An.
[IMG] Code ist An.
HTML-Code ist Aus.

Gehe zu


Alle Zeitangaben in WEZ +1. Es ist jetzt 01:39 Uhr.


Sitemap

().