protected override void OnPropertyChanged([CallerMemberName] string propertyName = null)
        {
            if (!this.initialized)
            {
                this.initialized = true;
                this.InitializeComponent();
            }

            switch (propertyName)
            {
            case nameof(base.TranslationX):
                base.OnPropertyChanged(propertyName);
                break;

            case nameof(CustomControl):
                cntCustomControl.Content = CustomControl;
                break;

            case nameof(FontFamily):
                lblLabel.FontFamily     = FontFamily;
                lblAssistive.FontFamily = FontFamily;
                break;

            case nameof(HorizontalTextAlignment):
                lblLabel.HorizontalTextAlignment     = HorizontalTextAlignment;
                lblAssistive.HorizontalTextAlignment = HorizontalTextAlignment;
                break;

            case nameof(this.LabelText):
                this.lblLabel.Text      = this.LabelText;
                this.lblLabel.IsVisible = !string.IsNullOrEmpty(this.LabelText);
                break;

            case nameof(this.LabelTextColor):
                this.lblLabel.TextColor = this.LabelTextColor;
                break;

            case nameof(this.LabelSize):
                this.lblLabel.FontSize = this.LabelSize;
                break;

            case nameof(this.AssistiveText):
                this.lblAssistive.Text      = this.AssistiveText;
                this.lblAssistive.IsVisible = !string.IsNullOrEmpty(this.AssistiveText);
                if (this.AnimateError && !string.IsNullOrEmpty(this.AssistiveText))
                {
                    ShakeAnimation.Animate(this);
                }
                break;

            case nameof(this.AssistiveTextColor):
                this.lblAssistive.TextColor = this.AssistiveTextColor;
                break;

            case nameof(this.AssistiveSize):
                this.lblAssistive.FontSize = this.AssistiveSize;
                break;
            }
        }
Пример #2
0
    //------------------------------------------------------------------------------------------------------------------

    #region Unitycallbacks

    private void Awake()
    {
        MyShake = GetComponent <ShakeAnimation>();

        //subscribe
        OxygenSystem.OnConsumeOxygen     += OnConsumeOxygen;
        OxygenSystem.OnEmptyTanks        += OnEmptyTanks;
        OxygenSystem.OnConsumeOxygenTank += WriteTanksQuantity;
        OxygenSystem.OnAddTank           += WriteTanksQuantity;
        OxygenSystem.OnTakeDamage        += TakeDamage;
    }
Пример #3
0
        public virtual void Create()
        {
            ModelRenderer.UpdateCameraRotation(0.0f);

            hud        = Sprite.FromFile("Assets/hud.png");
            hud_left   = Sprite.FromFile("Assets/hud_bottom_bar_left.png");
            hud_middle = Sprite.FromFile("Assets/hud_bottom_bar_middle.png");
            hud_right  = Sprite.FromFile("Assets/hud_bottom_bar_right.png");

            collisionShake = new ShakeAnimation(20, 0, 15, false);
        }
        private static bool OnAssistiveTextValidate(BindableObject bindable, object value)
        {
            var control = (MaterialSlider)bindable;

            // Used to animate the error when the assistive text doesn't change
            if (control.AnimateError && !string.IsNullOrEmpty(control.AssistiveText) && control.AssistiveText == (string)value)
            {
                ShakeAnimation.Animate(control);
            }

            return(true);
        }
        protected override void OnPropertyChanged([CallerMemberName] string propertyName = null)
        {
            if (!this.initialized)
            {
                this.InitializeComponent();
                this.initialized = true;
            }

            switch (propertyName)
            {
            case nameof(base.TranslationX):
                base.OnPropertyChanged(propertyName);
                break;

            case nameof(this.LabelText):
                this.lblLabel.Text      = this.LabelText;
                this.lblLabel.IsVisible = !string.IsNullOrEmpty(this.LabelText);
                break;

            case nameof(this.LabelTextColor):
                this.lblLabel.TextColor = this.LabelTextColor;
                break;

            case nameof(this.LabelSize):
                this.lblLabel.FontSize = this.LabelSize;
                break;

            case nameof(this.Padding):
                this.stcContainer.Padding = this.Padding;
                break;

            case nameof(this.AssistiveText):
                this.lblAssistive.Text      = this.AssistiveText;
                this.lblAssistive.IsVisible = !string.IsNullOrEmpty(this.AssistiveText);
                if (this.AnimateError && !string.IsNullOrEmpty(this.AssistiveText))
                {
                    ShakeAnimation.Animate(this);
                }
                break;

            case nameof(this.AssistiveTextColor):
                this.lblAssistive.TextColor = this.AssistiveTextColor;
                break;

            case nameof(this.AssistiveSize):
                this.lblAssistive.FontSize = this.AssistiveSize;
                break;
            }
        }
Пример #6
0
        public PinLoginPage()
        {
            InitializeComponent();

            MessagingService.Current.Subscribe("CodeInvalid", (e) =>
            {
                NumberGrid.InputTransparent = true;
                NumberGrid.IsEnabled        = false;
                var shake      = new ShakeAnimation();
                shake.Duration = "200";
                shake.Easing   = EasingType.SinInOut;
                CodeStack.Animate(shake);
                NumberGrid.InputTransparent = false;
                NumberGrid.IsEnabled        = true;
            });
        }
Пример #7
0
    public void ObjectClicked()
    {
        if (gameController.interfaceLocked)
        {
            return;
        }

        // Получаем фигуры, атакующие клетку
        Vector2Int cell = new Vector2Int((int)transform.position.x, (int)transform.position.y);

        Figure.FigureColor enemyColor       = Figure.InvertColor(gameController.boardState.turnColor);
        List <Figure>      attackingFigures = move.attackingFigures;

        King           king           = gameController.boardState.FindKingByColor(gameController.boardState.turnColor);
        ShakeAnimation shakeAnimation = gameController.FindTransformByPos(king.Pos).GetComponent <ShakeAnimation>();
        Figure         boundFigure    = gameController.boardState.GetFigureAtCell(move.from);

        foreach (Figure figure in attackingFigures)
        {
            // Добавляем объект
            GameObject newRedLine = Instantiate(gameController.redLine);
            gameController.redLines.Add(newRedLine);
            // Если это ход короля, то анмация тряски не нужна
            Action callback;
            if (boundFigure.GetType() == typeof(King))
            {
                callback = null;
            }
            else
            {
                callback = shakeAnimation.StartAnimation;
            }
            // Запускаем анимацию
            RedLineAnimation redLineAnimation = newRedLine.GetComponent <RedLineAnimation>();
            redLineAnimation.StartAnimation(
                beginPos: new Vector3(figure.Pos.x, figure.Pos.y),
                endPos: new Vector3(move.kingPos.x, move.kingPos.y),
                finishedCallback: callback
                );
        }
    }
Пример #8
0
        /// <internalonly />
        protected internal override ProceduralAnimation CreateEffectAnimation(EffectDirection direction)
        {
            FrameworkElement target = GetTarget();

            if (_translateTransform == null)
            {
                Transform existingTransform = target.RenderTransform;
                if (existingTransform != null)
                {
                    _translateTransform = existingTransform as TranslateTransform;

                    if (_translateTransform == null)
                    {
                        TransformGroup transformGroup = existingTransform as TransformGroup;

                        if (transformGroup != null)
                        {
                            foreach (Transform transform in transformGroup.Children)
                            {
                                _translateTransform = transform as TranslateTransform;
                                if (_translateTransform != null)
                                {
                                    break;
                                }
                            }
                        }
                    }
                }
            }

            if (_translateTransform == null)
            {
                throw new InvalidOperationException("The element does not have a translate transform associated with it.");
            }

            ShakeAnimation animation = new ShakeAnimation(_translateTransform, Duration, _shakeDistance);

            animation.Interpolation = GetEffectiveInterpolation();

            return(animation);
        }
