public SaKiMenuItemViewModel CreateCreateMenuItemGroup(string elementType) { var key = $"Create New group for {elementType}"; if (!_cache.ContainsKey(key)) { var group = new SaKiGroupMenuItemViewModel { Name = "Create New", Description = "Create new child WebElementInfo", Items = new ObservableCollection <SaKiMenuItemViewModel>() }; switch (elementType) { case "Root": group.Items.Add(CreateCreateCommandMenuItem(WebElementTypes.Directory)); group.Items.Add(CreateCreateCommandMenuItem(WebElementTypes.Page)); group.Items.Add(CreateCreateCommandMenuItem(WebElementTypes.Context)); break; case WebElementTypes.Directory: group.Items.Add(CreateCreateCommandMenuItem(WebElementTypes.Page)); group.Items.Add(CreateCreateCommandMenuItem(WebElementTypes.Context)); group.Items.Add(CreateCreateCommandMenuItem(WebElementTypes.Control)); group.Items.Add(CreateCreateCommandMenuItem(WebElementTypes.Directory)); break; case WebElementTypes.Page: case WebElementTypes.Context: case WebElementTypes.Control: group.Items.Add(CreateCreateCommandMenuItem(WebElementTypes.Element)); group.Items.Add(CreateCreateCommandMenuItem(WebElementTypes.Control)); group.Items.Add(CreateCreateCommandMenuItem(WebElementTypes.DropDown)); group.Items.Add(CreateCreateCommandMenuItem(WebElementTypes.RadioGroup)); group.Items.Add(CreateCreateCommandMenuItem(WebElementTypes.Reference)); group.Items.Add(CreateCreateCommandMenuItem(WebElementTypes.Frame)); break; default: MessageBox.Show($"Unknown element type: {elementType} to create Create New menu items group"); break; } _cache[key] = group; } return(_cache[key]); }
public SaKiMenuItemViewModel CreateActionsMenuItemGroup(string elementType, string parentType) { var key = $"Create actions for {elementType}"; if (elementType == WebElementTypes.Element) { key += $" {parentType}"; } if (!_cache.ContainsKey(key)) { var group = new SaKiGroupMenuItemViewModel { Name = "Actions", Description = "Actions to manage WebElements", Items = new ObservableCollection <SaKiMenuItemViewModel>() }; switch (elementType) { case "Root": group.Items.Add(CreateActionsCommandMenuItem("Paste")); break; case WebElementTypes.Directory: group.Items.Add(CreateActionsCommandMenuItem("Delete")); group.Items.Add(CreateActionsCommandMenuItem("Cut")); group.Items.Add(CreateActionsCommandMenuItem("Paste")); break; case WebElementTypes.Page: case WebElementTypes.Context: case WebElementTypes.Frame: case WebElementTypes.Reference: case WebElementTypes.Control: case WebElementTypes.DropDown: case WebElementTypes.RadioGroup: group.Items.Add(CreateActionsCommandMenuItem("Delete")); group.Items.Add(CreateActionsCommandMenuItem("Copy")); group.Items.Add(CreateActionsCommandMenuItem("Cut")); group.Items.Add(CreateActionsCommandMenuItem("Paste")); group.Items.Add(CreateActionsCommandMenuItem("Clone")); break; case WebElementTypes.Element: { switch (parentType) { case WebElementTypes.DropDown: case WebElementTypes.RadioGroup: group.Items.Add(CreateActionsCommandMenuItem("Copy")); break; case WebElementTypes.Context: case WebElementTypes.Control: group.Items.Add(CreateActionsCommandMenuItem("Delete")); group.Items.Add(CreateActionsCommandMenuItem("Copy")); group.Items.Add(CreateActionsCommandMenuItem("Cut")); group.Items.Add(CreateActionsCommandMenuItem("Paste")); group.Items.Add(CreateActionsCommandMenuItem("Clone")); break; default: MessageBox.Show($"Unexpected parent element type: {parentType} for creating actions menu items"); break; } } break; default: MessageBox.Show($"Unexpected element type: {elementType} for creating actions menu items"); break; } _cache[key] = group; } return(_cache[key]); }