Exemplo n.º 1
0
        public ScenarioModel(ScenarioBase scenario)
        {
            Scenario       = scenario;
            VisualSettings = Repository.VisualSettings.FirstOrDefault(x => x.ScenarioId == scenario.Id);
            if (VisualSettings == null)
            {
                Repository.Add(VisualSettings = new UserVisualSettings()
                {
                    UserId      = UsersRepository.SystemUser.Id,
                    ScenarioId  = scenario.Id,
                    VisualIndex = (Repository.VisualSettings.Any() ? Repository.VisualSettings.Max(x => x.VisualIndex) : 0) + 1
                });
                VisualSettings.AddictionalData.Set(Icon1Key, GetStandardIcon1());
                VisualSettings.AddictionalData.Set(Icon2Key, GetStandardIcon2());
                Repository.Save();
            }

            Scenario.SetOnStateChanged(ScenarioValueChanged);
            scenario.SetOnAvailabilityChanged(ScenarioAvailabilityChanged);
            Scenario.CalculateCurrentValueAsync(
                ViewScenarioActionSourceCrutch,
                (value) => {
                _value       = value;
                _smoothValue = ScenarioValueDouble;
                OnPropertyChanged(nameof(ScenarioValue));
                OnPropertyChanged(nameof(SmoothChangeValue));
            },
                null);

            OnPropertyChanged(nameof(Icon1));
            OnPropertyChanged(nameof(Icon2));
            OnPropertyChanged(nameof(AllowClick));
        }
Exemplo n.º 2
0
 private void RegisterInternal(ScenarioBase scenario)
 {
     scenario.SetOnStateChanged(EventTriggered);
 }