예제 #1
0
        protected override void InitControl()
        {
            if (IsDesignTime)
            {
                return;
            }

            this.tabControl = this.GetByName <TabControlCached>("TabControl");
            var tabControlItems = this.tabControl.Items;

            // local helper method for getting options tab order
            IEnumerable <ProtoOptionsCategory> GetOptionsCategoryOrder(ProtoOptionsCategory tab)
            {
                if (tab.OrderAfterCategory is not null)
                {
                    yield return(tab.OrderAfterCategory);
                }
            }

            this.allOptions = Api.FindProtoEntities <ProtoOptionsCategory>()
                              .OrderBy(o => o.ShortId)
                              .TopologicalSort(GetOptionsCategoryOrder);

            var headerTemplate = this.GetResource <ControlTemplate>("HeaderTemplate");

            foreach (var protoOptionsCategory in this.allOptions)
            {
                var control = protoOptionsCategory.CreateControl();
                tabControlItems.Add(
                    new TabItem()
                {
                    Header = new ContentControl()
                    {
                        Template    = headerTemplate,
                        DataContext = new ViewModelOptionsCategory(protoOptionsCategory)
                    },
                    Content = control,
                    Tag     = protoOptionsCategory
                });
            }

            this.tabControl.RefreshItems();
        }
예제 #2
0
 protected override void InitMenu()
 {
     this.DataContext = this.viewModel = new ViewModelWindowPolitics();
     this.tabControl  = this.GetByName <TabControlCached>("TabControl");
 }