Пример #9
0
        protected override void OnPropertyChanged([CallerMemberName] string propertyName = null)
        {
            if (!this.initialized)
            {
                this.initialized = true;
                this.InitializeComponent();
            }

            switch (propertyName)
            {
            case nameof(base.TranslationX):
                base.OnPropertyChanged(propertyName);
                break;

            case nameof(this.IsEnabled):
                SetIsEnabled();
                break;

            case nameof(this.TextColor):
                SetTextColor();
                break;

            case nameof(this.FontSize):
                SetFontSize();
                break;

            case nameof(this.FontFamily):
                SetFontFamily();
                break;

            case nameof(this.Keyboard):
                this.txtEntry.Keyboard = this.Keyboard;
                break;

            case nameof(KeyboardFlags):
                if (KeyboardFlags != null)
                {
                    try
                    {
                        string[]      flagNames = ((string)KeyboardFlags).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                        KeyboardFlags allFlags  = 0;
                        foreach (var flagName in flagNames)
                        {
                            KeyboardFlags flags = 0;
                            Enum.TryParse <KeyboardFlags>(flagName.Trim(), out flags);
                            if (flags != 0)
                            {
                                allFlags |= flags;
                            }
                        }
                        txtEntry.Keyboard = Keyboard.Create(allFlags);
                    }
                    catch
                    {
                        throw new XamlParseException("The keyboard flags are invalid or have a wrong specification.");
                    }
                }
                break;

            case nameof(TextTransform):
                ApplyTextTransform();
                break;

            case nameof(this.Length):
                this.txtEntry.MaxLength = this.Length;
                break;

            case nameof(this.LabelText):
                this.lblLabel.Text      = this.LabelText;
                this.lblLabel.IsVisible = !string.IsNullOrEmpty(this.LabelText);
                break;

            case nameof(this.LabelTextColor):
                SetLabelTextColor(lblLabel);
                break;

            case nameof(this.LabelSize):
                this.lblLabel.FontSize = this.LabelSize;
                break;

            case nameof(this.Padding):
                this.grdContainer.Padding = this.Padding;
                break;

            case nameof(CornerRadius):
                if (frmContainers != null)
                {
                    foreach (var frmContainer in frmContainers)
                    {
                        frmContainer.CornerRadius = Convert.ToInt32(CornerRadius);
                    }
                }
                break;

            case nameof(this.Type):
            case nameof(this.BackgroundColor):
            case nameof(this.BorderColor):
                SetTypeBackgroundAndBorderColor();
                break;

            case nameof(this.AssistiveText):
                this.lblAssistive.Text      = this.AssistiveText;
                this.lblAssistive.IsVisible = !string.IsNullOrEmpty(this.AssistiveText);
                if (this.AnimateError && !string.IsNullOrEmpty(this.AssistiveText))
                {
                    ShakeAnimation.Animate(this);
                }
                break;

            case nameof(this.AssistiveTextColor):
                this.lblAssistive.TextColor = this.AssistiveTextColor;
                break;

            case nameof(this.AssistiveSize):
                this.lblAssistive.FontSize = this.AssistiveSize;
                break;

            case nameof(this.TabIndex):
                if (this.TabIndex != 0)
                {
                    this.txtEntry.TabIndex = this.TabIndex;
                    this.TabIndex          = 0;
                }
                break;

            case nameof(this.IsTabStop):
                this.txtEntry.IsTabStop = this.IsTabStop;
                break;

            case nameof(this.ReturnType):
                this.txtEntry.ReturnType = this.ReturnType;

                if (this.ReturnType.Equals(Xamarin.Forms.ReturnType.Next))
                {
                    this.txtEntry.ReturnCommand = new Command(() =>
                    {
                        var currentTabIndex = this.txtEntry.TabIndex;
                        this.FocusNextElement(currentTabIndex);
                    });
                }
                break;

            case nameof(this.FieldHeightRequest):
                grdContainer.RowDefinitions = new RowDefinitionCollection();
                grdContainer.RowDefinitions.Add(new RowDefinition {
                    Height = this.FieldHeightRequest
                });

                if (frmContainers != null)
                {
                    foreach (var frmContainer in frmContainers)
                    {
                        frmContainer.HeightRequest = this.FieldHeightRequest;
                    }
                }
                break;

            case nameof(this.FieldWidthRequest):
                if (frmContainers != null)
                {
                    foreach (var frmContainer in frmContainers)
                    {
                        frmContainer.HorizontalOptions = LayoutOptions.Center;
                        frmContainer.WidthRequest      = this.FieldWidthRequest;
                    }
                }
                break;

            case nameof(this.IsCode):
                this.txtEntry.IsCode = this.IsCode;
                break;

            case nameof(HorizontalTextAlignment):
                SetHorizontalTextAlignment();
                break;
            }
        }
        protected override void OnPropertyChanged([CallerMemberName] string propertyName = null)
        {
            if (!this.initialized)
            {
                this.InitializeComponent();
                this.initialized = true;
            }

            switch (propertyName)
            {
            case nameof(base.TranslationX):
                base.OnPropertyChanged(propertyName);
                break;

            case nameof(this.IsEnabled):
                this.pckOptions.IsEnabled = this.IsEnabled;
                break;

            case nameof(this.TextColor):
                this.pckOptions.TextColor = this.TextColor;
                break;

            case nameof(this.FontSize):
                this.pckOptions.FontSize = this.FontSize;
                break;

            case nameof(this.LabelText):
                this.lblLabel.Text      = this.LabelText;
                this.lblLabel.IsVisible = !string.IsNullOrEmpty(this.LabelText);
                break;

            case nameof(this.LabelTextColor):
                this.lblLabel.TextColor = this.LabelTextColor;
                break;

            case nameof(this.LabelSize):
                this.lblLabel.FontSize = this.LabelSize;
                break;

            case nameof(this.Padding):
                this.frmContainer.Padding = this.Padding;
                break;

            case nameof(this.Type):
            case nameof(this.BackgroundColor):
            case nameof(this.BorderColor):
                switch (this.Type)
                {
                case FieldTypes.Filled:
                    this.frmContainer.BackgroundColor = this.BackgroundColor;
                    this.frmContainer.BorderColor     = this.BorderColor;
                    this.frmContainer.CornerRadius    = 20;
                    this.bxvLine.IsVisible            = false;
                    break;

                case FieldTypes.Outlined:
                    this.frmContainer.BackgroundColor = this.BackgroundColor;
                    this.frmContainer.BorderColor     = this.BorderColor;
                    this.frmContainer.CornerRadius    = 4;
                    this.bxvLine.IsVisible            = false;
                    break;

                case FieldTypes.Lined:
                    this.frmContainer.BackgroundColor = Color.Transparent;
                    this.frmContainer.BorderColor     = Color.Transparent;
                    this.bxvLine.IsVisible            = true;
                    this.bxvLine.Color = this.BorderColor;

                    this.frmContainer.HeightRequest = 30;

                    if (this.LeadingIconIsVisible)
                    {
                        this.lblLabel.Margin = new Thickness(36, this.lblLabel.Margin.Top,
                                                             this.lblLabel.Margin.Right, 0);
                        this.frmContainer.Padding = new Thickness(0);
                        this.lblAssistive.Margin  = new Thickness(36, this.lblAssistive.Margin.Top,
                                                                  this.lblAssistive.Margin.Right, this.lblAssistive.Margin.Bottom);
                        this.bxvLine.Margin = new Thickness(36, 0, 0, 0);
                    }
                    else
                    {
                        this.lblLabel.Margin      = new Thickness(0, this.lblLabel.Margin.Top, 0, 0);
                        this.frmContainer.Padding = new Thickness(0);
                        this.lblAssistive.Margin  = new Thickness(0, this.lblAssistive.Margin.Top, 0, this.lblAssistive.Margin.Bottom);
                    }
                    break;
                }
                break;

            case nameof(this.AssistiveText):
                this.lblAssistive.Text      = this.AssistiveText;
                this.lblAssistive.IsVisible = !string.IsNullOrEmpty(this.AssistiveText);
                if (this.AnimateError && !string.IsNullOrEmpty(this.AssistiveText))
                {
                    ShakeAnimation.Animate(this);
                }
                break;

            case nameof(this.AssistiveTextColor):
                this.lblAssistive.TextColor = this.AssistiveTextColor;
                break;

            case nameof(this.AssistiveSize):
                this.lblAssistive.FontSize = this.AssistiveSize;
                break;

            case nameof(this.LeadingIcon):
                if (!string.IsNullOrEmpty(this.LeadingIcon))
                {
                    this.imgLeadingIcon.Image.Source = this.LeadingIcon;
                }
                this.imgLeadingIcon.IsVisible = this.LeadingIconIsVisible;
                break;

            case nameof(this.TrailingIcon):
                if (!string.IsNullOrEmpty(this.TrailingIcon))
                {
                    this.imgTrailingIcon.Image.Source = this.TrailingIcon;
                }
                this.imgTrailingIcon.IsVisible = this.TrailingIconIsVisible && this.IsEnabled;
                break;
            }
        }
