示例#1
0
        private void OnBeforeQueryStatusUserShortcutsDynamicItem(object sender, EventArgs args)
        {
            List <ShortcutFileInfo> userShortcutsRegistry = userShortcutsManager.GetUserShortcutsRegistry();

            bool userShortcutsExist = userShortcutsRegistry.Count > 0;

            DynamicItemMenuCommand matchedCommand = (DynamicItemMenuCommand)sender;

            matchedCommand.Enabled = userShortcutsExist;
            matchedCommand.Visible = userShortcutsExist;

            if (userShortcutsExist)
            {
                //The root item in the expansion won't flow through IsValidDynamicItem as it will match against the actual DynamicItemMenuCommand based on the
                //'root' id given to that object on construction, only if that match fails will it try and call the dynamic id check, since it won't fail for
                //the root item we need to 'special case' it here as MatchedCommandId will be 0 in that case.
                bool isRootItem    = (matchedCommand.MatchedCommandId == 0);
                int  menuItemIndex = isRootItem ? 0 : (matchedCommand.MatchedCommandId - DynamicUserShortcutsStartCmdId);

                // Add an & to the front of the menu text so that the first letter becomes the accellerator key.
                matchedCommand.Text = GetMenuTextWithAccelerator(userShortcutsRegistry[menuItemIndex].DisplayName);
            }

            //Clear this out here as we are done with it for this item.
            matchedCommand.MatchedCommandId = 0;
        }
示例#2
0
        private void ExecuteUserShortcutsCommand(object sender, EventArgs args)
        {
            DynamicItemMenuCommand invokedCommand = (DynamicItemMenuCommand)sender;
            string           shortcutDefName      = invokedCommand.Text.Replace("&", "");// Remove the & (keyboard accelerator) from of the menu text
            ShortcutFileInfo userShortcutsDef     = userShortcutsManager.GetUserShortcutsInfo(shortcutDefName);
            string           importFilePath       = userShortcutsDef.Filepath;

            if (!File.Exists(importFilePath))
            {
                if (MessageBox.Show($"File does not exist: {importFilePath}\nRemove from shortcuts registry?", MSG_CAPTION_IMPORT, MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    userShortcutsManager.DeleteUserShortcutsDef(shortcutDefName);
                }
                return;
            }
            LoadKeyboardShortcutsFromVSSettingsFile(importFilePath);
        }
示例#3
0
        private void OnBeforeQueryStatusMappingSchemeDynamicItem(object sender, EventArgs args)
        {
            DynamicItemMenuCommand matchedCommand = (DynamicItemMenuCommand)sender;

            matchedCommand.Enabled = true;
            matchedCommand.Visible = true;

            //The root item in the expansion won't flow through IsValidDynamicItem as it will match against the actual DynamicItemMenuCommand based on the
            //'root' id given to that object on construction, only if that match fails will it try and call the dynamic id check, since it won't fail for
            //the root item we need to 'special case' it here as MatchedCommandId will be 0 in that case.
            bool isRootItem    = (matchedCommand.MatchedCommandId == 0);
            int  menuItemIndex = isRootItem ? 0 : (matchedCommand.MatchedCommandId - DynamicThemeStartCmdId);

            string mappingSchemeName = GetMappingSchemeName(menuItemIndex);

            matchedCommand.Text    = GetMenuTextWithAccelerator(mappingSchemeName);
            matchedCommand.Checked = IsSelected(mappingSchemeName);

            //Clear this out here as we are done with it for this item.
            matchedCommand.MatchedCommandId = 0;
        }
        /// <summary>
        /// Handler for the Load User Shortcuts menu items.
        /// </summary>
        private void ExecuteUserShortcutsCommand(object sender, EventArgs args)
        {
            // Get the name of shortcuts file from the invoked menu item (Dynamic menu - can't know at compile time)
            DynamicItemMenuCommand invokedCommand = (DynamicItemMenuCommand)sender;
            string shortcutDefName = invokedCommand.Text.Replace("&", "");  // Remove the & (keyboard accelerator) from the menu text

            // Lookup the cache of known keyoard import files and get the full filepath
            ShortcutFileInfo userShortcutsDef = userShortcutsManager.GetUserShortcutsInfo(shortcutDefName);
            string           importFilePath   = userShortcutsDef.Filepath;

            // If file is not available on the drive, abort and offer to remove it from the list.
            if (!File.Exists(importFilePath))
            {
                if (MessageBox.Show($"File does not exist: {importFilePath}\nRemove from shortcuts registry?", MSG_CAPTION_IMPORT, MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    userShortcutsManager.DeleteUserShortcutsDef(shortcutDefName);
                }
                return;
            }

            // Load the user shortcuts from the VSSettings file.
            var success = LoadKeyboardShortcutsFromVSSettingsFile(importFilePath);
        }
示例#5
0
        private void ExecuteMappingSchemeCommand(object sender, EventArgs args)
        {
            DynamicItemMenuCommand invokedCommand = (DynamicItemMenuCommand)sender;

            ApplyMappingScheme(invokedCommand.Text.Replace("&", ""));
        }