Beispiel #1
0
        protected void MergeRelateVDSection(VDSection sourceElement, ElementGroup elementGroup)
        {
            // Create link for path WidgetHasChildren.Children
            this.Children.Add(sourceElement);

            // create section title and body
            sourceElement.Head = this.Store.ElementFactory.CreateElement(VDSectionHead.DomainClassId) as VDSectionHead;
            sourceElement.Body = this.Store.ElementFactory.CreateElement(VDSectionBody.DomainClassId) as VDSectionBody;
            VDHoriSeparator hSeparator = this.Store.ElementFactory.CreateElement(VDHoriSeparator.DomainClassId) as VDHoriSeparator;

            hSeparator.TopWidget    = sourceElement.Head;
            hSeparator.BottomWidget = sourceElement.Body;
            sourceElement.Children.Add(hSeparator);
        }
Beispiel #2
0
        public void MergeTo(VDWidget targetWidget, ElementGroup elementGroup)
        {
            targetWidget.Children.Add(this);

            // the order of creating children is import, why??
            // first children, then grand-children???
            VDHoriContainer headContainer = this.Store.ElementFactory.CreateElement(VDHoriContainer.DomainClassId,
                                                                                    new PropertyAssignment(VDContainer.TagDomainPropertyId, HEADS_CONTAINER_TAG),
                                                                                    new PropertyAssignment(VDContainer.HasLeftAnchorDomainPropertyId, true),
                                                                                    new PropertyAssignment(VDContainer.HasRightAnchorDomainPropertyId, true),
                                                                                    new PropertyAssignment(VDContainer.HasTopAnchorDomainPropertyId, true)) as VDHoriContainer;
            VDFullFilledContainer bodyContainer = this.Store.ElementFactory.CreateElement(VDFullFilledContainer.DomainClassId,
                                                                                          new PropertyAssignment(VDContainer.TagDomainPropertyId, BODYS_CONTAINER_TAG),
                                                                                          new PropertyAssignment(VDContainer.HasLeftAnchorDomainPropertyId, true),
                                                                                          new PropertyAssignment(VDContainer.HasRightAnchorDomainPropertyId, true),
                                                                                          new PropertyAssignment(VDContainer.HasBottomAnchorDomainPropertyId, true)) as VDFullFilledContainer;

            VDHoriSeparator hSeparator = this.Store.ElementFactory.CreateElement(VDHoriSeparator.DomainClassId,
                                                                                 new PropertyAssignment(VDHoriSeparator.DefaultYDomainPropertyId, 0.5)) as VDHoriSeparator;

            hSeparator.TopWidget    = headContainer;
            hSeparator.BottomWidget = bodyContainer;

            this.Children.Add(headContainer);
            this.Children.Add(bodyContainer);
            this.Children.Add(hSeparator);

            VDTabHead head = this.Store.ElementFactory.CreateElement(
                VDTabHead.DomainClassId,
                new PropertyAssignment(VDTabHead.TabTitleDomainPropertyId, "New Tab")) as VDTabHead;
            VDTabBody body = this.Store.ElementFactory.CreateElement(VDTabBody.DomainClassId) as VDTabBody;

            this.ActiveHead = head;
            head.Body       = body;
            headContainer.Children.Add(head);
            bodyContainer.Children.Add(body);
        }
            public override RectangleD GetCompliantBounds(ShapeElement shape, RectangleD proposedBounds)
            {
                VDHoriSeparatorShape separatorShape = shape as VDHoriSeparatorShape;

                if (separatorShape == null)
                {
                    throw new ArgumentNullException("horizontalSeparatorShape");
                }

                VDWidgetShape parentShape = separatorShape.ParentShape as VDWidgetShape;

                if (parentShape == null || separatorShape.Store.InUndoRedoOrRollback)
                {
                    return(proposedBounds);
                }

                VDHoriSeparator model = separatorShape.ModelElement as VDHoriSeparator;

                if (model == null)
                {
                    return(proposedBounds);
                }

                bool   bFlagBoundsSet = false;
                PointD location       = proposedBounds.Location;
                SizeD  size           = proposedBounds.Size;

                // anchor to parent widget
                if (!separatorShape.Anchoring.HasLeftAnchor)
                {
                    separatorShape.Anchoring.SetLeftAnchor(0);
                }
                if (!separatorShape.Anchoring.HasRightAnchor)
                {
                    separatorShape.Anchoring.SetRightAnchor(1);
                }

                // anchor to top widget
                if (model.TopWidget != null)
                {
                    NodeShape topWidgetShape = parentShape.NestedChildShapes.Find(c => c.ModelElement == model.TopWidget) as NodeShape;
                    if (topWidgetShape != null)
                    {
                        if (!topWidgetShape.Anchoring.HasBottomAnchor)
                        {
                            topWidgetShape.Anchoring.SetBottomAnchor(separatorShape, AnchoringBehavior.Edge.Top, model.TopMargin);
                        }
                        //if (!separatorShape.Anchoring.HasLeftAnchor)
                        //    separatorShape.Anchoring.SetLeftAnchor(topWidgetShape, AnchoringBehavior.Edge.Left, 0);
                        //if (!separatorShape.Anchoring.HasRightAnchor)
                        //    separatorShape.Anchoring.SetRightAnchor(topWidgetShape, AnchoringBehavior.Edge.Right, 0);

                        // set bounds of HorizonalSeparator according to top widget
                        //location.X = topWidgetShape.Bounds.Left;
                        if (location.Y < VDConstants.DOUBLE_DIFF || location.Y + size.Height + VDConstants.DOUBLE_DIFF > parentShape.Bounds.Height)
                        {
                            location.Y = topWidgetShape.Bounds.Bottom + model.TopMargin;
                        }
                        bFlagBoundsSet = true;
                    }
                }

                // anchor to bottom widget
                if (model.BottomWidget != null)
                {
                    NodeShape bottomWidgetShape = parentShape.NestedChildShapes.Find(c => c.ModelElement == model.BottomWidget) as NodeShape;
                    if (bottomWidgetShape != null)
                    {
                        if (!bottomWidgetShape.Anchoring.HasTopAnchor)
                        {
                            bottomWidgetShape.Anchoring.SetTopAnchor(separatorShape, AnchoringBehavior.Edge.Bottom, model.BottomMargin);
                        }
                        //if (!separatorShape.Anchoring.HasLeftAnchor)
                        //    separatorShape.Anchoring.SetLeftAnchor(bottomWidgetShape, AnchoringBehavior.Edge.Left, 0);
                        //if (!separatorShape.Anchoring.HasRightAnchor)
                        //    separatorShape.Anchoring.SetRightAnchor(bottomWidgetShape, AnchoringBehavior.Edge.Right, 0);

                        // set bounds of handle according to bottom widget
                        if (!bFlagBoundsSet)
                        {
                            //location.X = bottomWidgetShape.Bounds.Left;
                            if (location.Y < VDConstants.DOUBLE_DIFF || location.Y + size.Height + VDConstants.DOUBLE_DIFF > parentShape.Bounds.Height)
                            {
                                location.Y = bottomWidgetShape.Bounds.Top - size.Height - model.BottomMargin;
                            }
                        }
                    }
                }

                // set initial Y position
                if (model.DefaultY >= 0)
                {
                    location.Y     = model.DefaultY;
                    model.DefaultY = -1;
                }

                return(new RectangleD(location, size));
            }