Exemplo n.º 1
0
            //!!!!!!not implemented
            //List<SystemKeyboardMouseValue> bindedKeyboardMouseValues =
            //   new List<SystemKeyboardMouseValue>();
            //List<SystemJoystickValue> bindedDefaultJoystickValues =
            //   new List<SystemJoystickValue>();

            //

            public GameControlItem(GameControlKeys controlKey)
            {
                this.controlKey = controlKey;

                //defaultKeyboardMouseValue
                {
                    FieldInfo field = typeof(GameControlKeys).GetField(
                        Enum.GetName(typeof(GameControlKeys), controlKey));
                    DefaultKeyboardMouseValueAttribute[] attributes =
                        (DefaultKeyboardMouseValueAttribute[])Attribute.GetCustomAttributes(
                            field, typeof(DefaultKeyboardMouseValueAttribute));

                    defaultKeyboardMouseValues = new SystemKeyboardMouseValue[attributes.Length];
                    for (int n = 0; n < attributes.Length; n++)
                    {
                        defaultKeyboardMouseValues[n] = attributes[n].Value;
                    }
                }

                //defaultJoystickValue
                {
                    FieldInfo field = typeof(GameControlKeys).GetField(
                        Enum.GetName(typeof(GameControlKeys), controlKey));
                    DefaultJoystickValueAttribute[] attributes = (DefaultJoystickValueAttribute[])
                                                                 Attribute.GetCustomAttributes(field, typeof(DefaultJoystickValueAttribute));

                    defaultJoystickValues = new SystemJoystickValue[attributes.Length];
                    for (int n = 0; n < attributes.Length; n++)
                    {
                        defaultJoystickValues[n] = attributes[n].Value;
                    }
                }
            }
        void Server_ReceiveControlKeyPress(RemoteEntityWorld sender, ReceiveDataReader reader)
        {
            //check to ensure that other players can not send messages to another player
            if (!Server_CheckRemoteEntityWorldAssociatedWithThisIntellect(sender))
            {
                return;
            }

            GameControlKeys controlKey = (GameControlKeys)reader.ReadVariableUInt32();
            float           strength   = reader.ReadSingle();

            if (!reader.Complete())
            {
                return;
            }

            //check for invalid value
            if (!Enum.IsDefined(typeof(GameControlKeys), (int)controlKey))
            {
                return;
            }
            if (strength <= 0)
            {
                return;
            }

            ControlKeyPress(controlKey, strength);
        }
        void Client_SendControlKeyReleaseToServer(GameControlKeys controlKey)
        {
            SendDataWriter writer = BeginNetworkMessage(typeof(PlayerIntellect),
                                                        (ushort)NetworkMessages.ControlKeyReleaseToServer);

            writer.WriteVariableUInt32((uint)controlKey);
            EndNetworkMessage();
        }
Exemplo n.º 4
0
 /// <summary>
 /// Initializes the perspective-specific <see cref="GameControlKeys"/>.
 /// </summary>
 static void InitPerspectiveSpecificKeys()
 {
     _moveUp             = new GameControlKeys("Move Up", SKC("MoveUp"), SKC("MoveDown"));
     _moveDown           = new GameControlKeys("Move Down", SKC("MoveDown"), SKC("MoveUp"));
     _moveStopHorizontal = new GameControlKeys("Move Stop Horizontal", null, _moveLeft.KeysDown.Concat(_moveRight.KeysDown));
     _moveStopVertical   = new GameControlKeys("Move Stop Vertical", null, _moveUp.KeysDown.Concat(_moveDown.KeysDown));
     _moveStop           = new GameControlKeys("Move Stop", null,
                                               _moveLeft.KeysDown.Concat(_moveRight.KeysDown).Concat(_moveUp.KeysDown).Concat(_moveDown.KeysDown));
 }
        private void Client_SendControlKeyPressToServer(GameControlKeys controlKey, float strength)
        {
            SendDataWriter writer = BeginNetworkMessage(typeof(PlayerIntellect),
                                                        (ushort)NetworkMessages.ControlKeyPressToServer);

            writer.WriteVariableUInt32((uint)controlKey);
            writer.Write(strength);
            EndNetworkMessage();
        }
Exemplo n.º 6
0
        public GameControlItem GetItemByControlKey(GameControlKeys controlKey)
        {
            GameControlItem item;

            if (!itemsControlKeysDictionary.TryGetValue(controlKey, out item))
            {
                return(null);
            }
            return(item);
        }
        public void Init(GameControlKeys keyDecel, GameControlKeys keyAccel, float increment, float decrement, float scale)
        {
            this.keyDecel = keyDecel;

            this.keyAccel = keyAccel;
            this.increment = increment;
            this.decrement = decrement;
            this.scale = scale;
            val = 0;
        }
 public void Init(GameControlKeys keyMinus, GameControlKeys keyPlus, float increment, float decrement, float damping, float scale)
 {
     this.keyMinus = keyMinus;
     this.keyPlus = keyPlus;
     this.increment = increment;
     this.decrement = decrement;
     this.damping = damping;
     this.scale = scale;
     val = 0;
 }
Exemplo n.º 9
0
        protected void ControlKeyRelease(GameControlKeys controlKey)
        {
            if (!IsControlKeyPressed(controlKey))
            {
                return;
            }

            controlKeysStrength[(int)controlKey] = 0;

            if (controlledObject != null)
            {
                controlledObject.DoIntellectCommand(new Command(controlKey, false));
            }
        }
Exemplo n.º 10
0
        public Intellect()
        {
            //calculate controlKeyCount
            if (controlKeyCount == 0)
            {
                foreach (object value in Enum.GetValues(typeof(GameControlKeys)))
                {
                    GameControlKeys controlKey = (GameControlKeys)value;
                    if ((int)controlKey >= controlKeyCount)
                    {
                        controlKeyCount = (int)controlKey + 1;
                    }
                }
            }

            controlKeysStrength = new float[controlKeyCount];
        }
