public static HotkeyCommand[] LoadHotkeys(string name)
        {
            //var settings = LoadSettings().FirstOrDefault(s => s.Name == name);
            HotkeySettings[] allSettings;
            HotkeySettings settings = new HotkeySettings();
            HotkeySettings scriptkeys = new HotkeySettings();
            allSettings = LoadSettings();

            GetUsedHotkeys(allSettings);

            foreach(HotkeySettings hs in allSettings)
            {
                if(hs.Name == name)
                    settings = hs;
                if(hs.Name == "Scripts")
                    scriptkeys = hs;
            }

            //HotkeyCommand[] scriptkeys = LoadSettings().FirstOrDefault(s => s.Name == name);

            if(settings != null) {
                //append general hotkeys to every form
                //HotkeyCommand[] scriptkeys = LoadScriptHotkeys();
                HotkeyCommand[] allkeys = new HotkeyCommand[settings.Commands.Length + scriptkeys.Commands.Length];
                settings.Commands.CopyTo(allkeys,0);
                scriptkeys.Commands.CopyTo(allkeys,settings.Commands.Length);

                return allkeys;
            }

            //return settings != null ? settings.Commands : null;
            return null;
        }
Esempio n. 2
0
        public static HotkeyCommand[] LoadHotkeys(string name)
        {
            var settings    = new HotkeySettings();
            var scriptKeys  = new HotkeySettings();
            var allSettings = LoadSettings();

            UpdateUsedKeys(allSettings);

            foreach (var setting in allSettings)
            {
                if (setting.Name == name)
                {
                    settings = setting;
                }

                if (setting.Name == "Scripts")
                {
                    scriptKeys = setting;
                }
            }

            // append general hotkeys to every form
            Validates.NotNull(settings.Commands);
            Validates.NotNull(scriptKeys.Commands);
            var allKeys = new HotkeyCommand[settings.Commands.Length + scriptKeys.Commands.Length];

            settings.Commands.CopyTo(allKeys, 0);
            scriptKeys.Commands.CopyTo(allKeys, settings.Commands.Length);

            return(allKeys);
        }
        public static HotkeyCommand[] LoadScriptHotkeys()
        {
            var curScripts = GitUI.Script.ScriptManager.GetScripts();

            HotkeyCommand[] scriptKeys = new HotkeyCommand[curScripts.Count];

            /* define unusable int for identifying a shortcut for a custom script is pressed
             * all integers above 9000 represent a scripthotkey
             * these integers are never matched in the 'switch' routine on a form and
             * therefore execute the 'default' action
             */

            int i = 0;

            foreach (GitUI.Script.ScriptInfo s in curScripts)
            {
                if (!string.IsNullOrEmpty(s.Name))
                {
                    scriptKeys[i] = new HotkeyCommand((int)s.HotkeyCommandIdentifier, s.Name.ToString())
                    {
                        KeyData = (Keys.None)
                    };
                    i++;
                }
            }
            return(scriptKeys);
        }
Esempio n. 4
0
        private void listMappings_SelectedIndexChanged(object sender, EventArgs e)
        {
            var lvi = this.listMappings.SelectedItems.Count > 0 ? this.listMappings.SelectedItems[0] : null;

            if (lvi != null)
            {
                var hotkey = lvi.Tag as HotkeyCommand;
                this.SelectedHotkeyCommand = hotkey;
            }
        }
Esempio n. 5
0
        private void UpdateListViewItems(HotkeySettings setting)
        {
            this.SelectedHotkeyCommand = null;

            this.listMappings.Items.Clear();
            if (setting != null)
                foreach (var cmd in setting.Commands)
                {
                    if (cmd != null)
                        this.listMappings.Items.Add(new ListViewItem(new[] { cmd.Name, cmd.KeyData.ToText() }) { Tag = cmd });
                }
        }
