private void SetupContextMenu(ERDiagram diagram)
        {
            if (diagram == null)
            {
                return;
            }

            foreach (IDiagramAction action in diagram.Actions)
            {
                if (action is ERDiagramActionSyncDescriptions)
                {
                    return;                                            //if this context menu is already part of the diagram, then we're done
                }
            }

            IDiagramTag tagTable = (IDiagramTag)diagram.GetType().InvokeMember("tagTable", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.GetField | System.Reflection.BindingFlags.Instance, null, diagram, null);

            ERDiagramActionSyncDescriptions syncAction = new ERDiagramActionSyncDescriptions(diagram, this);

            syncAction.Text          = "Sync Descriptions...";
            syncAction.DisplayIndex  = 0x19f;
            syncAction.Key           = new DiagramObjectKey(@"Actions\{0}", new object[] { "SyncDescriptions" });
            syncAction.AvailableRule = delegate(IEnumerable <IEnumerable <IDiagramTag> > tagSets)
            {
                return(tagSets.All <IEnumerable <IDiagramTag> >(tagSet => tagSet.Contains <IDiagramTag>(tagTable)));
            };
            diagram.GetType().InvokeMember("InitializeViewStates", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.InvokeMethod, null, diagram, new object[] { syncAction });
            diagram.Actions.Add(syncAction);
        }
        private void SetupContextMenu(ERDiagram diagram)
        {
            if (diagram == null) return;

            foreach (IDiagramAction action in diagram.Actions)
            {
                if (action is ERDiagramActionSyncDescriptions) return; //if this context menu is already part of the diagram, then we're done
            }

            IDiagramTag tagTable = (IDiagramTag)diagram.GetType().InvokeMember("tagTable", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.GetField | System.Reflection.BindingFlags.Instance, null, diagram, null);

            ERDiagramActionSyncDescriptions syncAction = new ERDiagramActionSyncDescriptions(diagram, this);
            syncAction.Text = "Sync Descriptions...";
            syncAction.DisplayIndex = 0x19f;
            syncAction.Key = new DiagramObjectKey(@"Actions\{0}", new object[] { "SyncDescriptions" });
            syncAction.AvailableRule = delegate(IEnumerable<IEnumerable<IDiagramTag>> tagSets)
            {
                return tagSets.All<IEnumerable<IDiagramTag>>(tagSet => tagSet.Contains<IDiagramTag>(tagTable));
            };
            diagram.GetType().InvokeMember("InitializeViewStates", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.InvokeMethod, null, diagram, new object[] { syncAction });
            diagram.Actions.Add(syncAction);
        }