Exemplo n.º 11
0
        /// <summary>
        /// Initializes the <see cref="GameControlsKeys"/> class.
        /// </summary>
        static GameControlsKeys()
        {
            // Create the GameControlKeys with the default keys
            _moveLeft  = new GameControlKeys("Move Left", SKC("MoveLeft"), SKC("MoveRight"));
            _moveRight = new GameControlKeys("Move Right", SKC("MoveRight"), SKC("MoveLeft"));

            _attack    = new GameControlKeys("Attack", SKC("Attack"));
            _useWorld  = new GameControlKeys("Use World", SKC("UseWorld"));
            _useShop   = new GameControlKeys("Use Shop", SKC("UseShop"));
            _talkToNPC = new GameControlKeys("Talk To NPC", SKC("TalkToNPC"));
            _pickUp    = new GameControlKeys("Pick Up", SKC("PickUp"));

            var emoteKeysDown = SKCs("Emote_Modifier1", "Emote_Modifier2");

            _emoteEllipsis    = new GameControlKeys("Emote Ellipsis", emoteKeysDown, null, SKCs("EmoteEllipsis"));
            _emoteExclamation = new GameControlKeys("Emote Exclamation", emoteKeysDown, null, SKCs("EmoteExclamation"));
            _emoteHeartbroken = new GameControlKeys("Emote Heartbroken", emoteKeysDown, null, SKCs("EmoteHeartbroken"));
            _emoteHearts      = new GameControlKeys("Emote Hearts", emoteKeysDown, null, SKCs("EmoteHearts"));
            _emoteMeat        = new GameControlKeys("Emote Meat", emoteKeysDown, null, SKCs("EmoteMeat"));
            _emoteQuestion    = new GameControlKeys("Emote Question", emoteKeysDown, null, SKCs("EmoteQuestion"));
            _emoteSweat       = new GameControlKeys("Emote Sweat", emoteKeysDown, null, SKCs("EmoteSweat"));

            var quickBarKeysDown = SKCs("QuickBarItem_Modifier1", "QuickBarItem_Modifier2");

            _quickBarItem0 = new GameControlKeys("Quick bar item 0", quickBarKeysDown, null, SKCs("QuickBarItem0"));
            _quickBarItem1 = new GameControlKeys("Quick bar item 1", quickBarKeysDown, null, SKCs("QuickBarItem1"));
            _quickBarItem2 = new GameControlKeys("Quick bar item 2", quickBarKeysDown, null, SKCs("QuickBarItem2"));
            _quickBarItem3 = new GameControlKeys("Quick bar item 3", quickBarKeysDown, null, SKCs("QuickBarItem3"));
            _quickBarItem4 = new GameControlKeys("Quick bar item 4", quickBarKeysDown, null, SKCs("QuickBarItem4"));
            _quickBarItem5 = new GameControlKeys("Quick bar item 5", quickBarKeysDown, null, SKCs("QuickBarItem5"));
            _quickBarItem6 = new GameControlKeys("Quick bar item 6", quickBarKeysDown, null, SKCs("QuickBarItem6"));
            _quickBarItem7 = new GameControlKeys("Quick bar item 7", quickBarKeysDown, null, SKCs("QuickBarItem7"));
            _quickBarItem8 = new GameControlKeys("Quick bar item 8", quickBarKeysDown, null, SKCs("QuickBarItem8"));
            _quickBarItem9 = new GameControlKeys("Quick bar item 9", quickBarKeysDown, null, SKCs("QuickBarItem9"));

            var windowKeysDown = SKCs("Window_Modifier1", "Window_Modifier2");

            _windowStats     = new GameControlKeys("Stats window", windowKeysDown, null, SKCs("Window_Stats"));
            _windowSkills    = new GameControlKeys("Skills window", windowKeysDown, null, SKCs("Window_Skills"));
            _windowInventory = new GameControlKeys("Inventory window", windowKeysDown, null, SKCs("Window_Inventory"));
            _windowEquipped  = new GameControlKeys("Equipped window", windowKeysDown, null, SKCs("Window_Equipped"));
            _windowGuild     = new GameControlKeys("Guild window", windowKeysDown, null, SKCs("Window_Guild"));

            // Initialize the keys specific to the perspective being used
            InitPerspectiveSpecificKeys();
        }
Exemplo n.º 12
0
        protected void ControlKeyPress(GameControlKeys controlKey, float strength)
        {
            //if (strength <= 0.0f)
            //    Log.Fatal("Intellect: ControlKeyPress: Invalid \"strength\"."); //Incin -- causing crash on mouse scroll down -120 example

            if (GetControlKeyStrength(controlKey) == strength)
            {
                return;
            }

            controlKeysStrength[(int)controlKey] = strength;

            if (controlledObject != null)
            {
                controlledObject.DoIntellectCommand(new Command(controlKey, true));
            }
        }
Exemplo n.º 13
0
        bool InitInternal()
        {
            //register config settings
            EngineApp.Instance.Config.RegisterClassParameters(typeof(GameControlsManager));

            //create items
            {
                int controlKeyCount = 0;
                {
                    foreach (object value in Enum.GetValues(typeof(GameControlKeys)))
                    {
                        GameControlKeys controlKey = (GameControlKeys)value;
                        if ((int)controlKey >= controlKeyCount)
                        {
                            controlKeyCount = (int)controlKey + 1;
                        }
                    }
                }

                items = new GameControlItem[controlKeyCount];
                for (int n = 0; n < controlKeyCount; n++)
                {
                    if (!Enum.IsDefined(typeof(GameControlKeys), n))
                    {
                        Log.Fatal("GameControlsManager: Init: Invalid \"GameControlKeys\" enumeration.");
                        return(false);
                    }
                    GameControlKeys controlKey = (GameControlKeys)n;
                    items[n] = new GameControlItem(controlKey);
                }
            }

            //itemsControlKeysDictionary
            {
                itemsControlKeysDictionary = new Dictionary <GameControlKeys, GameControlItem>();
                foreach (GameControlItem item in items)
                {
                    itemsControlKeysDictionary.Add(item.ControlKey, item);
                }
            }

            return(true);
        }
Exemplo n.º 14
0
        protected void ControlKeyPress(GameControlKeys controlKey, float strength)
        {
            if (strength <= 0.0f)
            {
                Log.Fatal("Intellect: ControlKeyPress: Invalid \"strength\".");
            }

            if (GetControlKeyStrength(controlKey) == strength)
            {
                return;
            }

            controlKeysStrength[(int)controlKey] = strength;

            if (controlledObject != null)
            {
                controlledObject.DoIntellectCommand(new Command(controlKey, true));
            }
        }
Exemplo n.º 15
0
 //Incin
 protected bool checkCommandConflict(GameControlKeys command)
 {
     if (GameControlsManager.Instance != null)
     {
         int count = GameControlsManager.Instance.GetControlKetCount();
         //foreach(GameControlKeys in GameControlKeys)
         GameControlsManager.GameControlItem item = GameControlsManager.Instance.GetItemByControlKey(command);
         if (item != null && item.ControlKey == command)
         {
             _conflictCommand = item;
             return(true);
         }
         else
         {
             _conflictCommand = null;
             return(false);
         }
     }
     return(false);
 }
Exemplo n.º 16
0
 //Incin
 protected bool checkCommandConflict(GameControlKeys command)
 {
     if (GameControlsManager.Instance != null)
     {
         int count = GameControlsManager.Instance.GetControlKetCount();
         //foreach(GameControlKeys in GameControlKeys)
         GameControlsManager.GameControlItem item = GameControlsManager.Instance.GetItemByControlKey(command);
         if (item != null && item.ControlKey == command)
         {
             _conflictCommand = item;
             return true;
         }
         else
         {
             _conflictCommand = null;
             return false;
         }
     }
     return false;
 }
Exemplo n.º 17
0
 internal Command( GameControlKeys key, bool keyPressed )
 {
     this.key = key;
     this.keyPressed = keyPressed;
 }
Exemplo n.º 18
0
        protected void ControlKeyRelease( GameControlKeys controlKey )
        {
            if( !IsControlKeyPressed( controlKey ) )
                return;
            if( controlKeysStrength != null )
                controlKeysStrength[ (int)controlKey ] = 0;

            if( controlledObject != null )
                controlledObject.DoIntellectCommand( new Command( controlKey, false ) );
        }
Exemplo n.º 19
0
        protected void ControlKeyPress( GameControlKeys controlKey, float strength )
        {
            if( strength <= 0.0f )
                Log.Fatal( "Intellect: ControlKeyPress: Invalid \"strength\"." );

            if( GetControlKeyStrength( controlKey ) == strength )
                return;

            if( controlKeysStrength != null )
                controlKeysStrength[ (int)controlKey ] = strength;

            if( controlledObject != null )
                controlledObject.DoIntellectCommand( new Command( controlKey, true ) );
        }
Exemplo n.º 20
0
 public bool IsControlKeyPressed( GameControlKeys key )
 {
     return GetControlKeyStrength( key ) != 0.0f;
 }
Exemplo n.º 21
0
 public float GetControlKeyStrength( GameControlKeys key )
 {
     if( controlKeysStrength == null )
         return 0;
     return controlKeysStrength[ (int)key ];
 }
