-
Notifications
You must be signed in to change notification settings - Fork 321
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AppNotificationBuilder - ProgressBar (#2780)
* First iteration * Fix formatting issues * Remove all references to toast * Add ProgressBar * Remove getters and other nits * Add XML outputs for all examples * Update examples and fix missing png * Add limitations * Add ArgumentSerializer and rename APIs * Fix some nits * Fix audio ctors * Add Deserializer functions and example * Apply review changes * Update AppNotificationBuilder-spec.md * Initial commit * Working on it * Add AppNotificationContent * Current impl * Working on unit tests * Added unit tests * Add Audio tests * Update APITests.cpp * Remove spec from PR * Rename AppNotification Builder API to match specs (#2766) * Renaming to match specs * Adding latest changes to specs * Code cleanup * Updating to reflect latest changes to the specs doc Co-authored-by: Eric Langlois <[email protected]> * Initial implementation * Update the spec with BuildNotification * Remove unused files * Add copyright to all files * Update AppNotificationBuilder.idl Adding copyright notice * Update pch.cpp Adding copyright notice * Update WindowsAppRuntime_DLL.vcxproj Removing references to fmt lib * Update packages.config Removing reference to fmt * Update AppNotificationBuilder.cpp Removing fmt since we won't be using and to unblock the build pipelines * Fixing build break * Addressing comments * Update error codes with messages * Add helper file * Add SetTimestamp impl * Add AppNotificationAudioLooping * Add IsSupported to attributes * Don't mix binding and value states * Code cleanup * Using printf as it is the norm for the builder * look proper * spacing * Reorder functions in idl to help github track changes properly * Keeping all progressBar tests together * PR feedback Co-authored-by: Paul Purifoy <[email protected]> Co-authored-by: Paul Purifoy <[email protected]> Co-authored-by: Eric Langlois <[email protected]>
- Loading branch information
1 parent
3d9830d
commit 5e4961a
Showing
8 changed files
with
334 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
dev/AppNotifications/AppNotificationBuilder/AppNotificationProgressBar.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
{ | ||
m_title = value; | ||
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(); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
dev/AppNotifications/AppNotificationBuilder/AppNotificationProgressBar.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
{ | ||
}; | ||
} |
Oops, something went wrong.