Ejemplo n.º 1
0
        /// <summary>
        /// Unassign keyboard key or joystick button when double clicked a Datagrid cell.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DataGrid_MouseButtonDoubleClick(object sender, MouseButtonEventArgs e)
        {
            KeyMappingTimer.Stop();
            NewDeviceDetectTimer.Stop();

            KeyAssgn selectedItem = (KeyAssgn)KeyMappingGrid.SelectedItem;

            if (selectedItem == null)
            {
                return;
            }
            if (KeyMappingGrid.CurrentColumn == null)
            {
                return;
            }
            if (selectedItem.GetVisibility() != "White")
            {
                return;
            }
            if (selectedItem.GetCallback() == "SimDoNothing")
            {
                return;
            }

            KeyMappingWindow.ShowKeyMappingWindow(this, selectedItem, keyFile, deviceControl, sender);

            deviceControl.SortDevice();
            ResortDevices();

            KeyMappingGrid.Items.Refresh();
            KeyMappingGrid.UnselectAllCells();

            NewDeviceDetectTimer.Start();
            KeyMappingTimer.Start();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Callback When clicked "Assign" Button. Opens AxisAssignWindow.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Assign_Click(object sender, RoutedEventArgs e)
        {
            AxisMovingTimer.Stop();
            NewDeviceDetectTimer.Stop();

            string whocalledwindow = ((System.Windows.Controls.Button)sender).Name;

            InGameAxAssgn axisAssign = AxisAssignWindow.ShowAxisAssignWindow(this, (InGameAxAssgn)inGameAxis[whocalledwindow], sender);

            // Reset PhysicalAxis previously assigned to same axis
            // In case of axis has been unassigned and saved.
            for (int i = 0; i < deviceControl.joyAssign.Length; i++)
            {
                deviceControl.joyAssign[i].ResetPreviousAxis(whocalledwindow);
            }
            if (deviceControl.mouse.GetMouseAxis().GetAxisName() == whocalledwindow)
            {
                deviceControl.mouse.LoadAx(new AxAssgn());
            }

            // When axis has been assigned.
            if (axisAssign.GetDeviceNumber() > -1)
            {
                deviceControl.joyAssign[axisAssign.GetDeviceNumber()].axis[axisAssign.GetPhysicalNumber()]
                    = new AxAssgn(whocalledwindow, axisAssign);
            }
            if (axisAssign.GetDeviceNumber() == -2)
            {
                wheelValue = 0;
                deviceControl.mouse.LoadAx(new AxAssgn(whocalledwindow, axisAssign));
            }

            joyAssign_2_inGameAxis();
            ResetAssgnWindow();

            NewDeviceDetectTimer.Start();
            AxisMovingTimer.Start();
        }