コード例 #1
0
ファイル: GroupBox.cs プロジェクト: CrazyLiu00/GMap
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            Color color = Color.White;

            {
                Alt.GUI.Temporary.Gwen.Control.GroupBox gb = new Alt.GUI.Temporary.Gwen.Control.GroupBox(this);
                gb.TextColor = color;
                gb.Text      = "Group Box (centered)";
                gb.SetBounds(10, 10, 200, 100);
                //Align.Center(gb);
            }

            {
                Alt.GUI.Temporary.Gwen.Control.GroupBox gb = new Alt.GUI.Temporary.Gwen.Control.GroupBox(this);
                gb.TextColor          = color;
                gb.AutoSizeToContents = true;
                gb.Text = "With Label (autosized)";
                gb.SetPosition(250, 10);
                Alt.GUI.Temporary.Gwen.Control.Label label = new Alt.GUI.Temporary.Gwen.Control.Label(gb);
                label.TextColor          = color;
                label.AutoSizeToContents = true;
                label.Text = "I'm a label";
            }

            {
                Alt.GUI.Temporary.Gwen.Control.GroupBox gb = new Alt.GUI.Temporary.Gwen.Control.GroupBox(this);
                gb.TextColor          = color;
                gb.AutoSizeToContents = true;
                gb.Text = "With Label (autosized)";
                gb.SetPosition(250, 50);
                Alt.GUI.Temporary.Gwen.Control.Label label = new Alt.GUI.Temporary.Gwen.Control.Label(gb);
                label.TextColor          = color;
                label.AutoSizeToContents = true;
                label.Text = "I'm a label. I'm a really long label!";
            }

            {
                Alt.GUI.Temporary.Gwen.Control.GroupBox gb = new Alt.GUI.Temporary.Gwen.Control.GroupBox(this);
                gb.TextColor          = color;
                gb.AutoSizeToContents = true;
                gb.Text = "Two docked Labels (autosized)";
                gb.SetPosition(250, 100);
                Alt.GUI.Temporary.Gwen.Control.Label label1 = new Alt.GUI.Temporary.Gwen.Control.Label(gb);
                label1.TextColor          = color;
                label1.AutoSizeToContents = true;
                label1.Text = "I'm a label";
                label1.Dock = Alt.GUI.Temporary.Gwen.Pos.Top;
                Alt.GUI.Temporary.Gwen.Control.Label label2 = new Alt.GUI.Temporary.Gwen.Control.Label(gb);
                label2.TextColor          = color;
                label2.AutoSizeToContents = true;
                label2.Text = "I'm a label. I'm a really long label!";
                label2.Dock = Alt.GUI.Temporary.Gwen.Pos.Top;
            }

            {
                Alt.GUI.Temporary.Gwen.Control.GroupBox gb = new Alt.GUI.Temporary.Gwen.Control.GroupBox(this);
                gb.TextColor          = color;
                gb.AutoSizeToContents = true;
                gb.Text = "Empty (autosized)";
                gb.SetPosition(10, 150);
            }

            {
                Alt.GUI.Temporary.Gwen.Control.GroupBox gb1 = new Alt.GUI.Temporary.Gwen.Control.GroupBox(this);
                gb1.TextColor = color;
                //Control.Label gb1 = new Label(this);
                gb1.Padding = Alt.GUI.Temporary.Gwen.Padding.Five;
                gb1.Text    = "Yo dawg,";
                gb1.SetPosition(10, 200);
                gb1.SetSize(350, 200);
                //gb1.AutoSizeToContents = true;

                Alt.GUI.Temporary.Gwen.Control.GroupBox gb2 = new Alt.GUI.Temporary.Gwen.Control.GroupBox(gb1);
                gb2.TextColor = color;
                gb2.Text      = "I herd";
                gb2.Dock      = Alt.GUI.Temporary.Gwen.Pos.Left;
                gb2.Margin    = Alt.GUI.Temporary.Gwen.Margin.Three;
                gb2.Padding   = Alt.GUI.Temporary.Gwen.Padding.Five;
                //gb2.AutoSizeToContents = true;

                Alt.GUI.Temporary.Gwen.Control.GroupBox gb3 = new Alt.GUI.Temporary.Gwen.Control.GroupBox(gb1);
                gb3.TextColor = color;
                gb3.Text      = "You like";
                gb3.Dock      = Alt.GUI.Temporary.Gwen.Pos.Fill;

                Alt.GUI.Temporary.Gwen.Control.GroupBox gb4 = new Alt.GUI.Temporary.Gwen.Control.GroupBox(gb3);
                gb4.TextColor          = color;
                gb4.Text               = "Group Boxes,";
                gb4.Dock               = Alt.GUI.Temporary.Gwen.Pos.Top;
                gb4.AutoSizeToContents = true;

                Alt.GUI.Temporary.Gwen.Control.GroupBox gb5 = new Alt.GUI.Temporary.Gwen.Control.GroupBox(gb3);
                gb5.TextColor = color;
                gb5.Text      = "So I put Group";
                gb5.Dock      = Alt.GUI.Temporary.Gwen.Pos.Fill;
                //gb5.AutoSizeToContents = true;

                Alt.GUI.Temporary.Gwen.Control.GroupBox gb6 = new Alt.GUI.Temporary.Gwen.Control.GroupBox(gb5);
                gb6.TextColor          = color;
                gb6.Text               = "Boxes in yo";
                gb6.Dock               = Alt.GUI.Temporary.Gwen.Pos.Left;
                gb6.AutoSizeToContents = true;

                Alt.GUI.Temporary.Gwen.Control.GroupBox gb7 = new Alt.GUI.Temporary.Gwen.Control.GroupBox(gb5);
                gb7.TextColor = color;
                gb7.Text      = "Boxes so you can";
                gb7.Dock      = Alt.GUI.Temporary.Gwen.Pos.Top;
                gb7.SetSize(100, 100);

                Alt.GUI.Temporary.Gwen.Control.GroupBox gb8 = new Alt.GUI.Temporary.Gwen.Control.GroupBox(gb7);
                gb8.TextColor          = color;
                gb8.Text               = "Group Box while";
                gb8.Dock               = Alt.GUI.Temporary.Gwen.Pos.Top;
                gb8.Margin             = Alt.GUI.Temporary.Gwen.Margin.Five;
                gb8.AutoSizeToContents = true;

                Alt.GUI.Temporary.Gwen.Control.GroupBox gb9 = new Alt.GUI.Temporary.Gwen.Control.GroupBox(gb7);
                gb9.TextColor          = color;
                gb9.Text               = "u Group Box";
                gb9.Dock               = Alt.GUI.Temporary.Gwen.Pos.Bottom;
                gb9.Padding            = Alt.GUI.Temporary.Gwen.Padding.Five;
                gb9.AutoSizeToContents = true;
            }

            // at the end to apply to all children
            DrawDebugOutlines = true;
        }
