Пример #1
0
        protected override void OnLayout(Miyagi.UI.Controls.Layout.LayoutEventArgs e)
        {
            base.OnLayout(e);

            //Ignore the Grid Layout Style for now because implementing things that have been promised is hard
            _cols = Math.Max(this.Width / GridLayoutStyle.CellSize.Width, 1);
            _rows = this.Controls.Count / _cols;
            int r = 0;
            int c = 0;

            foreach (Control con in this.Controls)
            {
                con.Width  = GridLayoutStyle.CellSize.Width;
                con.Height = GridLayoutStyle.CellSize.Height;
                con.Left   = c * GridLayoutStyle.CellSize.Width;
                con.Top    = r * GridLayoutStyle.CellSize.Height;
                if (con is SkinnedControl)
                {
                    ((SkinnedControl)con).Skin = GridLayoutStyle.CellSkin;
                }
                ++c;
                if (c % _cols == 0)
                {
                    c = 0;
                    ++r;
                }
            }
        }
Пример #2
0
        protected override void OnLayout(Miyagi.UI.Controls.Layout.LayoutEventArgs e)
        {
            base.OnLayout(e);

            if (this.IsDisposed)
            {
                return;
            }

            int tabwidth = 100;
            int tabcount = TabPages.Count;

            switch (TabStyle.Mode)
            {
            case Miyagi.UI.TabMode.FixedSize:
                tabwidth = TabStyle.Extent * 3;
                break;

            case Miyagi.UI.TabMode.Fill:
                tabwidth = tabcount > 0 ? this.ClientSize.Width / tabcount : 100;
                break;

            case Miyagi.UI.TabMode.AutoSize:
                if (TabStyle.Extent * 3 * tabcount < this.ClientSize.Width)
                {
                    tabwidth = TabStyle.Extent * 3;
                }
                else
                {
                    tabwidth = this.ClientSize.Width / tabcount;
                }
                break;
            }
            int i = 0;

            foreach (Panel p in this.TabPages.Keys)
            {
                if (p.IsDisposed)
                {
                    continue;
                }
                p.Width  = this.ClientSize.Width;
                p.Height = this.ClientSize.Height - this.TabStyle.Extent;
                p.Top    = TabStyle.Extent;

                Button b = TabButtons[this.TabPages[p]];
                b.TextStyle.Font = TabStyle.Font;

                if (p == ActiveTab)
                {
                    b.TextStyle.ForegroundColour = TabStyle.SelectColour;
                }
                else if (p.IsMouseOver)
                {
                    b.TextStyle.ForegroundColour = TabStyle.HoverColour;
                }
                else
                {
                    b.TextStyle.ForegroundColour = TabStyle.ForegroundColour;
                }

                b.Width  = tabwidth;
                b.Height = TabStyle.Extent;
                b.Left   = i * tabwidth;
                ++i;
            }
        }