using System; using System.Collections.Generic; using System.Windows.Forms; namespace TBF.UI.Item { public class EditString { string name; string variable; IList alreadyUsed; TextBox textBox; public EditString(string name, ref string variable, IList alreadyUsed) { this.name = name; this.variable = variable; this.alreadyUsed = alreadyUsed; this.textBox = new TextBox(); } public EditString(string name, ref string variable) : this (name, ref variable, new List()) { } public string Name() { return name; } public Control EmbeddedControl() { return textBox; } public string Print() { return variable; } public void Update(string strValue) { variable = strValue; } public bool Validate(string strValue, out string message) { if (alreadyUsed.Contains(strValue)) { message = string.Format("Value '{0}' was already used", strValue); return false; } else { message = string.Empty; return true; } } } }