public static void InitFormatterViewModel(IPropertyEditorViewModel propertyEditorViewModel, IUshortsFormatterViewModel formatterViewModel) { propertyEditorViewModel.FormatterParametersViewModel = new FormatterParametersViewModel(); propertyEditorViewModel.FormatterParametersViewModel.RelatedUshortsFormatterViewModel = formatterViewModel; }
public IConfigurationItem VisitProperty(IPropertyEditorViewModel propertyViewModel) { var property = _container.Resolve <IProperty>(); property.Address = ushort.Parse(propertyViewModel.Address ?? "0"); property.NumberOfPoints = ushort.Parse(propertyViewModel.NumberOfPoints ?? "0"); return(InitializeProperty(propertyViewModel, property)); }
private IConfigurationItem InitializeProperty(IPropertyEditorViewModel editorViewModel, IProperty property) { property.IsMeasureUnitEnabled = editorViewModel.IsMeasureUnitEnabled; property.MeasureUnit = editorViewModel.MeasureUnit; if (editorViewModel.IsRangeEnabled) { IRange range = _container.Resolve <IRange>(); if (editorViewModel.RangeViewModel.RangeTo != null) { range.RangeTo = double.Parse(editorViewModel.RangeViewModel.RangeTo); } if (editorViewModel.RangeViewModel.RangeFrom != null) { range.RangeFrom = double.Parse(editorViewModel.RangeViewModel.RangeFrom); } property.Range = range; property.IsRangeEnabled = editorViewModel.IsRangeEnabled; } if (editorViewModel.FormatterParametersViewModel != null) { property.UshortsFormatter = StaticContainer.Container.Resolve <ISaveFormatterService>() .CreateUshortsParametersFormatter(editorViewModel.FormatterParametersViewModel); } var sharedResourcesGlobalViewModel = _container.Resolve <ISharedResourcesGlobalViewModel>(); if (sharedResourcesGlobalViewModel.CheckDeviceSharedResourcesContainsViewModel(editorViewModel)) { sharedResourcesGlobalViewModel.AddResourceFromViewModel(editorViewModel, property); } property.NumberOfWriteFunction = editorViewModel.NumberOfWriteFunction; if (editorViewModel.DependencyViewModels != null) { List <IDependency> dependencies = new List <IDependency>(); dependencies = editorViewModel.DependencyViewModels .Select(_container.Resolve <DependencyFillHelper>().CreateDependencyModel).ToList(); property.Dependencies = dependencies; } property.IsFromBits = editorViewModel.IsFromBits; property.BitNumbers = editorViewModel.BitNumbersInWord.Where(model => model.IsChecked) .Select(model => (ushort)model.BitNumber).ToList(); if (editorViewModel is ICanBeHidden canBeHidden) { property.IsHidden = canBeHidden.IsHidden; } return(InitDefaults(property, editorViewModel)); }
private void InitializeProperty(IPropertyEditorViewModel editorPropertyViewModel, IProperty property) { editorPropertyViewModel.IsMeasureUnitEnabled = property.IsMeasureUnitEnabled; editorPropertyViewModel.MeasureUnit = property.MeasureUnit; editorPropertyViewModel.IsRangeEnabled = property.IsRangeEnabled; if (property.IsRangeEnabled) { IRangeViewModel rangeViewModel = _container.Resolve <IRangeViewModel>(); rangeViewModel.RangeFrom = property.Range.RangeFrom.ToString(); rangeViewModel.RangeTo = property.Range.RangeTo.ToString(); editorPropertyViewModel.RangeViewModel = rangeViewModel; } editorPropertyViewModel.Address = property.Address.ToString(); editorPropertyViewModel.NumberOfPoints = property.NumberOfPoints.ToString(); var formatterParametersViewModel = StaticContainer.Container.Resolve <IFormatterViewModelFactory>() .CreateFormatterViewModel(property.UshortsFormatter); editorPropertyViewModel.FormatterParametersViewModel = formatterParametersViewModel; editorPropertyViewModel.NumberOfWriteFunction = property.NumberOfWriteFunction; ISharedResourcesGlobalViewModel sharedResourcesGlobalViewModel = StaticContainer.Container.Resolve <ISharedResourcesGlobalViewModel>(); if (sharedResourcesGlobalViewModel.CheckDeviceSharedResourcesWithContainersContainsModel(property)) { sharedResourcesGlobalViewModel.AddExistingResourceWithContainer(editorPropertyViewModel, property); } if (property.Dependencies != null && property.Dependencies.Count > 0) { editorPropertyViewModel.DependencyViewModels.Clear(); editorPropertyViewModel.DependencyViewModels.AddCollection(property.Dependencies .Select(_container.Resolve <DependencyFillHelper>().CreateDependencyViewModel).ToList()); } editorPropertyViewModel.IsFromBits = property.IsFromBits; if (editorPropertyViewModel.BitNumbersInWord != null) { property.BitNumbers.ForEach(bitNum => editorPropertyViewModel.BitNumbersInWord.First(model => model.BitNumber == bitNum).IsChecked = true); } if (editorPropertyViewModel is ICanBeHidden canBeHidden) { canBeHidden.IsHidden = property.IsHidden; } InitializeBaseProperties(editorPropertyViewModel, property); }
public static IPropertyEditorViewModel AddPropertyViewModel( IList <IConfigurationItemViewModel> collection, int identity, ITypesContainer typesContainer) { IPropertyEditorViewModel rootProperty = ConfigurationItemEditorViewModelFactory.Create().VisitProperty(null) as IPropertyEditorViewModel; rootProperty.Address = (identity + _addressModifier).ToString(); rootProperty.NumberOfPoints = (identity + _numOfPointsModifier).ToString(); rootProperty.Name = (identity + _nameModifier).ToString(); rootProperty.NumberOfWriteFunction = (ushort)(identity + _numOfFunctionModifier); collection?.Add(rootProperty); InitFormatterViewModel(rootProperty, CreateFormatterViewModel(identity, typesContainer)); return(rootProperty); }
public static IPropertyEditorViewModel AddPropertyWithFormatterFromResourceViewModel( ObservableCollection <IConfigurationItemViewModel> collection, int identity) { IPropertyEditorViewModel property = ConfigurationItemEditorViewModelFactory.Create().VisitProperty(null) as IPropertyEditorViewModel; property.Address = (identity + _addressModifier).ToString(); property.NumberOfPoints = (identity + _numOfPointsModifier).ToString(); property.Name = (identity + _nameModifier).ToString(); property.NumberOfWriteFunction = (ushort)(identity + _numOfFunctionModifier); collection.Add(property); property.FormatterParametersViewModel = new FormatterParametersViewModel() { Name = "formatter" + identity, IsFromSharedResources = true, }; return(property); }
public static IPropertyEditorViewModel AddPropertyWithBitsViewModel( IList <IConfigurationItemViewModel> collection, int identity, ITypesContainer typesContainer) { IPropertyEditorViewModel rootProperty = ConfigurationItemEditorViewModelFactory.Create().VisitProperty(null) as IPropertyEditorViewModel; rootProperty.Address = (identity + _addressModifier).ToString(); rootProperty.NumberOfPoints = (identity + _numOfPointsModifier).ToString(); rootProperty.Name = (identity + _nameModifier).ToString(); rootProperty.NumberOfWriteFunction = (ushort)(identity + _numOfFunctionModifier); collection?.Add(rootProperty); rootProperty.IsFromBits = true; rootProperty.BitNumbersInWord.FirstOrDefault(model => model.BitNumber == identity).IsChecked = true; InitFormatterViewModel(rootProperty, CreateFormatterViewModel(identity, typesContainer)); return(rootProperty); }