public ToggleView(ScenarioBase scenario) : this()
        {
            var model = new ScenarioModel(scenario);

            DataContext = model;
            Unloaded   += (o, e) => model.Dispose();
        }
        public DateTimeView(ScenarioBase scenario) : this()
        {
            var model = new ScenarioModel(scenario);

            DataContext     = model;
            Unloaded       += (o, e) => model.Dispose();
            itemView.Click += ItemView_Click;
        }
Esempio n. 3
0
        public ButtonView(ScenarioBase scenario) : this()
        {
            var model = new ScenarioModel(scenario);

            DataContext     = model;
            Unloaded       += (o, e) => model.Dispose();
            itemView.Click += (o, e) => model.ScenarioValue = string.Empty;
        }
Esempio n. 4
0
        private async void SwitchesGrid_SelectedModelChanged(Switches.ScenarioModel obj)
        {
            BeginInitScenario();
            await constructorsResolver.SetScenario(switchesGrid.SelectedModel?.Scenario);

            btDeleteScenario.Visibility = switchesGrid.SelectedModel != null ? Visibility.Visible : Visibility.Collapsed;
            EndInitScenario();
        }
        public FloatViewSwitch(ScenarioModel model) : this()
        {
            DataContext = _model = model;

            var diff = model.Max - model.Min;

            _round = (int)(2 / diff);

            _tempValueToInstall = _tempValueToUpdate = model.ScenarioValue;
            lblCaption.Content  = _model.ScenarioValueWithUnit; //crutch #0

            //crutch #1
            _model.PropertyChanged += (o, e) =>
            {
                if (e.PropertyName == nameof(_model.ScenarioValue))
                {
                    if (model.ScenarioValue != _tempValueToInstall)
                    {
                        _tempValueToInstall   = model.ScenarioValue;
                        _scenarioValueChanged = true;
                    }
                }
            };

            _iteration   = (model.Max - model.Min) / 40;
            slider.Value = double.Parse(_tempValueToInstall ?? "0");

            //crutch #2
            slider.ValueChanged += (o, e) =>
            {
                var value = slider.Value;
                value = Math.Round(value, _round);

                _tempValueToUpdate    = value.ToString();
                _scenarioValueChanged = false;

                lblCaption.Content = _tempValueToUpdate + _model.Unit; //crutch #3
            };

            //crutch #4
            _tokenSource = SystemUtils.StartTimer(
                (token) =>
            {
                if (_tempValueToUpdate != _tempValueToInstall && !_scenarioValueChanged)
                {
                    model.ScenarioValue = _tempValueToInstall = _tempValueToUpdate;
                }

                if (_tempValueToInstall != _tempValueToUpdate && _scenarioValueChanged)
                {
                    Dispatcher.BeginInvoke(new Action(() =>
                    {
                        slider.Value = double.Parse(_tempValueToUpdate = _tempValueToInstall);
                    }));
                }
            },
                () => FloatView_ValueUpdateInterval);
        }
Esempio n. 6
0
        public InfoView(ScenarioBase scenario) : this()
        {
            var model = new ScenarioModel(scenario);

            DataContext = model;

            Unloaded += (o, e) => model.Dispose();

            itemView.Click += (o, e) => InfoViewSwitch.Show((newVal) => model.ScenarioValue = newVal);
        }
Esempio n. 7
0
        public StatusViewSwitch(ScenarioModel scenarioModel) : this()
        {
            DataContext = scenarioModel;

            tbScenarioName.Text = scenarioModel.ScenarioName;
            ItemView toSelect = null;

            foreach (var state in scenarioModel.AcceptedValues)
            {
                var itemView = new ItemView();
                itemView.Icon    = Icons.Icon.NavigateNext;
                itemView.Content = state;
                itemView.Margin  = new Thickness(0, 0, 0, 1);
                if (scenarioModel.ScenarioValue != null && scenarioModel.ScenarioValue.Equals(state))
                {
                    toSelect = itemView;
                }
                listItemsStates.Children.Add(itemView);
            }

            Loaded += (o, e) =>
            {
                if (toSelect != null)
                {
                    toSelect.Selected = true;
                    toSelect.Focus();
                }
            };

            listItemsStates.SelectionChanged += (o, e) =>
            {
                var selectedItem = listItemsStates.GetSelectedItems().FirstOrDefault() as ItemView;
                if (selectedItem != null && selectedItem.Content.ToString() != scenarioModel.ScenarioValue)
                {
                    scenarioModel.ScenarioValue = selectedItem.Content.ToString();
                    StateChanged?.Invoke(this, new RoutedEventArgs());
                }
            };
        }
