Example #1
0
        /// <summary>
        /// Get an array of selected accessible objects
        /// </summary>
        public AccessibleObject[] GetSelectedAccessibleObjects()
        {
            DiagramClientView        view   = myClientView;
            SelectedShapesCollection shapes = view.Selection;
            int selectionCount = shapes.Count;

            AccessibleObject[] retVal = new AccessibleObject[shapes.Count];
            int i = 0;

            foreach (DiagramItem item in shapes)
            {
                retVal[i] = item.GetAccessibleObject(view);
                ++i;
            }
            return(retVal);
        }
Example #2
0
        /// <summary>实现 IDTCommandTarget 接口的 QueryStatus 方法。此方法在更新该命令的可用性时调用</summary>
        /// <param term='commandName'>要确定其状态的命令的名称。</param>
        /// <param term='neededText'>该命令所需的文本。</param>
        /// <param term='status'>该命令在用户界面中的状态。</param>
        /// <param term='commandText'>neededText 参数所要求的文本。</param>
        /// <seealso class='Exec' />
        public void QueryStatus(string commandName, vsCommandStatusTextWanted neededText, ref vsCommandStatus status, ref object commandText)
        {
            if (neededText == vsCommandStatusTextWanted.vsCommandStatusTextWantedNone)
            {
                if (commandName == "BuffaloEntityConfig.Connect" ||
                    commandName == "BuffaloDBCreater.Connect")
                {
                    SelectedShapesCollection selectedShapes = SelectedShapes;
                    if (selectedShapes == null)
                    {
                        status = (vsCommandStatus)vsCommandStatus.vsCommandStatusUnsupported |
                                 vsCommandStatus.vsCommandStatusInvisible;
                        return;
                    }
                    bool findClass = false;
                    for (int i = 0; i < selectedShapes.Count; i++)
                    {
                        if (!(selectedShapes.TopLevelItems[i].Shape is ClrTypeShape))
                        {
                            continue;
                        }

                        ClrTypeShape sp = selectedShapes.TopLevelItems[i].Shape as ClrTypeShape;
                        if (!(sp.AssociatedType is ClrClass))
                        {
                            continue;
                        }
                        status = (vsCommandStatus)vsCommandStatus.vsCommandStatusSupported |
                                 vsCommandStatus.vsCommandStatusEnabled;
                        findClass = true;
                        break;
                    }
                    if (findClass == false)
                    {
                        status = (vsCommandStatus)vsCommandStatus.vsCommandStatusUnsupported |
                                 vsCommandStatus.vsCommandStatusInvisible;
                        return;
                    }
                }

                status = (vsCommandStatus)vsCommandStatus.vsCommandStatusSupported |
                         vsCommandStatus.vsCommandStatusEnabled;
            }
        }
Example #3
0
        public override void ElementAttributeChanged(ElementAttributeChangedEventArgs e)
        {
            // only respond to bounds changes
            if (e.MetaAttribute.Id == NodeShape.AbsoluteBoundsMetaAttributeGuid)
            {
                // get the NodeShape reference to work with.
                NodeShape thisShape = e.ModelElement as NodeShape;
                if (thisShape != null && thisShape.Diagram != null && thisShape != thisShape.Diagram)
                {
                    SelectedShapesCollection selection = thisShape.Diagram.ActiveDiagramView.Selection;
                    // make sure the specified shape is in the selection because we only want
                    // the selected shapes to move their connected shapes (not continously
                    // ripple this effect).
                    if (selection != null && selection.Contains(new DiagramItem(thisShape)) == true)
                    {
                        // calculate the change in bounds position.
                        RectangleD oldBounds = (RectangleD)e.OldValue;
                        RectangleD newBounds = (RectangleD)e.NewValue;
                        double     deltaX    = newBounds.X - oldBounds.X;
                        double     deltaY    = newBounds.Y - oldBounds.Y;


                        // find all of the connected shapes.
                        List <Shape> connectedShapes = GetConnectedShapes(thisShape);

                        foreach (Shape shape in connectedShapes)
                        {
                            // make sure the shape isn't in the selection,
                            // because those will be on their own as part of drag-drop.
                            if (selection.Contains(new DiagramItem(shape)) == false)
                            {
                                PointD currentLocation = shape.Location;
                                shape.Location = new PointD(currentLocation.X + deltaX,
                                                            currentLocation.Y + deltaY);
                            }
                        }
                    }
                }
            }
        }
