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

            var infos = new List <WebContext>();

            foreach (var model in _viewModel.Elements)
            {
                var info = WebFactory.CreateInfoFromModel(model)
                           as WebContext;

                if (info == null)
                {
                    continue;
                }

                infos.Add(info);
            }

            _webElementRepository.SetWebContexts(infos);
            _webElementRepository.SaveWebContexts();
        }
예제 #2
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;
        }
예제 #3
0
        private void LoadInfos()
        {
            _webElementRepository = new WebElementsRepository(@"C:\Dev\WebInfo\WebInfo\WebInfo.Test");
            _webElementRepository.LoadWebContexts();

            foreach (var context in _webElementRepository.GetWebContexts())
            {
                var model = WebFactory.CreateModelFromInfo(context);
                _viewModel.Elements.Add(model);
            }
        }
예제 #4
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;
        }
예제 #5
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);
        }