Exemple #1
0
        protected override void Initialize()
        {
            // Has to be initialized before child controls can be added
            this.gui.Initialize();

            this.menuBar = new MenuBar(this, gui);
            MenuButton fileMenu = new MenuButton(this, gui);

            fileMenu.Text         = "File";
            this.newMenuItem      = new MenuButton(this, gui);
            this.newMenuItem.Text = "New...";
            fileMenu.Add(this.newMenuItem);
            this.openMenuItem      = new MenuButton(this, gui);
            this.openMenuItem.Text = "Open...";
            fileMenu.Add(this.openMenuItem);
            this.saveMenuItem           = new MenuButton(this, gui);
            this.saveMenuItem.Text      = "Save";
            this.saveMenuItem.IsEnabled = false;
            fileMenu.Add(this.saveMenuItem);
            this.saveAsMenuItem           = new MenuButton(this, gui);
            this.saveAsMenuItem.Text      = "Save As...";
            this.saveAsMenuItem.IsEnabled = false;
            fileMenu.Add(this.saveAsMenuItem);
            this.exitMenuItem      = new MenuButton(this, gui);
            this.exitMenuItem.Text = "Exit";
            fileMenu.Add(this.exitMenuItem);
            menuBar.Add(fileMenu);
            MenuButton editMenu = new MenuButton(this, gui);

            editMenu.Text          = "Edit";
            this.undoMenuItem      = new MenuButton(this, gui);
            this.undoMenuItem.Text = "Undo";
            editMenu.Add(this.undoMenuItem);
            this.redoMenuItem      = new MenuButton(this, gui);
            this.redoMenuItem.Text = "Redo";
            editMenu.Add(this.redoMenuItem);
            this.menuBar.Add(editMenu);

            // Add menubar to gui
            this.gui.Add(this.menuBar);

            // Add event handlers
            this.newMenuItem.Click    += new ClickHandler(OnMenuItemClicked);
            this.openMenuItem.Click   += new ClickHandler(OnMenuItemClicked);
            this.saveMenuItem.Click   += new ClickHandler(OnMenuItemClicked);
            this.saveAsMenuItem.Click += new ClickHandler(OnMenuItemClicked);
            this.exitMenuItem.Click   += new ClickHandler(OnMenuItemClicked);
            this.undoMenuItem.Click   += new ClickHandler(OnMenuItemClicked);
            this.redoMenuItem.Click   += new ClickHandler(OnMenuItemClicked);

            base.Initialize();
        }
        void KeyDownFunction(KeyEventArgs args)
        {
            if (args.Key == Keys.Enter)
            {
                Window window = new Window(this, gui);
                window.Width  = 320;
                window.Height = 380;
                window.Close += new CloseHandler(WindowCloseFunction);

                string text = "Test Window " + windowNumber;
                window.TitleText = text;
                windowNumber++;

                ComboBox comboBox = new ComboBox(this, gui);
                comboBox.IsEditable = true;
                comboBox.ZOrder     = 1.0f;
                comboBox.X          = 20;
                comboBox.Y          = 54;

                for (int i = 0; i < 3; i++)
                {
                    comboBox.AddEntry("Test");
                }

                window.Add(comboBox);

                RadioButton radio1 = new RadioButton(this, gui);
                radio1.X    = 0;
                radio1.Y    = 0;
                radio1.Text = "Radio Test 1";

                RadioButton radio2 = new RadioButton(this, gui);
                radio2.X    = 0;
                radio2.Y    = 16;
                radio2.Text = "Radio Test 2";

                RadioButton radio3 = new RadioButton(this, gui);
                radio3.X    = 0;
                radio3.Y    = 32;
                radio3.Text = "Radio Test 3";

                RadioGroup group = new RadioGroup(this, gui);
                group.X      = 20;
                group.Y      = 89;
                group.Width  = 200;
                group.Height = 48;
                group.ZOrder = 1.0f;
                group.Add(radio1);
                group.Add(radio2);
                group.Add(radio3);

                window.Add(group);

                ListBox listBox = new ListBox(this, gui);
                listBox.X      = 20;
                listBox.Y      = 144;
                listBox.ZOrder = 1.0f;

                for (int i = 0; i < 15; i++)
                {
                    listBox.AddEntry("List Box Test " + (i + 1));
                }

                window.Add(listBox);

                MenuBar    menuBar = new MenuBar(this, gui);
                MenuButton item1   = new MenuButton(this, gui);
                item1.Text = "File";
                menuBar.Add(item1);
                MenuButton item2 = new MenuButton(this, gui);
                item2.Text      = "Edit";
                item2.IsEnabled = false;
                item2.IsEnabled = true;
                menuBar.Add(item2);

                MenuButton fileItem1 = new MenuButton(this, gui);
                fileItem1.Text       = "New";
                fileItem1.IconSource = new Rectangle(1, 189, 14, 14);
                fileItem1.IsEnabled  = false;
                item1.Add(fileItem1);
                MenuSeparator fileItem2 = new MenuSeparator(this, gui);
                item1.Add(fileItem2);
                MenuButton fileItem3 = new MenuButton(this, gui);
                fileItem3.Text       = "Close";
                fileItem3.IconSource = new Rectangle(16, 189, 15, 13);
                item1.Add(fileItem3);

                MenuButton item4 = new MenuButton(this, gui);
                item4.Text      = "Community";
                item4.IsEnabled = true;
                item2.Add(item4);
                MenuSeparator sep2 = new MenuSeparator(this, gui);
                item2.Add(sep2);
                MenuButton item5 = new MenuButton(this, gui);
                item5.Text = "Next Test";
                item4.Add(item5);
                MenuButton item6 = new MenuButton(this, gui);
                item6.Text            = "The Next Level!";
                item6.ShowMarginImage = false;
                item2.Add(item6);
                MenuButton item7 = new MenuButton(this, gui);
                item7.Text = "Booyeah ;-)";
                item6.Add(item7);
                window.Add(menuBar);

                gui.Add(window);

                MessageBox dialog = new MessageBox(this, gui, "Message box asking user a question.", "Message Box", MessageBoxButtons.Yes_No_Cancel, MessageBoxType.Question);
                dialog.Show(false);

                if (before == 1)
                {
                    gui.ApplySkin(skin, true, true);
                }

                before++;
            }
            else if (args.Key == Keys.A)
            {
                SkinnedComponent skin = new SkinnedComponent(this, gui);
            }
        }