예제 #1
0
파일: TabControl.cs 프로젝트: xxy1991/cozy
        /// <summary>
        /// Redraws the size positions.
        /// </summary>
        private void RedrawSizePositions()
        {
            // the width of tab-menu is the width of tab-control
            // the height of tab-menu is 1.2 times the theme height
            this.Menu.Config.PositionX = 0;
            this.Menu.Config.PositionY = 0;
            this.Menu.Config.Width = Config.Width;
            this.Menu.Config.Height = Theme.ControlHeight * 1.2f;

            // tab buttons will be aligned on the left side
            // there will be small spacing in between each tab-button
            // tab buttons will be added to the TabMenu
            for (var index = 0; index < this.tabs.Count; index++)
            {
                var tab = this.tabs[index];
                var button = tab.Button;
                if (button == null)
                {
                    button = new TabButton(Name + "-" + tab.TabName);
                    this.AddControl(button);
                }

                var w = Theme.ControlWidth;
                var h = Theme.ControlHeight;
                button.Config.PositionX = ((index * w) * 0.8f) + (w * 0.1f) - (w * 0.1f);
                button.Config.PositionY = this.Menu.Config.Height - h;
                button.Config.Width = w * 0.8f;
                button.Config.Height = h;
            }

            // tab containers will placed underneath the tab-menu
            // they fill up all the rest space of the tab-control
            for (var index = 0; index < this.tabs.Count; index++)
            {
                var tab = this.tabs[index];
                var container = tab.Container;
                if (container == null)
                {
                    container = new TabContainer(Name + "-" + tab.Container);
                    this.AddControl(container);
                }

                container.Config.PositionX = 0;
                container.Config.PositionY = this.Menu.Config.Height;
                container.Config.Width = this.Config.Width;
                container.Config.Height = this.Config.Height - this.Menu.Config.Height;
            }
        }