Exemplo n.º 1
0
        public TaskControls(Manager manager)
            : base(manager)
        {
            MinimumWidth  = 340;
            MinimumHeight = 140;
            Height        = 480;
            Center();
            Text = "Controls Test";

            TopPanel.Visible  = true;
            Caption.Text      = "Information";
            Description.Text  = "Demonstration of various controls available in Window Library";
            Caption.TextColor = Description.TextColor = new Color(96, 96, 96);

            grpEdit = new GroupPanel(Manager);
            grpEdit.Init();
            grpEdit.Parent = this;
            grpEdit.Anchor = EAnchors.Left | EAnchors.Top | EAnchors.Right;
            grpEdit.Width  = ClientWidth - 200;
            grpEdit.Height = 160;
            grpEdit.Left   = 8;
            grpEdit.Top    = TopPanel.Height + 8;
            grpEdit.Text   = "EditBox";

            pnlControls = new Panel(Manager);
            pnlControls.Init();
            pnlControls.Passive     = true;
            pnlControls.Parent      = this;
            pnlControls.Anchor      = EAnchors.Left | EAnchors.Top | EAnchors.Right;
            pnlControls.Left        = 8;
            pnlControls.Top         = grpEdit.Top + grpEdit.Height + 8;
            pnlControls.Width       = ClientWidth - 200;
            pnlControls.Height      = BottomPanel.Top - 32 - pnlControls.Top;
            pnlControls.BevelBorder = EBevelBorder.All;
            pnlControls.BevelMargin = 1;
            pnlControls.BevelStyle  = EBevelStyle.Etched;
            pnlControls.Color       = Color.Transparent;

            lblEdit = new Label(manager);
            lblEdit.Init();
            lblEdit.Parent = grpEdit;
            lblEdit.Left   = 16;
            lblEdit.Top    = 8;
            lblEdit.Text   = "Testing field:";
            lblEdit.Width  = 128;
            lblEdit.Height = 16;

            txtEdit = new TextBox(manager);
            txtEdit.Init();
            txtEdit.Parent = grpEdit;
            txtEdit.Left   = 16;
            txtEdit.Top    = 24;
            txtEdit.Width  = grpEdit.ClientWidth - 32;
            txtEdit.Height = 20;
            txtEdit.Anchor = EAnchors.Left | EAnchors.Top | EAnchors.Right | EAnchors.Bottom;
            txtEdit.Text   = "Text";

            rdbNormal = new RadioButton(manager);
            rdbNormal.Init();
            rdbNormal.Parent          = grpEdit;
            rdbNormal.Left            = 16;
            rdbNormal.Top             = 52;
            rdbNormal.Width           = grpEdit.ClientWidth - 32;
            rdbNormal.Anchor          = EAnchors.Left | EAnchors.Bottom | EAnchors.Right;
            rdbNormal.Checked         = true;
            rdbNormal.Text            = "Normal mode";
            rdbNormal.ToolTip.Text    = "Enables normal mode for TextBox control.";
            rdbNormal.CheckedChanged += new GodLesZ.Library.XNA.WindowLibrary.Controls.EventHandler(ModeChanged);

            rdbPassword = new RadioButton(manager);
            rdbPassword.Init();
            rdbPassword.Parent          = grpEdit;
            rdbPassword.Left            = 16;
            rdbPassword.Top             = 68;
            rdbPassword.Width           = grpEdit.ClientWidth - 32;
            rdbPassword.Anchor          = EAnchors.Left | EAnchors.Bottom | EAnchors.Right;
            rdbPassword.Checked         = false;
            rdbPassword.Text            = "Password mode";
            rdbPassword.ToolTip.Text    = "Enables password mode for TextBox control.";
            rdbPassword.CheckedChanged += new GodLesZ.Library.XNA.WindowLibrary.Controls.EventHandler(ModeChanged);

            chkBorders = new CheckBox(manager);
            chkBorders.Init();
            chkBorders.Parent          = grpEdit;
            chkBorders.Left            = 16;
            chkBorders.Top             = 96;
            chkBorders.Width           = grpEdit.ClientWidth - 32;
            chkBorders.Anchor          = EAnchors.Left | EAnchors.Bottom | EAnchors.Right;
            chkBorders.Checked         = false;
            chkBorders.Text            = "Borderless mode";
            chkBorders.ToolTip.Text    = "Enables or disables borderless mode for TextBox control.";
            chkBorders.CheckedChanged += new GodLesZ.Library.XNA.WindowLibrary.Controls.EventHandler(chkBorders_CheckedChanged);

            chkReadOnly = new CheckBox(manager);
            chkReadOnly.Init();
            chkReadOnly.Parent          = grpEdit;
            chkReadOnly.Left            = 16;
            chkReadOnly.Top             = 110;
            chkReadOnly.Width           = grpEdit.ClientWidth - 32;
            chkReadOnly.Anchor          = EAnchors.Left | EAnchors.Bottom | EAnchors.Right;
            chkReadOnly.Checked         = false;
            chkReadOnly.Text            = "Read only mode";
            chkReadOnly.ToolTip.Text    = "Enables or disables read only mode for TextBox control.\nThis mode is necessary to enable explicitly.";
            chkReadOnly.CheckedChanged += new GodLesZ.Library.XNA.WindowLibrary.Controls.EventHandler(chkReadOnly_CheckedChanged);

            string[] colors = new string[] { "Red", "Green", "Blue", "Yellow", "Orange", "Purple", "White", "Black", "Magenta", "Cyan",
                                             "Brown", "Aqua", "Beige", "Coral", "Crimson", "Gray", "Azure", "Ivory", "Indigo", "Khaki",
                                             "Orchid", "Plum", "Salmon", "Silver", "Gold", "Pink", "Linen", "Lime", "Olive", "Slate" };

            spnMain = new SpinBox(manager, ESpinBoxMode.List);
            spnMain.Init();
            spnMain.Parent = pnlControls;
            spnMain.Left   = 16;
            spnMain.Top    = 16;
            spnMain.Width  = pnlControls.Width - 32;
            spnMain.Height = 20;
            spnMain.Anchor = EAnchors.Left | EAnchors.Top | EAnchors.Right;
            spnMain.Items.AddRange(colors);
            spnMain.Mode = ESpinBoxMode.Range;

            spnMain.ItemIndex = 0;

            cmbMain = new ComboBox(manager);
            cmbMain.Init();
            cmbMain.Parent   = pnlControls;
            cmbMain.Left     = 16;
            cmbMain.Top      = 44;
            cmbMain.Width    = pnlControls.Width - 32;
            cmbMain.Height   = 20;
            cmbMain.ReadOnly = true;
            cmbMain.Anchor   = EAnchors.Left | EAnchors.Top | EAnchors.Right;
            cmbMain.Items.AddRange(colors);
            cmbMain.ItemIndex     = 0;
            cmbMain.MaxItems      = 5;
            cmbMain.ToolTip.Color = Color.Yellow;
            cmbMain.Movable       = cmbMain.Resizable = true;
            cmbMain.OutlineMoving = cmbMain.OutlineResizing = true;

            trkMain = new TrackBar(manager);
            trkMain.Init();
            trkMain.Parent        = pnlControls;
            trkMain.Left          = 16;
            trkMain.Top           = 72;
            trkMain.Width         = pnlControls.Width - 32;
            trkMain.Anchor        = EAnchors.Left | EAnchors.Top | EAnchors.Right;
            trkMain.Range         = 64;
            trkMain.Value         = 16;
            trkMain.ValueChanged += new GodLesZ.Library.XNA.WindowLibrary.Controls.EventHandler(trkMain_ValueChanged);

            lblTrack = new Label(manager);
            lblTrack.Init();
            lblTrack.Parent    = pnlControls;
            lblTrack.Left      = 16;
            lblTrack.Top       = 96;
            lblTrack.Width     = pnlControls.Width - 32;
            lblTrack.Anchor    = EAnchors.Left | EAnchors.Top | EAnchors.Right;
            lblTrack.Alignment = EAlignment.TopRight;
            lblTrack.TextColor = new Color(32, 32, 32);
            trkMain_ValueChanged(this, null);             // forcing label redraw with init values

            mnuListBox = new ContextMenu(manager);

            MenuItem i1 = new MenuItem("This is very long text");
            MenuItem i2 = new MenuItem("Menu", true);
            MenuItem i3 = new MenuItem("Item", false);
            //i3.Enabled = false;
            MenuItem i4 = new MenuItem("Separated", true);

            MenuItem i11 = new MenuItem();
            MenuItem i12 = new MenuItem();
            MenuItem i13 = new MenuItem();
            MenuItem i14 = new MenuItem();

            MenuItem i111 = new MenuItem();
            MenuItem i112 = new MenuItem();
            MenuItem i113 = new MenuItem();

            mnuListBox.Items.AddRange(new MenuItem[] { i1, i2, i3, i4 });
            i2.Items.AddRange(new MenuItem[] { i11, i12, i13, i14 });
            i13.Items.AddRange(new MenuItem[] { i111, i112, i113 });


            lstMain = new ListBox(manager);
            lstMain.Init();
            lstMain.Parent        = this;
            lstMain.Top           = TopPanel.Height + 8;
            lstMain.Left          = grpEdit.Left + grpEdit.Width + 8;
            lstMain.Width         = ClientWidth - lstMain.Left - 8;
            lstMain.Height        = ClientHeight - 16 - BottomPanel.Height - TopPanel.Height;
            lstMain.Anchor        = EAnchors.Top | EAnchors.Right | EAnchors.Bottom;
            lstMain.HideSelection = false;
            lstMain.Items.AddRange(colors);
            lstMain.ContextMenu = mnuListBox;

            prgMain = new ProgressBar(manager);
            prgMain.Init();
            prgMain.Parent  = this.BottomPanel;
            prgMain.Left    = lstMain.Left;
            prgMain.Top     = 10;
            prgMain.Width   = lstMain.Width;
            prgMain.Height  = 16;
            prgMain.Anchor  = EAnchors.Top | EAnchors.Right;
            prgMain.Mode    = EProgressBarMode.Infinite;
            prgMain.Passive = false;

            btnDisable = new Button(manager);
            btnDisable.Init();
            btnDisable.Parent    = BottomPanel;
            btnDisable.Left      = 8;
            btnDisable.Top       = 8;
            btnDisable.Text      = "Disable";
            btnDisable.Click    += new Controls.EventHandler(btnDisable_Click);
            btnDisable.TextColor = Color.FromNonPremultiplied(255, 64, 32, 200);

            btnProgress = new Button(manager);
            btnProgress.Init();
            btnProgress.Parent = BottomPanel;
            btnProgress.Left   = prgMain.Left - 16;
            btnProgress.Top    = prgMain.Top;
            btnProgress.Height = 16;
            btnProgress.Width  = 16;
            btnProgress.Text   = "!";
            btnProgress.Anchor = EAnchors.Top | EAnchors.Right;
            btnProgress.Click += new Controls.EventHandler(btnProgress_Click);

            mnuMain = new MainMenu(manager);

            mnuMain.Items.Add(i2);
            mnuMain.Items.Add(i13);
            mnuMain.Items.Add(i3);
            mnuMain.Items.Add(i4);

            MainMenu = mnuMain;

            ToolBarPanel tlp = new ToolBarPanel(manager);

            ToolBarPanel = tlp;

            ToolBar tlb  = new ToolBar(manager);
            ToolBar tlbx = new ToolBar(manager);

            tlb.FullRow  = true;
            tlbx.Row     = 1;
            tlbx.FullRow = false;

            tlp.Add(tlb);
            tlp.Add(tlbx);

            /*
             * tlb.Init();
             * tlb.Width = 256;
             * tlb.Parent = ToolBarPanel;*/


            //tlbx.Init();

            /*
             * tlbx.Width = 512;
             * tlbx.Top = 25;
             * tlbx.Parent = ToolBarPanel;*/

            /*
             * ToolBarButton tb1 = new ToolBarButton(manager);
             * tb1.Init();
             * tb1.Parent = tlb;
             * tb1.Left = 10;
             * tb1.Top = 1;
             * tb1.Glyph = new Glyph(Manager.Skin.Images["Icon.Warning"].Resource);
             * tb1.Glyph.SizeMode = SizeMode.Stretched;  */

            StatusBar stb = new StatusBar(Manager);

            StatusBar = stb;

            DefaultControl = txtEdit;

            OutlineMoving   = true;
            OutlineResizing = true;

            BottomPanel.BringToFront();

            SkinChanged += new GodLesZ.Library.XNA.WindowLibrary.Controls.EventHandler(TaskControls_SkinChanged);
            TaskControls_SkinChanged(null, null);
        }
