Exemplo n.º 1
0
        public StatusViewSwitch(SwitchScenarioModel scenarioModel) : this()
        {
            BindingContext = scenarioModel;

            foreach (var state in scenarioModel.AcceptedValues)
            {
                var itemView = new ItemView();
                itemView.Icon          = LazuriteUI.Icons.Icon.NavigateNext;
                itemView.Text          = state;
                itemView.HeightRequest = 50;
                itemView.Margin        = new Thickness(0, 0, 0, 1);
                if (scenarioModel.ScenarioValue.Equals(state))
                {
                    itemView.Selected = true;
                }
                listItemsStates.Children.Add(itemView);
            }

            listItemsStates.SelectionChanged += (o, e) =>
            {
                var selectedItem = listItemsStates.GetSelectedItems().FirstOrDefault() as ItemView;
                if (selectedItem != null && selectedItem.Text != scenarioModel.ScenarioValue)
                {
                    scenarioModel.ScenarioValue = selectedItem.Text;
                    StateChanged?.Invoke(this, new EventsArgs <StateChangedSource>(selectedItem.StrokeVisible ? StateChangedSource.VolumeButton : StateChangedSource.Tap));
                }
            };
        }
        public FloatViewSliderSwitch(SwitchScenarioModel model) : this()
        {
            BindingContext = _model = model;

            var diff = model.Max - model.Min;

            _round = (int)(2 / diff);

            //binding works incorrectly
            slider.Maximum = model.Max; //crutch
            slider.Minimum = model.Min; //crutch

            slider.Value         = double.Parse(model.ScenarioValue);
            _tempValue           = _tempValue_current = model.ScenarioValue;
            _iteration           = (model.Max - model.Min) / 20;
            slider.ValueChanged += (o, e) =>
            {
                var value = slider.Value;
                value      = Math.Round(value, _round);
                _tempValue = value.ToString();
            };
            _tokenSource = SystemUtils.StartTimer(
                (token) =>
            {
                if (_tempValue != _tempValue_current)
                {
                    model.ScenarioValue = _tempValue_current = _tempValue;
                }
            },
                () => FloatView_ValueUpdateInterval);
            SizeChanged += (o, e) =>
            {
                HeightRequest = Width * 2;
            };
        }
 public InfoViewSwitch(SwitchScenarioModel model)
 {
     InitializeComponent();
     BindingContext       = model;
     itemViewApply.Click += (o, e) => ApplyClicked?.Invoke(this, new EventsArgs <string>(tbText.Text));
     SizeChanged         += (o, e) => tbText.Focus();                   //crutch
     tbText.Keyboard      = Keyboard.Chat;
     tbText.TextChanged  += (o, e) => tbText.InvalidateMeasureCrutch(); //crutch
 }
Exemplo n.º 4
0
 public FloatViewManualSwitch(SwitchScenarioModel model)
 {
     InitializeComponent();
     BindingContext          = model;
     numericEntry.Max        = model.Max;
     numericEntry.Min        = model.Min;
     numericEntry.Completed += (o, e) => ApplyClicked?.Invoke(this, new EventsArgs <string>(numericEntry.Text));
     itemViewApply.Click    += (o, e) => ApplyClicked?.Invoke(this, new EventsArgs <string>(numericEntry.Text));
     SizeChanged            += (o, e) => numericEntry.Focus(); //crutch
 }
Exemplo n.º 5
0
        public InfoView(ScenarioInfo scenario) : this()
        {
            var model = new SwitchScenarioModel(scenario);

            BindingContext = model;

            itemView.Click += (o, e) => {
                var parent = Helper.GetLastParent(this);
                InfoViewSwitch.Show(model, parent);
            };
        }
        public static void Show(SwitchScenarioModel model, Grid parent)
        {
            var @switch = new InfoViewSwitch(model);
            var dialog  = new DialogView(@switch);

            @switch.ApplyClicked += (o, e) =>
            {
                dialog.Close();
                model.ScenarioValue = e.Value;
            };
            dialog.Show(parent);
        }
Exemplo n.º 7
0
        public ToggleView(ScenarioInfo scenario) : this()
        {
            BindingContext = _model = new SwitchScenarioModel(scenario);
            var context = SynchronizationContext.Current;

            // Binding works incorrectly
            _model.PropertyChanged += (o, e) =>
            {
                if (e.PropertyName == nameof(SwitchScenarioModel.ScenarioValue))
                {
                    context.Post((state) =>
                                 itemView.Selected = (bool)_converter.Convert(_model.ScenarioValue, null, null, null),
                                 null);
                }
            };

            itemView.Selected = (bool)_converter.Convert(_model.ScenarioValue, null, null, null);
        }
