Esempio n. 1
0
 public PropertiesManager(LocomotiveModel Locomotive, ILocoBaseSource dbSource)
 {
     this.Locomotive = Locomotive;
     using (var db = dbSource.GetContext())
     {
         LoadLocomotive(Locomotive, db);
     }
 }
Esempio n. 2
0
 public ICardViewModel GetPage(LocomotiveModel Locomotive)
 {
     PropertiesManager propertiesManager = _propertiesManagerFactory.GetPropertiesManager(Locomotive);
     var page = new DetailedCardViewModel(propertiesManager,
                                          _editorViewModelProvider,
                                          _eventAggregator, _propertyViewModelFactory,
                                          GetHints(propertiesManager));
     return page;
 }
Esempio n. 3
0
        /// <summary>Загружает информацию о локомотиве из базы</summary>
        private void LoadLocomotive(LocomotiveModel LoadingLocomotive, LocoDataContext db)
        {
            Locomotive loc = db.Locomotive.First(l => l.Id == LoadingLocomotive.Id);

            var xxx = loc
                .GetTargetProperties(db)
                .Select(
                    p =>
                    new
                    {
                        PropertyValue = p,
                        p.DicPropertyKind,
                        p.DicPropertyKind.Storage,
                        p.DicPropertyKind.DicValueType,
                        p.DicPropertyKind.Group,
                    })
                .ToList();

            Properties =
                xxx.Select(x =>
                           new PropertyModel(x.DicPropertyKind.Id, x.DicPropertyKind.Name, x.Group.Name,
                                             PropertyEncoding.GetEncoder(x.DicValueType.TypeName),
                                             x.Storage != null
                                                 ? new PropertyPlacement(x.Storage.StorageIndex, x.Storage.Offset, x.Storage.Length)
                                                 : null,
                                             DisplayIndex: x.DicPropertyKind.DisplayIndex,
                                             TargetValue: x.PropertyValue.GetPropertyValueObject(PropertyValueBase.GetPropertyType(x.DicValueType)),
                                             StringFormat: x.DicPropertyKind.StringFormat,
                                             DictionaryValues: db.GetDictionaryValues(x.DicPropertyKind) != null
                                                                   ? db.GetDictionaryValues(x.DicPropertyKind).ToDictionary(
                                                                       dv => PropertyValueBase.GetPropertyValueObject(PropertyValueBase.GetPropertyType(x.DicValueType), dv.Value),
                                                                       dv => dv.Key)
                                                                   : null))
                   .ToList();

            Properties.Add(SystemProperties.LocomotiveNumberProperty.GetPropertyModel(LoadingLocomotive.Number));
            Properties.Add(SystemProperties.SectionNumberProperty.GetPropertyModel(LoadingLocomotive.Section ?? ""));
            Properties.Add(SystemProperties.CombinedLocomotiveNumberProperty.GetPropertyModel(
                SystemProperties.CombineLocomotiveNumber(LoadingLocomotive.Number, LoadingLocomotive.Section)));
            Properties.Add(SystemProperties.KindUidProperty.GetPropertyModel(LoadingLocomotive.KindUid));

            Stores = Properties.Where(p => p.Placement != null)
                               .GroupBy(p => p.Placement.StorageIndex)
                               .ToDictionary(pg => pg.Key, pg => new StorageModel(pg.Key, pg.ToArray()));
        }
 public PropertiesManager GetPropertiesManager(LocomotiveModel Locomotive)
 {
     var propertiesManager = new PropertiesManager(Locomotive, _dbSource);
     _storageManager.StorageRead += (Sender, Args) => propertiesManager.UpdateStorageCurrentValue(Args.Index, Args.ReadValue);
     return propertiesManager;
 }