public static IControl Create(
            Command close,
            Command confirm,
            IControl fill,
            Command?cancel,
            Text?confirmText,
            Text?cancelText,
            Text?confirmTooltip)
        {
            var confirmButton = ThemedButton.Create(
                command: confirm.Then(close),
                label: confirmText ?? "OK",
                icon: Icons.Confirm(Theme.Active),
                tooltip: confirmTooltip ?? default(Text),
                hoverColor: Theme.Active);

            var cancelButton = ThemedButton.Create(
                command: (cancel ?? Command.Enabled(() => { }).Then(close)),
                label: cancelText ?? "Cancel",
                icon: Icons.Cancel(Theme.Cancel),
                tooltip: null,
                hoverColor: Theme.Cancel);

            var buttons = Layout.Dock()
                          .Bottom(
                Layout.Dock()
                .Top(Separator.Medium)
                .Fill(Layout.SubdivideHorizontallyWithSeparator(Separator.Medium, cancelButton, confirmButton)))
                          .Fill(fill);

            return(buttons);
        }
Example #2
0
        static IControl CreateButtons(IObserver <bool> showWindow, Action save)
        {
            var cancelButton = CreateButton(
                icon: Icons.Cancel(Theme.Cancel),
                text: "Cancel",
                clicked: Command.Enabled(() => showWindow.OnNext(false)));

            var doneButton = CreateButton(
                icon: Icons.Confirm(Theme.Active),
                text: "Done",
                clicked: Command.Enabled(() =>
            {
                save();
                showWindow.OnNext(false);
            }));

            var leftButton  = Platform.OperatingSystem == OS.Mac ? cancelButton : doneButton;
            var rightButton = Platform.OperatingSystem == OS.Mac ? doneButton : cancelButton;

            return(Layout.SubdivideHorizontally(
                       Layout.Dock().Right(Separator.Medium).Fill(leftButton),
                       rightButton)
                   .WithHeight(45));
        }