Example #4
0
        /// <summary>
        /// Called when the user selects an item on the diagram.
        /// Returns the shape that should actually be selected.
        /// </summary>
        /// <param name="currentSelection">The pre-existing selection.</param>
        /// <param name="proposedItemsToAdd">The items that will be selected. Modify this to select something else.</param>
        /// <param name="proposedItemsToRemove">Items that will be removed from the current selection.</param>
        /// <param name="primaryItem">The most recent item selected.</param>
        /// <returns>True if the selection was at least partially successful.</returns>
        public override bool GetCompliantSelection(SelectedShapesCollection currentSelection, DiagramItemCollection proposedItemsToAdd, DiagramItemCollection proposedItemsToRemove, DiagramItem primaryItem)
        {
            // We will modify proposedItemsToAdd, replacing component terminal shapes by component shapes.
            List <DiagramItem> toAdd  = new List <DiagramItem>();
            List <DiagramItem> toDrop = new List <DiagramItem>();

            foreach (DiagramItem item in proposedItemsToAdd)
            {
                if (item.Shape is ComponentTerminalShape)
                {
                    ComponentTerminal terminal = item.Shape.ModelElement as ComponentTerminal;
                    if (terminal == null)
                    {
                        continue;
                    }
                    toAdd.Add(new DiagramItem(item.Diagram.FindShape(terminal.Component)));
                    toDrop.Add(item);
                }
            }
            proposedItemsToAdd.Remove(toDrop); // Remove the terminals.
            proposedItemsToAdd.Add(toAdd);     // Add the parent components.

            return(base.GetCompliantSelection(currentSelection, proposedItemsToAdd, proposedItemsToRemove, primaryItem));
        }
Example #5
0
        /// <summary>
        /// Update our reading to reflect the current selection
        /// </summary>
        protected override void OnORMSelectionContainerChanged()
        {
            if (CurrentORMSelectionContainer != null)
            {
                ICollection selectedObjects = base.GetSelectedComponents();
                FactType    theFact         = null;
                FactType    secondaryFact   = null;
                if (selectedObjects != null)
                {
                    foreach (object element in selectedObjects)
                    {
                        FactType testFact = ORMEditorUtility.ResolveContextFactType(element);
                        // Handle selection of multiple elements as long as
                        // they all resolve to the same fact
                        if (theFact == null)
                        {
                            theFact = testFact;
                            Role                 testImpliedRole;
                            RoleProxy            proxy;
                            ObjectifiedUnaryRole objectifiedUnaryRole;
                            if (null != (testImpliedRole = element as Role))
                            {
                                if (null != (proxy = testImpliedRole.Proxy))
                                {
                                    secondaryFact = proxy.FactType;
                                }
                                else if (null != (objectifiedUnaryRole = testImpliedRole.ObjectifiedUnaryRole))
                                {
                                    secondaryFact = objectifiedUnaryRole.FactType;
                                }
                            }
                        }
                        else if (testFact != theFact)
                        {
                            theFact = null;
                            break;
                        }
                        else
                        {
                            secondaryFact = null;
                        }
                    }
                }
                if (theFact != null && theFact.HasImplicitReadings)
                {
                    theFact       = null;
                    secondaryFact = null;
                }

                ActiveFactType activeFact = EditingFactType;

                FactType currentFact        = activeFact.FactType;
                FactType currentImpliedFact = activeFact.ImpliedFactType;

                if (theFact == null && currentFact != null)
                {
                    EditingFactType = ActiveFactType.Empty;
                }
                //selection could change between the shapes that are related to the fact
                else if (theFact != currentFact || secondaryFact != currentImpliedFact)
                {
                    ReadOnlyCollection <RoleBase> displayOrder = null;
                    IORMDesignerView designerView;
                    DiagramView      designer;
                    if (null != (designerView = CurrentORMSelectionContainer as IORMDesignerView) &&
                        null != (designer = designerView.CurrentDesigner))
                    {
                        SelectedShapesCollection shapes = designer.DiagramClientView.Selection;
                        if (shapes.Count == 1)
                        {
                            DiagramItem item = null;
                            foreach (DiagramItem iter in shapes)
                            {
                                item = iter;
                                break;
                            }
                            ShapeElement  shape     = item.Shape;
                            FactTypeShape factShape = shape as FactTypeShape;
                            while (factShape == null)
                            {
                                shape = shape.ParentShape;
                                if (shape == null)
                                {
                                    break;
                                }
                                factShape = shape as FactTypeShape;
                            }
                            if (factShape != null)
                            {
                                FactType        shapeFactType = factShape.AssociatedFactType;
                                Objectification objectification;
                                if (shapeFactType == theFact)
                                {
                                    displayOrder = new ReadOnlyCollection <RoleBase>(factShape.DisplayedRoleOrder);
                                }
                                else if (secondaryFact == null &&
                                         null != (objectification = shapeFactType.ImpliedByObjectification) &&
                                         objectification.NestedFactType == theFact)
                                {
                                    secondaryFact = shapeFactType;
                                }
                            }
                        }
                    }
                    EditingFactType = new ActiveFactType(theFact, secondaryFact, displayOrder);
                }
            }
            else
            {
                EditingFactType = ActiveFactType.Empty;
            }
        }
