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 override void OnBoundsFixup(BoundsFixupState fixupState, int iteration, bool createdDuringViewFixup) { base.OnBoundsFixup(fixupState, iteration, createdDuringViewFixup); // be sure the isActiveTab property is set for Active Tab VDTabHead tabHead = this.ModelElement as VDTabHead; if (tabHead != null && tabHead.Parent != null && tabHead.Parent.Parent != null) { VDTab tab = tabHead.Parent.Parent as VDTab; if (tab != null && tab.ActiveHead == tabHead) { this.isActiveTab = true; } } }
public override void OnClick(DiagramPointEventArgs e) { if (this.ParentShape == null || this.ParentShape.ParentShape == null) { return; } VDTabShape tabShape = this.ParentShape.ParentShape as VDTabShape; if (tabShape == null) { return; } VDTab tab = tabShape.ModelElement as VDTab; if (tab == null) { return; } VDTabHead curHead = this.ModelElement as VDTabHead; if (curHead == null) { return; } if (tab.ActiveHead != curHead) { using (Transaction t = this.Store.TransactionManager.BeginTransaction("Set active tab")) { tab.ActiveHead = curHead; tabShape.relayoutChildren = true; // only show active tab's body shape, hide other body shapes t.Commit(); } } }
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); }