public override void OnClickAdditionalTitleIcon(int idx) { if (idx == ICON_INDEX_ADD_TAB) // addd new tab { VDTab tab = this.ModelElement as VDTab; if (tab == null || tab.HeadContainer == null || tab.BodyContainer == null) { return; } using (Transaction t = this.Store.TransactionManager.BeginTransaction("Add new tab page")) { 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; head.Body = body; tab.ActiveHead = head; tab.HeadContainer.Children.Add(head); tab.BodyContainer.Children.Add(body); this.relayoutChildren = true; // only show active tab's body shape, hide other body shapes t.Commit(); } } }
public override void OnRelayoutChildShapes() { if (this.BodyContainerShape == null) { return; } VDTab tab = this.ModelElement as VDTab; if (tab == null) { return; } // only show active tab's body shape, hide other body shapes foreach (var w in this.BodyContainerShape.NestedChildShapes) { VDTabBodyShape bodyShape = w as VDTabBodyShape; if (bodyShape != null) { VDTabBody body = bodyShape.ModelElement as VDTabBody; if (body == null || body.Head == null || body.Head != tab.ActiveHead) { bodyShape.Hide(); } else { bodyShape.Show(); } } } // set head background for active tab if (this.HeadContainerShape == null) { return; } foreach (var w in this.HeadContainerShape.NestedChildShapes) { VDTabHeadShape headShape = w as VDTabHeadShape; if (headShape != null) { VDTabHead head = headShape.ModelElement as VDTabHead; if (head == null || tab.ActiveHead != head) { headShape.isActiveTab = false; } else { headShape.isActiveTab = true; } } } //this.BodyContainerShape.relayoutChildren = true; // trigger body shapes' bounds rules }
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); }