Пример #1
0
        public void DemoteProperty(BatteryPropertyCode code)
        {
            TrippLitePropertyViewModel pm = null;

            foreach (var currentPm in ProminentProperties)
            {
                pm = currentPm;

                if (pm.Code == code)
                {
                    break;
                }

                pm = null;
            }

            if (pm is null)
            {
                return;
            }

            pm.Prominent = false;

            ProminentProperties.Remove(pm);
            Properties.Add(pm);
        }
Пример #2
0
        public void DemoteFromLoad(BatteryPropertyCode code)
        {
            TrippLitePropertyViewModel pm = null;

            foreach (var currentPm in ProminentProperties)
            {
                pm = currentPm;

                if (pm.Code == code)
                {
                    break;
                }

                pm = null;
            }

            if (pm is null)
            {
                return;
            }

            if (LoadProperties.Contains(pm))
            {
                LoadProperties.Remove(pm);
            }

            Properties.Add(pm);
        }
Пример #3
0
        public void PromoteToLoad(BatteryPropertyCode code, bool removeFromList = false)
        {
            TrippLitePropertyViewModel pm = null;

            foreach (var currentPm in Properties)
            {
                pm = currentPm;
                if (pm.Code == code)
                {
                    break;
                }
                pm = null;
            }

            if (pm is null)
            {
                return;
            }

            if (removeFromList)
            {
                Properties.Remove(pm);
            }

            LoadProperties.Add(pm);
        }
Пример #4
0
 public void ClearLoadBarProperty()
 {
     if (lbProp is object)
     {
         lbProp.PropertyChanged -= LoadBarWatch;
         lbProp = null;
     }
 }
Пример #5
0
        public void MakeLoadBarProperty(TrippLitePropertyViewModel prop, LoadBarPropertyHandler handler = null)
        {
            ClearLoadBarProperty();
            if (handler is null)
            {
                LoadBarHandler = new LoadBarPropertyHandler(0d, 100d);
            }
            else
            {
                LoadBarHandler = handler;
            }

            lbProp = prop;
            lbProp.IsActiveProperty = true;
            Dispatcher.Invoke(() => LoadBarWatch(this, new PropertyChangedEventArgs(nameof(LoadBarValue))));
            lbProp.PropertyChanged += LoadBarWatch;
        }
Пример #6
0
        private void InternalInit()
        {
            // ' build the view model property collection

            TrippLitePropertyViewModel pl;

            foreach (var p in SyncModel.PropertyBag)
            {
                if (p.Code != trippLite.PropertyMap.InputVoltage && p.Code != trippLite.PropertyMap.OutputVoltage)
                {
                    Properties.Add(new TrippLitePropertyViewModel(p, this));
                }
                else
                {
                    pl           = new TrippLitePropertyViewModel(p, this);
                    pl.Prominent = true;
                    ProminentProperties.Add(pl);
                    pl = null;
                }
            }

            PromoteToLoad(trippLite.PropertyMap.OutputPower);

            MakeLoadBarProperty(FindProperty(trippLite.PropertyMap.OutputLoad));

            SetValue(ProductStringPropertyKey, SyncModel.Device.ProductString);

            SetValue(ModelIdPropertyKey, SyncModel.ModelId);

            SetValue(SerialNumberPropertyKey, SyncModel.Device.SerialNumber);

            SetValue(TitlePropertyKey, SyncModel.Title);

            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Properties)));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(ProminentProperties)));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(ProductString)));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(ModelId)));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(SerialNumber)));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Title)));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(PowerState)));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(PowerStateDescription)));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(PowerStateDetail)));
        }