Esempio n. 8
0
 public DateTimeView(ScenarioBase scenario) : this()
 {
     DataContext     = new ScenarioModel(scenario);
     itemView.Click += ItemView_Click;
 }
Esempio n. 9
0
 public ToggleView(ScenarioBase scenario) : this()
 {
     DataContext = new ScenarioModel(scenario);
 }
Esempio n. 10
0
 private void SwitchesGrid_SelectedModelChanging(Switches.ScenarioModel arg1, ScenarioChangingEventArgs args)
 {
     ThroughScenarioSave(args.Apply);
 }
Esempio n. 11
0
 public ButtonView(ScenarioBase scenario) : this()
 {
     DataContext     = new ScenarioModel(scenario);
     itemView.Click += (o, e) =>
                       ((ScenarioModel)DataContext).ScenarioValue = string.Empty;
 }
 private void SwitchesGrid_SelectedModelChanged(Switches.ScenarioModel obj)
 {
     constructorsResolver.SetScenario(switchesGrid.SelectedModel?.Scenario);
     btDeleteScenario.Visibility = switchesGrid.SelectedModel != null ? Visibility.Visible : Visibility.Collapsed;
 }
Esempio n. 13
0
 public GeolocationView(ScenarioBase scenario) : this()
 {
     DataContext     = new ScenarioModel(scenario);
     itemView.Click += ItemView_Click;
 }
Esempio n. 14
0
        public StatusViewSwitch(ScenarioModel scenarioModel) : this()
        {
            DataContext = scenarioModel;

            BeginInit();

#if !DEBUG
            spSearch.Visibility = scenarioModel.AcceptedValues.Length > 150 ? Visibility.Visible : Visibility.Collapsed;
#endif

            tbScenarioName.Text = scenarioModel.ScenarioName;
            ItemViewFast initialSelectedItem = null;
            foreach (var state in scenarioModel.AcceptedValues)
            {
                var itemView = new ItemViewFast();
                itemView.Text   = state;
                itemView.Margin = new Thickness(0, 1, 0, 1);
                if (scenarioModel.ScenarioValue?.Equals(state) ?? false)
                {
                    initialSelectedItem = itemView;
                }
                listItemsStates.Children.Add(itemView);
            }

            tbSearch.Text = GetSearchCache(scenarioModel.Scenario.Id);

            if (!string.IsNullOrEmpty(tbSearch.Text))
            {
                ShowSearchResult();
            }

            Loaded += (o, e) =>
            {
                if (initialSelectedItem != null)
                {
                    initialSelectedItem.Selected = true;
                    initialSelectedItem.Focus();
                }
            };

            listItemsStates.SelectionChanged += (o, e) =>
            {
                var selectedItem = listItemsStates.GetSelectedItems().FirstOrDefault() as ItemViewFast;
                if (selectedItem != null)
                {
                    if (selectedItem.Text != scenarioModel.ScenarioValue)
                    {
                        scenarioModel.ScenarioValue = selectedItem.Text;
                        StateChanged?.Invoke(this, new RoutedEventArgs());
                    }
                }
                else
                {
                    scenarioModel.ScenarioValue = (scenarioModel.Scenario.ValueType as StateValueType).DefaultValue;
                    StateChanged?.Invoke(this, new RoutedEventArgs());
                }
            };

            tbSearch.TextChanged += (o, e) => {
                _timer?.Dispose();
                SetSearchCache(scenarioModel.Scenario.Id, tbSearch.Text);
                _timer = new Timer((s) => {
                    _timer = null;
                    Dispatcher.BeginInvoke(new Action(ShowSearchResult));
                }, null, 600, Timeout.Infinite);
            };

            EndInit();
        }