Пример #11
0
 void Start()
 {
     GameEvents.Instance.AddListener(this);
     Shake = GetComponent <ShakeAnimation>();
     Test();
 }
Пример #12
0
        protected override void OnPropertyChanged([CallerMemberName] string propertyName = null)
        {
            if (!this.initialized)
            {
                this.InitializeComponent();
                this.initialized = true;
            }

            // TODO: Check if you can take out the strong password.

            switch (propertyName)
            {
            case nameof(base.TranslationX):
                base.OnPropertyChanged(propertyName);
                break;

            case nameof(this.IsEnabled):
                this.txtEntry.IsEnabled = this.IsEnabled;
                break;

            case nameof(this.TextColor):
                this.txtEntry.TextColor = this.TextColor;
                break;

            case nameof(this.FontSize):
                this.txtEntry.FontSize = this.FontSize;
                break;

            case nameof(this.FontFamily):
                this.txtEntry.FontFamily     = this.FontFamily;
                this.lblLabel.FontFamily     = this.FontFamily;
                this.lblAssistive.FontFamily = this.FontFamily;
                break;

            case nameof(this.Placeholder):
                this.txtEntry.Placeholder = this.Placeholder;
                break;

            case nameof(this.PlaceholderColor):
                this.txtEntry.PlaceholderColor = this.PlaceholderColor;
                break;

            case nameof(this.Keyboard):
                this.txtEntry.Keyboard = this.Keyboard;
                break;

            case nameof(this.MaxLength):
                this.txtEntry.MaxLength = this.MaxLength;
                break;

            case nameof(this.LabelText):
                this.lblLabel.Text      = this.LabelText;
                this.lblLabel.IsVisible = !string.IsNullOrEmpty(this.LabelText);
                break;

            case nameof(this.LabelTextColor):
                this.lblLabel.TextColor = this.LabelTextColor;
                break;

            case nameof(this.LabelSize):
                this.lblLabel.FontSize = this.LabelSize;
                break;

            case nameof(this.Padding):
                this.frmContainer.Padding = this.Padding;
                break;

            case nameof(this.Type):
            case nameof(this.BackgroundColor):
            case nameof(this.BorderColor):
                switch (this.Type)
                {
                case FieldTypes.Filled:
                    this.frmContainer.BackgroundColor = this.BackgroundColor;
                    this.frmContainer.BorderColor     = this.BorderColor;
                    this.frmContainer.CornerRadius    = 20;
                    this.bxvLine.IsVisible            = false;
                    break;

                case FieldTypes.Outlined:
                    this.frmContainer.BackgroundColor = this.BackgroundColor;
                    this.frmContainer.BorderColor     = this.BorderColor;
                    this.frmContainer.CornerRadius    = 4;
                    this.bxvLine.IsVisible            = false;
                    break;

                case FieldTypes.Lined:
                    this.frmContainer.BackgroundColor = Color.Transparent;
                    this.frmContainer.BorderColor     = Color.Transparent;
                    this.bxvLine.IsVisible            = true;
                    this.bxvLine.Color = this.BorderColor;

                    this.frmContainer.HeightRequest = 30;

                    if (this.LeadingIconIsVisible)
                    {
                        this.lblLabel.Margin = new Thickness(36, this.lblLabel.Margin.Top,
                                                             this.lblLabel.Margin.Right, 0);
                        this.frmContainer.Padding = new Thickness(0);
                        this.lblAssistive.Margin  = new Thickness(36, this.lblAssistive.Margin.Top,
                                                                  this.lblAssistive.Margin.Right, this.lblAssistive.Margin.Bottom);
                        this.bxvLine.Margin = new Thickness(36, 0, 0, 0);
                    }
                    else
                    {
                        this.lblLabel.Margin      = new Thickness(0, this.lblLabel.Margin.Top, 0, 0);
                        this.frmContainer.Padding = new Thickness(0);
                        this.lblAssistive.Margin  = new Thickness(0, this.lblAssistive.Margin.Top, 0, this.lblAssistive.Margin.Bottom);
                    }
                    break;
                }
                break;

            case nameof(this.AssistiveText):
                this.lblAssistive.Text      = this.AssistiveText;
                this.lblAssistive.IsVisible = !string.IsNullOrEmpty(this.AssistiveText);
                if (this.AnimateError && !string.IsNullOrEmpty(this.AssistiveText))
                {
                    ShakeAnimation.Animate(this);
                }
                break;

            case nameof(this.AssistiveTextColor):
                this.lblAssistive.TextColor = this.AssistiveTextColor;
                break;

            case nameof(this.AssistiveSize):
                this.lblAssistive.FontSize = this.AssistiveSize;
                break;

            case nameof(this.IsPassword):
            case nameof(this.ShowPasswordIcon):
            case nameof(this.ShowPasswordIconIsVisible):
                this.txtEntry.IsPassword = this.IsPassword;
                if (!string.IsNullOrEmpty(this.ShowPasswordIcon))
                {
                    this.imgShowPasswordIcon.Image.Source = this.ShowPasswordIcon;
                }
                this.imgShowPasswordIcon.IsVisible = this.IsPassword && this.ShowPasswordIconIsVisible && !string.IsNullOrEmpty(this.ShowPasswordIcon);
                break;

            case nameof(this.ClearIcon):
            case nameof(this.ClearIconIsVisible):
                if (!string.IsNullOrEmpty(this.ClearIcon))
                {
                    this.imgClearIcon.Image.Source = this.ClearIcon;
                }
                this.imgClearIcon.IsVisible = this.ClearIconIsVisible && this.IsEnabled && !string.IsNullOrEmpty(this.Text);
                break;

            case nameof(this.LeadingIcon):
                if (!string.IsNullOrEmpty(this.LeadingIcon))
                {
                    this.imgLeadingIcon.Image.Source = this.LeadingIcon;
                }
                this.imgLeadingIcon.IsVisible = this.LeadingIconIsVisible;
                break;

            case nameof(this.TrailingIcon):
                if (!string.IsNullOrEmpty(this.TrailingIcon))
                {
                    this.imgTrailingIcon.Image.Source = this.TrailingIcon;
                }
                this.imgTrailingIcon.IsVisible = this.TrailingIconIsVisible;
                break;

            case nameof(this.TabIndex):
                if (this.TabIndex != 0)
                {
                    this.txtEntry.TabIndex = this.TabIndex;
                    this.TabIndex          = 0;
                }
                break;

            case nameof(this.IsTabStop):
                this.txtEntry.IsTabStop = this.IsTabStop;
                break;

            case nameof(this.ReturnType):
                this.txtEntry.ReturnType = this.ReturnType;

                if (this.ReturnType.Equals(Xamarin.Forms.ReturnType.Next))
                {
                    this.txtEntry.ReturnCommand = new Command(() =>
                    {
                        var currentTabIndex = this.txtEntry.TabIndex;
                        this.FocusNextElement(currentTabIndex);
                    });
                }
                break;
            }
        }
