示例#1
0
        public IDependencyResult CreateResultFromViewModel(IResultViewModel dependencyResult)
        {
            switch (dependencyResult)
            {
            case BlockInteractionResultViewModel blockInteractionResult:
                return(new BlockInteractionResult());

            case HidePropertyResultViewModel hidePropertyResultViewModel:
                return(new HidePropertyResult());

                break;

            case ApplyFormatterResultViewModel applyFormatterResultViewModel:
                var formatter =
                    _saveFormatterService.CreateUshortsParametersFormatter(applyFormatterResultViewModel
                                                                           .FormatterParametersViewModel);
                return(new ApplyFormatterResult()
                {
                    Name = formatter.Name,
                    UshortsFormatter = formatter
                });

                break;
            }


            return(null);
        }
        private void OnOkExecute(object obj)
        {
            if (SelectedUshortsFormatterViewModel == null)
            {
                return;
            }
            if (SelectedUshortsFormatterViewModel is IDynamicFormatterViewModel)
            {
                if (!((IDynamicFormatterViewModel)SelectedUshortsFormatterViewModel).IsValid)
                {
                    return;
                }
            }

            if (CurrentResourceString != null)
            {
                ISaveFormatterService saveFormatterService = _container.Resolve <ISaveFormatterService>();

                IUshortsFormatter resourceUshortsFormatter =
                    saveFormatterService.CreateUshortsParametersFormatter(SelectedUshortsFormatterViewModel);
                resourceUshortsFormatter.Name = CurrentResourceString;
                _sharedResourcesGlobalViewModel.UpdateSharedResource(resourceUshortsFormatter);


                _ushortFormattableViewModel.ForEach(model => model.FormatterParametersViewModel =
                                                        _container.Resolve <IFormatterViewModelFactory>().CreateFormatterViewModel(resourceUshortsFormatter));
            }
            else
            {
                _ushortFormattableViewModel.ForEach(model => model.FormatterParametersViewModel =
                                                        _container.Resolve <IFormatterParametersViewModel>());
                _ushortFormattableViewModel.ForEach(model => model.FormatterParametersViewModel.RelatedUshortsFormatterViewModel =
                                                        SelectedUshortsFormatterViewModel);
            }


            if (_ushortFormattableViewModel.Count == 1)
            {
                var ushortFormattableViewModel = _ushortFormattableViewModel.First();

                if (ushortFormattableViewModel is IBitsConfigViewModel bitsConfigViewModel)
                {
                    this.CopyBitsTo(bitsConfigViewModel);
                    IsBitsEditingEnabled = true;
                }
            }

            (obj as Window)?.Close();
        }
示例#3
0
        private void CreateFormatterParametersForResourcesViewModel(int identity)
        {
            ISharedResourcesGlobalViewModel sharedResourcesGlobalViewModel =
                _typesContainer.Resolve <ISharedResourcesGlobalViewModel>();
            var formatterViewModel = CreateFormatterViewModel(identity, _typesContainer);

            sharedResourcesGlobalViewModel.AddAsSharedResource(new FormatterParametersViewModel()
            {
                IsFromSharedResources = false,
                Name = "formatter" + identity,
                RelatedUshortsFormatterViewModel = formatterViewModel
            }, false);

            ISaveFormatterService saveFormatterService = _typesContainer.Resolve <ISaveFormatterService>();

            IUshortsFormatter resourceUshortsFormatter =
                saveFormatterService.CreateUshortsParametersFormatter(formatterViewModel);

            resourceUshortsFormatter.Name = "formatter" + identity;
            sharedResourcesGlobalViewModel.UpdateSharedResource(resourceUshortsFormatter);
        }