Пример #1
0
 static IControl Header(string header)
 {
     return(Layout.StackFromTop(
                Label.Create(header, Font.SystemDefault(15)),
                Shapes.Rectangle(fill: Color.FromRgb(0xffffff)).WithHeight(1).WithPadding(new Thickness <Points>(0, 5, 0, 5))
                ));
 }
Пример #2
0
 static IControl CreateNothingSelected()
 {
     return(Layout.StackFromTop(
                Label.Create("Nothing selected")
                )
            .WithPadding(new Thickness <Points>(0, 5, 0, 0)));
 }
Пример #3
0
 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));
 }
Пример #4
0
 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));
 }
Пример #5
0
        static IControl CreateProperty <T>(string propertyName, IObservable <T> value, Func <T, string> converter)
        {
            var prefix = propertyName + ": ";

            return(Label.Create(
                       value.StartWithNone()
                       .Select(val => val.MatchWith(
                                   some: v => prefix + converter(v),
                                   none: () => prefix + " - "))
                       .AsText()));
        }
Пример #6
0
        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))));
        }
Пример #7
0
 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));
 }