コード例 #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 "Md3ButtonGamepad":
                dev = Md.ThreeButton(portNum);
                break;

            case "Md6ButtonGamepad":
                dev = Md.SixButton(portNum);
                break;

            case "Md2ButtonGamepad":
                dev = Md.TwoButton(portNum);
                break;

            case "MdMegaMouse":
                dev = Md.MegaMouse(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",
                CloseByEscape   = false,
                CloseOnOverlay  = false,
                ShowCloseButton = false
            }, RootGrid);
        }