Exemplo n.º 8
0
 public FloatView(ScenarioInfo scenario) : this()
 {
     _model          = new SwitchScenarioModel(scenario);
     BindingContext  = _model;
     itemView.Click += itemView_Click;
 }
Exemplo n.º 9
0
 public DateTimeViewSwitch(SwitchScenarioModel model)
 {
     BindingContext = model;
     InitializeComponent();
 }
Exemplo n.º 10
0
 public DateTimeView(ScenarioInfo scenario) : this()
 {
     BindingContext  = new SwitchScenarioModel(scenario);
     itemView.Click += ItemView_Click;
 }
Exemplo n.º 11
0
 public GeolocationView(ScenarioInfo scenario) : this()
 {
     BindingContext  = new SwitchScenarioModel(scenario);
     itemView.Click += ItemView_Click;
 }
        public StatusViewSwitch(SwitchScenarioModel scenarioModel) : this()
        {
            //megaCrutchCode

            BindingContext = _model = scenarioModel;

            _model.PropertyChanged += _model_PropertyChanged;

            _currentVal = _model.ScenarioValue;

            listView.ItemsSource = _model.AcceptedValues; // Crutch to allocate listView height

            if (IsNeedShowSearchButton())
            {
                tbSearch.Text = GetSearchCache(_model.Scenario.ScenarioId);

                tbSearch.Completed += (o, e) => HandleSearch();

                // HELL
                bool initiateSearchHandled = false;
                listView.SizeChanged += (o, e) =>
                {
                    if (!initiateSearchHandled)
                    {
                        initiateSearchHandled = true;
                        if (!string.IsNullOrEmpty(tbSearch.Text))
                        {
                            HandleSearch();
                        }
                    }
                };

                btClearSearch.Click += (o, e) =>
                {
                    tbSearch.Text = string.Empty;
                    HandleSearch();
                };

                iconSearch.IsVisible = true;
                tbSearch.IsVisible   = true;
            }
            else
            {
                iconTitle.IsVisible = true;
                lblTitle.IsVisible  = true;
            }

            // Невозможно замапить объекты, так как, почему-то, сбивается размер всего контрола.
            // Если мапить строки, то размер нормальный.

            listView.ItemTemplate = new DataTemplate(() =>
            {
                var itemView = new ItemViewFast();
                itemView.SetBinding(ItemViewFast.TextProperty, ".");
                itemView.Selectable            = true;
                itemView.StrokeVisibilityClick = true;
                itemView.HeightRequest         = 42;

                itemView.SelectionChanged += (o, e) =>
                {
                    if (itemView.Selected)
                    {
                        foreach (var item in _visibleItems.Values)
                        {
                            if (item != itemView && item.Selected)
                            {
                                item.Selected = false;
                            }
                        }
                    }
                };

                itemView.PropertyChanged += (o, e) =>
                {
                    if (e.PropertyName == nameof(itemView.Text))
                    {
                        if (itemView.Text == _model.ScenarioValue)
                        {
                            itemView.Selected = true;
                        }
                        else if (itemView.Selected)
                        {
                            itemView.Selected = false;
                        }
                    }
                };

                itemView.Click += (o, e) =>
                {
                    if (_model.ScenarioValue == itemView.Text)
                    {
                        var valueType = _model.Scenario.ValueType as StateValueType;
                        RaiseSelect(valueType.DefaultValue, ItemView.ClickSource.CloseAnyway);
                    }
                    else
                    {
                        RaiseSelect(itemView.Text, (ItemView.ClickSource)e.Value);
                    }
                };

                var viewCell = new ViewCell();

                viewCell.Appearing += (o, e) =>
                {
                    if (itemView.Text != null)
                    {
                        if (_visibleItems.ContainsKey(itemView.Text))
                        {
                            _visibleItems.Remove(itemView.Text);
                        }

                        _visibleItems.Add(itemView.Text, itemView);

                        itemView.Selected = itemView.Text == _model.ScenarioValue;
                    }
                };
                viewCell.Disappearing += (o, e) =>
                {
                    if (itemView.Text != null && _visibleItems.ContainsKey(itemView.Text))
                    {
                        _visibleItems.Remove(itemView.Text);
                    }

                    itemView.Selected = false;
                };
                viewCell.View = itemView;
                return(viewCell);
            });
        }
Exemplo n.º 13
0
 public ImageView(ScenarioInfo scenario) : this()
 {
     BindingContext = new SwitchScenarioModel(scenario);
 }