コード例 #2
0
ファイル: Docking.cs プロジェクト: CrazyLiu00/GMap
        Base CreateControls(Base subject, int dock_idx, String name, int x, int y)
        {
            Alt.GUI.Temporary.Gwen.Control.GroupBox gb = new Alt.GUI.Temporary.Gwen.Control.GroupBox(this);
            gb.TextColor = labelColor;
            gb.SetBounds(x, y, 200, 150);
            gb.Text = name;

            Alt.GUI.Temporary.Gwen.Control.Label l_width = new Alt.GUI.Temporary.Gwen.Control.Label(gb);
            l_width.TextColor = labelColor;
            l_width.SetSize(35, 15);
            l_width.Text = "Width:";

            Alt.GUI.Temporary.Gwen.Control.HorizontalSlider width = new Alt.GUI.Temporary.Gwen.Control.HorizontalSlider(gb);
            width.Name     = "Width";
            width.UserData = subject;
            width.Min      = 50;
            width.Max      = 350;
            width.Value    = 100;
            width.SetSize(55, 15);
            width.ValueChanged += WidthChanged;
            Alt.GUI.Temporary.Gwen.Align.PlaceRightBottom(width, l_width);

            Alt.GUI.Temporary.Gwen.Control.Label l_height = new Alt.GUI.Temporary.Gwen.Control.Label(gb);
            l_height.TextColor = labelColor;
            l_height.SetSize(35, 15);
            l_height.Text = "Height:";
            Alt.GUI.Temporary.Gwen.Align.PlaceRightBottom(l_height, width, 10);

            Alt.GUI.Temporary.Gwen.Control.HorizontalSlider height = new Alt.GUI.Temporary.Gwen.Control.HorizontalSlider(gb);
            height.Name     = "Height";
            height.UserData = subject;
            height.Min      = 50;
            height.Max      = 350;
            height.Value    = 100;
            height.SetSize(55, 15);
            height.ValueChanged += HeightChanged;
            Alt.GUI.Temporary.Gwen.Align.PlaceRightBottom(height, l_height);

            Alt.GUI.Temporary.Gwen.Control.RadioButtonGroup dock = new Alt.GUI.Temporary.Gwen.Control.RadioButtonGroup(gb, "Dock");
            dock.TextColor = labelColor;
            dock.UserData  = subject; // store control that we are controlling
            dock.AddOption("Left");
            dock.AddOption("Top");
            dock.AddOption("Right");
            dock.AddOption("Bottom");
            dock.AddOption("Fill");
            dock.SetSelection(dock_idx);
            Alt.GUI.Temporary.Gwen.Align.PlaceDownLeft(dock, l_width, 5);
            //dock.DrawDebugOutlines = true;
            dock.Invalidate();

            Alt.GUI.Temporary.Gwen.Control.Label l_margin = new Alt.GUI.Temporary.Gwen.Control.Label(gb);
            l_margin.TextColor = labelColor;
            l_margin.Text      = "Margin:";
            l_margin.SetBounds(75, 20, 35, 15);
            //Align.PlaceRightBottom(l_margin, dock);
            // can't use Align to anchor with 'dock' because radio group is resized only after layout ~_~
            // this is become really cumbersome
            //l_margin.DrawDebugOutlines = true;

            Alt.GUI.Temporary.Gwen.Control.HorizontalSlider margin = new Alt.GUI.Temporary.Gwen.Control.HorizontalSlider(gb);
            margin.Name     = "Margin";
            margin.UserData = subject;
            margin.Min      = 0;
            margin.Max      = 50;
            margin.Value    = 10;
            margin.SetSize(55, 15);
            margin.ValueChanged += MarginChanged;
            Alt.GUI.Temporary.Gwen.Align.PlaceRightBottom(margin, l_margin);

            dock.SelectionChanged += DockChanged;

            return(gb);
        }