public void LoadData(string dataKey)
{
if (InvokeRequired)
{
try
{
Invoke((Delegate)new AttrDataItemForm.LoadDataDelegate(LoadData), dataKey);
}
catch { }
}
else
{
formDataAccess.WaitOne();
key = dataKey;
dataAttr = new DataAttr();
bool dataChanged = false;
if (attrDataUtils.GetDataAttr(ref dataAttr, ref dataChanged, key, "LoadData"))
{
if (dataChanged)
{
tbConnHnd.Text = "0x" + dataAttr.ConnHandle.ToString("X4");
tbHandle.Text = "0x" + dataAttr.Handle.ToString("X4");
if (dataAttr.UuidHex != string.Empty && dataAttr.UuidHex != null)
tbUuid.Text = "0x" + dataAttr.UuidHex;
tbUuidDesc.Text = dataAttr.UuidDesc;
string outStr = string.Empty;
if (lastValueDisplaySet)
{
devUtils.ConvertDisplayTypes(ValueDisplay.Hex, dataAttr.Value, ref lastValueDisplay, ref outStr, false);
}
else
{
devUtils.ConvertDisplayTypes(ValueDisplay.Hex, dataAttr.Value, ref dataAttr.ValueDisplay, ref outStr, false);
lastValueDisplay = dataAttr.ValueDisplay;
lastValueDisplaySet = true;
cbDataType.SelectedIndex = (int)lastValueDisplay;
}
tbValue.Text = outStr;
tbValueDesc.Text = dataAttr.ValueDesc;
tbProperties.Text = dataAttr.PropertiesStr;
bool flag = false;
if (dataAttr.PropertiesStr != null && dataAttr.PropertiesStr != string.Empty)
{
flag = true;
Color green = Color.Green;
Color red = Color.Red;
if ((dataAttr.Properties & 0x01) == 0x01)
lblBroadcast.ForeColor = green;
else
lblBroadcast.ForeColor = red;
if ((dataAttr.Properties & 0x02) == 0x02)
lblRead.ForeColor = green;
else
lblRead.ForeColor = red;
if ((dataAttr.Properties & 0x04) == 0x04)
lblWriteWithoutResponse.ForeColor = green;
else
lblWriteWithoutResponse.ForeColor = red;
if ((dataAttr.Properties & 0x08) == 0x08)
lblWrite.ForeColor = green;
else
lblWrite.ForeColor = red;
if ((dataAttr.Properties & 0x10) == 0x10)
lblNotify.ForeColor = green;
else
lblNotify.ForeColor = red;
if ((dataAttr.Properties & 0x20) == 0x20)
lblIndicate.ForeColor = green;
else
lblIndicate.ForeColor = red;
if ((dataAttr.Properties & 0x40) == 0x40)
lblAuthenticatedSignedWrites.ForeColor = green;
else
lblAuthenticatedSignedWrites.ForeColor = red;
if ((dataAttr.Properties & 0x80) == 0x80)
lblExtendedProperties.ForeColor = green;
else
lblExtendedProperties.ForeColor = red;
}
gbProperties.Enabled = flag;
tbProperties.Enabled = flag;
lblProperties.Enabled = flag;
lblBroadcast.Enabled = flag;
lblRead.Enabled = flag;
lblWriteWithoutResponse.Enabled = flag;
lblWrite.Enabled = flag;
lblNotify.Enabled = flag;
lblIndicate.Enabled = flag;
lblAuthenticatedSignedWrites.Enabled = flag;
lblExtendedProperties.Enabled = flag;
}
if (dataAttr.ValueEdit == ValueEdit.ReadOnly)
{
btnWriteValue.Enabled = false;
tbValue.ReadOnly = true;
}
else
{
btnWriteValue.Enabled = true;
tbValue.ReadOnly = false;
}
if (!lastValueDisplaySet)
cbDataType.SelectedIndex = (int)dataAttr.ValueDisplay;
}
formDataAccess.ReleaseMutex();
}
}