Ejemplo n.º 1
0
        public override Color GetButtonTextColor(IButtonElement button)
        {
            var styleColor = button.ButtonColor ?? StyleColor.Default;
            var color      = styleColor.GetColor(button.IsActive ? _activeButtonColor : _buttonColor);

            if (button.IsPressed)
            {
                color = color.Darken(0.3f);
            }
            else if (button.IsHovered)
            {
                color = color.Lighten(0.2f);
            }

            var brightness = color.ToHsl().Luminance;

            if (brightness > 0.5f)
            {
                return(Color.Black);
            }
            else
            {
                return(Color.White);
            }
        }
Ejemplo n.º 2
0
 public static void ElementClicked(VisualElement visualElement, IButtonElement ButtonElementManager)
 {
     if (visualElement.IsEnabled == true)
     {
         ButtonElementManager.Command?.Execute(ButtonElementManager.CommandParameter);
         ButtonElementManager.PropagateUpClicked();
     }
 }
Ejemplo n.º 3
0
 public static void ElementPressed(VisualElement visualElement, IButtonElement ButtonElementManager)
 {
     if (visualElement.IsEnabled == true)
     {
         ButtonElementManager.SetIsPressed(true);
         visualElement.ChangeVisualStateInternal();
         ButtonElementManager.PropagateUpPressed();
     }
 }
Ejemplo n.º 4
0
        static void OnCommandChanging(BindableObject bo, object o, object n)
        {
            IButtonElement button = (IButtonElement)bo;

            if (o != null)
            {
                (o as ICommand).CanExecuteChanged -= button.OnCommandCanExecuteChanged;
            }
        }
Ejemplo n.º 5
0
 public static void ElementReleased(VisualElement visualElement, IButtonElement ButtonElementManager)
 {
     if (visualElement.IsEnabled == true)
     {
         IButtonController buttonController = ButtonElementManager as IButtonController;
         ButtonElementManager.SetIsPressed(false);
         visualElement.ChangeVisualStateInternal();
         ButtonElementManager.PropagateUpReleased();
     }
 }
Ejemplo n.º 6
0
        public static void CommandCanExecuteChanged(object sender, EventArgs e)
        {
            IButtonElement ButtonElementManager = (IButtonElement)sender;
            ICommand       cmd = ButtonElementManager.Command;

            if (cmd != null)
            {
                ButtonElementManager.IsEnabledCore = cmd.CanExecute(ButtonElementManager.CommandParameter);
            }
        }
Ejemplo n.º 7
0
 public static void CommandChanged(IButtonElement sender)
 {
     if (sender.Command != null)
     {
         CommandCanExecuteChanged(sender, EventArgs.Empty);
     }
     else
     {
         sender.IsEnabledCore = true;
     }
 }
Ejemplo n.º 8
0
        static void OnCommandChanged(BindableObject bo, object o, object n)
        {
            IButtonElement button = (IButtonElement)bo;

            if (n is ICommand newCommand)
            {
                newCommand.CanExecuteChanged += button.OnCommandCanExecuteChanged;
            }

            CommandChanged(button);
        }
Ejemplo n.º 9
0
        public override void DrawButton(GuiRenderer renderer, IButtonElement button)
        {
            var styleColor = button.ButtonColor ?? StyleColor.Default;
            var color      = styleColor.GetColor(button.IsActive ? _activeButtonColor : _buttonColor);

            if (button.IsPressed)
            {
                color = color.Darken(0.3f);
            }
            else if (button.IsHovered)
            {
                color = color.Lighten(0.2f);
            }

            var borderColor = color.Lighten(0.15f);

            renderer.FillRectangle(button.BoundingBox, color);
            renderer.DrawRectangle(button.BoundingBox, borderColor, 2);
        }
Ejemplo n.º 10
0
 public virtual Color GetButtonTextColor(IButtonElement button)
 {
     return(Color.Black);
 }
Ejemplo n.º 11
0
 public abstract void DrawButton(GuiRenderer renderer, IButtonElement button);