public List <NetworkDiagram> GetInconsistentDiagrams(UtilityNetwork utilityNetwork) { // Get the DiagramManager from the utility network using (DiagramManager diagramManager = utilityNetwork.GetDiagramManager()) { List <NetworkDiagram> myList = new List <NetworkDiagram>(); // Loop through the network diagrams in the diagram manager foreach (NetworkDiagram diagram in diagramManager.GetNetworkDiagrams()) { NetworkDiagramInfo diagramInfo = diagram.GetDiagramInfo(); // If the diagram is not a system diagram and is in an inconsistent state, add it to our list if (!diagramInfo.IsSystem && diagram.GetConsistencyState() != NetworkDiagramConsistencyState.DiagramIsConsistent) { myList.Add(diagram); } else { diagram.Dispose(); // If we are not returning it we need to Dispose it } } return(myList); } }
/// <summary> /// Set Enclosure flag /// </summary> /// <param name="obj">ActiveMapViewChangedEventArgs</param> private void OnActiveMapViewChanged(ActiveMapViewChangedEventArgs obj) { if (obj == null || obj.IncomingView == null || obj.IncomingView.Map == null) { FrameworkApplication.State.Deactivate(EnableEnclosure); return; } QueuedTask.Run(() => { using UtilityNetwork un = GetUtilityNetworkFromActiveMap(); using DiagramManager dm = un?.GetDiagramManager(); try { DiagramTemplate dt = dm?.GetDiagramTemplate(csTemplateName); if (dt == null) { FrameworkApplication.State.Deactivate(EnableEnclosure); } else { FrameworkApplication.State.Activate(EnableEnclosure); } } catch { FrameworkApplication.State.Deactivate(EnableEnclosure); } }); }
/// <summary> /// Generate a diagram and apply the EnclosureLayout custom telco layout on its content /// </summary> /// <param name="cps">Cancelable Progressor Source to show the progression</param> /// <returns>An error comment if needed, empty of no error</returns> private async Task <string> RunCancelableEnclosure(CancelableProgressorSource cps) { string status = ""; List <Guid> listIds = null; NetworkDiagram myDiagram = null; await QueuedTask.Run(() => { cps.Progressor.Max = 3; cps.Progressor.Value += 0; cps.Progressor.Status = (cps.Progressor.Value * 100 / cps.Progressor.Max) + @" % Completed"; cps.Progressor.Message = "Step 1 – Get Selected Guids"; try { if (m_DiagramManager == null) { UtilityNetwork un = GetUtilityNetworkFromActiveMap(); if (un == null) { return; } m_DiagramManager = un.GetDiagramManager(); if (m_DiagramManager == null) { return; } } if (m_Template == null) { m_Template = m_DiagramManager.GetDiagramTemplate(csTemplateName); if (m_Template == null) { return; } } listIds = GetSelectedGuidFromActiveMap(); if (listIds.Count == 0) { return; } } catch (Exception ex) { status = string.Format("Selected guids\n{0}", ExceptionFormat(ex)); } }, cps.Progressor); await QueuedTask.Run(() => { cps.Progressor.Value += 1; cps.Progressor.Status = (cps.Progressor.Value * 100 / cps.Progressor.Max) + @" % Completed"; cps.Progressor.Message = string.Format("Step 2 – Generate a diagram based on the '{0}' template", csTemplateName); try { // generate a diagram myDiagram = m_DiagramManager.CreateNetworkDiagram(diagramTemplate: m_Template, globalIDs: listIds); } catch (Exception ex) { if (string.IsNullOrEmpty(status)) { status = string.Format("Generate diagram\n{0}", ExceptionFormat(ex)); } else { status = string.Format("Generate diagram\n{0}", ExceptionFormat(ex)); } } }, cps.Progressor); await QueuedTask.Run(() => { cps.Progressor.Value += 1; cps.Progressor.Status = (cps.Progressor.Value * 100 / cps.Progressor.Max) + @" % Completed"; cps.Progressor.Message = "Step 3 – Apply the EnclosureLayout custom telco layout"; try { // apply the telco custom layout EnclosureLayout myLayout = new EnclosureLayout(); myLayout.Execute(myDiagram); ShowDiagram(myDiagram); } catch (Exception ex) { if (string.IsNullOrEmpty(status)) { status = string.Format("Apply layout\n{0}", ExceptionFormat(ex)); } else { status = string.Format("Apply layout\n{0}", ExceptionFormat(ex)); } } }); return(status); }