Exemple #1
0
 static IControl CreateCompactSelectionControl(
     IProperty <Mode> mode,
     IProperty <bool> selectionEnabled,
     Command toggleMode)
 {
     return
         (Layout.StackFromLeft(
              Button.Create(selectionEnabled.Toggle(), state =>
                            Layout.Dock()
                            .Bottom(
                                Shapes.Rectangle(
                                    fill: Theme.Active)
                                .WithSize(new Size <Points>(1, 1)))
                            .Fill(
                                Layout.StackFromLeft(
                                    SelectionIcon.Create(selectionEnabled, true)
                                    .OnMouse(pressed: selectionEnabled.Toggle())
                                    .ShowWhen(selectionEnabled),
                                    TouchIcon.Create(selectionEnabled, true)
                                    .Center()
                                    .OnMouse(pressed: selectionEnabled.Toggle())
                                    .ShowWhen(selectionEnabled.IsFalse())))
                            .WithPadding(new Thickness <Points>(4, 0, 4, 0))
                            .WithBackground(
                                background: Observable.CombineLatest(
                                    state.IsEnabled, state.IsHovered,
                                    (enabled, hovering) =>
                                    hovering
                                                                                         ? Theme.FaintBackground
                                                                                         : Color.Transparent)
                                .Switch())
                            .SetToolTip("Enable to select elements in the app. Disable to interact with the app.")),
              Control.Empty.WithWidth(8),
              Button.Create(toggleMode, state =>
                            MinimizeAndMaximizeIcon.Create(mode)
                            .WithPadding(new Thickness <Points>(4, 0, 4, 0))
                            .WithBackground(
                                background: Observable.CombineLatest(
                                    state.IsEnabled, state.IsHovered,
                                    (enabled, hovering) =>
                                    hovering
                                                                                         ? Theme.FaintBackground
                                                                                         : Color.Transparent)
                                .Switch()))
              .SetToolTip("Switch between normal and compact mode. Click to switch mode.")));
 }
Exemple #2
0
 static IControl CreateFullSelectionControl(
     IProperty <bool> selectionEnabled)
 {
     return
         (Layout.StackFromLeft(
              Layout.Dock()
              .Bottom(
                  Shapes.Rectangle(
                      fill: selectionEnabled.IsFalse()
                      .Select(e => e ? Color.Transparent : Theme.Active)
                      .Switch())
                  .WithHeight(1))
              .Fill(
                  CreateHeaderControl(
                      icon: SelectionIcon.Create(selectionEnabled, true),
                      tooltipText: "Enable to select elements in the app.",
                      buttonText: "Selection",
                      labelColor: selectionEnabled.IsFalse()
                      .Select(e => e ? Theme.DefaultText : Theme.ActiveHover)
                      .Switch(),
                      command: selectionEnabled.Toggle())),
              Control.Empty.WithWidth(24),
              Layout.Dock()
              .Bottom(
                  Shapes.Rectangle(
                      fill: selectionEnabled.IsFalse()
                      .Select(e => e ? Theme.Active : Color.Transparent)
                      .Switch())
                  .WithHeight(1))
              .Fill(
                  CreateHeaderControl(
                      icon: TouchIcon.Create(selectionEnabled, true),
                      tooltipText: "Enable to intract with the app.",
                      buttonText: "Touch",
                      labelColor: selectionEnabled
                      .Select(e => e ? Theme.DefaultText : Theme.ActiveHover)
                      .Switch(),
                      command: selectionEnabled.Toggle()))));
 }