internal static EntityDesignerDiagram GetExistingViewDiagram(MicrosoftDataEntityDesignDocDataBase docData, string diagramId)
        {
            EntityDesignerDiagram diagram = null;
            var diagrams = docData.GetDiagramPartition().ElementDirectory.FindElements <EntityDesignerDiagram>();

            if (diagrams.Count > 0)
            {
                if (String.IsNullOrEmpty(diagramId) == false)
                {
                    diagram = diagrams.Where(d => d.DiagramId == diagramId).FirstOrDefault();
                }
                else
                {
                    // If the diagramid is not set, just select the first diagram.
                    diagram = diagrams[0];
                }
            }
            return(diagram);
        }
Exemple #2
0
        /// <summary>
        /// Called to initialize the view after the corresponding document has been loaded.
        /// </summary>
        protected override bool LoadView()
        {
            base.LoadView();

            global::System.Diagnostics.Debug.Assert(this.DocData.RootElement != null);
            if (this.DocData.RootElement == null)
            {
                return(false);
            }

            // The diagram should exist in the diagram partition by now, just need to find it and connect it to this view.
            MicrosoftDataEntityDesignDocDataBase docData = this.DocData as MicrosoftDataEntityDesignDocDataBase;

            global::System.Diagnostics.Debug.Assert(docData != null, "DocData for MicrosoftDataEntityDesignDocViewBase should be an MicrosoftDataEntityDesignDocDataBase!");
            DslModeling::Partition diagramPartition = docData.GetDiagramPartition();

            if (diagramPartition != null)
            {
                global::System.Collections.ObjectModel.ReadOnlyCollection <global::Microsoft.Data.Entity.Design.EntityDesigner.View.EntityDesignerDiagram> diagrams = docData.GetDiagramPartition().ElementDirectory.FindElements <global::Microsoft.Data.Entity.Design.EntityDesigner.View.EntityDesignerDiagram>();
                if (diagrams.Count > 0)
                {
                    global::System.Diagnostics.Debug.Assert(diagrams.Count == 1, "Found more than one diagram, using the first one found.");
                    this.Diagram = (DslDiagrams::Diagram)diagrams[0];
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }

            return(true);
        }
 internal static EntityDesignerDiagram GetExistingViewDiagram(MicrosoftDataEntityDesignDocDataBase docData, string diagramId)
 {
     EntityDesignerDiagram diagram = null;
     var diagrams = docData.GetDiagramPartition().ElementDirectory.FindElements<EntityDesignerDiagram>();
     if (diagrams.Count > 0)
     {
         if (String.IsNullOrEmpty(diagramId) == false)
         {
             diagram = diagrams.Where(d => d.DiagramId == diagramId).FirstOrDefault();
         }
         else
         {
             // If the diagramid is not set, just select the first diagram.
             diagram = diagrams[0];
         }
     }
     return diagram;
 }