Exemplo n.º 22
0
        protected void ControlKeyPress(GameControlKeys controlKey, float strength)
        {
            //if (strength <= 0.0f)
            //    Log.Fatal("Intellect: ControlKeyPress: Invalid \"strength\"."); //Incin -- causing crash on mouse scroll down -120 example

            if (GetControlKeyStrength(controlKey) == strength)
                return;

            controlKeysStrength[(int)controlKey] = strength;

            if (controlledObject != null)
                controlledObject.DoIntellectCommand(new Command(controlKey, true));
        }
 /// <summary>
 /// Initializes the perspective-specific <see cref="GameControlKeys"/>.
 /// </summary>
 static void InitPerspectiveSpecificKeys()
 {
     _jump     = new GameControlKeys("Jump", SKC("MoveUp"));
     _moveStop = new GameControlKeys("Move Stop", null, _moveLeft.KeysDown.Concat(_moveRight.KeysDown));
 }
Exemplo n.º 24
0
            //!!!!!!not implemented
            //List<SystemKeyboardMouseValue> bindedKeyboardMouseValues =
            //   new List<SystemKeyboardMouseValue>();
            //List<SystemJoystickValue> bindedDefaultJoystickValues =
            //   new List<SystemJoystickValue>();
            //
            public GameControlItem( GameControlKeys controlKey )
            {
                this.controlKey = controlKey;

                //defaultKeyboardMouseValue
                {
                    FieldInfo field = typeof( GameControlKeys ).GetField(
                        Enum.GetName( typeof( GameControlKeys ), controlKey ) );
                    DefaultKeyboardMouseValueAttribute[] attributes =
                        (DefaultKeyboardMouseValueAttribute[])Attribute.GetCustomAttributes(
                        field, typeof( DefaultKeyboardMouseValueAttribute ) );

                    defaultKeyboardMouseValues = new SystemKeyboardMouseValue[ attributes.Length ];
                    for( int n = 0; n < attributes.Length; n++ )
                        defaultKeyboardMouseValues[ n ] = attributes[ n ].Value;
                }

                //defaultJoystickValue
                {
                    FieldInfo field = typeof( GameControlKeys ).GetField(
                        Enum.GetName( typeof( GameControlKeys ), controlKey ) );
                    DefaultJoystickValueAttribute[] attributes = (DefaultJoystickValueAttribute[])
                        Attribute.GetCustomAttributes( field, typeof( DefaultJoystickValueAttribute ) );

                    defaultJoystickValues = new SystemJoystickValue[ attributes.Length ];
                    for( int n = 0; n < attributes.Length; n++ )
                        defaultJoystickValues[ n ] = attributes[ n ].Value;
                }
            }
Exemplo n.º 25
0
 public GameControlsKeyUpEventData( GameControlKeys controlKey )
     : base(controlKey)
 {
 }
Exemplo n.º 26
0
 internal Command(GameControlKeys key, bool keyPressed)
 {
     this.key        = key;
     this.keyPressed = keyPressed;
 }
Exemplo n.º 27
0
 void Client_SendControlKeyReleaseToServer( GameControlKeys controlKey )
 {
     SendDataWriter writer = BeginNetworkMessage( typeof( PlayerIntellect ),
         (ushort)NetworkMessages.ControlKeyReleaseToServer );
     writer.WriteVariableUInt32( (uint)controlKey );
     EndNetworkMessage();
 }
Exemplo n.º 28
0
 public GameControlsKeyDownEventData(GameControlKeys controlKey, float strength)
     : base(controlKey)
 {
     this.strength = strength;
 }
Exemplo n.º 29
0
 public GameControlsKeyDownEventData( GameControlKeys controlKey, float strength )
     : base(controlKey)
 {
     this.strength = strength;
 }
Exemplo n.º 30
0
 private void Client_SendControlKeyPressToServer(GameControlKeys controlKey, float strength)
 {
     SendDataWriter writer = BeginNetworkMessage(typeof(PlayerIntellect),
         (ushort)NetworkMessages.ControlKeyPressToServer);
     writer.WriteVariableUInt32((uint)controlKey);
     writer.Write(strength);
     EndNetworkMessage();
 }
Exemplo n.º 31
0
 //
 public GameControlsKeyEventData( GameControlKeys controlKey )
 {
     this.controlKey = controlKey;
 }
Exemplo n.º 32
0
 public GameControlsKeyUpEventData(GameControlKeys controlKey)
     : base(controlKey)
 {
 }
Exemplo n.º 33
0
 public GameControlItem GetItemByControlKey( GameControlKeys controlKey )
 {
     GameControlItem item;
     if( !itemsControlKeysDictionary.TryGetValue( controlKey, out item ) )
         return null;
     return item;
 }
Exemplo n.º 34
0
 public bool IsControlKeyPressed(GameControlKeys key)
 {
     return(GetControlKeyStrength(key) != 0.0f);
 }
Exemplo n.º 35
0
 public float GetControlKeyStrength( GameControlKeys key )
 {
     return controlKeysStrength[ (int)key ];
 }
Exemplo n.º 36
0
 public float GetControlKeyStrength(GameControlKeys key)
 {
     return(controlKeysStrength[(int)key]);
 }
Exemplo n.º 37
0
        //

        public GameControlsKeyEventData(GameControlKeys controlKey)
        {
            this.controlKey = controlKey;
        }