Example #6
0
        /// <summary>实现 IDTCommandTarget 接口的 Exec 方法。此方法在调用该命令时调用。</summary>
        /// <param term='commandName'>要执行的命令的名称。</param>
        /// <param term='executeOption'>描述该命令应如何运行。</param>
        /// <param term='varIn'>从调用方传递到命令处理程序的参数。</param>
        /// <param term='varOut'>从命令处理程序传递到调用方的参数。</param>
        /// <param term='handled'>通知调用方此命令是否已被处理。</param>
        /// <seealso class='Exec' />
        public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled)
        {
            handled = false;
            if (executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault)
            {
                try
                {
                    if (IsCommand(commandName, "BuffaloEntityConfig"))
                    {
                        SelectedShapesCollection selectedShapes = SelectedShapes;
                        if (selectedShapes == null)
                        {
                            return;
                        }
                        for (int i = 0; i < selectedShapes.Count; i++)
                        {
                            if (!(selectedShapes.TopLevelItems[i].Shape is ClrTypeShape))
                            {
                                continue;
                            }
                            ClrTypeShape sp = selectedShapes.TopLevelItems[i].Shape as ClrTypeShape;
                            if (!(sp.AssociatedType is ClrClass))
                            {
                                continue;
                            }
                            using (FrmClassDesigner st = new FrmClassDesigner())
                            {
                                Diagram selDiagram = SelectedDiagram;
                                st.SelectedClass = sp;
                                st.DesignerInfo  = GetDesignerInfo();
                                st.ShowDialog();
                            }
                        }
                        handled = true;
                        return;
                    }
                    else if (IsCommand(commandName, "BuffaloDBCreater"))
                    {
                        SelectedShapesCollection selectedShapes = SelectedShapes;
                        if (selectedShapes == null)
                        {
                            return;
                        }
                        List <ClrClass> lstClass = new List <ClrClass>();
                        for (int i = 0; i < selectedShapes.Count; i++)
                        {
                            if (!(selectedShapes.TopLevelItems[i].Shape is ClrTypeShape))
                            {
                                continue;
                            }
                            ClrTypeShape sp        = selectedShapes.TopLevelItems[i].Shape as ClrTypeShape;
                            ClrClass     classType = sp.AssociatedType as ClrClass;
                            if (classType == null)
                            {
                                continue;
                            }
                            lstClass.Add(classType);
                        }
                        using (FrmDBCreate st = new FrmDBCreate())
                        {
                            Diagram selDiagram = SelectedDiagram;
                            st.SelectedClass = lstClass;
                            //st.SelectDocView = SelectDocView;
                            //st.CurrentProject = CurrentProject;
                            //st.SelectedDiagram = selDiagram;
                            st.DesignerInfo = GetDesignerInfo();
                            st.ShowDialog();
                        }
                        handled = true;
                        return;
                    }

                    else if (IsCommand(commandName, "BuffaloDBToEntity"))
                    {
                        Diagram dia = SelectedDiagram;
                        if (!(dia is ShapeElement))
                        {
                            return;
                        }
                        using (FrmAllTables frmTables = new FrmAllTables())
                        {
                            //frmTables.SelectedDiagram = dia;
                            //frmTables.SelectDocView = SelectDocView;
                            //frmTables.CurrentProject = CurrentProject;
                            frmTables.DesignerInfo = GetDesignerInfo();
                            frmTables.ShowDialog();
                        }
                    }

                    else if (IsCommand(commandName, "BuffaloShowHideSummery"))
                    {
                        Diagram dia = this.SelectedDiagram;

                        if (dia != null)
                        {
                            VSConfigManager.InitConfig(_applicationObject.Version);
                            ShapeSummaryDisplayer.ShowOrHideSummary(dia, this);
                            this.SelectDocView.CurrentDesigner.ScrollDown();
                            this.SelectDocView.CurrentDesigner.ScrollUp();

                            handled = true;
                        }
                    }
                    else if (IsCommand(commandName, "BuffaloDBCreateAll"))
                    {
                        List <ClrClass> lstClass = GetAllClass(SelectedDiagram);
                        if (lstClass == null)
                        {
                            return;
                        }
                        using (FrmDBCreate st = new FrmDBCreate())
                        {
                            Diagram selDiagram = SelectedDiagram;
                            st.SelectedClass = lstClass;
                            //st.SelectDocView = SelectDocView;
                            //st.CurrentProject = CurrentProject;
                            //st.SelectedDiagram = selDiagram;
                            st.DesignerInfo = GetDesignerInfo();
                            st.ShowDialog();
                        }
                        handled = true;
                        return;
                    }
                    else if (IsCommand(commandName, "BuffaloDBSet"))
                    {
                        string dalNamespace = GetDesignerInfo().GetNameSpace() + ".DataAccess";
                        ShapeElementMoveableCollection nestedChildShapes = SelectedDiagram.NestedChildShapes;

                        FrmDBSetting.ShowConfig(GetDesignerInfo(), dalNamespace);
                    }
                    else if (IsCommand(commandName, "BuffaloEntityRemove"))
                    {
                        SelectedShapesCollection selectedShapes = SelectedShapes;
                        if (selectedShapes == null)
                        {
                            return;
                        }
                        for (int i = 0; i < selectedShapes.Count; i++)
                        {
                            if (!(selectedShapes.TopLevelItems[i].Shape is ClrTypeShape))
                            {
                                continue;
                            }
                            ClrTypeShape sp = selectedShapes.TopLevelItems[i].Shape as ClrTypeShape;
                            if (!(sp.AssociatedType is ClrClass))
                            {
                                continue;
                            }
                            EntityConfig entity = new EntityConfig(sp.AssociatedType,
                                                                   GetDesignerInfo());
                            //entity.SelectDocView = SelectDocView;
                            if (MessageBox.Show("是否要删除实体:" + entity.ClassName +
                                                " 及其相关的业务类?", "提示", MessageBoxButtons.YesNo,
                                                MessageBoxIcon.Question) == DialogResult.Yes)
                            {
                                EntityRemoveHelper.RemoveEntity(entity);
                            }
                        }
                    }

                    else if (IsCommand(commandName, "BuffaloUpdateEntityByDB"))
                    {
                        SelectedShapesCollection selectedShapes = SelectedShapes;
                        if (selectedShapes == null)
                        {
                            return;
                        }
                        for (int i = 0; i < selectedShapes.Count; i++)
                        {
                            if (!(selectedShapes.TopLevelItems[i].Shape is ClrTypeShape))
                            {
                                continue;
                            }
                            ClrTypeShape sp       = selectedShapes.TopLevelItems[i].Shape as ClrTypeShape;
                            ClrClass     curClass = sp.AssociatedType as ClrClass;
                            if (curClass == null)
                            {
                                continue;
                            }
                            EntityConfig entity = EntityConfig.GetEntityConfigByTable(curClass,
                                                                                      GetDesignerInfo());
                            entity.GenerateCode();
                        }
                        handled = true;
                        return;
                    }
                    if (IsCommand(commandName, "BuffaloUI"))
                    {
                        SelectedShapesCollection selectedShapes = SelectedShapes;
                        if (selectedShapes == null)
                        {
                            return;
                        }
                        for (int i = 0; i < selectedShapes.Count; i++)
                        {
                            if (!(selectedShapes.TopLevelItems[i].Shape is ClrTypeShape))
                            {
                                continue;
                            }
                            ClrTypeShape sp = selectedShapes.TopLevelItems[i].Shape as ClrTypeShape;
                            if (!(sp.AssociatedType is ClrClass))
                            {
                                continue;
                            }
                            using (FrmUIGenerater st = new FrmUIGenerater())
                            {
                                Diagram selDiagram = SelectedDiagram;
                                st.CurEntityInfo = new EntityInfo(sp.AssociatedType, GetDesignerInfo());
                                st.BindTargetProjects(AllProjects);
                                st.ShowDialog();
                            }
                        }
                        handled = true;
                        return;
                    }
                    if (IsCommand(commandName, "commandGenDal"))
                    {
                        GreanDataAccess();
                        return;
                    }
                }
                catch (Exception ex)
                {
                    FrmCompileResault.ShowCompileResault(null, ex.ToString(), "错误");
                }
            }
        }
