-
Notifications
You must be signed in to change notification settings - Fork 433
AppNotificationBuilder - ProgressBar #2780
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7119200
4765ea2
30a4376
40bd764
8668d3a
1545006
e470027
422eae8
f55aad3
aa7ed04
e0b2847
15b477c
903956a
bbe8a26
f5a745f
435a152
238684d
5423935
d427450
5dc491a
2b24c69
33a4b1b
5bd1f9e
51fabe4
41a699e
97226a5
a1634f8
51a3312
5ea7ddd
ab89042
019077a
f8b850e
6b28335
f45fb7a
f81258e
8851cae
224877f
861014d
a934566
19d0cd4
ab271d6
24e7669
9c6bb22
8f51b89
f8ed6ca
49c02bb
3b3b08c
a2212e2
14a6e6c
604a24f
b2fafbf
f58cd45
cccfba6
057071a
b56536a
5d5a50f
29c561a
7be9f9c
232632e
e2f9e57
13fea1b
703c0a9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. See LICENSE in the project root for license information. | ||
|
|
||
| #include "pch.h" | ||
| #include "AppNotificationProgressBar.h" | ||
| #include "Microsoft.Windows.AppNotifications.Builder.AppNotificationProgressBar.g.cpp" | ||
|
|
||
| namespace winrt::Microsoft::Windows::AppNotifications::Builder::implementation | ||
| { | ||
| AppNotificationProgressBar::AppNotificationProgressBar() | ||
| :m_titleBindMode{ BindMode::NotSet }, | ||
| m_statusBindMode{ BindMode::NotSet }, | ||
| m_valueBindMode{ BindMode::NotSet }, | ||
| m_valueStringOverrideBindMode{ BindMode::NotSet } | ||
| {}; | ||
|
|
||
| void AppNotificationProgressBar::Title(winrt::hstring const& value) | ||
| { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No check for empty args here or anywhere else?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, there's a task to handle that in a hollistic manner later. At this point we only check for empty IDs and such but not for normal values. This is the strategy used for the entirety of the builder for preview1 |
||
| m_title = value; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need locks here and everywhere else?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No locks anywhere. Howard confirmed that we should be locking anything in this class as it isn't intended to be used in a multi-threaded situation |
||
| m_titleBindMode = BindMode::Value; | ||
| } | ||
|
|
||
| void AppNotificationProgressBar::Status(winrt::hstring const& value) | ||
| { | ||
| m_status = value; | ||
| m_statusBindMode = BindMode::Value; | ||
| } | ||
|
|
||
| void AppNotificationProgressBar::Value(double value) | ||
| { | ||
| THROW_HR_IF_MSG(E_INVALIDARG, value < 0.0 || value > 1.0, "You must provide a value between 0.0 and 1.0"); | ||
|
|
||
| m_value = value; | ||
| m_valueBindMode = BindMode::Value; | ||
| } | ||
|
|
||
| void AppNotificationProgressBar::ValueStringOverride(winrt::hstring const& value) | ||
| { | ||
| m_valueStringOverride = value; | ||
| m_valueStringOverrideBindMode = BindMode::Value; | ||
| } | ||
|
|
||
| winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationProgressBar AppNotificationProgressBar::SetTitle(winrt::hstring const& value) | ||
| { | ||
| Title(value); | ||
|
|
||
| return *this; | ||
| } | ||
|
|
||
| winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationProgressBar AppNotificationProgressBar::BindTitle() | ||
| { | ||
| m_titleBindMode = BindMode::Bind; | ||
|
|
||
| return *this; | ||
| } | ||
|
|
||
| winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationProgressBar AppNotificationProgressBar::SetStatus(winrt::hstring const& value) | ||
| { | ||
| Status(value); | ||
|
|
||
| return *this; | ||
| } | ||
|
|
||
| winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationProgressBar AppNotificationProgressBar::BindStatus() | ||
| { | ||
| m_statusBindMode = BindMode::Bind; | ||
|
|
||
| return *this; | ||
| } | ||
|
|
||
| winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationProgressBar AppNotificationProgressBar::SetValue(double value) | ||
| { | ||
| Value(value); | ||
|
|
||
| return *this; | ||
| } | ||
|
|
||
| winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationProgressBar AppNotificationProgressBar::BindValue() | ||
| { | ||
| m_valueBindMode = BindMode::Bind; | ||
|
|
||
| return *this; | ||
| } | ||
|
|
||
| winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationProgressBar AppNotificationProgressBar::SetValueStringOverride(winrt::hstring const& value) | ||
| { | ||
| ValueStringOverride(value); | ||
|
|
||
| return *this; | ||
| } | ||
|
|
||
| winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationProgressBar AppNotificationProgressBar::BindValueStringOverride() | ||
| { | ||
| m_valueStringOverrideBindMode = BindMode::Bind; | ||
|
|
||
| return *this; | ||
| } | ||
|
|
||
| winrt::hstring AppNotificationProgressBar::ToString() | ||
| { | ||
| auto title{ wil::str_printf<std::wstring>(L" title='%ls'", m_titleBindMode == BindMode::Value ? m_title.c_str() : L"{progressTitle}") }; | ||
| auto status{ wil::str_printf<std::wstring>(L" status='%ls'", m_statusBindMode == BindMode::Value ? m_status.c_str() : L"{progressStatus}") }; | ||
| auto value{ wil::str_printf<std::wstring>(L" value='%ls'", m_valueBindMode == BindMode::Value ? wil::str_printf<std::wstring>(L"%g", m_value).c_str() : L"{progressValue}") }; | ||
| auto valueStringOverride{ wil::str_printf < std::wstring>(L" valueStringOverride='%ls'", m_valueStringOverrideBindMode == BindMode::Value ? m_valueStringOverride.c_str() : L"{progressValueString}") }; | ||
|
|
||
| return wil::str_printf<std::wstring>(L"<progress%ls%ls%ls%ls/>", | ||
| m_titleBindMode == BindMode::NotSet ? L"" :title.c_str(), | ||
| status.c_str(), | ||
| value.c_str(), | ||
| m_valueStringOverrideBindMode == BindMode::NotSet ? L"" : valueStringOverride.c_str()).c_str(); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. See LICENSE in the project root for license information. | ||
|
|
||
| #pragma once | ||
| #include "Microsoft.Windows.AppNotifications.Builder.AppNotificationProgressBar.g.h" | ||
|
|
||
| namespace winrt::Microsoft::Windows::AppNotifications::Builder::implementation | ||
| { | ||
|
|
||
| struct AppNotificationProgressBar : AppNotificationProgressBarT<AppNotificationProgressBar, winrt::Windows::Foundation::IStringable> | ||
| { | ||
| AppNotificationProgressBar(); | ||
|
|
||
| // Properties | ||
| void Title(winrt::hstring const& value); | ||
| winrt::hstring Title() { return m_title; }; | ||
|
|
||
| void Status(winrt::hstring const& value); | ||
| winrt::hstring Status() { return m_status; }; | ||
|
|
||
| void Value(double value); | ||
| double Value() { return m_value; }; | ||
|
|
||
| void ValueStringOverride(winrt::hstring const& value); | ||
| winrt::hstring ValueStringOverride() { return m_valueStringOverride; }; | ||
|
|
||
| // Fluent setters | ||
| winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationProgressBar SetTitle(winrt::hstring const& value); | ||
| winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationProgressBar BindTitle(); | ||
|
|
||
| winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationProgressBar SetStatus(winrt::hstring const& value); | ||
| winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationProgressBar BindStatus(); | ||
|
|
||
| winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationProgressBar SetValue(double value); | ||
| winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationProgressBar BindValue(); | ||
|
|
||
| winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationProgressBar SetValueStringOverride(winrt::hstring const& value); | ||
| winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationProgressBar BindValueStringOverride(); | ||
|
|
||
| // IStringable | ||
| winrt::hstring ToString(); | ||
|
|
||
| private: | ||
| enum class BindMode {NotSet, Bind, Value}; | ||
|
|
||
| BindMode m_titleBindMode; | ||
| winrt::hstring m_title; | ||
| BindMode m_statusBindMode; | ||
| winrt::hstring m_status; | ||
| BindMode m_valueBindMode; | ||
| double m_value; | ||
| BindMode m_valueStringOverrideBindMode; | ||
| winrt::hstring m_valueStringOverride; | ||
| }; | ||
| } | ||
| namespace winrt::Microsoft::Windows::AppNotifications::Builder::factory_implementation | ||
| { | ||
| struct AppNotificationProgressBar : AppNotificationProgressBarT<AppNotificationProgressBar, implementation::AppNotificationProgressBar> | ||
| { | ||
| }; | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.