Ejemplo n.º 1
0
 private void BAddKeyClick(object sender, EventArgs e)
 {
     foreach (var item in Enum.GetValues(typeof(WindowsAPI.VirtualKeyCode)))
     {
         if (cbAddKey.Text.Equals(WindowsAPI.GetVirtualKeyName((WindowsAPI.VirtualKeyCode)item)))
         {
             _button.Value = _button.Value.AddKey((WindowsAPI.VirtualKeyCode)item);
             break;
         }
     }
 }
Ejemplo n.º 2
0
        public override string AsFriendlyString()
        {
            StringBuilder sb            = new StringBuilder();
            bool          bMultipleKeys = KeyCount > 1;

            foreach (var input in _input)
            {
                if (input.Data.Keyboard.Flags == 0)
                {
                    sb.AppendFormat(bMultipleKeys ? "[{0}] " : "{0} ",
                                    WindowsAPI.GetVirtualKeyName((WindowsAPI.VirtualKeyCode)input.Data.Keyboard.KeyCode));
                }
            }
            return(sb.ToString().Trim());
        }
Ejemplo n.º 3
0
        public override ApplicationAction RemoveKey(int index)
        {
            var current = 0;
            var item    = 0;

            foreach (var input in _input)
            {
                if (input.Data.Keyboard.Flags == 0)
                {
                    var tmp = string.Format(KeyCount > 1 ? "[{0}] " : "{0} ",
                                            WindowsAPI.GetVirtualKeyName((WindowsAPI.VirtualKeyCode)input.Data.Keyboard.KeyCode));
                    current += tmp.Length;
                    if (index <= current)
                    {
                        return(RemoveItem(item));
                    }
                    item++;
                }
            }

            return(this);
        }
Ejemplo n.º 4
0
        public CecButtonConfigUI(CecButtonConfigItem button)
        {
            _button = button;
            InitializeComponent();

            var keys = Enum.GetValues(typeof(WindowsAPI.VirtualKeyCode));

            string[] friendlyNames = new string[keys.Length];
            for (int i = 0; i < keys.Length; i++)
            {
                friendlyNames[i] = WindowsAPI.GetVirtualKeyName((WindowsAPI.VirtualKeyCode)keys.GetValue(i));
            }
            Array.Sort(friendlyNames);
            foreach (var item in friendlyNames)
            {
                cbAddKey.Items.Add(item);
            }

            button.SettingChanged += delegate
            {
                _lastSelectedText = 0;
                tbAction.Text     = button.Value.AsFriendlyString().Trim();
            };

            lButtonName.Text = button.Label.Text;
            tbAction.Text    = button.Value.AsFriendlyString().Trim();

            //TODO
            cbAddAction.Items.Add(ApplicationInput.FriendlyActionName(ActionType.CloseControllerApplication));
            cbAddAction.Items.Add(ApplicationInput.FriendlyActionName(ActionType.StartApplication));

            // take the icon of the main window
            ComponentResourceManager resources = new ComponentResourceManager(typeof(CECTray));

            Icon = resources.GetObject("$this.Icon") as Icon;
        }