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();
        }
Example #2
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);
        }
Example #3
0
 public ResultFillHelper(IFormatterEditorFactory formatterEditorFactory, IFormatterViewModelFactory formatterViewModelFactory, ISaveFormatterService saveFormatterService)
 {
     this._formatterEditorFactory = formatterEditorFactory;
     _formatterViewModelFactory   = formatterViewModelFactory;
     _saveFormatterService        = saveFormatterService;
 }