예제 #1
0
        private KeyBindItem GetBindItem(GamePadButtonType type)
        {
            string      line = Parse.KeysToString(Controller.GetProfile(), XInputWrapper.GamePadButtons[type]);
            KeyBindItem item = new KeyBindItem(Controller.GetLanguage()[type.ToString()], line);

            item.InputChanged = () =>
            {
                AssignKeystroke(Controller.GetProfile(), type, item.GetText());
            };

            item.SetContextMenu(_menu);

            return(item);
        }
예제 #2
0
        public override void InitElements()
        {
            _menu = new ContextMenu(GetHandler(), _copy, _paste, _clear, _manualMode);
            _menu.SetBackground(50, 50, 50);
            _menu.SetShadow(5, 0, 0, Color.FromArgb(210, 0, 0, 0));

            Factory.Styles.GetContextMenuItemStyle().SetStyle(_copy, _paste, _clear, _manualMode);
            _copy.AddItem(Factory.Items.GetImageMenuItem(Factory.Resources.CopyIcon, Color.FromArgb(12, 180, 105)));
            _paste.AddItem(Factory.Items.GetImageMenuItem(Factory.Resources.PasteIcon, Color.FromArgb(173, 139, 186)));
            _clear.AddItem(Factory.Items.GetImageMenuItem(Factory.Resources.ClearIcon, Color.FromArgb(200, 116, 116)));
            _manualMode.AddItem(Factory.Items.GetImageMenuItem(Factory.Resources.PlusIcon, Color.FromArgb(10, 168, 232)));

            _copy.EventMouseClick += (sender, args) =>
            {
                if (_menu.ReturnFocus != null)
                {
                    TextEdit field = _menu.ReturnFocus as TextEdit;
                    if (field != null)
                    {
                        CommonService.SetClipboardString(field.GetText());
                    }
                }
            };

            _paste.EventMouseClick += (sender, args) =>
            {
                if (_menu.ReturnFocus != null)
                {
                    TextEdit field = _menu.ReturnFocus as TextEdit;
                    if (field != null)
                    {
                        field.SetText(CommonService.GetClipboardString());
                    }
                }
            };

            _clear.EventMouseClick += (sender, args) =>
            {
                if (_menu.ReturnFocus != null)
                {
                    TextEdit field = _menu.ReturnFocus as TextEdit;
                    if (field != null)
                    {
                        field.Clear();
                    }
                }
            };

            _manualMode.EventMouseClick += (sender, args) =>
            {
                if (_menu.ReturnFocus != null)
                {
                    TextEdit field = _menu.ReturnFocus as TextEdit;
                    if (field != null)
                    {
                        ManualKeyBinder mkb = new ManualKeyBinder();
                        mkb.OnCloseDialog += () =>
                        {
                            string result = mkb.Result;
                            if (!result.Equals(String.Empty))
                            {
                                field.SetText(result);
                                KeyBindItem parent = field.GetParent() as KeyBindItem;
                                parent?.InputChanged?.Invoke();
                            }
                        };
                        mkb.Show(GetHandler());
                    }
                }
            };

            _leftBinds.SetSpacing(0, 10);
            _rightBinds.SetSpacing(0, 10);

            AddItems(
                _leftBinds,
                _rightBinds
                );
            UpdateUI();
        }