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 List<ERDiagram> _hookedERDiagrams = new List<ERDiagram>(); private void SetupContextMenu(ERDiagram diagram) { if (diagram == null) { return; } //if (_hookedERDiagrams.Contains(diagram)) return; foreach (IDiagramAction action in diagram.Actions) { if (action is ERDiagramActionHideMemberIf) { return; //if this context menu is already part of the diagram, then we're done } } IDiagramTag tagHierarchyLevel = (IDiagramTag)diagram.GetType().InvokeMember("tagHierarchyLevel", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.GetField | System.Reflection.BindingFlags.Instance, null, diagram, null); ERDiagramActionHideMemberIf levels = new ERDiagramActionHideMemberIf(diagram, this); levels.Text = "Set HideMemberIf..."; levels.DisplayIndex = 0x19f; levels.Key = new DiagramObjectKey(@"Actions\{0}", new object[] { "HideMemberIf" }); levels.AvailableRule = delegate(IEnumerable <IEnumerable <IDiagramTag> > tagSets) { return(tagSets.All <IEnumerable <IDiagramTag> >(tagSet => tagSet.Contains <IDiagramTag>(tagHierarchyLevel))); }; diagram.GetType().InvokeMember("InitializeViewStates", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.InvokeMethod, null, diagram, new object[] { levels }); diagram.Actions.Add(levels); //_hookedERDiagrams.Add(diagram); }
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 List<ERDiagram> _hookedERDiagrams = new List<ERDiagram>(); private void SetupContextMenu(ERDiagram diagram) { if (diagram == null) return; //if (_hookedERDiagrams.Contains(diagram)) return; foreach (IDiagramAction action in diagram.Actions) { if (action is ERDiagramActionHideMemberIf) return; //if this context menu is already part of the diagram, then we're done } IDiagramTag tagHierarchyLevel = (IDiagramTag)diagram.GetType().InvokeMember("tagHierarchyLevel", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.GetField | System.Reflection.BindingFlags.Instance, null, diagram, null); ERDiagramActionHideMemberIf levels = new ERDiagramActionHideMemberIf(diagram, this); levels.Text = "Set HideMemberIf..."; levels.DisplayIndex = 0x19f; levels.Key = new DiagramObjectKey(@"Actions\{0}", new object[] { "HideMemberIf" }); levels.AvailableRule = delegate(IEnumerable<IEnumerable<IDiagramTag>> tagSets) { return tagSets.All<IEnumerable<IDiagramTag>>(tagSet => tagSet.Contains<IDiagramTag>(tagHierarchyLevel)); }; diagram.GetType().InvokeMember("InitializeViewStates", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.InvokeMethod, null, diagram, new object[] { levels }); diagram.Actions.Add(levels); //_hookedERDiagrams.Add(diagram); }