private static void AddSeparator(CefMenuModel model) { if (model.Count > 0 && model.GetItemTypeAt(model.Count - 1) != CefMenuItemType.Separator) { model.AddSeparator(); } }
/// <summary> /// The on before context menu. /// </summary> /// <param name="browser"> /// The browser. /// </param> /// <param name="frame"> /// The frame. /// </param> /// <param name="state"> /// The state. /// </param> /// <param name="model"> /// The model. /// </param> protected override void OnBeforeContextMenu(CefBrowser browser, CefFrame frame, CefContextMenuParams state, CefMenuModel model) { base.OnBeforeContextMenu(browser, frame, state, model); for (int x = model.Count - 1; x > -1; x--) { var item = model.GetLabelAt(x); if (item == "&Back" || item == "&Forward" || item == "&Print…" || item == "&View page source") { model.RemoveAt(x); } } if (model.Count == 1 && model.GetItemTypeAt(0).ToString() == "Separator") { model.RemoveAt(0); } model.AddItem((int)(CefMenuId)ShowDevTools, "Show DevTools"); model.AddItem((int)(CefMenuId)Refresh, "Refresh"); }