public void WorkEnded(Tuple <string, bool> input, Tuple <RetrieveAllEntitiesResponse, Dictionary <string, EntitySelection> > value, Exception exception)
        {
            try
            {
                if (exception != null)
                {
                    MessageBox.Show(exception.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (value != null)
                {
                    RetrieveAllEntitiesResponse result = value.Item1;
                    metadataTree.BackgroundImage = null;
                    metadataTree.Enabled         = true;
                    metadataTree.Nodes.Clear();
                    myPlugin.entityMetadatas = result.EntityMetadata;
                    foreach (var item in result.EntityMetadata.OrderBy(x => x.LogicalName))
                    {
                        if (item.DisplayName.LocalizedLabels.Count == 0)
                        {
                            continue;
                        }

                        TreeNodeAdv attributes = new TreeNodeAdv("Attributes")
                        {
                            ShowCheckBox        = true,
                            InteractiveCheckBox = true
                        };

                        TreeNodeAdv relationships = new TreeNodeAdv("Relationships")
                        {
                            ShowCheckBox        = true,
                            InteractiveCheckBox = true
                        };

                        TreeNodeAdv node = new TreeNodeAdv($"{item.LogicalName}: {item.DisplayName.LocalizedLabels[0].Label}",
                                                           new TreeNodeAdv[] { attributes, relationships })
                        {
                            ExpandedOnce        = true,
                            ShowCheckBox        = true,
                            InteractiveCheckBox = true,
                            Tag = item
                        };
                        metadataTree.Nodes.Add(node);
                        if (input.Item2)
                        {
                            AttributeMetadataHandler.CreateAttributeNodes(attributes, item, checkedState: true);
                            RelationshipMetadataHandler.CreateRelationshipNodes(relationships, item, checkedState: true);
                        }
                    }
                    if (!input.Item2)
                    {
                        entitySelectionHandler.SelectGenerated();
                    }

                    myPlugin.pluginViewModel.All_Metadata_Requested = input.Item2;
                    myPlugin.pluginViewModel.Generate_Enabled       = true;
                }
            }
#pragma warning disable CA1031 // We don't want our plugin to crash because of unhandled exceptions
            catch (Exception ex)
#pragma warning restore CA1031 // Do not catch general exception types
            {
                MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 private void MnuSelectGenerated_Click(object sender, EventArgs e)
 {
     MnuSelectNone_Click(sender, e);
     EntitySelectionHandler.SelectGenerated();
 }