Exemple #1
0
        protected void CheckEmulatorInput()
        {
            var button = NesEmulatorHandler.GetCurrentInput();

            if (button == null)
            {
                return;
            }
            KeyCode    = (int)button.Item1;
            ButtonName = button.Item2;
            Close();
        }
Exemple #2
0
        protected override void OnClosing(CancelEventArgs e)
        {
            if (!_shortcut)
            {
                Application.RemoveMessageFilter(this);
                Timer.Stop();
                Timer.Dispose();
                NesEmulatorHandler.EndInputCheck();
            }

            base.OnClosing(e);
        }
Exemple #3
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            if (!_shortcut)
            {
                Application.AddMessageFilter(this);
                Timer = new Timer {
                    Interval = 10
                };
                Timer.Tick += (s, a) => CheckEmulatorInput();
                Timer.Start();

                NesEmulatorHandler.InitiateInputCheck();
            }
        }
Exemple #4
0
        public void SetMappings(List <KeyboardMapping> mappings)
        {
            Mappings = mappings;
            SuspendLayout();
            Controls.Clear();
            foreach (var mapping in mappings)
            {
                var panel = new Panel();
                panel.Dock   = DockStyle.Top;
                panel.Height = 25;

                var button = new Button();
                button.Text = mapping.Name;
                button.Size = new System.Drawing.Size(75, 23);
                button.UseVisualStyleBackColor = true;

                panel.Controls.Add(button);

                var label = new Label();
                label.Location = new System.Drawing.Point(80, 5);
                label.Text     = mapping.MappedToName ?? NesEmulatorHandler.GetInputName(mapping.MappedTo);

                panel.Controls.Add(label);
                button.Click += (s, a) =>
                {
                    using (var keyAssignDialog = new ButtonAssignment(false))
                    {
                        keyAssignDialog.StartPosition = FormStartPosition.CenterParent;
                        keyAssignDialog.ShowDialog(this);
                        mapping.MappedTo     = keyAssignDialog.KeyCode;
                        mapping.MappedToName = keyAssignDialog.ButtonName;
                    }
                    label.Text = mapping.MappedToName ?? NesEmulatorHandler.GetInputName(mapping.MappedTo);
                    SelectNextControl(button, true, false, true, true);
                };

                Controls.Add(panel);
                Controls.SetChildIndex(panel, 0);
            }
            ResumeLayout();
        }
Exemple #5
0
 public ButtonAssignment(bool shortcut)
 {
     _emulator = new NesEmulatorHandler(this);
     _shortcut = shortcut;
     InitializeComponent();
 }