예제 #1
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            UI.Init(new Vector2(width, height), new TextFont(Content, "Font/"));
            UI.AddInterface("Interface1");
            tbInfo     = new Label(null, "Item Name", 14, TextOrientation.Left, new Vector2(100, 75), new Vector2(250, 25), Color.Black, Color.Transparent);
            tb         = new TextBox(null, "", 14, 30, new Vector2(100, 100), new Vector2(250, 25), null, null, null, null);
            addButton  = new Button(null, "Add Item", 14, TextOrientation.Left, new Vector2(100, 150), new Vector2(100, 25));
            remButton  = new Button(null, "Remove Item", 14, TextOrientation.Left, new Vector2(225, 150), new Vector2(125, 25));
            lb         = new ListBox(null, 14, TextOrientation.Left, new Vector2(100, 200), new Vector2(250, 500), null, null, null, null);
            pbProgress = new ProgressBar(null, new Vector2(400, 200), new Vector2(100, 25), 0, 100, 75, 14, false, null, null, null, null);
            sSlider    = new Slider(null, new Vector2(400, 250), new Vector2(100, 25), 50, 1, 0, 100, 14, TextOrientation.Center, null, null, true, true, true);
            ibMenu     = new InfoBar(null);

            ibMenu.AddElement("File");
            ibMenu.AddElement("Edit");
            Window window = new Window(null, null, "Stuff", TextOrientation.Left, Vector2.Zero, new Vector2(200), true, true, true, true);

            window.Open(new Vector2(100, 100));

            addButton.Disable();
            remButton.Disable();
            lb.SelectedItemCountChanged += (sender) => { if (lb.Count > 0 && lb.SelectedItems.Count > 0)
                                                         {
                                                             remButton.Enable();
                                                         }
                                                         else
                                                         {
                                                             remButton.Disable();
                                                         } };
            tb.TextChanged += (sender) => { if (tb.Text != "")
                                            {
                                                addButton.Enable();
                                            }
                                            else
                                            {
                                                addButton.Disable();
                                            } };
            tb.EnterPressed += (sender) => { if (tb.Text != "")
                                             {
                                                 lb.AddItem(tb.Text); tb.Clear();
                                             }
            };

            lb.TransferToFront();

            addButton.Clicked += (sender) => { lb.AddItem(tb.Text); tb.Clear(); };
            remButton.Clicked += (sender) => { lb.RemoveSelectedItems(); };
        }