/// <summary> /// Reads and draws the char that writer has written to the common Buffer /// </summary> public void Update() { while (active) { char c; if (CharacterBuffer.getChar(out c)) { tb.BeginInvoke((Action) delegate() { tb.Text = "" + c; }); } } }
/// <summary> /// Loops the amount of time we need to change char /// Picks a random value that represents an index in out allowedChars-string /// When finished it inovkes the Form1 to enable the answer-bar /// </summary> public void StartAddingCharacters() { while (CharacterBuffer.currentNrOfChars != nrOfCharacters) { if (!CharacterBuffer.charWritten) { CharacterBuffer.setChar(allowedChars[rnd.Next(1, 40)]); Thread.Sleep(displayTimer); } } displayBox.BeginInvoke((Action) delegate() { displayBox.Text = ""; }); answerBox.BeginInvoke((Action) delegate() { answerBox.Enabled = true; }); submitButton.BeginInvoke((Action) delegate() { submitButton.Enabled = true; }); }
/// <summary> /// Sets the needed attribrutes for writer. /// nrOfCharacters is the amount of times it should produce a new char /// displaytimer is the amount of time that should pass between chaning chars /// </summary> public void SetAttributes(int nrOfCharacters, int displayTimer) { this.nrOfCharacters = nrOfCharacters; this.displayTimer = displayTimer; CharacterBuffer.SetNrOfChars(nrOfCharacters); }