Beispiel #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(OnChangeDeviceClicked);

            // Now add the sample specific UI
            y = 10;
            const int ComboBox1     = ChangeDevice + 1;
            const int CheckBox1     = ChangeDevice + 2;
            const int CheckBox2     = ChangeDevice + 3;
            const int Radiobutton1  = ChangeDevice + 4;
            const int Radiobutton2  = ChangeDevice + 5;
            const int Radiobutton3  = ChangeDevice + 6;
            const int Button1       = ChangeDevice + 7;
            const int Button2       = ChangeDevice + 8;
            const int Radiobutton4  = ChangeDevice + 9;
            const int Radiobutton5  = ChangeDevice + 10;
            const int SliderControl = ChangeDevice + 11;

            ComboBox cb1 = sampleUi.AddComboBox(ComboBox1, 35, y += 24, 125, 22);

            for (int i = 0; i < 50; i++)
            {
                cb1.AddItem("Item#" + i.ToString(), null);
            }
            sampleUi.AddCheckBox(CheckBox1, "Checkbox1", 35, y         += 24, 125, 22, false);
            sampleUi.AddCheckBox(CheckBox2, "Checkbox2", 35, y         += 24, 125, 22, false);
            sampleUi.AddRadioButton(Radiobutton1, 1, "Radio1G1", 35, y += 24, 125, 22, true);
            sampleUi.AddRadioButton(Radiobutton2, 1, "Radio2G1", 35, y += 24, 125, 22, false);
            sampleUi.AddRadioButton(Radiobutton3, 1, "Radio3G1", 35, y += 24, 125, 22, false);
            sampleUi.AddButton(Button1, "Button1", 35, y += 24, 125, 22);
            sampleUi.AddButton(Button2, "Button2", 35, y += 24, 125, 22);
            sampleUi.AddRadioButton(Radiobutton4, 2, "Radio1G2", 35, y += 24, 125, 22, true);
            sampleUi.AddRadioButton(Radiobutton5, 2, "Radio2G2", 35, y += 24, 125, 22, false);
            sampleUi.AddSlider(SliderControl, 50, y += 24, 100, 22);

            // If you wanted to respond to any of these you would need to add an event hook here
        }
        /// <summary>
        /// Creates the controls for use in the dialog
        /// </summary>
        private void CreateControls()
        {
            dialog = new Dialog(parent);
            dialog.IsUsingKeyboardInput = true;
            dialog.SetFont(0, "Arial", 15, FontWeight.Normal);
            dialog.SetFont(1, "Arial", 28, FontWeight.Bold);

            // Right justify static controls
            Element e = dialog.GetDefaultElement(ControlType.StaticText, 0);

            e.textFormat = DrawTextFormat.VerticalCenter | DrawTextFormat.Right;

            // Title
            StaticText title = dialog.AddStatic((int)SettingsDialogControlIds.Static, "Direct3D Settings", 10, 5, 400, 50);

            e            = title[0];
            e.FontIndex  = 1;
            e.textFormat = DrawTextFormat.Top | DrawTextFormat.Left;

            // Adapter
            dialog.AddStatic((int)SettingsDialogControlIds.Static, "Display Adapter", 10, 50, 180, 23);
            adapterCombo = dialog.AddComboBox((int)SettingsDialogControlIds.Adapter, 200, 50, 300, 23);

            // Device Type
            dialog.AddStatic((int)SettingsDialogControlIds.Static, "Render Device", 10, 75, 180, 23);
            deviceCombo = dialog.AddComboBox((int)SettingsDialogControlIds.DeviceType, 200, 75, 300, 23);

            // Windowed / Fullscreen
            windowedButton = dialog.AddRadioButton((int)SettingsDialogControlIds.Windowed, (int)SettingsDialogControlIds.RadioButtonGroup,
                                                   "Windowed", 240, 105, 300, 16, false);
            clipBox = dialog.AddCheckBox((int)SettingsDialogControlIds.DeviceClip, "Clip to device when window spans across multiple monitors",
                                         250, 126, 400, 16, false);
            fullscreenButton = dialog.AddRadioButton((int)SettingsDialogControlIds.Fullscreen, (int)SettingsDialogControlIds.RadioButtonGroup, "Full Screen",
                                                     240, 147, 300, 16, false);

            // Adapter Format
            adapterFormatStatic = dialog.AddStatic((int)SettingsDialogControlIds.AdapterFormatLabel, "Adapter Format",
                                                   10, 180, 180, 23);
            adapterFormatCombo = dialog.AddComboBox((int)SettingsDialogControlIds.AdapterFormat, 200, 180, 300, 23);

            // Resolution
            resolutionStatic = dialog.AddStatic((int)SettingsDialogControlIds.ResolutionLabel, "Resolution", 10, 205, 180, 23);
            resolution       = dialog.AddComboBox((int)SettingsDialogControlIds.Resolution, 200, 205, 300, 23);
            resolution.SetDropHeight(106);

            // Refresh Rate
            refreshStatic = dialog.AddStatic((int)SettingsDialogControlIds.RefreshRateLabel, "Refresh Rate", 10, 230, 180, 23);
            refreshCombo  = dialog.AddComboBox((int)SettingsDialogControlIds.RefreshRate, 200, 230, 300, 23);

            // BackBuffer Format
            dialog.AddStatic((int)SettingsDialogControlIds.Static, "Back Buffer Format", 10, 265, 180, 23);
            backBufferCombo = dialog.AddComboBox((int)SettingsDialogControlIds.BackBufferFormat, 200, 265, 300, 23);

            // Depth Stencil
            dialog.AddStatic((int)SettingsDialogControlIds.Static, "Depth/Stencil Format", 10, 290, 180, 23);
            depthStencilCombo = dialog.AddComboBox((int)SettingsDialogControlIds.DepthStencil, 200, 290, 300, 23);

            // Multisample Type
            dialog.AddStatic((int)SettingsDialogControlIds.Static, "Multisample Type", 10, 315, 180, 23);
            multiSampleTypeCombo = dialog.AddComboBox((int)SettingsDialogControlIds.MultisampleType, 200, 315, 300, 23);

            // Multisample Quality
            dialog.AddStatic((int)SettingsDialogControlIds.Static, "Multisample Quality", 10, 340, 180, 23);
            multiSampleQualityCombo = dialog.AddComboBox((int)SettingsDialogControlIds.MultisampleQuality, 200, 340, 300, 23);

            // Vertex Processing
            dialog.AddStatic((int)SettingsDialogControlIds.Static, "Vertex Processing", 10, 365, 180, 23);
            vertexCombo = dialog.AddComboBox((int)SettingsDialogControlIds.VertexProcessing, 200, 365, 300, 23);

            // Present Interval
            dialog.AddStatic((int)SettingsDialogControlIds.Static, "Present Interval", 10, 390, 180, 23);
            presentCombo = dialog.AddComboBox((int)SettingsDialogControlIds.PresentInterval, 200, 390, 300, 23);

            // Add the ok/cancel buttons
            Button okButton     = dialog.AddButton((int)SettingsDialogControlIds.OK, "OK", 230, 435, 73, 31);
            Button cancelButton = dialog.AddButton((int)SettingsDialogControlIds.Cancel, "Cancel", 315, 435, 73, 31, 0, true);

            okButton.Click     += new EventHandler(OnOkClicked);
            cancelButton.Click += new EventHandler(OnCancelClicked);
        }
Beispiel #3
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);
        }