Пример #13
0
        protected override void OnPropertyChanged([CallerMemberName] string propertyName = null)
        {
            if (!this.initialized)
            {
                this.initialized = true;
                this.InitializeComponent();


                // TODO: add autosize property
                this.txtEditor.AutoSize = EditorAutoSizeOption.Disabled;

                // TODO: apply the height of the control.
            }

            switch (propertyName)
            {
            case nameof(base.TranslationX):
                base.OnPropertyChanged(propertyName);
                break;

            case nameof(this.IsEnabled):
                this.txtEditor.IsEnabled = this.IsEnabled;
                break;

            case nameof(this.TextColor):
                this.txtEditor.TextColor = this.TextColor;
                break;

            case nameof(this.FontSize):
                this.txtEditor.FontSize = this.FontSize;
                break;

            case nameof(this.FontFamily):
                this.txtEditor.FontFamily    = this.FontFamily;
                this.lblLabel.FontFamily     = this.FontFamily;
                this.lblAssistive.FontFamily = this.FontFamily;
                break;

            case nameof(this.Placeholder):
                this.txtEditor.Placeholder = this.Placeholder;
                break;

            case nameof(this.PlaceholderColor):
                this.txtEditor.PlaceholderColor = this.PlaceholderColor;
                break;

            case nameof(this.Keyboard):
                this.txtEditor.Keyboard = this.Keyboard;
                break;

            case nameof(this.MaxLength):
                this.txtEditor.MaxLength = this.MaxLength;
                break;

            case nameof(this.LabelText):
                this.lblLabel.Text      = this.LabelText;
                this.lblLabel.IsVisible = !string.IsNullOrEmpty(this.LabelText);
                break;

            case nameof(this.LabelTextColor):
                this.lblLabel.TextColor = this.LabelTextColor;
                break;

            case nameof(this.LabelSize):
                this.lblLabel.FontSize = this.LabelSize;
                break;

            case nameof(this.Padding):
                this.frmContainer.Padding = this.Padding;
                break;

            case nameof(this.Type):
            case nameof(this.BackgroundColor):
            case nameof(this.BorderColor):
                switch (this.Type)
                {
                case FieldTypes.Filled:
                    this.frmContainer.BackgroundColor = this.BackgroundColor;
                    this.frmContainer.BorderColor     = this.BorderColor;
                    this.frmContainer.CornerRadius    = 20;
                    this.bxvLine.IsVisible            = false;
                    break;

                case FieldTypes.Outlined:
                    this.frmContainer.BackgroundColor = this.BackgroundColor;
                    this.frmContainer.BorderColor     = this.BorderColor;
                    this.frmContainer.CornerRadius    = 4;
                    this.bxvLine.IsVisible            = false;
                    break;

                case FieldTypes.Lined:
                    this.frmContainer.BackgroundColor = Color.Transparent;
                    this.frmContainer.BorderColor     = Color.Transparent;
                    this.bxvLine.IsVisible            = true;
                    this.bxvLine.Color = this.BorderColor;

                    //this.frmContainer.HeightRequest = 30;

                    if (this.LeadingIconIsVisible)
                    {
                        this.lblLabel.Margin = new Thickness(36, this.lblLabel.Margin.Top,
                                                             this.lblLabel.Margin.Right, 0);
                        this.frmContainer.Padding = new Thickness(0);
                        this.lblAssistive.Margin  = new Thickness(36, this.lblAssistive.Margin.Top,
                                                                  this.lblAssistive.Margin.Right, this.lblAssistive.Margin.Bottom);
                        this.bxvLine.Margin = new Thickness(36, 0, 0, 0);
                    }
                    else
                    {
                        this.lblLabel.Margin      = new Thickness(0, this.lblLabel.Margin.Top, 0, 0);
                        this.frmContainer.Padding = new Thickness(0);
                        this.lblAssistive.Margin  = new Thickness(0, this.lblAssistive.Margin.Top, 0, this.lblAssistive.Margin.Bottom);
                    }
                    break;
                }
                break;

            case nameof(this.AssistiveText):
                this.lblAssistive.Text      = this.AssistiveText;
                this.lblAssistive.IsVisible = !string.IsNullOrEmpty(this.AssistiveText);
                if (this.AnimateError && !string.IsNullOrEmpty(this.AssistiveText))
                {
                    ShakeAnimation.Animate(this);
                }
                break;

            case nameof(this.AssistiveTextColor):
                this.lblAssistive.TextColor = this.AssistiveTextColor;
                break;

            case nameof(this.AssistiveSize):
                this.lblAssistive.FontSize = this.AssistiveSize;
                break;

            case nameof(this.ClearIcon):
            case nameof(this.ClearIconIsVisible):
                if (!string.IsNullOrEmpty(this.ClearIcon))
                {
                    this.imgClearIcon.Image.Source = this.ClearIcon;
                }
                this.imgClearIcon.IsVisible = this.ClearIconIsVisible && this.IsEnabled && !string.IsNullOrEmpty(this.Text);
                break;

            case nameof(this.LeadingIcon):
                if (!string.IsNullOrEmpty(this.LeadingIcon))
                {
                    this.imgLeadingIcon.Image.Source = this.LeadingIcon;
                }
                this.imgLeadingIcon.IsVisible = this.LeadingIconIsVisible;
                break;

            case nameof(this.TrailingIcon):
                if (!string.IsNullOrEmpty(this.TrailingIcon))
                {
                    this.imgTrailingIcon.Image.Source = this.TrailingIcon;
                }
                this.imgTrailingIcon.IsVisible = this.TrailingIconIsVisible;
                break;

            case nameof(this.TabIndex):
                if (this.TabIndex != 0)
                {
                    this.txtEditor.TabIndex = this.TabIndex;
                    this.TabIndex           = 0;
                }
                break;

            case nameof(this.IsTabStop):
                this.txtEditor.IsTabStop = this.IsTabStop;
                break;

            case nameof(this.FieldHeightRequest):
                this.frmContainer.HeightRequest = this.FieldHeightRequest;
                break;
            }
        }