Example #7
0
        // Methods
        public override void DoPaint(DiagramPaintEventArgs e, ShapeElement parentShape)
        {
            base.DoPaint(e, parentShape);
            Font          font        = this.GetFont(e.View);
            CDCompartment compartment = parentShape as CDCompartment;

            if (compartment != null)
            {
                ListField listField = null;
                foreach (ShapeField field2 in compartment.ShapeFields)
                {
                    if (field2 is ListField)
                    {
                        listField = field2 as ListField;
                        break;
                    }
                }
                float MemberLineHeight  = (float)listField.GetItemHeight(parentShape);
                float MemberStartMargin = 0f;
                float stringMargin      = 0.02f;
                if (listField != null)
                {
                    int itemCount = compartment.GetItemCount(listField);
                    for (int i = 0; i < itemCount; i++)
                    {
                        ItemDrawInfo itemDrawInfo = new ItemDrawInfo();
                        MemberStartMargin = (float)listField.GetItemRectangle(parentShape, i, 0).Y;
                        compartment.GetItemDrawInfo(listField, i, itemDrawInfo);
                        if (itemDrawInfo.Disabled)
                        {
                            continue;
                        }
                        string[] strArray = itemDrawInfo.Text.Split(new char[] { ':', '(', '{', '<' });

                        Member menberByName = this.GetMenberByName(parentShape.ParentShape, strArray[0].Trim());
                        if ((menberByName == null))
                        {
                            continue;
                        }
                        string docSummary      = menberByName.DocSummary;
                        string genericTypeName = "";

                        genericTypeName = menberByName.MemberTypeShortName;

                        BackBrush.Color     = Color.White;
                        VarBrush.Color      = Color.Blue;
                        ModifierBrush.Color = Color.Blue;
                        NameBrush.Color     = Color.Black;
                        SummaryBrush.Color  = Color.Green;
                        SelectedShapesCollection seleShapes = this._FromAddin.SelectedShapes;
                        if (seleShapes != null)
                        {
                            foreach (DiagramItem item in seleShapes)
                            {
                                if (((item.Shape == compartment) && (item.Field == listField)) && (item.SubField.SubFieldHashCode == i))
                                {
                                    this.BackBrush.Color = SystemColors.Highlight;
                                    VarBrush.Color       = Color.White;
                                    NameBrush.Color      = Color.White;
                                    SummaryBrush.Color   = Color.White;
                                    ModifierBrush.Color  = Color.White;
                                    break;
                                }
                            }
                        }



                        float      recX  = (float)itemDrawInfo.ImageMargin;//0.16435f
                        RectangleD bound = parentShape.BoundingBox;

                        float width = (float)bound.Width;
                        //float MemberStartMargin = 0.26f;


                        e.Graphics.FillRectangle(this.BackBrush, VSConfigManager.CurConfig.MemberMarginX,
                                                 MemberStartMargin, width,
                                                 MemberLineHeight);

                        float curX = VSConfigManager.CurConfig.MemberMarginX;

                        string memberTypeName = menberByName.MemberTypeName.TrimEnd('?', '[', ']');
                        if (BackBrush.Color == Color.White)//非选中状态
                        {
                            if ((memberTypeName != "void") && (menberByName.MemberTypeLookupName == memberTypeName))
                            {
                                VarBrush.Color = Color.DodgerBlue;
                            }
                            //if (!menberByName.IsSpecialName)
                            //{
                            //    VarBrush.Color = Color.DodgerBlue;
                            //}
                        }
                        string curStr = null;

                        if (EnumUnit.ContainerValue((int)_summaryShowInfo, (int)SummaryShowItem.TypeName))
                        {
                            if (menberByName.IsStatic)
                            {
                                curStr = "static";
                                e.Graphics.DrawString(curStr, font, ModifierBrush, curX,
                                                      MemberStartMargin + stringMargin);
                                curX += e.Graphics.MeasureString(curStr, font).Width;
                            }


                            curStr = genericTypeName + " ";
                            e.Graphics.DrawString(curStr, font, this.VarBrush, curX,
                                                  MemberStartMargin + stringMargin);
                            curX += e.Graphics.MeasureString(curStr, font).Width;
                        }
                        if (EnumUnit.ContainerValue((int)_summaryShowInfo, (int)SummaryShowItem.MemberName))
                        {
                            curStr = menberByName.Name;
                            if (menberByName is ClrMethod)
                            {
                                curStr += "()";
                            }


                            e.Graphics.DrawString(curStr, font, this.NameBrush, curX,
                                                  MemberStartMargin + stringMargin);
                            curX += e.Graphics.MeasureString(curStr, font).Width;
                        }
                        if (EnumUnit.ContainerValue((int)_summaryShowInfo, (int)SummaryShowItem.Summary))
                        {
                            if (!string.IsNullOrEmpty(curStr))
                            {
                                curStr = ":";
                            }
                            else
                            {
                                curStr = "";
                            }
                            curStr += HttpUtility.HtmlDecode(docSummary);
                            e.Graphics.DrawString(curStr, font, this.SummaryBrush, curX,
                                                  MemberStartMargin + stringMargin);
                        }
                    }
                }
            }
        }