Exemplo n.º 38
0
        ///<summary>
        /// ____MADE IN THE +
        /// USA + France +
        /// ___ InCin filtering by combo boxes and listboxes --- all me
        ///void CreateAdd_Custom_Control_Dialogue()
        ///populate all drop downs and comboboxes
        ///filter by device or device Type
        ///hide unneeded info or unhide pages
        /// </summary>
        private void CreateAdd_Custom_Control_Dialogue()
        {
            //load custom binding window
            Control Add_Custom_Control = ControlDeclarationManager.Instance.CreateControl(@"GUI\Add_Custom_Control.gui");
            Add_Custom_Control.TopMost = true;
            Add_Custom_Control.MouseCover = true;

            //Add
            Controls.Add(Add_Custom_Control);

            #region AddCustomControl.Gui

            #region MainControls

            ComboBox cmbDeviceType;
            cmbDeviceType = (ComboBox)Add_Custom_Control.Controls["cmbDeviceType"];
            //cmbDeviceType.Items.Add("Nothing_Selected"); //using enum Nothing_Selected
            foreach (var value in Enum.GetValues(typeof(Devices)))
            {
                //if(!(value.ToString().Contains(Devices.GetServices.ToString())) && !(value.ToString().Contains(Devices.All_Devices.ToString()))) //exclude for internal use

                cmbDeviceType.Items.Add(value);
            }
            cmbDeviceType.SelectedIndex = 0;
            ComboBox cmbDevice;
            cmbDevice = (ComboBox)Add_Custom_Control.Controls["cmbDevice"];
            cmbDevice.Items.Add("Nothing_Selected");
            cmbDevice.Items.Add("Keyboard"); //unhandled object as multiple devices
            cmbDevice.Items.Add("Mouse");   //unhandled object as a multiple devices
            if (InputDeviceManager.Instance != null)
            {
                foreach (InputDevice devicename in InputDeviceManager.Instance.Devices)
                    cmbDevice.Items.Add(devicename); //handled objects
                //filter
            }
            cmbDevice.SelectedIndex = 0;

            Control cntrlCommands = (Control)Add_Custom_Control.Controls["cntrlCommands"];
            cntrlCommands.Visible = false;
            //Commands Available
            ListBox lstCommand;
            lstCommand = (ListBox)Add_Custom_Control.Controls["cntrlCommands"].Controls["lstCommand"];
            lstCommand.Items.Add("Nothing_Selected");
            lstCommand.SelectedIndex = 0;
            foreach (var value in Enum.GetValues(typeof(GameControlKeys)))
            {
                lstCommand.Items.Add(value);
            }

            //control Tab Controls
            //TabControl MainOptionsTabControl;
            MainOptionsTabControl = (TabControl)Add_Custom_Control.Controls["MainOptionsTabControl"];
            MainOptionsTabControl.SelectedIndexChange += MainOptionsTabControl_SelectedIndexChange;
            MainOptionsTabControl.Visible = true;

            MainOptionsTabControl.Visible = false; //hide all subcontrols for now

            pageControlsButtons[0] = (Button)Add_Custom_Control.Controls["MainOptionsTabControl"].Controls["btnMouseOptions"];
            pageControlsButtons[1] = (Button)Add_Custom_Control.Controls["MainOptionsTabControl"].Controls["btnKeyboardOptions"];
            pageControlsButtons[2] = (Button)Add_Custom_Control.Controls["MainOptionsTabControl"].Controls["btnJoystickOptions"];
            foreach (Button pageButton in pageControlsButtons)
            {
                pageButton.Click += new Button.ClickDelegate(pageControlsButton_Click);
            }

            pageControlsButtons[0].PerformClick();

            TextBox lblMessage = (TextBox)Add_Custom_Control.Controls["lblMessage"]; // holds message of selected items
            lblMessage.Text = "Nothing_Selected";

            ScrollBar scrlSelectedStrength;
            scrlSelectedStrength = (ScrollBar)MainOptionsTabControl.Controls["scrlSelectedStrength"];

            //incin -- not updating the strength atm, gotta figure this out..
            scrlSelectedStrength.ValueChange += delegate(ScrollBar sender)
            {
                while (sender.Value != Strength_selected)
                {
                    Strength_selected = sender.Value;
                }
                if (message != null)
                {
                    if (message.Contains(" Strength: "))
                    {
                        message = message.Replace(" Strength: " + old_strength.ToString("F2"), " Strength: " + Strength_selected.ToString("F2"));
                        lblMessage.Text = message;
                    }
                }
                old_strength = Strength_selected;
            };

            #endregion MainControls

            #region pageMouseoptions

            Control pageMouseOptions;
            pageMouseOptions = (Control)Add_Custom_Control.Controls["MainOptionsTabControl"].Controls["pageMouseOptions"];
            //Page visible= false || true;

            #region MouseTabControls

            //MainOptionsTabControl.MouseTabControl.pageMouseButtonOptions
            TabControl MouseTabControl = (TabControl)pageMouseOptions.Controls["MouseTabControl"];

            ComboBox cmbMouseButtonChoices;
            cmbMouseButtonChoices = (ComboBox)MouseTabControl.Controls["pageMouseButtonOptions"].Controls["cmbMouseButtonChoices"];
            cmbMouseButtonChoices.Items.Add("Nothing_Selected");
            foreach (var value in Enum.GetValues(typeof(EMouseButtons)))
            {
                cmbMouseButtonChoices.Items.Add(value);
            }

            cmbMouseButtonChoices.SelectedIndex = 0;

            //MainOptionsTabControl.MouseTabControl.pageMouseScrollOptions.cmbMouseScrollChoices
            ComboBox cmbMouseScrollChoices;
            cmbMouseScrollChoices = (ComboBox)MouseTabControl.Controls["pageMouseScrollOptions"].Controls["cmbMouseScrollChoices"];
            cmbMouseScrollChoices.Items.Add("Nothing_Selected");
            foreach (var value in Enum.GetValues(typeof(MouseScroll)))
            {
                cmbMouseScrollChoices.Items.Add(value);
            }
            cmbMouseScrollChoices.SelectedIndex = 0;

            #endregion MouseTabControls

            #endregion pageMouseoptions

            #region pageKeyboardOptions

            Control pageKeyboardOptions = (Control)Add_Custom_Control.Controls["MainOptionsTabControl"].Controls["pageKeyboardOptions"];
            //visible false true?

            ListBox lstKeyboardButtonChoices;
            lstKeyboardButtonChoices = (ListBox)pageKeyboardOptions.Controls["lstKeyboardButtonChoices"];
            lstKeyboardButtonChoices.Items.Add("Nothing_Selected");
            foreach (var value in Enum.GetValues(typeof(EKeys)))
            {
                lstKeyboardButtonChoices.Items.Add(value);
            }
            lstKeyboardButtonChoices.SelectedIndex = 0;
            //if (lstKeyboardButtonChoices.ItemButtons["lstKeyboardButtonChoices"]Text.Contains("Nothing_Selected") != null)
            //    lstKeyboardButtonChoices.SelectedIndex = -1;

            #endregion pageKeyboardOptions

            //MainOptionsTabControl.pageJoystickOptions
            //tabJoystickControlOptions

            #region pageJoystickOptions

            Control pageJoystickOptions;
            pageJoystickOptions = (Control)Add_Custom_Control.Controls["MainOptionsTabControl"].Controls["pageJoystickOptions"];//.Controls["tabJoystickControlOptions"];

            tabJoystickControlOptions = (TabControl)pageJoystickOptions.Controls["tabJoystickControlOptions"];
            tabJoystickControlOptions.SelectedIndexChange += tabJoystickControlOptions_SelectedIndexChange;

            pagejoystickButtons[0] = (Button)tabJoystickControlOptions.Controls["btnSliderOptions"];
            pagejoystickButtons[1] = (Button)tabJoystickControlOptions.Controls["btnAxisOptions"];
            pagejoystickButtons[2] = (Button)tabJoystickControlOptions.Controls["btnButtonOptions"];

            foreach (Button pageButton in pagejoystickButtons)
            {
                pageButton.Click += new Button.ClickDelegate(joystickPageTabButtons_Click);
            }

            #region pageSliderOptions

            Control pageSliderOptions = tabJoystickControlOptions.Controls["pageSliderOptions"];

            #region cmbSliderChoices

            ComboBox cmbSliderChoices;

            cmbSliderChoices = (ComboBox)pageSliderOptions.Controls["cmbSliderChoices"];
            cmbSliderChoices.Items.Add("Nothing_Selected");
            foreach (var value in Enum.GetValues(typeof(JoystickSliders)))
            {
                cmbSliderChoices.Items.Add(value);
            }
            cmbSliderChoices.SelectedIndex = 0;

            ComboBox cmbSliderAxisChoices;
            cmbSliderAxisChoices = (ComboBox)pageSliderOptions.Controls["cmbSliderAxisChoices"];
            cmbSliderAxisChoices.Items.Add("Nothing_Selected");
            foreach (var value in Enum.GetValues(typeof(JoystickSliderAxes)))
            {
                cmbSliderAxisChoices.Items.Add(value);
            }
            cmbSliderAxisChoices.SelectedIndex = 0;

            ComboBox cmbSliderAxisFilterChoices;
            cmbSliderAxisFilterChoices = (ComboBox)pageSliderOptions.Controls["cmbSliderAxisFilterChoices"];
            cmbSliderAxisFilterChoices.Items.Add("Nothing_Selected");
            foreach (var value in Enum.GetValues(typeof(JoystickAxisFilters)))
            {
                cmbSliderAxisFilterChoices.Items.Add(value);
            }
            cmbSliderAxisFilterChoices.SelectedIndex = 0;

            #endregion cmbSliderChoices

            #endregion pageSliderOptions

            #region pageAxisOptions

            Control pageAxisOptions = tabJoystickControlOptions.Controls["pageAxisOptions"];
            ComboBox cmbAxisChoices;
            cmbAxisChoices = (ComboBox)pageAxisOptions.Controls["cmbAxisChoices"];
            cmbAxisChoices.Items.Add("Nothing_Selected");
            foreach (var value in Enum.GetValues(typeof(JoystickSliderAxes)))
            {
                cmbAxisChoices.Items.Add(value);
            }
            cmbAxisChoices.SelectedIndex = 0;

            ComboBox cmbAxisFilterChoices;
            cmbAxisFilterChoices = (ComboBox)pageAxisOptions.Controls["cmbAxisFilterChoices"];
            cmbAxisFilterChoices.Items.Add("Nothing_Selected");
            foreach (var value in Enum.GetValues(typeof(JoystickAxisFilters)))
            {
                cmbAxisFilterChoices.Items.Add(value);
            }
            cmbAxisFilterChoices.SelectedIndex = 0;

            Control pageJoystickButtonOptions = tabJoystickControlOptions.Controls["pageJoystickButtonOptions"];
            ListBox lstJoyButtonChoices = (ListBox)pageJoystickButtonOptions.Controls["lstJoyButtonChoices"];
            lstJoyButtonChoices.Items.Add("Nothing_Selected");
            foreach (var value in Enum.GetValues(typeof(JoystickButtons)))
            {
                lstJoyButtonChoices.Items.Add(value);
            }
            lstJoyButtonChoices.SelectedIndex = 0;

            #endregion pageAxisOptions

            #endregion pageJoystickOptions

            //___ InCin filtering by combo boxes and listboxes --- all me
            // setting all indexes at 0 -- tracks "Nothing_Selected"

            #region IndexChanged

            //if(page visible == enabled){
            cmbMouseButtonChoices.SelectedIndexChange += delegate(ComboBox sender)
            {
                message = null;
                if (cmbDeviceType.SelectedIndex == 0 || lstCommand.SelectedIndex == 0) //Nothing_Selected
                    return;

                if (sender.SelectedIndex == 0)
                {
                    //message = "Device: " + cmbDevice.SelectedItem.ToString();
                    message = "DeviceType: " + cmbDeviceType.SelectedItem.ToString();
                    message += " Command: " + lstCommand.SelectedItem.ToString();
                    message += " MouseButton: Nothing_Selected";
                    message += " Strength: " + scrlSelectedStrength.Value.ToString("F2");
                }
                else
                {
                    //message = "Device: " + cmbDevice.SelectedItem.ToString();
                    message = "DeviceType: " + cmbDeviceType.SelectedItem.ToString();
                    message += " Command: " + lstCommand.SelectedItem.ToString();
                    message += " MouseButton: " + sender.SelectedItem.ToString();
                    message += " Strength: " + scrlSelectedStrength.Value.ToString("F2");
                }
                lblMessage.Text = message;
            };

            cmbMouseScrollChoices.SelectedIndexChange += delegate(ComboBox sender)
            {
                message = null;
                if (cmbDeviceType.SelectedIndex == 0 || lstCommand.SelectedIndex == 0)// Nothing_Selected
                    return;

                if (sender.SelectedIndex == 0)
                {
                    //message = "Device: " + cmbDevice.SelectedItem.ToString();
                    message = "DeviceType: " + cmbDeviceType.SelectedItem.ToString();
                    message += " Command: " + lstCommand.SelectedItem.ToString();
                    message += " MouseScroll: Nothing_Selected";
                    message += " Strength: " + scrlSelectedStrength.Value.ToString("F2");
                    lstKeyboardButtonChoices.Visible = false;
                }
                else
                {
                    //message = "Device: " + cmbDevice.SelectedItem.ToString();
                    message = "DeviceType: " + cmbDeviceType.SelectedItem.ToString();
                    message += " Command: " + lstCommand.SelectedItem.ToString();
                    message += " MouseScroll: " + sender.SelectedItem.ToString();
                    message += " Strength: " + scrlSelectedStrength.Value.ToString("F2");
                    lstKeyboardButtonChoices.Visible = true;
                }
                lblMessage.Text = message;
            };

            lstKeyboardButtonChoices.SelectedIndexChange += delegate(ListBox sender)
            {
                message = null;
                //MainOptionsTabControl.Visible = false;
                if (cmbDeviceType.SelectedIndex == 0 || lstCommand.SelectedIndex == 0)
                    return;

                if (sender.SelectedIndex == 0) // Nothing_Selected
                {
                    //Nothing_Selected
                    //message = "Device: " + cmbDevice.SelectedItem.ToString();
                    message = "DeviceType: " + cmbDeviceType.SelectedItem.ToString();
                    message += " Command: " + lstCommand.SelectedItem.ToString();
                    message += " KeyboardButton: Nothing_Selected";
                    message += " Strength: " + scrlSelectedStrength.Value.ToString("F2");
                }
                else
                {
                    //message = "Device: " + cmbDevice.SelectedItem.ToString();
                    message = "DeviceType: " + cmbDeviceType.SelectedItem.ToString();
                    message += " Command: " + lstCommand.SelectedItem.ToString();
                    message += " KeyboardButton: " + sender.SelectedItem.ToString();
                    message += " Strength: " + scrlSelectedStrength.Value.ToString("F2");
                }
                lblMessage.Text = message;
            };

            //}
            //if(page visible == enabled)
            cmbSliderChoices.SelectedIndexChange += delegate(ComboBox sender)
            {
                message = null;
                //MainOptionsTabControl.Visible = false;
                if (cmbDeviceType.SelectedIndex == 0 || lstCommand.SelectedIndex == 0)  // Nothing_Selected
                {
                    return;
                }

                if (sender.SelectedIndex == 0)
                {
                    //message = "Device: " + cmbDevice.SelectedItem.ToString();
                    message = "DeviceType: " + cmbDeviceType.SelectedItem.ToString();
                    message += " Command: " + lstCommand.SelectedItem.ToString();
                    message += " Slider: Nothing_Selected";
                    message += " Axis: Nothing_Selected";
                    message += " AxisFilter: Nothing_Selected";
                    message += " Strength: " + scrlSelectedStrength.Value.ToString("F2");
                    //cmbSliderChoices.Visible = false;
                }
                else //if( sender.SelectedIndex != 0)
                {
                    //message = "Device: " + cmbDevice.SelectedItem.ToString();
                    message = "DeviceType: " + cmbDeviceType.SelectedItem.ToString();
                    message += " Command: " + lstCommand.SelectedItem.ToString();
                    message += " Slider: " + sender.SelectedItem.ToString(); //sender
                    message += " Axis: Nothing_Selected";
                    message += " AxisFilter: Nothing_Selected";
                    //event update
                    message += " Strength: " + scrlSelectedStrength.Value.ToString("F2"); //recursive scroll change
                    //cmbSliderAxisChoices.Visible = true;
                }
                lblMessage.Text = message;
            };

            cmbSliderAxisChoices.SelectedIndexChange += delegate(ComboBox sender)
            {
                message = null;
                if (cmbDeviceType.SelectedIndex == 0 || lstCommand.SelectedIndex == 0 || cmbSliderChoices.SelectedIndex == 0) // Nothing_Selected
                    return;

                if (sender.SelectedIndex == 0)
                {
                    //message = "Device: " + cmbDevice.SelectedItem.ToString();
                    message = "DeviceType: " + cmbDeviceType.SelectedItem.ToString();
                    message += " Command: " + lstCommand.SelectedItem.ToString();
                    message += " Slider: " + cmbSliderChoices.SelectedItem.ToString();
                    message += " Axis: Nothing_Selected";
                    message += " AxisFilter: Nothing_Selected";
                    message += " Strength: " + scrlSelectedStrength.Value.ToString("F2");
                    cmbSliderAxisFilterChoices.Visible = false;
                }
                else
                {
                    //message = "Device: " + cmbDevice.SelectedItem.ToString();
                    message = "DeviceType: " + cmbDeviceType.SelectedItem.ToString();
                    message += " Command: " + lstCommand.SelectedItem.ToString();
                    message += " Slider: " + cmbSliderChoices.SelectedItem.ToString();
                    message += " Axis: " + sender.SelectedItem.ToString();
                    message += " AxisFilter: Nothing_Selected";
                    message += " Strength: " + scrlSelectedStrength.Value.ToString("F2");
                    cmbSliderAxisFilterChoices.Visible = true;
                }
                lblMessage.Text = message;
            };

            cmbSliderAxisFilterChoices.SelectedIndexChange += delegate(ComboBox sender)
            {
                message = null;
                if (cmbDeviceType.SelectedIndex == 0 || lstCommand.SelectedIndex == 0 || cmbSliderChoices.SelectedIndex == 0 || cmbSliderAxisChoices.SelectedIndex == 0)// Nothing_Selected
                    return;

                if (sender.SelectedIndex == 0)
                {
                    //message = "Device: " + cmbDevice.SelectedItem.ToString();
                    message = "DeviceType: " + cmbDeviceType.SelectedItem.ToString();
                    message += " Command: " + lstCommand.SelectedItem.ToString();
                    message += " Slider: " + cmbSliderChoices.SelectedItem.ToString();
                    message += " Axis: " + cmbSliderAxisChoices.SelectedItem.ToString();
                    message += " AxisFilter: Nothing_Selected";
                    message += " Strength: " + scrlSelectedStrength.Value.ToString("F2");
                }
                else
                {
                    //message = "Device: " + cmbDevice.SelectedItem.ToString();
                    message = "DeviceType: " + cmbDeviceType.SelectedItem.ToString();
                    message += " Command: " + lstCommand.SelectedItem.ToString();
                    message += " Slider: " + cmbSliderChoices.SelectedItem;
                    message += " Axis: " + cmbSliderChoices.SelectedItem.ToString();
                    message += " AxisFilter: " + sender.SelectedItem.ToString();
                    message += " Strength: " + scrlSelectedStrength.Value.ToString("F2");
                }
                lblMessage.Text = message;
            };
            //}
            //if(page visible == enabled){
            cmbAxisChoices.SelectedIndexChange += delegate(ComboBox sender)
            {
                message = null;
                if (cmbDeviceType.SelectedIndex == 0 || lstCommand.SelectedIndex == 0)// Nothing_Selected
                {
                    cntrlCommands.Visible = false;
                    //MainOptionsTabControl.Visible = false;
                    return;
                }

                if (cmbAxisChoices.SelectedIndex == 0)
                {
                    //message = "Device: " + cmbDevice.SelectedItem.ToString();
                    message = "DeviceType: " + cmbDeviceType.SelectedItem.ToString();
                    message += " Command: " + lstCommand.SelectedItem.ToString();
                    message += " Axis: Nothing_Selected";
                    message += " AxisFilter: Nothing_Selected";
                    message += " Strength: " + scrlSelectedStrength.Value.ToString("F2");
                }
                else
                {
                    //message = "Device: " + cmbDevice.SelectedItem.ToString();
                    message = "DeviceType: " + cmbDeviceType.SelectedItem.ToString();
                    message += " Command: " + lstCommand.SelectedItem.ToString();
                    message += " Axis: " + sender.SelectedItem.ToString();
                    message += " AxisFilter: Nothing_Selected";
                    message += " Strength: " + scrlSelectedStrength.Value.ToString("F2");
                }
                lblMessage.Text = message;
            };

            cmbAxisFilterChoices.SelectedIndexChange += delegate(ComboBox sender)
            {
                message = null;
                if (cmbDeviceType.SelectedIndex == 0 || lstCommand.SelectedIndex == 0 || cmbAxisChoices.SelectedIndex == 0)
                {
                    //MainOptionsTabControl.Visible = false;
                    return;
                }
                if (cmbAxisFilterChoices.SelectedIndex == 0)
                {
                    //message = "Device: " + cmbDevice.SelectedItem.ToString();
                    message = "DeviceType: " + cmbDeviceType.SelectedItem.ToString();
                    message += " Command: " + lstCommand.SelectedItem.ToString();
                    message += " Axis: " + cmbAxisChoices.SelectedItem.ToString();
                    message += " AxisFilter: Nothing_Selected";
                    message += " Strength: " + scrlSelectedStrength.Value.ToString("F2");
                }
                else
                {
                    //message = "Device: " + cmbDevice.SelectedItem.ToString();
                    message = "DeviceType: " + cmbDeviceType.SelectedItem.ToString();
                    message += " Command: " + lstCommand.SelectedItem.ToString();
                    message += " Axis: " + cmbAxisChoices.SelectedItem.ToString();
                    message += " AxisFilter: " + sender.SelectedItem.ToString();
                    message += " Strength: " + scrlSelectedStrength.Value.ToString("F2");
                }
                lblMessage.Text = message;
            };

            lstJoyButtonChoices.SelectedIndexChange += delegate(ListBox sender)
            {
                message = null;
                if (cmbDeviceType.SelectedIndex == 0 || lstCommand.SelectedIndex == 0)
                {
                    //MainOptionsTabControl.Visible = false;

                    return;
                }
                if (lstJoyButtonChoices.SelectedIndex == 0)
                {
                    //message = "Device: " + cmbDevice.SelectedItem.ToString();
                    message = "DeviceType: " + cmbDeviceType.SelectedItem.ToString();
                    message += " Command: " + lstCommand.SelectedItem.ToString();
                    message += " JoystickButton: Nothing_Selected";
                    message += " Strength: " + scrlSelectedStrength.Value.ToString("F2");
                }
                else
                {
                    //message = "Device: " + cmbDevice.SelectedItem.ToString();
                    message = "DeviceType: " + cmbDeviceType.SelectedItem.ToString();
                    message += " Command: " + lstCommand.SelectedItem.ToString();
                    message += " JoystickButton: " + sender.SelectedItem.ToString();
                    message += " Strength: " + scrlSelectedStrength.Value.ToString("F2");
                }
                lblMessage.Text = message;
            };
            //}

            lstCommand.SelectedIndexChange += delegate(ListBox sender)
            {
                message = null;
                if (cmbDeviceType.SelectedIndex == 0)
                    return;

                if (sender.SelectedIndex == 0)
                {
                    //message = "Device: " + cmbDevice.SelectedItem.ToString();
                    message = "DeviceType: " + cmbDeviceType.SelectedItem.ToString();
                    message += " Command: " + "Nothing_Selected";
                    message += " Bind: Nothing_Selected";
                    message += " Strength: " + scrlSelectedStrength.Value.ToString("F2");
                    MainOptionsTabControl.Visible = false;
                }
                else
                {
                    //message = "Device: " + cmbDevice.SelectedItem.ToString();
                    message = "DeviceType: " + cmbDeviceType.SelectedItem.ToString();
                    message += " Command: " + lstCommand.SelectedItem.ToString();
                    message += " Bind: Nothing_Selected";
                    message += " Strength: " + scrlSelectedStrength.Value.ToString("F2");
                    MainOptionsTabControl.Visible = true;
                }
                lblMessage.Text = message;
            };

            #region comboDeviceType

            // Filters down through each TabControl hides what isn't needed
            // MainOptionsTabControl
            // MouseTabControl
            //  Primary choices

            cmbDeviceType.SelectedIndexChange += delegate(ComboBox sender)
            {
                message = null;
                if (sender.SelectedIndex == -1)
                {
                    cntrlCommands.Visible = false;
                    MainOptionsTabControl.Visible = false;
                    return;
                }
                if (sender.SelectedIndex != 0)
                {
                    Devices devicetype = devicetype_selected = (Devices)sender.SelectedItem;
                    cntrlCommands.Visible = true;
                    MainOptionsTabControl.Visible = false;
                    switch (devicetype)
                    {
                        case Devices.Mouse:
                            {
                                pageControlsButton_Click(pageControlsButtons[0]);
                                pageControlsButtons[0].Enable = true;
                                pageControlsButtons[1].Enable = false;
                                pageControlsButtons[2].Enable = false;
                                break;
                            }
                        case Devices.Keyboard:
                            {
                                pageControlsButton_Click(pageControlsButtons[1]);
                                pageControlsButtons[0].Enable = false;
                                pageControlsButtons[1].Enable = true;
                                pageControlsButtons[2].Enable = false;
                                break;
                            }

                        case Devices.Joystick:
                            {
                                pageControlsButton_Click(pageControlsButtons[2]);
                                pageControlsButtons[0].Enable = false;
                                pageControlsButtons[1].Enable = false;
                                pageControlsButtons[2].Enable = true;
                                break;
                            }

                        case Devices.Joystick_Xbox360:
                            {
                                pageControlsButton_Click(pageControlsButtons[2]);
                                pageControlsButtons[0].Enable = false;
                                pageControlsButtons[1].Enable = true;
                                pageControlsButtons[2].Enable = true;
                                break;
                            }
                        case Devices.Joystick_Playstation:
                            {
                                pageControlsButton_Click(pageControlsButtons[2]);
                                pageControlsButtons[0].Enable = false;
                                pageControlsButtons[1].Enable = true;
                                pageControlsButtons[2].Enable = true;
                                break;
                            }
                        case Devices.Joystick_WII:
                            {
                                pageControlsButton_Click(pageControlsButtons[2]);
                                pageControlsButtons[0].Enable = false;
                                pageControlsButtons[1].Enable = true;
                                pageControlsButtons[2].Enable = true;
                                break;
                            }
                        //case Devices.Custom_Audio:
                        //    {
                        //        pageControlsButton_Click(pageControlsButtons[2]);
                        //        pageControlsButtons[0].Enable = true;
                        //        pageControlsButtons[1].Enable = true;
                        //        pageControlsButtons[2].Enable = true;
                        //        break;
                        //    }
                        case Devices.Custom:
                            {
                                pageControlsButton_Click(pageControlsButtons[0]);
                                pageControlsButtons[0].Enable = true;
                                pageControlsButtons[1].Enable = true;
                                pageControlsButtons[2].Enable = true;
                                break;
                            }
                        default:
                            {
                                pageControlsButton_Click(pageControlsButtons[0]);
                                pageControlsButtons[0].Enable = true;
                                pageControlsButtons[1].Enable = true;
                                pageControlsButtons[2].Enable = true;
                                break;
                            }
                    }
                    message = "DeviceType: " + cmbDeviceType.SelectedItem.ToString();
                    message += " Command: Nothing_Selected";
                    message += " Bind: Nothing_Selected";
                    message += " Strength: " + scrlSelectedStrength.Value.ToString("F2");

                    if (lstCommand.SelectedIndex != 0)
                    {
                        message = "DeviceType: " + cmbDeviceType.SelectedItem.ToString();
                        message += " Command: " + lstCommand.SelectedItem.ToString();
                        message += " Bind: Nothing_Selected";
                        message += " Strength: " + scrlSelectedStrength.Value.ToString("F2");
                    }
                }
                else
                {
                    message = " Nothing_Selected";
                    cntrlCommands.Visible = false;
                    MainOptionsTabControl.Visible = false;
                    pageControlsButtons[0].Enable = true;
                    pageControlsButtons[1].Enable = true;
                    pageControlsButtons[2].Enable = true;
                }
                lblMessage.Text = message;
            };

            #endregion comboDeviceType

            #region comboDevice

            // server  selected.music == "<station>"
            //cmbDevice.SelectedIndexChange += delegate(ComboBox sender)
            //{
            //    //if (sender.SelectedIndex != -1)
            //    //{
            //    //    InputDevice inputdevices = (InputDevice)sender.SelectedItem;
            //    //    //Set deviceType
            //    //    // continue
            //    //}
            //    //lblMessage.Text = message;
            //    ;
            //    //hidden for now
            //};

            #endregion comboDevice

            #endregion IndexChanged

            #region ButtonOK

            ((Button)Add_Custom_Control.Controls["buttonOK"]).Click += delegate(Button sender)
            {
                if (cmbDeviceType.SelectedIndex == 0)
                {
                    CreateMessageBox("No Device selected, select a device first!");
                    return;
                }
                else //(cmbDeviceType.SelectedIndex != 0)
                    devicetype_selected = (Devices)cmbDeviceType.SelectedItem;

                if (lstCommand.SelectedIndex == 0)
                {
                    CreateMessageBox("No Command binding selected, select a Command first!");
                    return;
                }
                else // if (lstCommand.SelectedIndex != 0)
                    command_selected = (GameControlKeys)lstCommand.SelectedItem;

                float currentstrength = float.Parse(Strength_selected.ToString("F2"));
                //if (pageControlsButtons[0].Enable == true || pageControlsButtons[1].Enable == true || pageControlsButtons[2].Enable == true)

                switch (devicetype_selected) //devicetype
                {
                    case Devices.Nothing_Selected:
                        {
                            CreateMessageBox("No Device selected, select a device first!");
                            return;
                        }
                    //break;
                    case Devices.Keyboard:
                        {
                            // group Keyboard
                            if (lstKeyboardButtonChoices.SelectedIndex != 0)
                            {
                                GameControlsManager.SystemKeyboardMouseValue key;
                                lstKeyboardButtonChoices_selected = (EKeys)lstKeyboardButtonChoices.SelectedItem;
                                Strength_selected = currentstrength;

                                if (!GameControlsManager.Instance.IsAlreadyBinded((EKeys)lstKeyboardButtonChoices_selected/*, currentstrength*/, out key) && key == null)
                                {
                                    //GameControlsManager.Instance.GetItemByControlKey(command_selected).BindedKeyboardMouseValues.Add(new GameControlsManager.SystemKeyboardMouseValue(lstKeyboardButtonChoices_selected)); //devicetype_selected));
                                    var controlItem = GameControlsManager.Instance.GetItemByControlKey(command_selected);
                                    var newSystemValue = new GameControlsManager.SystemKeyboardMouseValue(lstKeyboardButtonChoices_selected);
                                    newSystemValue.Parent = controlItem;
                                    newSystemValue.Strength = Strength_selected;
                                    controlItem.BindedKeyboardMouseValues.Add(newSystemValue);
                                    //Game.OptionsWindow.UpdateBindedInputControlsListBox();
                                }
                                else
                                {
                                    message = "Key" + cmbMouseButtonChoices_selected + ": Command: " + command_selected + " Strength: 1 is already bound";
                                    lblMessage.Text = message;
                                    CreateMessageBox(message);
                                    message = "";
                                    cmbMouseButtonChoices_selected = 0;
                                    lstCommand.SelectedIndex = 0;
                                    return;
                                }
                            }
                            else
                            {
                                lstKeyboardButtonChoices.SelectedIndex = 0;
                                lstKeyboardButtonChoices_selected = (EKeys)0;
                            }

                            break;
                        }
                    case Devices.Mouse:
                        {
                            // group Mouse

                            if (cmbMouseButtonChoices.SelectedIndex != 0)
                            {
                                ////check for existing matching binds before saving
                                GameControlsManager.SystemKeyboardMouseValue key;
                                cmbMouseButtonChoices_selected = (EMouseButtons)cmbMouseButtonChoices.SelectedItem;

                                if (GameControlsManager.Instance.IsAlreadyBinded((EMouseButtons)cmbMouseButtonChoices_selected, out key)) //currentstrength,
                                {
                                    message = "Mouse Button" + cmbMouseButtonChoices_selected + ": Command: " + command_selected + " is already bound"; //" Strength: " + currentstrength +
                                    //new MessageBoxWindow( text, "Key already bound. Clearing , try again", null );
                                    CreateMessageBox(message);
                                    cmbMouseButtonChoices_selected = 0;
                                    cmbMouseButtonChoices.SelectedIndex = 0;
                                    lstCommand.SelectedIndex = 0;
                                    message = "";
                                    return;
                                }

                                var cmbMouseButtonChoicesControlItem = GameControlsManager.Instance.GetItemByControlKey(command_selected);
                                var cmbMouseButtonChoicesSystemValue = new GameControlsManager.SystemKeyboardMouseValue(cmbMouseButtonChoices_selected, currentstrength);
                                cmbMouseButtonChoicesSystemValue.Parent = cmbMouseButtonChoicesControlItem;
                                cmbMouseButtonChoicesControlItem.BindedKeyboardMouseValues.Add(cmbMouseButtonChoicesSystemValue);
                                //UpdateBindedInputControlsListBox();
                            }
                            else if (cmbMouseScrollChoices.SelectedIndex != 0)
                            {
                                GameControlsManager.SystemKeyboardMouseValue key;
                                cmbMouseScrollChoices_selected = (MouseScroll)cmbMouseScrollChoices.SelectedItem;

                                if (GameControlsManager.Instance.IsAlreadyBinded((MouseScroll)cmbMouseScrollChoices_selected, currentstrength, out key))
                                {
                                    message = "Mouse Button" + cmbMouseScrollChoices_selected + ": Command: " + command_selected + " is already bound"; //+ " Strength: " + currentstrength
                                    //new MessageBoxWindow( text, "Key already bound. Clearing , try again", null );
                                    CreateMessageBox(message);
                                    message = "";
                                    return;
                                }

                                var cmbMouseScrollChoicescontrolItem = GameControlsManager.Instance.GetItemByControlKey(command_selected);
                                var cmbMouseScrollChoicesSystemValue = new GameControlsManager.SystemKeyboardMouseValue(cmbMouseScrollChoices_selected, currentstrength);
                                cmbMouseScrollChoicesSystemValue.Parent = cmbMouseScrollChoicescontrolItem;
                                //cmbMouseScrollChoicesSystemValue.Strength = Strength_selected;
                                cmbMouseScrollChoicescontrolItem.BindedKeyboardMouseValues.Add(cmbMouseScrollChoicesSystemValue);
                                //UpdateBindedInputControlsListBox();
                            }
                            else
                            {
                                cmbMouseButtonChoices.SelectedIndex = 0;
                                cmbMouseButtonChoices_selected = (EMouseButtons)0;
                                cmbMouseScrollChoices.SelectedIndex = 0;
                                cmbMouseScrollChoices_selected = (MouseScroll)0;
                            }
                            break;
                        }

                    case Devices.Joystick:
                    case Devices.Joystick_Playstation:
                    case Devices.Joystick_WII:
                    case Devices.Joystick_Xbox360:
                        {
                            //Filter by tab
                            //group joystick //slider options

                            if (cmbSliderChoices.SelectedIndex != 0 && cmbSliderAxisChoices.SelectedIndex != 0 && cmbSliderAxisFilterChoices.SelectedIndex != 0)
                            {
                                //if (cmbSliderChoices.SelectedIndex != 0)
                                cmbSliderChoices_selected = (JoystickSliders)cmbSliderChoices.SelectedItem;
                                //if (cmbSliderAxisChoices.SelectedIndex != 0)
                                cmbSliderAxisChoices_selected = (JoystickSliderAxes)cmbSliderAxisChoices.SelectedItem;
                                //if (cmbSliderAxisFilterChoices.SelectedIndex != 0)
                                cmbSliderAxisFilterChoices_selected = (JoystickAxisFilters)cmbSliderAxisFilterChoices.SelectedItem;

                                var cmbSliderChoicescontrolItem = GameControlsManager.Instance.GetItemByControlKey(command_selected);
                                var cmbSliderChoicesSystemValue = new GameControlsManager.SystemJoystickValue(cmbSliderChoices_selected, cmbSliderAxisChoices_selected, cmbSliderAxisFilterChoices_selected, currentstrength);
                                cmbSliderChoicesSystemValue.Parent = cmbSliderChoicescontrolItem;
                                cmbSliderChoicescontrolItem.bindedJoystickValues.Add(cmbSliderChoicesSystemValue);
                                //UpdateBindedInputControlsListBox();
                                break;
                            }
                            else
                            {
                                cmbSliderChoices.SelectedIndex = 0;
                                cmbSliderChoices_selected = (JoystickSliders)0;
                                cmbSliderAxisChoices.SelectedIndex = 0;
                                cmbSliderAxisChoices_selected = (JoystickSliderAxes)0;
                                cmbSliderAxisFilterChoices.SelectedIndex = 0;
                                cmbSliderAxisFilterChoices_selected = (JoystickAxisFilters)0;
                            }

                            //axis filter
                            if (cmbAxisChoices.SelectedIndex != 0)
                                cmbAxisChoices_selected = (JoystickSliderAxes)cmbAxisChoices.SelectedItem;
                            else
                            {
                                cmbAxisChoices.SelectedIndex = 0;
                                cmbAxisChoices_selected = (JoystickSliderAxes)0;
                            }

                            if (cmbAxisFilterChoices.SelectedIndex == 0)
                                cmbAxisFilterChoices_selected = (JoystickAxisFilters)cmbAxisFilterChoices.SelectedItem;
                            else
                            {
                                cmbAxisFilterChoices.SelectedIndex = 0;
                                cmbAxisFilterChoices_selected = (JoystickAxisFilters)0;
                            }

                            //buttons
                            if (lstJoyButtonChoices.SelectedIndex == 0)
                                lstJoyButtonChoices_selected = (JoystickButtons)lstJoyButtonChoices.SelectedItem;
                            else
                            {
                                lstJoyButtonChoices.SelectedIndex = 0;
                                lstJoyButtonChoices_selected = (JoystickButtons)0;
                            }
                            break;
                        }

                    case Devices.Custom:
                        {
                            break;
                        }
                    //case Devices.Custom_Audio:
                    //    {
                    //        break;
                    //    }
                }
                //GameControlsManager.Instance.GetItemByControlKey(command_selected).BindedKeyboardMouseValues.Add(new GameControlsManager.SystemKeyboardMouseValue(lstKeyboardButtonChoices_selected));
                //save bind

                //GameControlsManager.Instance.SaveCustomConfig();
                //GameControlsManager.Instance.LoadCustomConfig();
                Add_Custom_Control.SetShouldDetach();
            };

            #endregion ButtonOK

            ((Button)Add_Custom_Control.Controls["buttonReset"]).Click += delegate(Button sender)
            {
                cmbDevice.SelectedIndex = 0;
                cmbDeviceType.SelectedIndex = 0;
                lstCommand.SelectedIndex = 0;
                cmbMouseButtonChoices.SelectedIndex = 0;
                cmbMouseScrollChoices.SelectedIndex = 0;
                lstKeyboardButtonChoices.SelectedIndex = 0;
                cmbSliderChoices.SelectedIndex = 0;
                cmbSliderAxisChoices.SelectedIndex = 0;
                cmbSliderAxisFilterChoices.SelectedIndex = 0;
                cmbAxisChoices.SelectedIndex = 0;
                cmbAxisFilterChoices.SelectedIndex = 0;
                lstJoyButtonChoices.SelectedIndex = 0;
                cntrlCommands.Visible = false;
                scrlSelectedStrength.Value = 1f;
                MainOptionsTabControl.Visible = false;
                message = " Nothing_Selected";
                lblMessage.Text = message;
            };

            ((Button)Add_Custom_Control.Controls["buttonCancel"]).Click += delegate(Button sender)
            {
                Add_Custom_Control.SetShouldDetach();
            };

            #endregion AddCustomControl.Gui

            MainOptionsTabControl.SelectedIndex = lastPageIndex2;
            UpdateMainOptionsPageButtonsState();
        }