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 PropertyEditorViewModel(ITypesContainer container, IRangeViewModel rangeViewModel, ILocalizerService localizerService) { _container = container; _localizerService = localizerService; RangeViewModel = rangeViewModel; DependencyViewModels = new ObservableCollection <IDependencyViewModel>(); NumberOfPoints = "1"; BitNumbersInWord = new ObservableCollection <IBitViewModel>(); for (int i = 15; i >= 0; i--) { IBitViewModel bitViewModel = new BitViewModel(i, true); BitNumbersInWord.Add(bitViewModel); } }
private void SetModel(object value) { if (value is IQuickMemoryAccessSetting) { IQuickMemoryAccessSetting setting = value as IQuickMemoryAccessSetting; _quickMemoryAccessSetting = setting; foreach (IRange range in setting.QuickAccessAddressRanges) { IRangeViewModel rangeViewModel = _rangeViewModelGettingFunc(); rangeViewModel.RangeFrom = range.RangeFrom.ToString(); rangeViewModel.RangeTo = range.RangeTo.ToString(); RangeViewModels.Add(rangeViewModel); } IsSettingEnabled = _quickMemoryAccessSetting.IsSettingEnabled; } }
public ComplexPropertyEditorViewModel(ITypesContainer container, IRangeViewModel rangeViewModel, ILocalizerService localizerService, IApplicationGlobalCommands applicationGlobalCommands, Func <ISharedBitViewModel> sharedBitViewModelGettingFunc) : base(container, rangeViewModel, localizerService) { _applicationGlobalCommands = applicationGlobalCommands; _sharedBitViewModelGettingFunc = sharedBitViewModelGettingFunc; SubPropertyEditorViewModels = new ObservableCollection <ISubPropertyEditorViewModel>(); SubmitCommand = new RelayCommand <object>(OnSubmit); CancelCommand = new RelayCommand <object>(OnCancel); MainBitNumbersInWordCollection = new ObservableCollection <ISharedBitViewModel>(); for (int i = 15; i >= 0; i--) { ISharedBitViewModel sharedBitViewModel = sharedBitViewModelGettingFunc(); sharedBitViewModel.NumberOfBit = i; MainBitNumbersInWordCollection.Add(sharedBitViewModel); } }
public SubPropertyEditorViewModel(ITypesContainer container, IRangeViewModel rangeViewModel, ILocalizerService localizerService) : base(container, rangeViewModel, localizerService) { BitNumbersInWord = new ObservableCollection <ISharedBitViewModel>(); }