Пример #14
0
    /// <summary>
    /// Вызывется после завершения анимации перемещения фигуры.
    /// </summary>
    public void EndMove()
    {
        // Делаем ход на BoardState
        boardState.ExecuteMove(currentMove);

        // Перемещаем спрайт на слой ниже
        SpriteRenderer spriteRenderer = currentMovingPiece.GetChild(0).GetComponent <SpriteRenderer>();

        spriteRenderer.sortingLayerName = "Pieces";
        currentMovingPiece = null;

        // Обновляем список разрешенных ходов
        boardState.UpdateLegalMoves();
        Debug.Log($"{boardState.turnColor} has {boardState.moveList.FindAll(move => move.attackingFigures.Count == 0).Count} moves");

        // Шах
        King          king             = boardState.FindKingByColor(boardState.turnColor);
        List <Figure> attackingFigures = boardState.GetFiguresAttackingFigure(king);

        if (attackingFigures.Count > 0)
        {
            Debug.Log($"CHECK TO {boardState.turnColor} KING");
            // Рисуем красные линии
            ShakeAnimation shakeAnimation = FindTransformByPos(king.Pos).GetComponent <ShakeAnimation>();
            foreach (Figure figure in attackingFigures)
            {
                // Добавляем объект
                GameObject newRedLine = Instantiate(redLine);
                redLines.Add(newRedLine);
                // Запускаем анимацию
                RedLineAnimation redLineAnimation = newRedLine.GetComponent <RedLineAnimation>();
                redLineAnimation.StartAnimation(
                    beginPos: new Vector3(figure.Pos.x, figure.Pos.y),
                    endPos: new Vector3(king.Pos.x, king.Pos.y),
                    finishedCallback: shakeAnimation.StartAnimation
                    );
            }
        }

        BoardState.CheckState checkState = boardState.GetCheckState();
        // Мат
        if (checkState == BoardState.CheckState.mate)
        {
            Debug.Log($"MATE TO {boardState.turnColor} KING");
            gameEnded = true;
            endgameText.gameObject.SetActive(true);
            string text = boardState.turnColor == Figure.FigureColor.black ? "Белые выиграли" : "Черные выграли";
            endgameText.transform.GetChild(0).GetComponent <Text>().text = text;
            return;
        }
        // Пат
        else if (checkState == BoardState.CheckState.stalemate)
        {
            Debug.Log($"STALEMATE TO {boardState.turnColor} KING");
            gameEnded = true;
            endgameText.gameObject.SetActive(true);
            string text = "Ничья";
            endgameText.transform.GetChild(0).GetComponent <Text>().text = text;
            return;
        }

        // Снимаем блокировку интерфейса
        interfaceLocked = false;
    }
Пример #15
0
 protected override void Awake()
 {
     base.Awake();
     Shake  = GetComponent <ShakeAnimation>();
     UiDoor = GetComponent <UiDoor>();
 }
