コード例 #1
0
ファイル: MenuUtil.cs プロジェクト: yueker/poderosa
        private static int BuildMenuContentsForGroup(int index, ICommandTarget target, ToolStripItemCollection children, IPoderosaMenuGroup grp)
        {
            int count = 0;

            foreach (IPoderosaMenu m in grp.ChildMenus)
            {
                ToolStripMenuItem mi = new ToolStripMenuItem();
                children.Insert(index++, mi); //途中挿入のことも
                mi.DropDownOpening += new EventHandler(OnPopupMenu);
                mi.Enabled          = m.IsEnabled(target);
                mi.Checked          = mi.Enabled ? m.IsChecked(target) : false;
                mi.Text             = m.Text; //Enabledを先に
                mi.Tag              = new MenuItemTag(grp, m, target);

                IPoderosaMenuFolder folder;
                IPoderosaMenuItem   leaf;
                if ((folder = m as IPoderosaMenuFolder) != null)
                {
                    BuildMenuContents(mi, folder);
                }
                else if ((leaf = m as IPoderosaMenuItem) != null)
                {
                    mi.Click += new EventHandler(OnClickMenu);
                    IGeneralCommand gc = leaf.AssociatedCommand as IGeneralCommand;
                    if (gc != null)
                    {
                        mi.ShortcutKeyDisplayString = WinFormsUtil.FormatShortcut(CommandManagerPlugin.Instance.CurrentKeyBinds.GetKey(gc));
                    }
                }

                count++;
            }

            return(count);
        }
コード例 #2
0
ファイル: CommandManager.cs プロジェクト: yueker/poderosa
 public void SaveTo(StructuredText node)
 {
     node.Clear();
     foreach (Tag tag in _data)
     {
         if (tag.Key != tag.Command.DefaultShortcutKey)
         {
             node.Set(tag.Command.CommandID, WinFormsUtil.FormatShortcut(tag.Key, '+'));
         }
     }
 }