Example #1
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            font = new Alt.Sketch.Font(Skin.DefaultFont.FontFamily, 20);

            outer = new Alt.GUI.Temporary.Gwen.Control.Label(this);
            outer.SetBounds(10, 10, 400, 400);

            Alt.GUI.Temporary.Gwen.Control.Label inner1 = new Alt.GUI.Temporary.Gwen.Control.Label(outer);
            inner1.TextColor = labelColor;
            inner1.Text      = "1";
            inner1.Font      = font;
            inner1.SetSize(100, 100);
            inner1.Dock = Alt.GUI.Temporary.Gwen.Pos.Left;

            Alt.GUI.Temporary.Gwen.Control.Label inner2 = new Alt.GUI.Temporary.Gwen.Control.Label(outer);
            inner2.TextColor = labelColor;
            inner2.Text      = "2";
            inner2.Font      = font;
            inner2.SetSize(100, 100);
            inner2.Dock = Alt.GUI.Temporary.Gwen.Pos.Top;

            Alt.GUI.Temporary.Gwen.Control.Label inner3 = new Alt.GUI.Temporary.Gwen.Control.Label(outer);
            inner3.TextColor = labelColor;
            inner3.Text      = "3";
            inner3.Font      = font;
            inner3.SetSize(100, 100);
            inner3.Dock = Alt.GUI.Temporary.Gwen.Pos.Right;

            Alt.GUI.Temporary.Gwen.Control.Label inner4 = new Alt.GUI.Temporary.Gwen.Control.Label(outer);
            inner4.TextColor = labelColor;
            inner4.Text      = "4";
            inner4.Font      = font;
            inner4.SetSize(100, 100);
            inner4.Dock = Alt.GUI.Temporary.Gwen.Pos.Bottom;

            Alt.GUI.Temporary.Gwen.Control.Label inner5 = new Alt.GUI.Temporary.Gwen.Control.Label(outer);
            inner5.TextColor = labelColor;
            inner5.Text      = "5";
            inner5.Font      = font;
            inner5.SetSize(100, 100);
            inner5.Dock = Alt.GUI.Temporary.Gwen.Pos.Fill;

            outer.DrawDebugOutlines = true;

            inner1.UserData = CreateControls(inner1, 0, "Control 1", 440, 10);
            inner2.UserData = CreateControls(inner2, 1, "Control 2", 650, 10);
            inner3.UserData = CreateControls(inner3, 2, "Control 3", 440, 170);
            inner4.UserData = CreateControls(inner4, 3, "Control 4", 650, 170);
            inner5.UserData = CreateControls(inner5, 4, "Control 5", 440, 330);

            Alt.GUI.Temporary.Gwen.Control.Label l_padding = new Alt.GUI.Temporary.Gwen.Control.Label(this);
            l_padding.TextColor = labelColor;
            l_padding.Text      = "Padding:";
            l_padding.SetSize(60, 19);
            Alt.GUI.Temporary.Gwen.Align.PlaceDownLeft(l_padding, outer, 20);

            Alt.GUI.Temporary.Gwen.Control.HorizontalSlider padding = new Alt.GUI.Temporary.Gwen.Control.HorizontalSlider(this);
            padding.Min   = 0;
            padding.Max   = 200;
            padding.Value = 10;
            padding.SetSize(100, 20);
            padding.ValueChanged += PaddingChanged;
            Alt.GUI.Temporary.Gwen.Align.PlaceRightBottom(padding, l_padding);

            //DrawDebugOutlines = true;
        }
Example #2
0
        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);
        }
