Ejemplo n.º 1
0
        public DiagramItem AddCompositors(DiagramItem parentDiagramElement,
                                          XMLSchema.group childGroup, DiagramItemGroupType type,
                                          string nameSpace)
        {
            ClearSearch();
            if (childGroup != null)
            {
                DiagramItem childDiagramGroup = new DiagramItem();
                childDiagramGroup.ItemType = DiagramItemType.group;

                XMLSchema.group referenceGroup = null;
                if (childGroup.@ref != null)
                {
                    childDiagramGroup.IsReference = true;
                    childDiagramGroup.Name        = [email protected] != null ? [email protected] : "";
                    childDiagramGroup.NameSpace   = [email protected] != null ? [email protected] : "";
                    XSDObject grpObject = null;
                    if (_elementsByName.TryGetValue(childDiagramGroup.FullName, out grpObject) && grpObject != null)
                    {
                        XMLSchema.group group = grpObject.Tag as XMLSchema.group;
                        if (group != null)
                        {
                            referenceGroup = childGroup;
                            childGroup     = group;
                        }
                    }
                }
                else if (type == DiagramItemGroupType.Group)
                {
                    childDiagramGroup.Name      = childGroup.name != null ? childGroup.name : "";
                    childDiagramGroup.NameSpace = nameSpace;
                }
                else
                {
                    childDiagramGroup.NameSpace = nameSpace;
                }

                childDiagramGroup.Diagram   = this;
                childDiagramGroup.TabSchema = childGroup;
                int occurrence;
                if (int.TryParse(referenceGroup != null ? referenceGroup.minOccurs : childGroup.minOccurs, out occurrence))
                {
                    childDiagramGroup.MinOccurrence = occurrence;
                }
                else
                {
                    childDiagramGroup.MinOccurrence = -1;
                }
                //try { childDiagramGroup.MinOccurrence = int.Parse(childGroup.minOccurs); }
                //catch { childDiagramGroup.MinOccurrence = -1; }
                if (int.TryParse(referenceGroup != null ? referenceGroup.maxOccurs : childGroup.maxOccurs, out occurrence))
                {
                    childDiagramGroup.MaxOccurrence = occurrence;
                }
                else
                {
                    childDiagramGroup.MaxOccurrence = -1;
                }
                //try { childDiagramGroup.MaxOccurrence = int.Parse(childGroup.maxOccurs); }
                //catch { childDiagramGroup.MaxOccurrence = -1; }
                childDiagramGroup.HasChildElements = true;
                childDiagramGroup.GroupType        = type;

                if (parentDiagramElement == null)
                {
                    _rootElements.Add(childDiagramGroup);
                }
                else
                {
                    childDiagramGroup.Parent = parentDiagramElement;
                    parentDiagramElement.ChildElements.Add(childDiagramGroup);
                }

                return(childDiagramGroup);
            }
            return(null);
        }
Ejemplo n.º 2
0
        public DiagramItem AddCompositors(DiagramItem parentDiagramElement, 
            XMLSchema.group childGroup, DiagramItemGroupType type,
            string nameSpace)
        {
            if (childGroup != null)
            {
                DiagramItem childDiagramGroup = new DiagramItem();
                childDiagramGroup.ItemType = DiagramItemType.group;
                if (childGroup.@ref != null)
                {
                    childDiagramGroup.IsReference = true;
                    childDiagramGroup.Name = [email protected] != null ? [email protected] : "";
                    childDiagramGroup.NameSpace = [email protected] != null ? [email protected] : "";
                    XSDObject grpObject = null;
                    if (_elementsByName.TryGetValue(childDiagramGroup.FullName, out grpObject) && grpObject != null)
                    {
                        XMLSchema.group group = grpObject.Tag as XMLSchema.group;
                        if (group != null)
                            childGroup = group;
                    }
                }
                else if (type == DiagramItemGroupType.Group)
                {
                    childDiagramGroup.Name = childGroup.name != null ? childGroup.name : "";
                    childDiagramGroup.NameSpace = nameSpace;
                }
                else
                {
                    childDiagramGroup.NameSpace = nameSpace;
                }

                childDiagramGroup.Diagram = this;
                childDiagramGroup.TabSchema = childGroup;
                int occurrence;
                if (int.TryParse(childGroup.minOccurs, out occurrence))
                    childDiagramGroup.MinOccurrence = occurrence;
                else
                    childDiagramGroup.MinOccurrence = -1;
                //try { childDiagramGroup.MinOccurrence = int.Parse(childGroup.minOccurs); }
                //catch { childDiagramGroup.MinOccurrence = -1; }
                if (int.TryParse(childGroup.maxOccurs, out occurrence))
                    childDiagramGroup.MaxOccurrence = occurrence;
                else
                    childDiagramGroup.MaxOccurrence = -1;
                //try { childDiagramGroup.MaxOccurrence = int.Parse(childGroup.maxOccurs); }
                //catch { childDiagramGroup.MaxOccurrence = -1; }
                childDiagramGroup.HasChildElements = true;
                childDiagramGroup.GroupType = type;

                if (parentDiagramElement == null)
                    _rootElements.Add(childDiagramGroup);
                else
                {
                    childDiagramGroup.Parent = parentDiagramElement;
                    parentDiagramElement.ChildElements.Add(childDiagramGroup);
                }

                return childDiagramGroup;
            }
            return null;
        }