Exemple #1
0
        public void Prepare(List <CombinedWebElementInfoViewModel> contexts,
                            string originalWebElementTreePath,
                            List <string> blockedElementsBreadStrings,
                            List <string> blockedElementTypes)
        {
            IsEditMode = originalWebElementTreePath != null;

            WebElements = new ObservableCollection <CombinedWebElementInfoViewModel>();

            foreach (var context in contexts)
            {
                var info    = WebElementsViewModelsHelper.CreateInfoFromModel(context);
                var model   = WebElementsViewModelsHelper.CreateModelFromInfo(info);
                var cleared = WebElementsViewModelsHelper.ClearAccrodingToBlocked(model,
                                                                                  blockedElementsBreadStrings,
                                                                                  blockedElementTypes);
                if (cleared != null)
                {
                    WebElements.Add((CombinedWebElementInfoViewModel)cleared);
                }
            }

            OriginalWebElementTreePath = originalWebElementTreePath;

            if (OriginalWebElementTreePath != null)
            {
                SelectedWebElementTreePath = OriginalWebElementTreePath;
            }
        }
        protected override void ExecuteCommand()
        {
            if (!CanExecute(null))
            {
                return;
            }

            var existedNames = WebElementCommandsHelper.GetExistedNamesForChildWebElements(
                Selected,
                _webElementsTreeUserControl,
                null);

            var textDialog = new TextDialog("Clonned WebElement name");

            textDialog.Validate = str => !existedNames.Contains(str);

            if (textDialog.ShowDialog() != true)
            {
                return;
            }

            var info  = WebElementsViewModelsHelper.CreateInfoFromModel(Selected);
            var model = WebElementsViewModelsHelper.CreateModelFromInfo(info);

            model.Name = textDialog.Text;

            if (Selected.Parent == null)
            {
                if (model is CombinedWebElementInfoViewModel wc)
                {
                    _webElementsTreeUserControl.WebElements.Add(wc);
                }
                else
                {
                    MessageBox.Show("WebElement to clone is not a CombinedWebElementInfoViewModel. Magic Error.");
                }
            }
            else
            {
                model.Parent = Selected.Parent;
                Selected.Parent.Elements.Add(model);
            }
        }
Exemple #3
0
        protected override void ExecuteCommand()
        {
            if (!CanExecute(null))
            {
                return;
            }

            WebElementInfoViewModel model = Cut;

            var combined = Selected as CombinedWebElementInfoViewModel;

            if (combined == null && Selected != null)
            {
                MessageBox.Show("Magic!!! Try to paste to not combined element!");
                return;
            }

            if (combined != null)
            {
                if (combined.Elements == null)
                {
                    combined.Elements = new ObservableCollection <WebElementInfoViewModel>();
                }
            }

            if (Copied != null)
            {
                var info = WebElementsViewModelsHelper.CreateInfoFromModel(Copied);
                model = WebElementsViewModelsHelper.CreateModelFromInfo(info);
            }
            else
            {
                if (model.Parent != null)
                {
                    model.Parent.Elements.Remove(model);
                }
                else
                {
                    _webElementsTreeUserControl.WebElements.Remove(model as CombinedWebElementInfoViewModel);
                }
            }

            model.Parent = combined;

            if (combined != null)
            {
                combined.Elements.Add(model);
            }
            else
            {
                var cmb = model as CombinedWebElementInfoViewModel;
                if (cmb == null)
                {
                    MessageBox.Show("Magic!!! Try to paste not combined element to Root!");
                    return;
                }
                _webElementsTreeUserControl.WebElements.Add(cmb);
            }

            _webElementsTreeUserControl.SelectedWebElement = model;
        }