Пример #16
0
        protected override void OnPropertyChanged([CallerMemberName] string propertyName = null)
        {
            if (!this.initialized)
            {
                try
                {
                    this.InitializeComponent();
                    this.initialized = true;
                }
                catch (Exception e)
                {
                    //HACK: When run using XF 4.4 there are a bunch of NameScope errors, not sure why
                    Debug.WriteLine("MediaDoublePicker.xaml.xs  : " + e.Message + " : Property - " + propertyName);
                }
            }

            switch (propertyName)
            {
            case nameof(base.TranslationX):
                base.OnPropertyChanged(propertyName);
                break;

            case nameof(this.IsEnabled):
                this.pckOptions.IsEnabled = this.IsEnabled;
                break;

            case nameof(this.TextColor):
                this.pckOptions.TextColor = this.TextColor;
                break;

            case nameof(this.FontSize):
                this.pckOptions.FontSize = this.FontSize;
                break;

            case nameof(this.FontFamily):
                this.pckOptions.FontFamily   = this.FontFamily;
                this.lblLabel.FontFamily     = this.FontFamily;
                this.lblAssistive.FontFamily = this.FontFamily;
                break;

            case nameof(this.LabelText):
                this.lblLabel.Text      = this.LabelText;
                this.lblLabel.IsVisible = !string.IsNullOrEmpty(this.LabelText);
                break;

            case nameof(this.LabelTextColor):
                this.lblLabel.TextColor = this.LabelTextColor;
                break;

            case nameof(this.LabelSize):
                this.lblLabel.FontSize = this.LabelSize;
                break;

            case nameof(this.Padding):
                this.frmContainer.Padding = this.Padding;
                break;

            case nameof(this.Type):
            case nameof(this.BackgroundColor):
            case nameof(this.BorderColor):
                switch (this.Type)
                {
                case FieldTypes.Filled:
                    this.frmContainer.BackgroundColor = this.BackgroundColor;
                    this.frmContainer.BorderColor     = this.BorderColor;
                    this.frmContainer.CornerRadius    = 20;
                    this.bxvLine.IsVisible            = false;
                    break;

                case FieldTypes.Outlined:
                    this.frmContainer.BackgroundColor = this.BackgroundColor;
                    this.frmContainer.BorderColor     = this.BorderColor;
                    this.frmContainer.CornerRadius    = 4;
                    this.bxvLine.IsVisible            = false;
                    break;

                case FieldTypes.Lined:
                    this.frmContainer.BackgroundColor = Color.Transparent;
                    this.frmContainer.BorderColor     = Color.Transparent;
                    this.bxvLine.IsVisible            = true;
                    this.bxvLine.Color = this.BorderColor;

                    this.frmContainer.HeightRequest = 30;

                    if (this.LeadingIconIsVisible)
                    {
                        this.lblLabel.Margin = new Thickness(36, this.lblLabel.Margin.Top,
                                                             this.lblLabel.Margin.Right, 0);
                        this.frmContainer.Padding = new Thickness(0);
                        this.lblAssistive.Margin  = new Thickness(36, this.lblAssistive.Margin.Top,
                                                                  this.lblAssistive.Margin.Right, this.lblAssistive.Margin.Bottom);
                        this.bxvLine.Margin = new Thickness(36, 0, 0, 0);
                    }
                    else
                    {
                        this.lblLabel.Margin      = new Thickness(0, this.lblLabel.Margin.Top, 0, 0);
                        this.frmContainer.Padding = new Thickness(0);
                        this.lblAssistive.Margin  = new Thickness(0, this.lblAssistive.Margin.Top, 0, this.lblAssistive.Margin.Bottom);
                    }
                    break;
                }
                break;

            case nameof(this.AssistiveText):
                this.lblAssistive.Text      = this.AssistiveText;
                this.lblAssistive.IsVisible = !string.IsNullOrEmpty(this.AssistiveText);
                if (this.AnimateError && !string.IsNullOrEmpty(this.AssistiveText))
                {
                    ShakeAnimation.Animate(this);
                }
                break;

            case nameof(this.AssistiveTextColor):
                this.lblAssistive.TextColor = this.AssistiveTextColor;
                break;

            case nameof(this.AssistiveSize):
                this.lblAssistive.FontSize = this.AssistiveSize;
                break;

            case nameof(this.LeadingIcon):
                if (!string.IsNullOrEmpty(this.LeadingIcon))
                {
                    this.imgLeadingIcon.Image.Source = this.LeadingIcon;
                }
                this.imgLeadingIcon.IsVisible = this.LeadingIconIsVisible;
                break;

            case nameof(this.TrailingIcon):
                if (!string.IsNullOrEmpty(this.TrailingIcon))
                {
                    this.imgTrailingIcon.Image.Source = this.TrailingIcon;
                }
                this.imgTrailingIcon.IsVisible = this.TrailingIconIsVisible && this.IsEnabled;
                break;

            case nameof(this.HorizontalTextAlignment):
                this.lblLabel.HorizontalTextAlignment     = this.HorizontalTextAlignment;
                this.pckOptions.HorizontalTextAlignment   = this.HorizontalTextAlignment;
                this.lblAssistive.HorizontalTextAlignment = this.HorizontalTextAlignment;
                break;

            case nameof(this.Placeholder):
                this.pckOptions.Placeholder = this.Placeholder;
                break;

            case nameof(this.PlaceholderColor):
                this.pckOptions.PlaceholderColor = this.PlaceholderColor;
                break;

            case nameof(this.Separator):
                this.pckOptions.Separator = this.Separator;
                break;
            }
        }
        protected void UpdateLayout(string propertyName, Label lblLabel, Label lblAssistive, Frame frmContainer, BoxView bxvLine, CustomImageButton imgLeadingIcon, CustomImageButton imgTrailingIcon)
        {
            switch (propertyName)
            {
            case nameof(IsEnabled):
                SetIsEnabled();
                SetTextColor();
                SetLabelTextColor(lblLabel);
                SetBorderAndBackgroundColors(frmContainer, bxvLine);
                break;

            case nameof(TextColor):
                SetTextColor();
                break;

            case nameof(FontSize):
                SetFontSize();
                break;

            case nameof(FontFamily):
            case nameof(LabelFontFamily):
            case nameof(AssistiveFontFamily):
                SetFontFamily();

                if (LabelFontFamily != null)
                {
                    lblLabel.FontFamily = LabelFontFamily;
                }
                else if (LabelFontFamily == null && FontFamily != null)
                {
                    lblLabel.FontFamily = FontFamily;
                }

                if (AssistiveFontFamily != null)
                {
                    lblAssistive.FontFamily = AssistiveFontFamily;
                }
                else if (AssistiveFontFamily == null && FontFamily != null)
                {
                    lblAssistive.FontFamily = FontFamily;
                }


                //lblLabel.FontFamily = FontFamily;
                //lblAssistive.FontFamily = FontFamily;
                break;

            case nameof(Placeholder):
                SetPlaceholder();
                break;

            case nameof(PlaceholderColor):
                SetPlaceholderColor();
                break;

            case nameof(LabelText):
                lblLabel.Text      = LabelText;
                lblLabel.IsVisible = !string.IsNullOrEmpty(LabelText);
                break;

            case nameof(LabelTextColor):
                SetLabelTextColor(lblLabel);
                break;

            case nameof(LabelSize):
                lblLabel.FontSize = LabelSize;
                break;

            case nameof(LabelMargin):
                lblLabel.Margin = LabelMargin;
                break;

            case nameof(Padding):
                SetPadding();
                break;

            case nameof(CornerRadius):
                frmContainer.CornerRadius = Convert.ToInt32(CornerRadius);
                break;

            case nameof(Type):
            case nameof(BackgroundColor):
            case nameof(BorderColor):
                SetBorderAndBackgroundColors(frmContainer, bxvLine);

                if (Type == FieldTypes.Lined)
                {
                    frmContainer.HeightRequest = 30;

                    if (LeadingIconIsVisible)
                    {
                        lblLabel.Margin      = new Thickness(36, lblLabel.Margin.Top, lblLabel.Margin.Right, 0);
                        frmContainer.Padding = new Thickness(0);
                        lblAssistive.Margin  = new Thickness(36, lblAssistive.Margin.Top, lblAssistive.Margin.Right, lblAssistive.Margin.Bottom);
                        bxvLine.Margin       = new Thickness(36, 0, 0, 0);
                    }
                    else
                    {
                        lblLabel.Margin      = new Thickness(0, lblLabel.Margin.Top, 0, 0);
                        frmContainer.Padding = new Thickness(0);
                        lblAssistive.Margin  = new Thickness(0, lblAssistive.Margin.Top, 0, lblAssistive.Margin.Bottom);
                    }
                }
                break;

            case nameof(AssistiveText):
                lblAssistive.Text      = AssistiveText;
                lblAssistive.IsVisible = !string.IsNullOrEmpty(AssistiveText);
                if (AnimateError && !string.IsNullOrEmpty(AssistiveText))
                {
                    ShakeAnimation.Animate(this);
                }
                break;

            case nameof(AssistiveTextColor):
                lblAssistive.TextColor = AssistiveTextColor;
                break;

            case nameof(AssistiveSize):
                lblAssistive.FontSize = AssistiveSize;
                break;

            case nameof(AssistiveMargin):
                lblAssistive.Margin = AssistiveMargin;
                break;

            case nameof(LeadingIcon):
                if (!string.IsNullOrEmpty(LeadingIcon))
                {
                    imgLeadingIcon.SetImage(LeadingIcon);
                }

                imgLeadingIcon.IsVisible = LeadingIconIsVisible;
                break;

            case nameof(CustomLeadingIcon):
                if (CustomLeadingIcon != null)
                {
                    imgLeadingIcon.SetCustomImage(CustomLeadingIcon);
                }

                imgLeadingIcon.IsVisible = LeadingIconIsVisible;
                break;

            case nameof(LeadingIconCommand):
                if (LeadingIconCommand != null)
                {
                    imgLeadingIcon.Tapped = () =>
                    {
                        if (LeadingIconCommand != null)
                        {
                            LeadingIconCommand.Execute(LeadingIconCommandParameter);
                        }
                    };
                }
                break;

            case nameof(TrailingIcon):
                if (!string.IsNullOrEmpty(TrailingIcon))
                {
                    imgTrailingIcon.SetImage(TrailingIcon);
                }

                imgTrailingIcon.IsVisible = TrailingIconIsVisible;
                break;

            case nameof(CustomTrailingIcon):
                if (CustomTrailingIcon != null)
                {
                    imgTrailingIcon.SetCustomImage(CustomTrailingIcon);
                }

                imgTrailingIcon.IsVisible = TrailingIconIsVisible;
                break;

            case nameof(TrailingIconCommand):
                if (TrailingIconCommand != null)
                {
                    imgTrailingIcon.Tapped = () =>
                    {
                        if (TrailingIconCommand != null)
                        {
                            TrailingIconCommand.Execute(TrailingIconCommandParameter);
                        }
                    };
                }
                break;

            case nameof(FieldHeightRequest):
                frmContainer.HeightRequest = FieldHeightRequest;
                break;

            case nameof(HorizontalTextAlignment):
                SetHorizontalTextAlignment();
                lblLabel.HorizontalTextAlignment     = HorizontalTextAlignment;
                lblAssistive.HorizontalTextAlignment = HorizontalTextAlignment;
                break;
            }
        }
