TBF.UI : Item.EditXyz added.
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace TBF.UI.Item
|
||||
{
|
||||
public class EditString
|
||||
{
|
||||
string name;
|
||||
string variable;
|
||||
IList<string> alreadyUsed;
|
||||
TextBox textBox;
|
||||
|
||||
public EditString(string name, ref string variable, IList<string> 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<string>())
|
||||
{
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user