Exemplo n.º 2
0
        public TaskControls()
        {
            MinimumWidth  = 340;
            MinimumHeight = 140;
            Height        = 480;
            CenterWindow();
            Text = "Controls Test";

            TopPanel.Visible  = true;
            Caption.Text      = "Information";
            Description.Text  = "Demonstration of various controls available in Neoforce Controls library.";
            Caption.TextColor = Description.TextColor = new Color(96, 96, 96);

            grpEdit = new GroupPanel
            {
                Parent = this,
                Anchor = Anchors.Left | Anchors.Top | Anchors.Right,
                Width  = ClientWidth - 200,
                Height = 160,
                Left   = 8,
                Top    = TopPanel.Height + 8,
                Text   = "EditBox"
            };

            pnlControls = new Panel
            {
                Passive     = true,
                Parent      = this,
                Anchor      = Anchors.Left | Anchors.Top | Anchors.Right,
                Left        = 8,
                Top         = grpEdit.Top + grpEdit.Height + 8,
                Width       = ClientWidth - 200,
                BevelBorder = BevelBorder.All,
                BevelMargin = 1,
                BevelStyle  = BevelStyle.Etched,
                Color       = Color.Transparent
            };
            pnlControls.Height = BottomPanel.Top - 32 - pnlControls.Top;

            lblEdit = new Label
            {
                Parent = grpEdit,
                Left   = 16,
                Top    = 8,
                Text   = "Testing field:",
                Width  = 128,
                Height = 16,
            };

            txtEdit = new TextBox
            {
                Parent = grpEdit,
                Left   = 16,
                Top    = 24,
                Width  = grpEdit.ClientWidth - 32,
                Height = 20,
                Anchor = Anchors.Left | Anchors.Top | Anchors.Right | Anchors.Bottom,
                Text   = "Text"
            };

            rdbNormal = new RadioButton
            {
                Parent  = grpEdit,
                Left    = 16,
                Top     = 52,
                Width   = grpEdit.ClientWidth - 32,
                Anchor  = Anchors.Left | Anchors.Bottom | Anchors.Right,
                Checked = true,
                Text    = "Normal mode",
                ToolTip = { Text = "Enables normal mode for TextBox control." }
            };
            rdbNormal.CheckedChanged += ModeChanged;

            rdbPassword = new RadioButton
            {
                Parent  = grpEdit,
                Left    = 16,
                Top     = 68,
                Width   = grpEdit.ClientWidth - 32,
                Anchor  = Anchors.Left | Anchors.Bottom | Anchors.Right,
                Checked = false,
                Text    = "Password mode",
                ToolTip = { Text = "Enables password mode for TextBox control." }
            };
            rdbPassword.CheckedChanged += ModeChanged;

            chkBorders = new CheckBox
            {
                Parent  = grpEdit,
                Left    = 16,
                Top     = 96,
                Width   = grpEdit.ClientWidth - 32,
                Anchor  = Anchors.Left | Anchors.Bottom | Anchors.Right,
                Checked = false,
                Text    = "Borderless mode",
                ToolTip = { Text = "Enables or disables borderless mode for TextBox control." }
            };
            chkBorders.CheckedChanged += chkBorders_CheckedChanged;

            chkReadOnly = new CheckBox
            {
                Parent  = grpEdit,
                Left    = 16,
                Top     = 110,
                Width   = grpEdit.ClientWidth - 32,
                Anchor  = Anchors.Left | Anchors.Bottom | Anchors.Right,
                Checked = false,
                Text    = "Read only mode",
                ToolTip =
                {
                    Text = "Enables or disables read only mode for TextBox control.\nThis mode is necessary to enable explicitly."
                }
            };
            chkReadOnly.CheckedChanged += chkReadOnly_CheckedChanged;

            string[] colors = new string[] { "Red", "Green", "Blue", "Yellow", "Orange", "Purple", "White", "Black", "Magenta", "Cyan",
                                             "Brown", "Aqua", "Beige", "Coral", "Crimson", "Gray", "Azure", "Ivory", "Indigo", "Khaki",
                                             "Orchid", "Plum", "Salmon", "Silver", "Gold", "Pink", "Linen", "Lime", "Olive", "Slate" };

            spnMain = new SpinBox(SpinBoxMode.List)
            {
                Parent    = pnlControls,
                Left      = 16,
                Top       = 16,
                Width     = pnlControls.Width - 32,
                Height    = 20,
                Anchor    = Anchors.Left | Anchors.Top | Anchors.Right,
                Mode      = SpinBoxMode.Range,
                ItemIndex = 0
            };
            spnMain.Items.AddRange(colors);

            cmbMain = new ComboBox
            {
                Parent       = pnlControls,
                Left         = 16,
                Top          = 44,
                Width        = pnlControls.Width - 32,
                Height       = 20,
                ReadOnly     = true,
                Anchor       = Anchors.Left | Anchors.Top | Anchors.Right,
                ItemIndex    = 0,
                MaxItemsShow = 5,
                ToolTip      = { Color = Color.Yellow }
            };
            cmbMain.Movable       = cmbMain.Resizable = true;
            cmbMain.OutlineMoving = cmbMain.OutlineResizing = true;
            cmbMain.Items.AddRange(colors);

            trkMain = new TrackBar
            {
                Parent = pnlControls,
                Left   = 16,
                Top    = 72,
                Width  = pnlControls.Width - 32,
                Anchor = Anchors.Left | Anchors.Top | Anchors.Right,
                Value  = 16
            };
            trkMain.ValueChanged += trkMain_ValueChanged;

            lblTrack = new Label
            {
                Parent    = pnlControls,
                Left      = 16,
                Top       = 96,
                Width     = pnlControls.Width - 32,
                Anchor    = Anchors.Left | Anchors.Top | Anchors.Right,
                Alignment = Alignment.TopRight,
                TextColor = new Color(32, 32, 32)
            };
            trkMain_ValueChanged(this, null); // forcing label redraw with init values

            mnuListBox = new ContextMenu();

            MenuItem i1 = new MenuItem("This is very long text");
            MenuItem i2 = new MenuItem("Menu", true);
            MenuItem i3 = new MenuItem("Item", false);
            MenuItem i4 = new MenuItem("Separated", true);

            MenuItem i11 = new MenuItem();
            MenuItem i12 = new MenuItem();
            MenuItem i13 = new MenuItem();
            MenuItem i14 = new MenuItem();

            MenuItem i111 = new MenuItem();
            MenuItem i112 = new MenuItem();
            MenuItem i113 = new MenuItem();

            mnuListBox.Items.AddRange(new MenuItem[] { i1, i2, i3, i4 });
            i2.Items.AddRange(new MenuItem[] { i11, i12, i13, i14 });
            i13.Items.AddRange(new MenuItem[] { i111, i112, i113 });

            lstMain = new ListBox
            {
                Parent        = this,
                Top           = TopPanel.Height + 8,
                Left          = grpEdit.Left + grpEdit.Width + 8,
                Height        = ClientHeight - 16 - BottomPanel.Height - TopPanel.Height,
                Anchor        = Anchors.Top | Anchors.Right | Anchors.Bottom,
                HideSelection = false,
                ContextMenu   = mnuListBox
            };
            lstMain.Width = ClientWidth - lstMain.Left - 8;
            lstMain.Items.AddRange(colors);

            prgMain = new ProgressBar
            {
                Parent  = BottomPanel,
                Left    = lstMain.Left,
                Top     = 10,
                Width   = lstMain.Width,
                Height  = 16,
                Anchor  = Anchors.Top | Anchors.Right,
                Mode    = ProgressBarMode.Infinite,
                Passive = false
            };

            btnDisable = new Button
            {
                Parent    = BottomPanel,
                Left      = 8,
                Top       = 8,
                Text      = "Disable",
                TextColor = Color.FromNonPremultiplied(255, 64, 32, 200)
            };
            btnDisable.Click += btnDisable_Click;


            btnProgress = new Button
            {
                Parent = BottomPanel,
                Left   = prgMain.Left - 16,
                Top    = prgMain.Top,
                Height = 16,
                Width  = 16,
                Text   = "!",
                Anchor = Anchors.Top | Anchors.Right
            };
            btnProgress.Click += btnProgress_Click;

            mnuMain = new MainMenu {
                Width = Width, Anchor = Anchors.Left | Anchors.Top
            };

            mnuMain.Items.Add(i2);
            mnuMain.Items.Add(i13);
            mnuMain.Items.Add(i3);
            mnuMain.Items.Add(i4);

            MainMenu = mnuMain;

            ToolBarPanel tlp = new ToolBarPanel();

            ToolBarPanel = tlp;

            ToolBar tlb = new ToolBar
            {
                Parent  = tlp,
                Movable = true
            };
            ToolBar tlbx = new ToolBar
            {
                Parent  = tlp,
                Movable = true
            };

            tlb.FullRow  = true;
            tlbx.Row     = 1;
            tlbx.FullRow = false;

            StatusBar stb = new StatusBar();

            StatusBar = stb;

            Label t = new Label
            {
                Parent = stb,
                Text   = "Status Bar", Left = 5, Top = 5
            };

            DefaultControl = txtEdit;

            OutlineMoving   = true;
            OutlineResizing = true;

            BottomPanel.BringToFront();

            SkinChanged += TaskControls_SkinChanged;
            TaskControls_SkinChanged(null, null);
        }