Exemplo n.º 1
0
        private async void btnControlsConfigure_Click(object sender, RoutedEventArgs e)
        {
            // get button name
            Button button = (Button)sender;
            string name   = button.Name;

            // remove beginning and end
            name = name.Replace("btn", "").Replace("Configure", "");

            // get the relevant combox
            ComboBox cb = (ComboBox)this.FindName("cmb" + name);

            // get the virtual port number
            string selectedString = cb.SelectionBoxItem.ToString();
            int    portNum        = Convert.ToInt32(selectedString.Replace("Virtual Port ", ""));

            DeviceDefinition dev = new DeviceDefinition();

            switch (name)
            {
            case "SsGamepad":
                dev = Ss.GamePad(portNum);
                break;

            case "Ss3DGamepad":
                dev = Ss.ThreeD(portNum);
                break;

            case "SsMission":
                dev = Ss.Mission(portNum);
                break;

            case "SsDualMission":
                dev = Ss.DMission(portNum);
                break;

            case "SsWheel":
                dev = Ss.Wheel(portNum);
                break;

            case "SsGun":
                dev = Ss.Gun(portNum);
                break;

            case "SsMouse":
                dev = Ss.Mouse(portNum);
                break;

            default:
                return;
            }

            mw.ControllerDefinition = dev;

            // launch controller configuration window
            Grid RootGrid = (Grid)mw.FindName("RootGrid");
            await mw.ShowChildWindowAsync(new ConfigureController()
            {
                IsModal         = true,
                AllowMove       = false,
                Title           = "Controller Configuration",
                CloseOnOverlay  = false,
                CloseByEscape   = false,
                ShowCloseButton = false
            }, RootGrid);
        }