Ejemplo n.º 1
0
        public static void RefreshMenuContents(ToolStripMenuItem menuitem, IPoderosaMenuFolder contents)
        {
            //若干手抜きだが、VolatileContentsと混合していると比較が面倒。なので一つでもVolatileならリビルドしてしまう
            bool contains_volatile = false;

            foreach (IPoderosaMenuGroup grp in contents.ChildGroups)
            {
                if (grp.IsVolatileContent)
                {
                    contains_volatile = true;
                    break;
                }
            }

            if (contains_volatile)
            {
                menuitem.DropDownItems.Clear();
                BuildMenuContents(menuitem, contents);
            }
            else
            {
                foreach (ToolStripItem mi in menuitem.DropDownItems)
                {
                    MenuItemTag tag = mi.Tag as MenuItemTag;
                    if (tag != null)   //BarではTagなしだ
                    {
                        ToolStripMenuItem mi2 = mi as ToolStripMenuItem;
                        Debug.Assert(mi2 != null);
                        mi2.Enabled = tag.Menu.IsEnabled(tag.CommandTarget);
                        mi2.Checked = mi.Enabled ? tag.Menu.IsChecked(tag.CommandTarget) : false;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private static IPoderosaMenuGroup SafeMenuItemToMenuGroup(ToolStripMenuItem item)
        {
            object t = item.Tag;

            if (t == null)
            {
                return(null);
            }

            MenuItemTag mitag = t as MenuItemTag;

            return(mitag == null ? null : mitag.MenuGroup);
        }
Ejemplo n.º 3
0
        //メインメニュー用 遅延作成
        private static void OnRootPopupMenu(object sender, EventArgs args)
        {
            ToolStripMenuItem mi  = sender as ToolStripMenuItem;
            MenuItemTag       tag = (MenuItemTag)mi.Tag;

            if (!tag.Created)
            {
                BuildMenuContents(mi, (IPoderosaMenuFolder)tag.Menu);
                tag.Created = true;
                return;
            }
            OnPopupMenu(sender, args); //通常のポップアップ動作
        }
Ejemplo n.º 4
0
        private static void OnClickMenu(object sender, EventArgs args)
        {
            try {
                ToolStripMenuItem mi   = sender as ToolStripMenuItem;
                MenuItemTag       tag  = ((MenuItemTag)mi.Tag);
                IPoderosaMenuItem item = tag.Menu as IPoderosaMenuItem;
                Debug.Assert(item != null);

                if (item is IPoderosaMenuItemWithArgs)
                {
                    CommandManagerPlugin.Instance.Execute(item.AssociatedCommand, tag.CommandTarget, ((IPoderosaMenuItemWithArgs)item).AdditionalArgs);
                }
                else
                {
                    CommandManagerPlugin.Instance.Execute(item.AssociatedCommand, tag.CommandTarget);
                }
            }
            catch (Exception ex) {
                RuntimeUtil.ReportException(ex);
            }
        }