private void signalAttributes_RowValidating( object sender, DataGridViewCellCancelEventArgs e )
{
var name = signalAttributes.Rows[e.RowIndex].Cells[0].Value as string;
var type = signalAttributes.Rows[e.RowIndex].Cells[1].Value as string;
var value = signalAttributes.Rows[e.RowIndex].Cells[2].Value as string;
try
{
SignalFunctionType sf = _signalFunctionType as SignalFunctionType;
XmlElement element = _signalFunctionType as XmlElement;
if (sf != null && (!string.IsNullOrWhiteSpace(value) && IsPhysicalType( ATMLContext.NS_STDBSC, sf.GetType().Name, name)))
{
var physical = new Physical( value );
physical.Validate();
signalAttributes.Rows[e.RowIndex].Cells[2].Style.BackColor =
signalAttributes.Rows[e.RowIndex].Cells[1].Style.BackColor;
signalAttributes.Rows[e.RowIndex].Cells[2].ToolTipText = "";
}
if (element != null)
{
if (type != null && ( "Physical".Equals(type) || "Frequency".Equals(type) ) )//TODO: Lookup attribute type in schema
{
var physical = new Physical(value);
physical.Validate();
signalAttributes.Rows[e.RowIndex].Cells[2].Style.BackColor =
signalAttributes.Rows[e.RowIndex].Cells[1].Style.BackColor;
signalAttributes.Rows[e.RowIndex].Cells[2].ToolTipText = "";
}
}
}
catch (Exception err)
{
signalAttributes.Rows[e.RowIndex].Cells[2].Style.BackColor = Color.LightPink;
signalAttributes.Rows[e.RowIndex].Cells[2].ToolTipText = err.Message;
}
}