Пример #18
0
        /// <internalonly />
        protected internal override ProceduralAnimation CreateEffectAnimation(EffectDirection direction)
        {
            FrameworkElement target = GetTarget();

            if (_translateTransform == null) {
                Transform existingTransform = target.RenderTransform;
                if (existingTransform != null) {
                    _translateTransform = existingTransform as TranslateTransform;

                    if (_translateTransform == null) {
                        TransformGroup transformGroup = existingTransform as TransformGroup;

                        if (transformGroup != null) {
                            foreach (Transform transform in transformGroup.Children) {
                                _translateTransform = transform as TranslateTransform;
                                if (_translateTransform != null) {
                                    break;
                                }
                            }
                        }
                    }
                }
            }

            if (_translateTransform == null) {
                throw new InvalidOperationException("The element does not have a translate transform associated with it.");
            }

            ShakeAnimation animation = new ShakeAnimation(_translateTransform, Duration, _shakeDistance);
            animation.Interpolation = GetEffectiveInterpolation();

            return animation;
        }
Пример #19
0
 void Start()
 {
     showNum = 0;
     sa      = GetComponent <ShakeAnimation>();
 }
        protected override void OnPropertyChanged([CallerMemberName] string propertyName = null)
        {
            if (!this.initialized)
            {
                this.initialized = true;
                this.InitializeComponent();
            }

            switch (propertyName)
            {
            case nameof(base.TranslationX):
                base.OnPropertyChanged(propertyName);
                break;

            case nameof(this.IsEnabled):
                SetIsEnabled();
                break;

            case nameof(this.TextColor):
                SetTextColor();
                break;

            case nameof(this.FontSize):
                SetFontSize();
                break;

            case nameof(this.FontFamily):
                SetFontFamily();
                break;

            case nameof(this.Keyboard):
                this.txtEntry.Keyboard = this.Keyboard;
                break;

            case nameof(this.Length):
                this.txtEntry.MaxLength = this.Length;
                break;

            case nameof(this.LabelText):
                this.lblLabel.Text      = this.LabelText;
                this.lblLabel.IsVisible = !string.IsNullOrEmpty(this.LabelText);
                break;

            case nameof(this.LabelTextColor):
                SetLabelTextColor(lblLabel);
                break;

            case nameof(this.LabelSize):
                this.lblLabel.FontSize = this.LabelSize;
                break;

            case nameof(this.Padding):
                this.grdContainer.Padding = this.Padding;
                break;

            case nameof(CornerRadius):
                if (frmContainers != null)
                {
                    foreach (var frmContainer in frmContainers)
                    {
                        frmContainer.CornerRadius = Convert.ToInt32(CornerRadius);
                    }
                }
                break;

            case nameof(this.Type):
            case nameof(this.BackgroundColor):
            case nameof(this.BorderColor):
                SetTypeBackgroundAndBorderColor();
                break;

            case nameof(this.AssistiveText):
                this.lblAssistive.Text      = this.AssistiveText;
                this.lblAssistive.IsVisible = !string.IsNullOrEmpty(this.AssistiveText);
                if (this.AnimateError && !string.IsNullOrEmpty(this.AssistiveText))
                {
                    ShakeAnimation.Animate(this);
                }
                break;

            case nameof(this.AssistiveTextColor):
                this.lblAssistive.TextColor = this.AssistiveTextColor;
                break;

            case nameof(this.AssistiveSize):
                this.lblAssistive.FontSize = this.AssistiveSize;
                break;

            case nameof(this.TabIndex):
                if (this.TabIndex != 0)
                {
                    this.txtEntry.TabIndex = this.TabIndex;
                    this.TabIndex          = 0;
                }
                break;

            case nameof(this.IsTabStop):
                this.txtEntry.IsTabStop = this.IsTabStop;
                break;

            case nameof(this.ReturnType):
                this.txtEntry.ReturnType = this.ReturnType;

                if (this.ReturnType.Equals(Xamarin.Forms.ReturnType.Next))
                {
                    this.txtEntry.ReturnCommand = new Command(() =>
                    {
                        var currentTabIndex = this.txtEntry.TabIndex;
                        this.FocusNextElement(currentTabIndex);
                    });
                }
                break;

            case nameof(this.FieldHeightRequest):
                grdContainer.RowDefinitions = new RowDefinitionCollection();
                grdContainer.RowDefinitions.Add(new RowDefinition {
                    Height = this.FieldHeightRequest
                });

                if (frmContainers != null)
                {
                    foreach (var frmContainer in frmContainers)
                    {
                        frmContainer.HeightRequest = this.FieldHeightRequest;
                    }
                }
                break;

            case nameof(this.FieldWidthRequest):
                if (frmContainers != null)
                {
                    foreach (var frmContainer in frmContainers)
                    {
                        frmContainer.HorizontalOptions = LayoutOptions.Center;
                        frmContainer.WidthRequest      = this.FieldWidthRequest;
                    }
                }
                break;

            case nameof(this.IsCode):
                this.txtEntry.IsCode = this.IsCode;
                break;

            case nameof(HorizontalTextAlignment):
                SetHorizontalTextAlignment();
                break;
            }
        }
        private static AnimationDefinition GetAnimationDefinition(string animationName)
        {
            AnimationDefinition animationDefinition = null;

            if (animationName != null)
            {
                switch (animationName.ToLower())
                {
                case "flash": animationDefinition = new FlashAnimation(); break;

                case "bounce": animationDefinition = new BounceAnimation(); break;

                case "shake": animationDefinition = new ShakeAnimation(); break;

                case "tada": animationDefinition = new TadaAnimation(); break;

                case "swing": animationDefinition = new SwingAnimation(); break;

                case "wobble": animationDefinition = new WobbleAnimation(); break;

                case "pulse": animationDefinition = new PulseAnimation(); break;

                case "breathing": animationDefinition = new BreathingAnimation(); break;

                case "jump": animationDefinition = new JumpAnimation(); break;

                case "flip": animationDefinition = new FlipAnimation(); break;

                case "flipinx": animationDefinition = new FlipInXAnimation(); break;

                case "flipoutx": animationDefinition = new FlipOutXAnimation(); break;

                case "flipiny": animationDefinition = new FlipInYAnimation(); break;

                case "flipouty": animationDefinition = new FlipOutYAnimation(); break;

                case "fadein": animationDefinition = new FadeInAnimation(); break;

                case "fadeout": animationDefinition = new FadeOutAnimation(); break;

                case "fadeinleft": animationDefinition = new FadeInLeftAnimation(); break;

                case "fadeinright": animationDefinition = new FadeInRightAnimation(); break;

                case "fadeinup": animationDefinition = new FadeInUpAnimation(); break;

                case "fadeindown": animationDefinition = new FadeInDownAnimation(); break;

                case "fadeoutleft": animationDefinition = new FadeOutLeftAnimation(); break;

                case "fadeoutright": animationDefinition = new FadeOutRightAnimation(); break;

                case "fadeoutup": animationDefinition = new FadeOutUpAnimation(); break;

                case "fadeoutdown": animationDefinition = new FadeOutDownAnimation(); break;

                case "bouncein": animationDefinition = new BounceInAnimation(); break;

                case "bounceout": animationDefinition = new BounceOutAnimation(); break;

                case "bounceinleft": animationDefinition = new BounceInLeftAnimation(); break;

                case "bounceinright": animationDefinition = new BounceInRightAnimation(); break;

                case "bounceinup": animationDefinition = new BounceInUpAnimation(); break;

                case "bounceindown": animationDefinition = new BounceInDownAnimation(); break;

                case "bounceoutleft": animationDefinition = new BounceOutLeftAnimation(); break;

                case "bounceoutright": animationDefinition = new BounceOutRightAnimation(); break;

                case "bounceoutup": animationDefinition = new BounceOutUpAnimation(); break;

                case "bounceoutdown": animationDefinition = new BounceOutDownAnimation(); break;

                case "scalein": animationDefinition = new ScaleInAnimation(); break;

                case "scaleout": animationDefinition = new ScaleOutAnimation(); break;

                case "lightspeedinleft": animationDefinition = new LightSpeedInLeftAnimation(); break;

                case "lightspeedinright": animationDefinition = new LightSpeedInRightAnimation(); break;

                case "lightspeedoutleft": animationDefinition = new LightSpeedOutLeftAnimation(); break;

                case "lightspeedoutright": animationDefinition = new LightSpeedOutRightAnimation(); break;

                case "hinge": animationDefinition = new HingeAnimation(); break;

                case "reset": animationDefinition = new ResetAnimation(); break;
                }
            }
            return(animationDefinition);
        }
        protected override void OnPropertyChanged([CallerMemberName] string propertyName = null)
        {
            if (!this.initialized)
            {
                this.initialized = true;
                this.InitializeComponent();
            }

            switch (propertyName)
            {
            case nameof(LabelText):
                lblLabel.Text      = LabelText;
                lblLabel.IsVisible = !string.IsNullOrEmpty(LabelText);
                break;

            case nameof(LabelTextColor):
                lblLabel.TextColor = LabelTextColor;
                break;

            case nameof(DisabledLabelTextColor):
                if (IsEnabled)
                {
                    lblLabel.TextColor = LabelTextColor;
                }
                else
                {
                    lblLabel.TextColor = DisabledLabelTextColor;
                }
                break;

            case nameof(LabelSize):
                lblLabel.FontSize = LabelSize;
                break;

            case nameof(LabelValueFormat):
                lblValue.Text = Value.ToString(LabelValueFormat);
                break;

            case nameof(LabelValueColor):
                lblValue.TextColor = LabelValueColor;
                break;

            case nameof(DisabledLabelValueColor):
                lblValue.TextColor = IsEnabled ? LabelValueColor : DisabledLabelValueColor;
                break;

            case nameof(LabelValueSize):
                lblValue.FontSize = LabelValueSize;
                break;

            case nameof(LabelValueIsVisible):
                lblValue.IsVisible = LabelValueIsVisible;
                lblValue.Text      = Value.ToString(LabelValueFormat);
                break;

            case nameof(LabelMinimumText):
                lblMinimum.Text      = LabelMinimumText;
                lblMinimum.IsVisible = !string.IsNullOrEmpty(LabelMinimumText) && (!ShowIcons || !MinimumIconIsVisible);
                break;

            case nameof(LabelMinimumTextColor):
                lblMinimum.TextColor = LabelMinimumTextColor;
                break;

            case nameof(DisabledLabelMinimumTextColor):
                if (IsEnabled)
                {
                    lblMinimum.TextColor = LabelMinimumTextColor;
                }
                else
                {
                    lblMinimum.TextColor = DisabledLabelMinimumTextColor;
                }
                break;

            case nameof(LabelMinimumSize):
                lblMinimum.FontSize = LabelMinimumSize;
                break;

            case nameof(LabelMaximumText):
                lblMaximum.Text      = LabelMaximumText;
                lblMaximum.IsVisible = !string.IsNullOrEmpty(LabelMaximumText) && (!ShowIcons || !MaximumIconIsVisible);
                break;

            case nameof(LabelMaximumTextColor):
                lblMaximum.TextColor = LabelMaximumTextColor;
                break;

            case nameof(DisabledLabelMaximumTextColor):
                if (IsEnabled)
                {
                    lblMaximum.TextColor = LabelMaximumTextColor;
                }
                else
                {
                    lblMaximum.TextColor = DisabledLabelMaximumTextColor;
                }
                break;

            case nameof(LabelMaximumSize):
                lblMaximum.FontSize = LabelMaximumSize;
                break;

            case nameof(AssistiveText):
                lblAssistive.Text      = AssistiveText;
                lblAssistive.IsVisible = !string.IsNullOrEmpty(AssistiveText);
                if (AnimateError && !string.IsNullOrEmpty(AssistiveText))
                {
                    ShakeAnimation.Animate(this);
                }
                break;

            case nameof(AssistiveTextColor):
                lblAssistive.TextColor = AssistiveTextColor;
                break;

            case nameof(AssistiveSize):
                lblAssistive.FontSize = AssistiveSize;
                break;

            case nameof(MinimumIcon):
                if (!string.IsNullOrEmpty(this.MinimumIcon))
                {
                    imgMinimum.SetImage(MinimumIcon);
                }

                SetMinimumIconIsVisible();
                break;

            case nameof(CustomMinimumIcon):
                if (CustomMinimumIcon != null)
                {
                    imgMinimum.SetCustomImage(CustomMinimumIcon);
                }

                SetMinimumIconIsVisible();
                break;

            case nameof(MaximumIcon):
                if (!string.IsNullOrEmpty(this.MaximumIcon))
                {
                    imgMaximum.SetImage(MaximumIcon);
                }

                SetMaximumIconIsVisible();
                break;

            case nameof(CustomMaximumIcon):
                if (CustomMaximumIcon != null)
                {
                    imgMaximum.SetCustomImage(CustomMaximumIcon);
                }

                SetMaximumIconIsVisible();
                break;

            case nameof(BackgroundImage):
                if (!string.IsNullOrEmpty(this.BackgroundImage))
                {
                    bckgImage.SetImage(BackgroundImage);
                    bckgImage.IsVisible = true;
                }
                else
                {
                    bckgImage.IsVisible = false;
                }

                break;

            case nameof(CustomBackgroundImage):
                if (CustomBackgroundImage != null)
                {
                    bckgImage.SetCustomImage(CustomBackgroundImage);
                    bckgImage.IsVisible = true;
                }
                else
                {
                    bckgImage.IsVisible = false;
                }

                break;

            case nameof(ThumbImage):
                if (!string.IsNullOrEmpty(this.ThumbImage))
                {
                    slider.ThumbImageSource = ThumbImage;
                }
                break;

            case nameof(MinimumValue):
                slider.Minimum = MinimumValue;
                break;

            case nameof(MaximumValue):
                slider.Maximum = MaximumValue;
                break;

            case nameof(ActiveTrackColor):
                slider.ActiveTrackColor = ActiveTrackColor;
                break;

            case nameof(InactiveTrackColor):
                slider.InactiveTrackColor = InactiveTrackColor;
                break;

            case nameof(ThumbColor):
                slider.ThumbColor = ThumbColor;
                break;

            case nameof(TrackHeight):
                slider.TrackHeight = TrackHeight;
                break;

            case nameof(TrackCornerRadius):
                slider.TrackCornerRadius = TrackCornerRadius;
                break;

            case nameof(UserInteractionEnabled):
                slider.UserInteractionEnabled = UserInteractionEnabled;
                break;

            case nameof(IsEnabled):
                this.IsEnabled = IsEnabled;
                SetEnable();
                break;

            case nameof(ShowIcons):
                SetMinimumIconIsVisible();
                SetMaximumIconIsVisible();
                break;
            }

            base.OnPropertyChanged(propertyName);
        }
Пример #23
0
 private void Start()
 {
     MyShaker = GetComponent <ShakeAnimation>();
     OxygenSystem.OnTakeDamage += TakeDamage;
 }