Example #8
0
        // Methods
        public override void DoPaint(DiagramPaintEventArgs e, ShapeElement parentShape)
        {
            base.DoPaint(e, parentShape);
            Font          font        = this.GetFont(e.View);
            CDCompartment compartment = parentShape as CDCompartment;

            if (compartment != null)
            {
                ListField listField = null;
                foreach (ShapeField field2 in compartment.ShapeFields)
                {
                    if (field2 is ListField)
                    {
                        listField = field2 as ListField;
                        break;
                    }
                }
                float MemberLineHeight = (float)listField.GetItemHeight(parentShape);
                if (listField != null)
                {
                    int itemCount = compartment.GetItemCount(listField);
                    for (int i = 0; i < itemCount; i++)
                    {
                        ItemDrawInfo itemDrawInfo = new ItemDrawInfo();
                        compartment.GetItemDrawInfo(listField, i, itemDrawInfo);
                        if (!itemDrawInfo.Disabled)
                        {
                            string[] strArray     = itemDrawInfo.Text.Split(new char[] { ':', '(', '{' });
                            Member   menberByName = this.GetMenberByName(parentShape.ParentShape, strArray[0].Trim());
                            if ((menberByName != null))
                            {
                                string docSummary = menberByName.DocSummary;
                                this.BackBrush.Color    = Color.White;
                                this.SummaryBrush.Color = Color.Green;
                                this.NameBrush.Color    = Color.Black;
                                SelectedShapesCollection seleShapes = this._FromAddin.SelectedShapes;
                                if (seleShapes != null)
                                {
                                    foreach (DiagramItem item in seleShapes)
                                    {
                                        if (((item.Shape == compartment) && (item.Field == listField)) && (item.SubField.SubFieldHashCode == i))
                                        {
                                            this.BackBrush.Color    = SystemColors.Highlight;
                                            this.SummaryBrush.Color = Color.White;
                                            this.NameBrush.Color    = Color.White;
                                            break;
                                        }
                                    }
                                }
                                float      height = 0.19f;
                                float      recX   = (float)itemDrawInfo.ImageMargin;//0.16435f
                                RectangleD bound  = parentShape.BoundingBox;
                                float      width  = (float)bound.Width;



                                e.Graphics.FillRectangle(this.BackBrush, 0f,
                                                         (0f + MemberLineHeight * (float)i),
                                                         width, MemberLineHeight);

                                DBConfigInfo dbInfo = DBConfigInfo.LoadInfo(_FromAddin.GetDesignerInfo());

                                string curStr = null;
                                float  curX   = 0f;
                                if (EnumUnit.ContainerValue((int)_summaryShowInfo, (int)SummaryShowItem.MemberName))
                                {
                                    curStr = menberByName.Name;

                                    e.Graphics.DrawString(curStr, font, this.NameBrush, curX,
                                                          (0f + MemberLineHeight * (float)i + 0.02f));
                                    curX += e.Graphics.MeasureString(curStr, font).Width;
                                }
                                if (EnumUnit.ContainerValue((int)_summaryShowInfo, (int)SummaryShowItem.Summary))
                                {
                                    if (!string.IsNullOrEmpty(curStr))
                                    {
                                        curStr = ":";
                                    }
                                    else
                                    {
                                        curStr = "";
                                    }
                                    curStr += HttpUtility.HtmlDecode(menberByName.DocSummary);
                                    e.Graphics.DrawString(curStr, font, this.SummaryBrush, curX,
                                                          (0f + MemberLineHeight * (float)i + 0.02f));
                                }
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        ///     Returns the first selection item in the provided selection.
        /// </summary>
        /// <param name="currentSelection"></param>
        /// <param name="proposedShapesToAdd"></param>
        /// <param name="proposedShapesToRemove"></param>
        /// <returns></returns>
        private static DiagramItem FirstSelectionItem(
            SelectedShapesCollection currentSelection, DiagramItemCollection proposedShapesToAdd,
            DiagramItemCollection proposedShapesToRemove)
        {
            // Temporary list that stores what the selections will look like.
            var actualSelection = new DiagramItemCollection();

            // Add current selection items to the list.
            foreach (DiagramItem item in currentSelection)
            {
                if (item != null
                    && actualSelection.Contains(item) == false)
                {
                    actualSelection.Add(item);
                }
            }

            // Include additional diagram items that will be selected.
            foreach (var item in proposedShapesToAdd)
            {
                if (item != null
                    && actualSelection.Contains(item) == false)
                {
                    actualSelection.Add(item);
                }
            }

            // Remove diagram items that will be unselected.
            foreach (var item in proposedShapesToRemove)
            {
                if (item != null
                    && actualSelection.Contains(item))
                {
                    actualSelection.Remove(item);
                }
            }

            // Return the first item in the list.
            if (actualSelection.Count > 0)
            {
                return actualSelection[0];
            }
            return null;
        }
 /// <summary>
 ///     Helper method to cancel a diagram item to be selected.
 /// </summary>
 /// <param name="diagramItem"></param>
 /// <param name="currentSelection"></param>
 /// <param name="proposedItemsToAdd"></param>
 /// <param name="proposedItemsToRemove"></param>
 private static void RemoveSelectedDiagramItem(
     DiagramItem diagramItem, SelectedShapesCollection currentSelection, DiagramItemCollection proposedItemsToAdd,
     DiagramItemCollection proposedItemsToRemove)
 {
     if (currentSelection.Contains(diagramItem) == false
         && proposedItemsToAdd.Contains(diagramItem))
     {
         proposedItemsToAdd.Remove(diagramItem);
     }
     if (currentSelection.Contains(diagramItem)
         && proposedItemsToRemove.Contains(diagramItem) == false)
     {
         proposedItemsToRemove.Add(diagramItem);
     }
 }
            /// <summary>
            ///     Called by the design surface to allow selection filtering
            /// </summary>
            /// <param name="currentSelection">[in] The current selection before any ShapeElements are added or removed.</param>
            /// <param name="proposedItemsToAdd">[in/out] The proposed DiagramItems to be added to the selection.</param>
            /// <param name="proposedItemsToRemove">[in/out] The proposed DiagramItems to be removed from the selection.</param>
            /// <param name="primaryItem">
            ///     [in/out] The proposed DiagramItem to become the primary DiagramItem of the selection.
            ///     A null value signifies that the last DiagramItem in the resultant selection should be assumed as the
            ///     primary DiagramItem.
            /// </param>
            /// <returns>
            ///     true if some or all of the selection was accepted; false if the entire selection proposal
            ///     was rejected. If false, appropriate feedback will be given to the user to indicate that the
            ///     selection was rejected.
            /// </returns>
            public override bool GetCompliantSelection(
                SelectedShapesCollection currentSelection, DiagramItemCollection proposedItemsToAdd,
                DiagramItemCollection proposedItemsToRemove, DiagramItem primaryItem)
            {
                base.GetCompliantSelection(currentSelection, proposedItemsToAdd, proposedItemsToRemove, primaryItem);

                var originalProposedItemsToAdd = new DiagramItem[proposedItemsToAdd.Count];
                proposedItemsToAdd.CopyTo(originalProposedItemsToAdd, 0);

                // we only perform this with selection rectangles, in which case the focused item will be the diagram 
                // and the user clicks on the "Properties" or "Navigation Properties" compartment on an entity
                if (currentSelection.FocusedItem != null
                    && currentSelection.FocusedItem.Shape == _diagram)
                {
                    foreach (var item in originalProposedItemsToAdd)
                    {
                        if (item.Shape != null
                            && item.Shape is ElementListCompartment)
                        {
                            // only perform this if we have selected the "Scalar Properties" ListCompartment or
                            // the "Navigation Properties" ListCompartment
                            var elListCompartment = item.Shape as ElementListCompartment;
                            if (elListCompartment.DefaultCreationDomainClass.Id == ViewModelProperty.DomainClassId
                                || elListCompartment.DefaultCreationDomainClass.Id == ViewModelNavigationProperty.DomainClassId)
                            {
                                // we don't perform this if a Property or NavigationProperty was selected
                                var representedShapeElements = item.RepresentedElements.OfType<ShapeElement>();
                                if (representedShapeElements.Count() == 1
                                    && representedShapeElements.Contains(item.Shape))
                                {
                                    // find the parent EntityTypeShape that houses this ListCompartment
                                    var entityTypeShape = elListCompartment.ParentShape as EntityTypeShape;
                                    Debug.Assert(
                                        entityTypeShape != null, "Why isn't the parent of the list compartment an EntityTypeShape?");
                                    var entityTypeShapeDiagramItem = new DiagramItem(entityTypeShape);

                                    // add the parent EntityTypeShape if it doesn't already exist in the collection
                                    if (!currentSelection.Contains(entityTypeShapeDiagramItem)
                                        && proposedItemsToAdd.Contains(entityTypeShapeDiagramItem) == false)
                                    {
                                        proposedItemsToAdd.Add(entityTypeShapeDiagramItem);
                                    }

                                    proposedItemsToAdd.Remove(item);
                                }
                            }
                        }
                    }
                }

                // The code below is responsible to enforce the following diagram items selection rule. (see Multiple Diagram spec).
                // - if an entity-type-shape is selected, no diagram-item can be selected in the diagram.
                // - if diagram-item that is not an entity-type-shape is selected, no entity-type-shape can be selected.
                var firstDiagramItem = FirstSelectionItem(currentSelection, proposedItemsToAdd, proposedItemsToRemove);
                if (firstDiagramItem != null
                    && proposedItemsToAdd.Count > 0)
                {
                    var isFirstDiagramItemEntityTypeShape = firstDiagramItem.Shape is EntityTypeShape;

                    // For Multi selection rules, we can only select EntityTypeShapes or else but not both.
                    foreach (var item in proposedItemsToAdd.ToList())
                    {
                        if (isFirstDiagramItemEntityTypeShape && ((item.Shape is EntityTypeShape) == false))
                        {
                            RemoveSelectedDiagramItem(item, currentSelection, proposedItemsToAdd, proposedItemsToRemove);
                        }
                        else if (isFirstDiagramItemEntityTypeShape == false
                                 && (item.Shape is EntityTypeShape))
                        {
                            RemoveSelectedDiagramItem(item, currentSelection, proposedItemsToAdd, proposedItemsToRemove);
                        }
                    }
                }
                return true;
            }