Example #1
0
        private void btnSetup_Click(object sender, EventArgs e)
        {
            int            index        = 0;
            ControllerType type         = ControllerType.None;
            string         selectedText = "";

            if (sender == btnSetupP1)
            {
                type         = cboPlayer1.GetEnumValue <ControllerType>();
                selectedText = cboPlayer1.SelectedItem.ToString();
                index        = 0;
            }
            else if (sender == btnSetupP2)
            {
                type         = cboPlayer2.GetEnumValue <ControllerType>();
                selectedText = cboPlayer2.SelectedItem.ToString();
                index        = 1;
            }
            else if (sender == btnSetupP3)
            {
                type         = cboPlayer3.GetEnumValue <ControllerType>();
                selectedText = cboPlayer3.SelectedItem.ToString();
                index        = 2;
            }
            else if (sender == btnSetupP4)
            {
                type         = cboPlayer4.GetEnumValue <ControllerType>();
                selectedText = cboPlayer4.SelectedItem.ToString();
                index        = 3;
            }
            else if (sender == btnSetupP5)
            {
                type         = cboPlayer4.GetEnumValue <ControllerType>();
                selectedText = cboPlayer5.SelectedItem.ToString();
                index        = 4;
            }

            BaseInputConfigForm frm = null;
            InputConfig         cfg = (InputConfig)Entity;

            switch (type)
            {
            case ControllerType.SnesController:
                frm = new frmControllerConfig(cfg.Controllers[index], index);
                break;

            case ControllerType.SuperScope:
                //frm = new frmSuperScopeConfig();
                break;

            case ControllerType.SnesMouse:
                //frm = new frmMouseConfig();
                break;
            }

            if (frm != null)
            {
                OpenSetupWindow(frm, (Button)sender, selectedText, index);
            }
        }
Example #2
0
        private void OpenSetupWindow(BaseInputConfigForm frm, Button btn, string title, int port)
        {
            Point     point  = btn.PointToScreen(new Point(0, btn.Height));
            Rectangle screen = Screen.FromControl(btn).Bounds;

            if (frm.Height + point.Y > screen.Bottom)
            {
                //Show on top instead
                point.Y -= btn.Height + frm.Height;

                if (point.Y < 0)
                {
                    point.Y = 0;
                }
            }

            if (frm.Width + point.X > screen.Right)
            {
                //Show on left instead
                point.X -= frm.Width - btn.Width;
                if (point.X < 0)
                {
                    point.X = 0;
                }
            }

            frm.Text          = title;
            frm.StartPosition = FormStartPosition.Manual;
            frm.Top           = point.Y;
            frm.Left          = point.X;

            if (frm.ShowDialog(this) == DialogResult.OK)
            {
                InputConfig cfg = (InputConfig)Entity;
                cfg.Controllers[port] = frm.Config;
            }
            frm.Dispose();
        }