Esempio n. 6
0
        private void UpdateListViewItems(HotkeySettings setting)
        {
            this.SelectedHotkeyCommand = null;

            this.listMappings.Items.Clear();
            if (setting != null)
            {
                foreach (var cmd in setting.Commands)
                {
                    this.listMappings.Items.Add(new ListViewItem(new[] { cmd.Name, cmd.KeyData.ToText() })
                    {
                        Tag = cmd
                    });
                }
            }
        }
        private static void GetUsedHotkeys(HotkeySettings[] settings)
        {
            UsedKeys.Clear();
            foreach (HotkeySettings hs in settings)
            {
                for (int i = 0; i < hs.Commands.Length; i++)
                {
                    HotkeyCommand hotkeyCommand = hs.Commands[i];

                    if (hotkeyCommand != null && !UsedKeys.Contains(hotkeyCommand.KeyData))
                    {
                        UsedKeys.Add(hotkeyCommand.KeyData);
                    }
                }
            }
            //MessageBox.Show(UsedKeys.Count.ToString());
        }
        public static HotkeyCommand[] LoadScriptHotkeys()
        {
            var curScripts = GitUI.Script.ScriptManager.GetScripts();

            HotkeyCommand[] scriptKeys = new HotkeyCommand[curScripts.Count];

            /* define unusable int for identifying a shortcut for a custom script is pressed
             * all integers above 9000 represent a scripthotkey
             * these integers are never matched in the 'switch' routine on a form and
             * therefore execute the 'default' action
             */

            return(curScripts.
                   Where(s => !s.Name.IsNullOrEmpty()).
                   Select(s => new HotkeyCommand((int)s.HotkeyCommandIdentifier, s.Name)
            {
                KeyData = (Keys.None)
            })
                   .ToArray());
        }
        public static HotkeyCommand[] LoadHotkeys(string name)
        {
            ////var settings = LoadSettings().FirstOrDefault(s => s.Name == name);
            HotkeySettings[] allSettings;
            HotkeySettings   settings   = new HotkeySettings();
            HotkeySettings   scriptkeys = new HotkeySettings();

            allSettings = LoadSettings();

            GetUsedHotkeys(allSettings);

            foreach (HotkeySettings hs in allSettings)
            {
                if (hs.Name == name)
                {
                    settings = hs;
                }

                if (hs.Name == "Scripts")
                {
                    scriptkeys = hs;
                }
            }

            ////HotkeyCommand[] scriptkeys = LoadSettings().FirstOrDefault(s => s.Name == name);

            if (settings != null)
            {
                // append general hotkeys to every form
                ////HotkeyCommand[] scriptkeys = LoadScriptHotkeys();
                HotkeyCommand[] allkeys = new HotkeyCommand[settings.Commands.Length + scriptkeys.Commands.Length];
                settings.Commands.CopyTo(allkeys, 0);
                scriptkeys.Commands.CopyTo(allkeys, settings.Commands.Length);

                return(allkeys);
            }

            ////return settings != null ? settings.Commands : null;
            return(null);
        }
Esempio n. 10
0
        public static HotkeyCommand[] LoadScriptHotkeys()
        {
            var curScripts = GitUI.Script.ScriptManager.GetScripts();

            HotkeyCommand[] scriptKeys = new HotkeyCommand[curScripts.Count];
            /* define unusable int for identifying a shortcut for a custom script is pressed
             * all integers above 9000 represent a scripthotkey
             * these integers are never matched in the 'switch' routine on a form and
             * therefore execute the 'default' action
             */

            int i=0;
            foreach (GitUI.Script.ScriptInfo s in curScripts)
            {
                if (!string.IsNullOrEmpty(s.Name))
                {
                    scriptKeys[i] = new HotkeyCommand((int)s.HotkeyCommandIdentifier, s.Name) { KeyData = (Keys.None) };
                    i++;
                }
            }
            return scriptKeys;
        }
Esempio n. 11
0
 private void UpdateTextBox(HotkeyCommand command)
 {
     txtHotkey.KeyData = (command != null) ? command.KeyData : Keys.None;
 }
Esempio n. 12
0
 private void listMappings_SelectedIndexChanged(object sender, EventArgs e)
 {
     var lvi = this.listMappings.SelectedItems.Count > 0 ? this.listMappings.SelectedItems[0] : null;
     if (lvi != null)
     {
         var hotkey = lvi.Tag as HotkeyCommand;
         this.SelectedHotkeyCommand = hotkey;
     }
 }
Esempio n. 13
0
 private void UpdateTextBox(HotkeyCommand command)
 {
     txtHotkey.KeyData = (command != null) ? command.KeyData : Keys.None;
 }