diff options
Diffstat (limited to 'src/Editor/Text/Def/TextUICocoa/Extras/InfoBar/InfoBarViewModel.cs')
-rw-r--r-- | src/Editor/Text/Def/TextUICocoa/Extras/InfoBar/InfoBarViewModel.cs | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/Editor/Text/Def/TextUICocoa/Extras/InfoBar/InfoBarViewModel.cs b/src/Editor/Text/Def/TextUICocoa/Extras/InfoBar/InfoBarViewModel.cs new file mode 100644 index 0000000..4913e40 --- /dev/null +++ b/src/Editor/Text/Def/TextUICocoa/Extras/InfoBar/InfoBarViewModel.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; + +namespace Microsoft.VisualStudio.Text.Editor +{ + public readonly struct InfoBarAction + { + public string Title { get; } + public Action Handler { get; } + public bool IsDefault { get; } + + public InfoBarAction(string title, Action handler, bool isDefault = false) + { + Title = title; + Handler = handler; + IsDefault = isDefault; + } + + public void Invoke() + => Handler?.Invoke(); + } + + public sealed class InfoBarViewModel + { + public string PrimaryLabelText { get; } + + public string SecondaryLabelText { get; } + + public IReadOnlyList<InfoBarAction> Actions { get; } + + public Action DismissedHandler { get; } + + public InfoBarViewModel( + string primaryLabelText, + string secondaryLabelText, + IReadOnlyList<InfoBarAction> actions, + Action dismissedHandler = null) + { + PrimaryLabelText = primaryLabelText; + SecondaryLabelText = secondaryLabelText; + Actions = actions; + DismissedHandler = dismissedHandler; + } + + public void InvokeDismissed() + => DismissedHandler?.Invoke(); + } +}
\ No newline at end of file |