private void OnEditDestination(object sender, CommandEventArgs e)
        {
            if (Grid.SelectedRows != null && Grid.SelectedRows.Count == 1)
            {
                try
                {
                    InstanceState dataItem        = (InstanceState)(Grid.SelectedRows[0].Cells[0].Tag as GridDataItem).DataItem;
                    Guid          currentObjectId = dataItem.PartialMonitoringObjectId;
                    if (currentObjectId == Guid.Empty && dataItem.ManagedEntityId != Guid.Empty)
                    {
                        currentObjectId = dataItem.ManagedEntityId;
                    }
                    if (currentObjectId == Guid.Empty)
                    {
                        currentObjectId = dataItem.GetPartialMonitoringObject(ManagementGroup).Id;
                    }
                    using (NewDestinationDialog newDestinationDialog = new NewDestinationDialog(ManagementGroup, currentObjectId))
                    {
                        newDestinationDialog.ShowDialog();
                    }

                    // emulate Refresh command
                    OnRefreshCommand(sender, e);
                }
                catch (Exception ex)
                {
                    MessageBox.Show($"In {System.Reflection.MethodBase.GetCurrentMethod().Name} {ex.GetType().Name} said {ex.Message} at {ex.StackTrace}");
                }
            }
        }
 private void OnAddNewTest(object sender, CommandEventArgs e)
 {
     if (Grid.SelectedRows != null && Grid.SelectedRows.Count == 1 && TestClassesInitialized)
     {
         try
         {
             InstanceState dataItem        = (InstanceState)(Grid.SelectedRows[0].Cells[0].Tag as GridDataItem).DataItem;
             Guid          currentObjectId = dataItem.PartialMonitoringObjectId;
             if (currentObjectId == Guid.Empty && dataItem.ManagedEntityId != Guid.Empty)
             {
                 currentObjectId = dataItem.ManagedEntityId;
             }
             if (currentObjectId == Guid.Empty)
             {
                 currentObjectId = dataItem.GetPartialMonitoringObject(ManagementGroup).Id;
             }
             using (NewTestDialog newTestDialog = new NewTestDialog(ManagementGroup, TestClassesAddCommands[e.Id.Guid], ManagementGroup.EntityObjects.GetObject <MonitoringObject>(currentObjectId, ObjectQueryOptions.Default), Guid.Empty))
             {
                 newTestDialog.ShowDialog();
             }
             SendRefreshCommandToDetailView();
         }
         catch (Exception ex)
         {
             MessageBox.Show($"In {System.Reflection.MethodBase.GetCurrentMethod().Name} {ex.GetType().Name} said {ex.Message} at {ex.StackTrace}");
         }
     }
 }