protected virtual void GetContextMenu(string where)
        {
            Assert.ArgumentNotNullOrEmpty(where, "where");
            IDataView dataView = this.GetDataView();

            if (dataView != null)
            {
                string source  = Sitecore.Context.ClientPage.ClientRequest.Source;
                string control = Sitecore.Context.ClientPage.ClientRequest.Control;
                int    num     = source.LastIndexOf("_");
                Assert.IsTrue(num >= 0, "Invalid source ID");
                string id   = ShortID.Decode(StringUtil.Mid(source, num + 1));
                Item   item = dataView.GetItem(id);
                if (item != null)
                {
                    SheerResponse.DisableOutput();
                    Sitecore.Shell.Framework.ContextMenu menu = new Sitecore.Shell.Framework.ContextMenu();
                    CommandContext context = new CommandContext(item);
                    Sitecore.Web.UI.HtmlControls.Menu contextMenu = menu.Build(context);
                    contextMenu.AddDivider();
                    contextMenu.Add("__Refresh", "Refresh", "Applications/16x16/refresh.png", string.Empty, string.Concat(new object[] { "javascript:Sitecore.Treeview.refresh(\"", source, "\",\"", control, "\",\"", item.ID.ToShortID(), "\")" }), false, string.Empty, MenuItemType.Normal);
                    SheerResponse.EnableOutput();
                    SheerResponse.ShowContextMenu(control, where, contextMenu);
                }
            }
        }
 protected void Gutter_ContextMenu()
 {
     var contextMenu = new Sitecore.Web.UI.HtmlControls.Menu();
     SheerResponse.DisableOutput();
     Item item = Context.Database.GetItem(Sitecore.ItemBucket.Kernel.Util.Constants.ContentEditorGutterFolder);
     Assert.IsNotNull(item, typeof(Item), "Item \"/sitecore/content/Applications/Content Editor/Gutters\" not found", new object[0]);
     List<ID> activeRendererIDs = GutterManager.GetActiveRendererIDs();
     foreach (Item item2 in item.Children)
     {
         contextMenu.Add("M" + item2.ID.ToShortID(), item2["Header"], item2.Appearance.Icon, string.Empty, "SetGutterRenderer(\"" + item2.ID + "\")", activeRendererIDs.Contains(item2.ID), string.Empty, MenuItemType.Check);
     }
     contextMenu.AddDivider();
     contextMenu.Add("__Refresh", "Refresh", "Applications/16x16/refresh.png", string.Empty, "Gutter_Refresh", false, string.Empty, MenuItemType.Normal);
     SheerResponse.EnableOutput();
     SheerResponse.ShowContextMenu(Context.ClientPage.ClientRequest.Control, string.Empty, contextMenu);
 }
 protected void Validator_ContextMenu(string markerId)
 {
     Assert.ArgumentNotNull(markerId, "markerId");
     Assert.IsTrue(UserOptions.ContentEditor.ShowValidatorBar, "Validator bar is switched off in Content Editor.");
     var byMarkerID = ValidatorManager.GetValidators(ValidatorsMode.ValidatorBar, this.ValidatorsKey).GetByMarkerID(markerId);
     if (byMarkerID != null)
     {
         SheerResponse.DisableOutput();
         var contextMenu = new Sitecore.Web.UI.HtmlControls.Menu();
         if (byMarkerID.HasMenu)
         {
             Assert.IsNotNull(Context.ContentDatabase, "Content database not found.");
             Assert.IsNotNull(byMarkerID.ValidatorID, "Validator ID is null.");
             Item item = Context.ContentDatabase.GetItem(byMarkerID.ValidatorID);
             if (item != null)
             {
                 contextMenu.AddFromDataSource(item, byMarkerID.MarkerID);
                 contextMenu.AddDivider();
             }
         }
         contextMenu.Add("Suppress Validation Rule", string.Empty, string.Format("Validator_SuppressValidator(\"{0}\")", markerId));
         SheerResponse.EnableOutput();
         SheerResponse.ShowContextMenu(Context.ClientPage.ClientRequest.Control, string.Empty, contextMenu);
     }
 }
 protected void TreeSearchOptionName_Click()
 {
     string control = Context.ClientPage.ClientRequest.Control;
     string str2 = StringUtil.Mid(control, 20);
     SheerResponse.DisableOutput();
     var menu = new Sitecore.Web.UI.HtmlControls.Menu();
     Hashtable fieldInfo = this.FieldInfo;
     bool flag = false;
     SortedList list = new SortedList(StringComparer.Ordinal);
     foreach (FieldInfo info in fieldInfo.Values)
     {
         Item item = Client.ContentDatabase.GetItem(info.FieldID);
         if (item != null)
         {
             if (!list.ContainsKey(item.Name))
             {
                 list.Add(item.Name, item.Key);
             }
             flag = true;
         }
     }
     if (flag)
     {
         foreach (string str3 in list.Keys)
         {
             menu.Add("F" + list[str3], str3, string.Empty, string.Empty, "javascript:scContent.changeSearchCriteria(\"" + str2 + "\",\"" + str3 + "\")", false, string.Empty, MenuItemType.Normal);
         }
         menu.AddDivider();
     }
     menu.Add("Remove", "Remove", string.Empty, string.Empty, "javascript:scContent.removeSearchCriteria(\"" + str2 + "\")", false, string.Empty, MenuItemType.Normal);
     SheerResponse.EnableOutput();
     SheerResponse.ShowPopup(control, "below", menu);
 }
        protected void ShowTabContextMenu()
        {
            var contextMenu = new Sitecore.Web.UI.HtmlControls.Menu();
            Database database = Factory.GetDatabase("master", false);
            Assert.IsNotNull(database, typeof(Database));
            Item item = database.GetItem("{DB14B596-67DD-4C93-BE7C-2BDBADEB64C2}"); //Tab Options
            Assert.IsNotNull(item, typeof(Ribbon));
            ListString str = new ListString(UserOptions.ContentEditor.VisibleStrips);
            SheerResponse.DisableOutput();
            foreach (Item item2 in item.Children)
            {
                Item strip = item2;

                contextMenu.Add("S" + strip.ID.ToShortID(), strip.Name, string.Empty, string.Empty, "CloseTabs(\"" + strip.ID + "\")", false, string.Empty, MenuItemType.Check);

            }
            contextMenu.AddDivider();
            contextMenu.Add("__Refresh", "Refresh", string.Empty, string.Empty, "RefreshItem", false, string.Empty, MenuItemType.Normal);

            SheerResponse.EnableOutput();
            SheerResponse.ShowContextMenu(Context.ClientPage.ClientRequest.Control, "contextmenu", contextMenu);
        }
 protected void ShowRibbonContextMenu()
 {
     var contextMenu = new Sitecore.Web.UI.HtmlControls.Menu();
     Database database = Factory.GetDatabase("core", false);
     Assert.IsNotNull(database, typeof(Database));
     Item item = database.GetItem(ItemIDs.DefaultRibbon);
     Assert.IsNotNull(item, typeof(Ribbon));
     ListString str = new ListString(UserOptions.ContentEditor.VisibleStrips);
     SheerResponse.DisableOutput();
     foreach (Item item2 in item.Children)
     {
         Item strip = item2;
         if (strip.TemplateID == TemplateIDs.Reference)
         {
             strip = strip.Database.Items[strip["Reference"]];
         }
         if (this.CanBeShown(strip))
         {
             bool check = strip["Hidden by default"] != "1";
             if (str.Count > 0)
             {
                 check = str.Contains(strip.ID.ToString());
             }
             contextMenu.Add("S" + strip.ID.ToShortID(), strip["Header"], string.Empty, string.Empty, "ToggleRibbonStrip(\"" + strip.ID + "\")", check, string.Empty, MenuItemType.Check);
         }
     }
     contextMenu.AddDivider();
     contextMenu.Add("__Reset", "Reset", string.Empty, string.Empty, "ResetRibbonStrips", false, string.Empty, MenuItemType.Normal);
     CommandState hidden = CommandState.Hidden;
     Command command = CommandManager.GetCommand("ribbon:customize");
     if (command != null)
     {
         hidden = CommandManager.QueryState(command, CommandContext.Empty);
     }
     if ((hidden == CommandState.Enabled) || (hidden == CommandState.Down))
     {
         contextMenu.Add("__Customize", "Customize", string.Empty, string.Empty, "ribbon:customize", false, string.Empty, MenuItemType.Normal);
     }
     SheerResponse.EnableOutput();
     SheerResponse.ShowContextMenu(Context.ClientPage.ClientRequest.Control, "contextmenu", contextMenu);
 }