private void btnEditObject_Click(object sender, EventArgs e)
{
TestStationDescriptionInstrument tsi =
testStationDescriptionInstrumentControl1.TestStationDescriptionInstrument;
if (tsi != null && tsi.Item != null)
{
var docRef = tsi.Item as DocumentReference;
if (docRef != null)
{
Document document = DocumentManager.GetDocument(docRef.uuid);
if (document == null)
{
MessageBox.Show(string.Format("Test Station Instrument \"{0}\" does not exist in the document database.", docRef.uuid));
}
else
{
InstrumentDescription instrument =
InstrumentDescription.Deserialize(Encoding.UTF8.GetString(document.DocumentContent));
var form = new InstrumentForm();
form.InstrumentDescription = instrument;
//form.TopMost = true;
Visible = false;
form.Closed += delegate
{
if (DialogResult.OK == form.DialogResult)
{
instrument = form.InstrumentDescription;
document.DocumentContent = Encoding.UTF8.GetBytes(instrument.Serialize());
PersistanceController.Save(document);
}
Visible = true;
};
form.Show(this);
}
}
}
}