Example #3
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            Color color = Color.White;

            {
                Alt.GUI.Temporary.Gwen.Control.Label label = new Alt.GUI.Temporary.Gwen.Control.Label(this);
                label.Text      = "Standard label (not autosized)";
                label.TextColor = color;
                label.SetBounds(10, 10, 150, 12);
            }
            {
                Alt.GUI.Temporary.Gwen.Control.Label label = new Alt.GUI.Temporary.Gwen.Control.Label(this);
                label.AutoSizeToContents = true;
                label.Text      = "Chinese: \u4E45\u6709\u5F52\u5929\u613F \u7EC8\u8FC7\u9B3C\u95E8\u5173";
                label.TextColor = color;
                label.SetPosition(10, 30);
            }
            {
                Alt.GUI.Temporary.Gwen.Control.Label label = new Alt.GUI.Temporary.Gwen.Control.Label(this);
                label.AutoSizeToContents = true;
                label.Text      = "Japanese: \u751F\u3080\u304E\u3000\u751F\u3054\u3081\u3000\u751F\u305F\u307E\u3054";
                label.TextColor = color;
                label.SetPosition(10, 50);
            }
            {
                Alt.GUI.Temporary.Gwen.Control.Label label = new Alt.GUI.Temporary.Gwen.Control.Label(this);
                label.AutoSizeToContents = true;
                label.Text      = "Korean: \uADF9\uC9C0\uD0D0\uD5D8\u3000\uD611\uD68C\uACB0\uC131\u3000\uCCB4\uACC4\uC801\u3000\uC5F0\uAD6C";
                label.TextColor = color;
                label.SetPosition(10, 70);
            }
            {
                Alt.GUI.Temporary.Gwen.Control.Label label = new Alt.GUI.Temporary.Gwen.Control.Label(this);
                label.AutoSizeToContents = true;
                label.Text      = "Hindi: \u092F\u0947 \u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926 \u0939\u093F\u0928\u094D\u0926\u0940 \u092E\u0947\u0902 \u0939\u0948\u0964";
                label.TextColor = color;
                label.SetPosition(10, 90);
            }
            {
                Alt.GUI.Temporary.Gwen.Control.Label label = new Alt.GUI.Temporary.Gwen.Control.Label(this);
                label.AutoSizeToContents = true;
                label.Text      = "Arabic: \u0627\u0644\u0622\u0646 \u0644\u062D\u0636\u0648\u0631 \u0627\u0644\u0645\u0624\u062A\u0645\u0631 \u0627\u0644\u062F\u0648\u0644\u064A";
                label.TextColor = color;
                label.SetPosition(10, 110);
            }
            {
                Alt.GUI.Temporary.Gwen.Control.Label label = new Alt.GUI.Temporary.Gwen.Control.Label(this);
                label.AutoSizeToContents = true;
                label.MouseInputEnabled  = true; // needed for tooltip
                label.Text      = "Wow, Coloured Text (and tooltip)";
                label.TextColor = Color.Cyan;
                label.SetToolTipText("I'm a tooltip");
                font3 = new Font("Motorwerk", 20);
                ((Alt.GUI.Temporary.Gwen.Control.Label)label.ToolTip).Font = font3;
                label.SetPosition(10, 130);
            }
            {
                Alt.GUI.Temporary.Gwen.Control.Label label = new Alt.GUI.Temporary.Gwen.Control.Label(this);
                label.AutoSizeToContents = true;
                label.Text = "Coloured Text With Alpha";
                //label.TextColor = Color.FromArgb(200, 0, 0, 255);
                //label.TextColor = Color.FromArgb(100, 255, 0, 0);
                label.TextColor = Color.FromArgb(200, Color.Lime * 1.2);
                label.SetPosition(10, 150);
            }
            {
                // Note that when using a custom font, this font object has to stick around
                // for the lifetime of the label. Rethink, or is that ideal?
                font1 = new Font("Comic Sans MS", 25);

                Alt.GUI.Temporary.Gwen.Control.Label label = new Alt.GUI.Temporary.Gwen.Control.Label(this);
                label.AutoSizeToContents = true;
                label.Text      = "Custom Font (Comic Sans 25)";
                label.TextColor = color;
                label.SetPosition(10, 170);
                label.Font = font1;
            }
            {
                font2 = new Font("French Script MT", 35);

                Alt.GUI.Temporary.Gwen.Control.Label label = new Alt.GUI.Temporary.Gwen.Control.Label(this);
                label.AutoSizeToContents = true;
                label.Font = font2;
                label.SetPosition(10, 210);
                label.Text      = "Custom Font (French Script MT 35)";
                label.TextColor = color;
            }

            // alignment test
            {
                Alt.GUI.Temporary.Gwen.Control.Label txt = new Alt.GUI.Temporary.Gwen.Control.Label(this);
                txt.SetPosition(10, 280);
                txt.Text               = "Alignment test";
                txt.TextColor          = color;
                txt.AutoSizeToContents = true;

                Alt.GUI.Temporary.Gwen.Control.Label outer = new Alt.GUI.Temporary.Gwen.Control.Label(this);
                outer.SetBounds(10, 300, 190, 190);

                Alt.GUI.Temporary.Gwen.Control.Label l11 = new Alt.GUI.Temporary.Gwen.Control.Label(outer);
                l11.SetBounds(10, 10, 50, 50);
                l11.Text      = "TL";
                l11.TextColor = color;
                l11.Alignment = Alt.GUI.Temporary.Gwen.Pos.Top | Alt.GUI.Temporary.Gwen.Pos.Left;

                Alt.GUI.Temporary.Gwen.Control.Label l12 = new Alt.GUI.Temporary.Gwen.Control.Label(outer);
                l12.SetBounds(70, 10, 50, 50);
                l12.Text      = "T";
                l12.TextColor = color;
                l12.Alignment = Alt.GUI.Temporary.Gwen.Pos.Top | Alt.GUI.Temporary.Gwen.Pos.CenterH;

                Alt.GUI.Temporary.Gwen.Control.Label l13 = new Alt.GUI.Temporary.Gwen.Control.Label(outer);
                l13.SetBounds(130, 10, 50, 50);
                l13.Text      = "TR";
                l13.TextColor = color;
                l13.Alignment = Alt.GUI.Temporary.Gwen.Pos.Top | Alt.GUI.Temporary.Gwen.Pos.Right;

                Alt.GUI.Temporary.Gwen.Control.Label l21 = new Alt.GUI.Temporary.Gwen.Control.Label(outer);
                l21.SetBounds(10, 70, 50, 50);
                l21.Text      = "L";
                l21.TextColor = color;
                l21.Alignment = Alt.GUI.Temporary.Gwen.Pos.Left | Alt.GUI.Temporary.Gwen.Pos.CenterV;

                Alt.GUI.Temporary.Gwen.Control.Label l22 = new Alt.GUI.Temporary.Gwen.Control.Label(outer);
                l22.SetBounds(70, 70, 50, 50);
                l22.Text      = "C";
                l22.TextColor = color;
                l22.Alignment = Alt.GUI.Temporary.Gwen.Pos.CenterH | Alt.GUI.Temporary.Gwen.Pos.CenterV;

                Alt.GUI.Temporary.Gwen.Control.Label l23 = new Alt.GUI.Temporary.Gwen.Control.Label(outer);
                l23.SetBounds(130, 70, 50, 50);
                l23.Text      = "R";
                l23.TextColor = color;
                l23.Alignment = Alt.GUI.Temporary.Gwen.Pos.Right | Alt.GUI.Temporary.Gwen.Pos.CenterV;

                Alt.GUI.Temporary.Gwen.Control.Label l31 = new Alt.GUI.Temporary.Gwen.Control.Label(outer);
                l31.SetBounds(10, 130, 50, 50);
                l31.Text      = "BL";
                l31.TextColor = color;
                l31.Alignment = Alt.GUI.Temporary.Gwen.Pos.Bottom | Alt.GUI.Temporary.Gwen.Pos.Left;

                Alt.GUI.Temporary.Gwen.Control.Label l32 = new Alt.GUI.Temporary.Gwen.Control.Label(outer);
                l32.SetBounds(70, 130, 50, 50);
                l32.Text      = "B";
                l32.TextColor = color;
                l32.Alignment = Alt.GUI.Temporary.Gwen.Pos.Bottom | Alt.GUI.Temporary.Gwen.Pos.CenterH;

                Alt.GUI.Temporary.Gwen.Control.Label l33 = new Alt.GUI.Temporary.Gwen.Control.Label(outer);
                l33.SetBounds(130, 130, 50, 50);
                l33.Text      = "BR";
                l33.TextColor = color;
                l33.Alignment = Alt.GUI.Temporary.Gwen.Pos.Bottom | Alt.GUI.Temporary.Gwen.Pos.Right;

                outer.DrawDebugOutlines = true;
            }
        }