Пример #1
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.
            EFModelDocDataBase docData = this.DocData as EFModelDocDataBase;

            global::System.Diagnostics.Debug.Assert(docData != null, "DocData for EFModelDocViewBase should be an EFModelDocDataBase!");
            var l_diagramName = string.IsNullOrEmpty(this.diagramName) ? global::System.IO.Path.GetFileNameWithoutExtension(docData.FileName) : this.diagramName;
            DslModeling::Partition diagramPartition = docData.GetDiagramPartition();

            if (diagramPartition != null)
            {
                global::System.Collections.ObjectModel.ReadOnlyCollection <global::Sawczyn.EFDesigner.EFModel.EFModelDiagram> diagrams = docData.GetDiagramPartition().ElementDirectory.FindElements <global::Sawczyn.EFDesigner.EFModel.EFModelDiagram>();
                if (diagrams.Count > 0)
                {
                    var l_diagram = diagrams.FirstOrDefault(diagram => diagram.Name.Equals(l_diagramName, global::System.StringComparison.Ordinal));
                    if (null == l_diagram && !string.IsNullOrEmpty(this.diagramName))
                    {
                        return(false);
                    }
                    this.Diagram = l_diagram ?? diagrams[0];
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }


            return(true);
        }
Пример #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.
            EFModelDocDataBase docData = this.DocData as EFModelDocDataBase;

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

            if (diagramPartition != null)
            {
                global::System.Collections.ObjectModel.ReadOnlyCollection <global::Sawczyn.EFDesigner.EFModel.EFModelDiagram> diagrams = docData.GetDiagramPartition().ElementDirectory.FindElements <global::Sawczyn.EFDesigner.EFModel.EFModelDiagram>();
                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);
        }