Exemple #1
0
        /// <summary>
        /// Initializes the application
        /// </summary>
        public void InitializeApplication()
        {
            int y = 10;
            // Initialize the HUD
            Button fullScreen   = hud.AddButton(ToggleFullscreen, "Toggle full screen", 35, y, 125, 22);
            Button toggleRef    = hud.AddButton(ToggleReference, "Toggle reference (F3)", 35, y += 24, 125, 22);
            Button changeDevice = hud.AddButton(ChangeDevice, "Change Device (F2)", 35, y += 24, 125, 22);

            // Hook the button events for when these items are clicked
            fullScreen.Click   += new EventHandler(OnFullscreenClicked);
            toggleRef.Click    += new EventHandler(OnRefClicked);
            changeDevice.Click += new EventHandler(OnChangeDevicClicked);

            // Update some fonts
            sampleUi.SetFont(1, "Comic Sans MS", 24, FontWeight.Normal);
            sampleUi.SetFont(2, "Courier New", 16, FontWeight.Normal);

            // Now add the sample specific UI
            y = 10;
            sampleUi.AddStatic(StaticControl, "This is a static control.", 0, 0, 200, 30);
            sampleUi.AddStatic(OutputStaticControl, "This static control provides feedback for your action.  It will change as you interact with the UI controls.",
                               20, 50, 620, 300);

            sampleUi.GetStaticText(OutputStaticControl)[0].FontColor.States[(int)ControlState.Normal] = new ColorValue(0.0f, 1.0f, 0.0f, 1.0f); // Change color to green
            sampleUi.GetStaticText(OutputStaticControl)[0].textFormat = DrawTextFormat.Left | DrawTextFormat.Top | DrawTextFormat.WordBreak;
            sampleUi.GetStaticText(OutputStaticControl)[0].FontIndex  = 1;

            // Edit box
            EditBox edit = sampleUi.AddEditBox(EditBoxControl, "Edit control with default styles.  Type text here and press Enter.",
                                               20, 440, 600, 32);

            // Slider
            Slider sl = sampleUi.AddSlider(SliderControl, 200, 450, 200, 24, 0, 1000, 500, false);

            // Check boxes
            Checkbox hotKey = sampleUi.AddCheckBox(CheckBoxControl, "This is a checkbox with hotkey.  Press 'C' to toggle the check state.",
                                                   150, 450, 350, 24, false, System.Windows.Forms.Keys.C, false);
            Checkbox clearEdit = sampleUi.AddCheckBox(ClearEditControl, "This checkbox controls whether the edit control text is cleared when Enter is pressed.",
                                                      150, 460, 430, 24, false);

            // Combo box
            ComboBox combo = sampleUi.AddComboBox(ComboBoxControl, 0, 0, 200, 24);

            if (combo != null)
            {
                // Add some items
                combo.SetDropHeight(100);
                combo.AddItem("Combo box item", 0x11111111);
                combo.AddItem("Placeholder", 0x12121212);
                combo.AddItem("One more", 0x13131313);
                combo.AddItem("I can't get enough", 0x14141414);
                combo.AddItem("Ok, last one, I promise", 0x15151515);
            }

            // Radio buttons
            sampleUi.AddRadioButton(RadioButton1A, 1, "Radio group 1 Amy", 0, 50, 200, 24, false);
            sampleUi.AddRadioButton(RadioButton1B, 1, "Radio group 1 Brian", 0, 50, 200, 24, false);
            sampleUi.AddRadioButton(RadioButton1C, 1, "Radio group 1 Clark", 0, 50, 200, 24, false);

            sampleUi.AddRadioButton(RadioButton2A, 2, "Single", 0, 50, 70, 24, false);
            sampleUi.AddRadioButton(RadioButton2B, 2, "Double", 0, 50, 70, 24, false);
            sampleUi.AddRadioButton(RadioButton2C, 2, "Trouble", 0, 50, 70, 24, false);

            // List boxes
            ListBox singleBox = sampleUi.AddListBox(ListBoxControl, 30, 400, 200, 150, ListBoxStyle.SingleSelection);

            for (int i = 0; i < 15; i++)
            {
                singleBox.AddItem("Single-selection listbox item " + i.ToString(), i);
            }

            ListBox multiBox = sampleUi.AddListBox(ListBoxControlMulti, 30, 400, 200, 150, ListBoxStyle.Multiselection);

            for (int i = 0; i < 30; i++)
            {
                multiBox.AddItem("Multi-selection listbox item " + i.ToString(), i);
            }

            // Hook some events
            sl.ValueChanged   += new EventHandler(OnValueChanged);
            hotKey.Changed    += new EventHandler(OnHotkeyBoxChanged);
            clearEdit.Changed += new EventHandler(OnClearEditChanged);
            combo.Changed     += new EventHandler(OnComboChanged);
            edit.Changed      += new EventHandler(OnEditChanged);
            edit.Enter        += new EventHandler(OnEnterHit);
            // All the radio buttons
            sampleUi.GetRadioButton(RadioButton1A).Changed += new EventHandler(OnRadioButtonChanged);
            sampleUi.GetRadioButton(RadioButton1B).Changed += new EventHandler(OnRadioButtonChanged);
            sampleUi.GetRadioButton(RadioButton1C).Changed += new EventHandler(OnRadioButtonChanged);
            sampleUi.GetRadioButton(RadioButton2A).Changed += new EventHandler(OnRadioButtonChanged);
            sampleUi.GetRadioButton(RadioButton2B).Changed += new EventHandler(OnRadioButtonChanged);
            sampleUi.GetRadioButton(RadioButton2C).Changed += new EventHandler(OnRadioButtonChanged);
            // Finally the listboxes
            singleBox.DoubleClick += new EventHandler(OnDoubleClick);
            singleBox.Selection   += new EventHandler(OnSingleSelection);
            multiBox.DoubleClick  += new EventHandler(OnDoubleClick);
            multiBox.Selection    += new EventHandler(OnMultiSelection);
        }