public List <SaKiMenuItemViewModel> CreateMenuItemsForWebElement() { var elementInfo = _webElementsTreeUserControl.SelectedWebElement; var et = elementInfo?.ElementType ?? "Root"; var p = elementInfo?.Parent?.ElementType ?? "Root"; var key = $"Menu Items for {et} {p}"; var isAnyParentRef = WebElementsViewModelsHelper.IsAnyParentReference(elementInfo); if (isAnyParentRef) { key = "Reference"; } if (elementInfo != null && elementInfo.ElementType == WebElementTypes.Reference) { key = $"Menu Items for {et} {p} ref"; } if (!_menusCache.ContainsKey(key)) { var items = new List <SaKiMenuItemViewModel>(); if (isAnyParentRef) { items.Add(CreateCopyNameMenuItem()); items.Add(CreateGoToReferencedMenuItem()); } else { if (elementInfo != null) { items.Add(CreateCopyNameMenuItem()); if (elementInfo.ElementType == WebElementTypes.Reference) { items.Add(CreateGoToReferencedMenuItem()); } items.Add(CreateEditMenuItem()); } if (WebElementCommandsHelper.CanElementHasCustomChildren(elementInfo)) { items.Add(CreateCreateMenuItemGroup(et)); } items.Add(CreateActionsMenuItemGroup(et, p)); } _menusCache[key] = items; } return(_menusCache[key]); }
public override bool CanExecute(object parameter) { var result = CutOrCopied != null && Selected != CutOrCopied && !WebElementsViewModelsHelper.IsAnyParentReference(Selected) && WebElementCommandsHelper.CanElementHasCustomChildren(Selected) && !(Cut != null && Selected.IsDescendantdFor(Cut as CombinedWebElementInfoViewModel)) && ((Selected as CombinedWebElementInfoViewModel)?.Elements ?? _webElementsTreeUserControl.WebElements.Cast <WebElementInfoViewModel>()) ?.FirstOrDefault(e => e.Name == CutOrCopied.Name) == null; return(result); }