static IControl StrokeButton(Text text, Command cmd, Brush foreground, Brush background, Brush hoverColor) { return(Button.Create(cmd, state => Label.Create( text, textAlignment: TextAlignment.Center, font: Theme.DescriptorFont, color: Observable.CombineLatest( state.IsEnabled, state.IsHovered, (enabled, hovering) => hovering ? hoverColor : foreground) .Switch()) .CenterVertically() .WithBackground(Shapes.Rectangle( fill: background, cornerRadius: Observable.Return(new CornerRadius(2)), stroke: Stroke.Create(1, Observable.CombineLatest( state.IsEnabled, state.IsHovered, (enabled, hovering) => hovering ? hoverColor : foreground) .Switch())))) .WithHeight(DefaultButtonHeight) .SetCursor(Cursor.Pointing)); }
static IControl SolidColorButton(Text text, Command cmd, Brush foreground, Brush background, Brush hoverColor, Brush altTextColor) { return(Button.Create(cmd, state => Label.Create( text, textAlignment: TextAlignment.Center, font: Theme.DescriptorFont, color: Theme.CurrentTheme.Select(theme => ( theme == Themes.OriginalDark ? altTextColor : foreground)) .Switch()) .Center() .WithBackground(Shapes.Rectangle( fill: Observable.CombineLatest( state.IsEnabled, state.IsHovered, (enabled, hovering) => hovering ? hoverColor : background) .Switch(), cornerRadius: Observable.Return(new CornerRadius(2))))) .WithHeight(DefaultButtonHeight) .SetCursor(Cursor.Pointing)); }
static IControl CreateDebugItem(string name, Command selected) { var isSelected = SelectedControl.NotNone().Select(sel => sel == name); return(Button.Create( text: name, clicked: selected, content: states => Label.Create(name, color: states.IsHovered.Select(hovered => hovered ? Color.FromBytes(0x6d, 0xc0, 0xd2) : Color.White).AsBrush()) .WithPadding(new Thickness <Points>(10, 5, 10, 5)) .WithOverlay(Shapes.Rectangle(fill: isSelected.Select(hovered => hovered ? Color.FromBytes(0x6d, 0xc0, 0xd2, 100) : Color.Transparent).AsBrush())) ) .SetContextMenu(Menu.Item("Open in Text Editor", () => new Shell().OpenWithDefaultApplication(DebugControls.Value[name].FilePath)))); }
public static IControl TextButton(Text text, Command cmd, Brush color, Brush hoverColor, Font font) { return(Button.Create(cmd, state => Label.Create( text, textAlignment: TextAlignment.Left, font: font, color: Observable.CombineLatest( state.IsEnabled, state.IsHovered, (enabled, hovering) => hovering ? hoverColor : color) .Switch())) .SetCursor(Cursor.Pointing)); }
public static IControl CloseButton( Command close, Brush idleColor, Brush pressedColor, int height = 11, int thickness = 1, int padding = 7) { return(Button.Create( close, states => { var color = states.IsPressed .Select(clicked => clicked ? pressedColor : idleColor) .Switch(); return MainWindowIcons .CloseIcon(new Points(height), Stroke.Create(thickness, color)) .WithPadding(new Thickness <Points>(padding)); })); }