Exemple #1
0
        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();
                }
            }
        }
Exemple #2
0
        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
        }
Exemple #3
0
        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;
                }
            }
        }
Exemple #4
0
        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();
                }
            }
        }