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); } }
public static void ElementClicked(VisualElement visualElement, IButtonElement ButtonElementManager) { if (visualElement.IsEnabled == true) { ButtonElementManager.Command?.Execute(ButtonElementManager.CommandParameter); ButtonElementManager.PropagateUpClicked(); } }
public static void ElementPressed(VisualElement visualElement, IButtonElement ButtonElementManager) { if (visualElement.IsEnabled == true) { ButtonElementManager.SetIsPressed(true); visualElement.ChangeVisualStateInternal(); ButtonElementManager.PropagateUpPressed(); } }
static void OnCommandChanging(BindableObject bo, object o, object n) { IButtonElement button = (IButtonElement)bo; if (o != null) { (o as ICommand).CanExecuteChanged -= button.OnCommandCanExecuteChanged; } }
public static void ElementReleased(VisualElement visualElement, IButtonElement ButtonElementManager) { if (visualElement.IsEnabled == true) { IButtonController buttonController = ButtonElementManager as IButtonController; ButtonElementManager.SetIsPressed(false); visualElement.ChangeVisualStateInternal(); ButtonElementManager.PropagateUpReleased(); } }
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); } }
public static void CommandChanged(IButtonElement sender) { if (sender.Command != null) { CommandCanExecuteChanged(sender, EventArgs.Empty); } else { sender.IsEnabledCore = true; } }
static void OnCommandChanged(BindableObject bo, object o, object n) { IButtonElement button = (IButtonElement)bo; if (n is ICommand newCommand) { newCommand.CanExecuteChanged += button.OnCommandCanExecuteChanged; } CommandChanged(button); }
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); }
public virtual Color GetButtonTextColor(IButtonElement button) { return(Color.Black); }
public abstract void DrawButton(GuiRenderer renderer, IButtonElement button);