Beispiel #1
0
        /// <summary>
        /// Set the picker value
        /// </summary>
        /// <param name="value">The value to set the picker to</param>
        public override void SetPickerValue(int value)
        {
            pickerValue = value;
            if (PickerValue < 0)
            {
                pickerValue = m_PickerLenght - 1;
            }
            if (PickerValue > m_PickerLenght - 1)
            {
                pickerValue = 0;
            }

            // Set top values
            for (int i = 0; i < topTextFieldsTextMesh.Length; ++i)
            {
                topTextFieldsTextMesh[i].SetText(GetCalcualteValue(i + 1, false).ToString(m_ValueFormat));
            }

            // Set bottom values
            for (int j = 0; j < bottomTextFieldsTextMesh.Length; ++j)
            {
                bottomTextFieldsTextMesh[j].SetText(GetCalcualteValue(j + 1).ToString(m_ValueFormat));
            }

            selectedValueFieldTextMesh.SetText(PickerValue.ToString(m_ValueFormat));
        }
Beispiel #2
0
        protected override void OnPropertyChanged(string propertyName = null)
        {
            base.OnPropertyChanged(propertyName);
            if (propertyName.Equals(StepsProperty.PropertyName))
            {
                for (int i = 0; i < Steps; i++)
                {
                    var button = new Button
                    {
                        ClassId = $"{i + 1}",
                        Style   = Application.Current.Resources["ButtonCreatorStyle"] as Style
                    };

                    button.Clicked += Handle_Clicked;

                    Children.AddHorizontal(button);
                }
            }
            else if (propertyName.Equals(PlaceHolderProperty.PropertyName))
            {
                foreach (var child in Children)
                {
                    (child as Button).Text = PlaceHolder;
                }
            }
            else if (propertyName.Equals(PickerValueProperty.PropertyName) &&
                     Data != null &&
                     LastStackId == Data[nameof(LastStackId)] &&
                     LastSelectedButton.Text != (PickerValue * 5).ToString())
            {
                if (PickerValue == 0)
                {
                    LastSelectedButton.Text      = PlaceHolder;
                    LastSelectedButton.TextColor = Color.LightGray;
                }
                else
                {
                    try
                    {
                        if (InstaCategoryEnum.SurfaceSoilings.ToString().Equals(InstaCategory.ToString()))
                        {
                            Data["Count"] = (PickerValue * 5).ToString();
                        }
                        else
                        {
                            Data["Count"] = PickerValue.ToString();
                        }
                        LastSelectedButton.Text      = Data["Count"];
                        LastSelectedButton.TextColor = Color.Black;
                        GetData(LastSelectedButton);
                    }
                    catch (Exception exception) { Crashes.TrackError(exception); }
                }
            }
        }
Beispiel #3
0
        protected override void OnPropertyChanged(string propertyName = null)
        {
            base.OnPropertyChanged(propertyName);
            if (propertyName.Equals(StepsProperty.PropertyName))
            {
                var FirstHardButton = new Button
                {
                    ClassId = "1",
                    Text    = State.Hard.ToString(),
                    Style   = Application.Current.Resources["ButtonCreatorHygienStyle"] as Style
                };
                FirstHardButton.Clicked += Handle_Clicked;

                Children.Add(FirstHardButton);
                for (int i = 1; i <= Steps; i++)
                {
                    var EasyButton = new Button
                    {
                        Text    = State.Easy.ToString(),
                        ClassId = $"{i * i + 1}",
                        Style   = Application.Current.Resources["ButtonCreatorStyle"] as Style
                    };

                    EasyButton.Clicked += Handle_Clicked;
                    var HardButton = new Button
                    {
                        Text    = State.Hard.ToString(),
                        ClassId = $"{i * i + 2}",
                    };
                    Children.Add(EasyButton);

                    if (i == Steps)
                    {
                        HardButton.Style = Application.Current.Resources["ButtonCreatorStyle"] as Style;
                    }
                    else
                    {
                        HardButton.Style = Application.Current.Resources["ButtonCreatorHygienStyle"] as Style;
                    }

                    HardButton.Clicked += Handle_Clicked;

                    Children.Add(HardButton);
                }
            }
            else if (propertyName.Equals(PickerValueProperty.PropertyName) && Data != null && LastLayoutId == Data["Category"] && LastSelectedButton.Text != PickerValue.ToString())
            {
                if (PickerValue == 0)
                {
                    LastSelectedButton.TextColor = Color.LightGray;
                    switch (LastSelectedButton.ClassId)
                    {
                    case "1":
                        LastSelectedButton.Text = State.Hard.ToString();
                        break;

                    case "2":
                        LastSelectedButton.Text = State.Easy.ToString();
                        break;

                    case "3":
                        LastSelectedButton.Text = State.Hard.ToString();
                        break;

                    case "5":
                        LastSelectedButton.Text = State.Easy.ToString();
                        break;

                    case "6":
                        LastSelectedButton.Text = State.Hard.ToString();
                        break;
                    }
                }
                else
                {
                    try
                    {
                        Data["Count"]                = PickerValue.ToString();
                        LastSelectedButton.Text      = Data["Count"];
                        LastSelectedButton.TextColor = Color.Black;
                        GetData(LastSelectedButton);
                    }
                    catch (Exception exception) { Crashes.TrackError(exception); }
                }
            }
        }