예제 #1
0
        private void AddControlMenuItem_Click(object sender, RoutedEventArgs e)
        {
            if (_viewModel.SelectedElement == null)
            {
                return;
            }

            if (!(_viewModel.SelectedElement is CombinedElementViewModel combined))
            {
                MessageBox.Show($"Selected Element: {_viewModel.SelectedElement.Name} is not nested from CombinedElementViewModel. But has to");
                return;
            }

            var model = WebFactory.CreateCombinedElementModel();

            var dialog = new WebElementDetailsWindow(model, combined.GetExistedNames(), false);

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

            if (combined.Elements == null)
            {
                combined.Elements = new ObservableCollection <WebElementViewModel>();
            }
            model.Parent = combined;
            combined.Elements.Add(model);

            _viewModel.SelectedElement = model;
        }
예제 #2
0
        private void AddDropDownMenuItem_Click(object sender, RoutedEventArgs e)
        {
            if (_viewModel.SelectedElement == null)
            {
                return;
            }

            if (!(_viewModel.SelectedElement is CombinedElementViewModel combined))
            {
                MessageBox.Show($"Selected Element: {_viewModel.SelectedElement.Name} is not nested from CombinedElementViewModel. But has to");
                return;
            }

            var model = WebFactory.CreateDropDownElementModel();

            var dialog = new WebElementDetailsWindow(model, combined.GetExistedNames(), false);

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

            var ddName = model.Name.Replace("DropDown", "").Trim();

            var input = model.Elements.First(el => el.InnerKey == DropDownElementInfo.Keys.Input);

            input.Name = $"{ddName} Input";

            dialog = new WebElementDetailsWindow(input, model.GetExistedNames(), true);
            if (dialog.ShowDialog() != true)
            {
                return;
            }

            var option = model.Elements.First(el => el.InnerKey == DropDownElementInfo.Keys.Option);

            option.Name = $"{ddName} Option";

            dialog = new WebElementDetailsWindow(option, model.GetExistedNames(), true);
            if (dialog.ShowDialog() != true)
            {
                return;
            }


            if (combined.Elements == null)
            {
                combined.Elements = new ObservableCollection <WebElementViewModel>();
            }
            model.Parent = combined;
            combined.Elements.Add(model);

            _viewModel.SelectedElement = model;
        }
예제 #3
0
        private void AddContextMenuItem_Click(object sender, RoutedEventArgs e)
        {
            var contextModel = WebFactory.CreateWebContextModel();
            var dialog       = new WebElementDetailsWindow(contextModel, _viewModel.GetExistedNames(), false);

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

            _viewModel.Elements.Add(contextModel);
        }
예제 #4
0
        private void EditMenuItem_Click(object sender, RoutedEventArgs e)
        {
            if (_viewModel.SelectedElement == null)
            {
                return;
            }

            List <string> existedNames = null;

            if (_viewModel.SelectedElement is WebContextViewModel)
            {
                existedNames = _viewModel.GetExistedNames();
            }
            else
            {
                var parent = _viewModel.SelectedElement.Parent;
                if (parent == null)
                {
                    MessageBox.Show($"Selected Element: {_viewModel.SelectedElement.Name} doesn't have parent. But has to");
                    return;
                }
                if (parent is CombinedElementViewModel combined)
                {
                    existedNames = combined.GetExistedNames();
                }
                else
                {
                    MessageBox.Show($"Selected Element: {_viewModel.SelectedElement.Name} has parent that is not nested from CombinedElementViewModel. But has to");
                    return;
                }
            }

            var dialog = new WebElementDetailsWindow(_viewModel.SelectedElement, existedNames, true);

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