From 312548952ca56c3316ca2e820c8c37ef62eb1f4e Mon Sep 17 00:00:00 2001 From: T Paine <30241445+teaP@users.noreply.github.com> Date: Tue, 27 Oct 2020 15:16:15 -0700 Subject: [PATCH] Adding InfoBar Control (#3325) * Remove prototype infobar * Added blank InfoBar back. * Copied over most properties and test app contents. * Added back event args and handle ShowCloseButton. * Updated action button params to ActionButton, added IsIconVisible, hooked up IconSource, renamed ShowCloseButton -> IsUserDismissable * Added back the events. * Added custom content area. * Added InfoBarPanel to change between horizontal and vertical layout depending on if the content fits. * Added CloseButtonStyle. * Clean up markup, moved magic numbers into themeresources. * Added AutomationPeer and notifications. * Cleaned up resources, added high contrast colors and border. * UI updates to match figma. * Word wrapping and layout * Hopefully fixed layout issues. * Updates following API review. * Add more tests. * Cleanup! * Notification update. * Comment clarification. * Update to Background property * PR fixes * Fixing solution file * TextBlock -> FontIcon * Update brush names, critical -> error, added icon brushes for different severities. * Separate foreground colors for title and message. * Fix build warning * This was incorrect, I have no idea why this made it build on github. * Add tooltip to close button * Attempt to fix solution * Fix for RS2 --- FeatureAreas.props | 5 +- MUXControls.sln | 27 +- MUXControlsInnerLoop.sln | 28 ++ .../CloseButtonClickEventArgs.properties.cpp | 16 + dev/Generated/InfoBar.properties.cpp | 465 ++++++++++++++++++ dev/Generated/InfoBar.properties.h | 117 +++++ .../InfoBarAutomationPeer.properties.cpp | 16 + .../InfoBarClosedEventArgs.properties.cpp | 16 + .../InfoBarClosingEventArgs.properties.cpp | 16 + dev/Generated/InfoBarPanel.properties.cpp | 76 +++ dev/Generated/InfoBarPanel.properties.h | 26 + .../InfoBarTemplateSettings.properties.cpp | 54 ++ .../InfoBarTemplateSettings.properties.h | 21 + dev/InfoBar/InfoBar.cpp | 236 +++++++++ dev/InfoBar/InfoBar.h | 56 +++ dev/InfoBar/InfoBar.idl | 143 ++++++ dev/InfoBar/InfoBar.vcxitems | 52 ++ dev/InfoBar/InfoBar.xaml | 219 +++++++++ dev/InfoBar/InfoBarAutomationPeer.cpp | 68 +++ dev/InfoBar/InfoBarAutomationPeer.h | 22 + dev/InfoBar/InfoBarClosedEventArgs.cpp | 13 + dev/InfoBar/InfoBarClosedEventArgs.h | 14 + dev/InfoBar/InfoBarClosingEventArgs.cpp | 23 + dev/InfoBar/InfoBarClosingEventArgs.h | 18 + dev/InfoBar/InfoBarPanel.cpp | 134 +++++ dev/InfoBar/InfoBarPanel.h | 18 + dev/InfoBar/InfoBarTemplateSettings.cpp | 11 + dev/InfoBar/InfoBarTemplateSettings.h | 15 + dev/InfoBar/InfoBar_themeresources.xaml | 124 +++++ dev/InfoBar/InteractionTests/InfoBarTests.cs | 163 ++++++ .../InfoBar_InteractionTests.shproj | 2 +- dev/InfoBar/Strings/en-us/Resources.resw | 140 ++++++ dev/InfoBar/TestUI/InfoBar.cs | 428 ---------------- dev/InfoBar/TestUI/InfoBarPage.xaml | 194 ++++---- dev/InfoBar/TestUI/InfoBarPage.xaml.cs | 258 ++++------ dev/InfoBar/TestUI/InfoBar_TestUI.projitems | 7 +- dev/InfoBar/TestUI/InfoBar_TestUI.shproj | 2 +- dev/InfoBar/TestUI/Themes/InfoBarStyles.xaml | 184 ------- dev/ResourceHelper/ResourceAccessor.h | 5 + dev/Telemetry/RuntimeProfiler.h | 1 + dev/dll/Microsoft.UI.Xaml.vcxproj | 9 +- test/MUXControlsTestApp/App.xaml.cs | 4 - 42 files changed, 2531 insertions(+), 915 deletions(-) create mode 100644 dev/Generated/CloseButtonClickEventArgs.properties.cpp create mode 100644 dev/Generated/InfoBar.properties.cpp create mode 100644 dev/Generated/InfoBar.properties.h create mode 100644 dev/Generated/InfoBarAutomationPeer.properties.cpp create mode 100644 dev/Generated/InfoBarClosedEventArgs.properties.cpp create mode 100644 dev/Generated/InfoBarClosingEventArgs.properties.cpp create mode 100644 dev/Generated/InfoBarPanel.properties.cpp create mode 100644 dev/Generated/InfoBarPanel.properties.h create mode 100644 dev/Generated/InfoBarTemplateSettings.properties.cpp create mode 100644 dev/Generated/InfoBarTemplateSettings.properties.h create mode 100644 dev/InfoBar/InfoBar.cpp create mode 100644 dev/InfoBar/InfoBar.h create mode 100644 dev/InfoBar/InfoBar.idl create mode 100644 dev/InfoBar/InfoBar.vcxitems create mode 100644 dev/InfoBar/InfoBar.xaml create mode 100644 dev/InfoBar/InfoBarAutomationPeer.cpp create mode 100644 dev/InfoBar/InfoBarAutomationPeer.h create mode 100644 dev/InfoBar/InfoBarClosedEventArgs.cpp create mode 100644 dev/InfoBar/InfoBarClosedEventArgs.h create mode 100644 dev/InfoBar/InfoBarClosingEventArgs.cpp create mode 100644 dev/InfoBar/InfoBarClosingEventArgs.h create mode 100644 dev/InfoBar/InfoBarPanel.cpp create mode 100644 dev/InfoBar/InfoBarPanel.h create mode 100644 dev/InfoBar/InfoBarTemplateSettings.cpp create mode 100644 dev/InfoBar/InfoBarTemplateSettings.h create mode 100644 dev/InfoBar/InfoBar_themeresources.xaml create mode 100644 dev/InfoBar/Strings/en-us/Resources.resw delete mode 100644 dev/InfoBar/TestUI/InfoBar.cs delete mode 100644 dev/InfoBar/TestUI/Themes/InfoBarStyles.xaml diff --git a/FeatureAreas.props b/FeatureAreas.props index 643bb2a819..14673d4fa9 100644 --- a/FeatureAreas.props +++ b/FeatureAreas.props @@ -84,6 +84,10 @@ + + + productOnly + @@ -266,7 +270,6 @@ $(DefineConstants);FEATURE_SCROLLPRESENTER_ENABLED - $(DefineConstants);FEATURE_INFOBAR_ENABLED $(DefineConstants);FEATURE_NAVIGATIONVIEW_ENABLED $(DefineConstants);INNERLOOP_BUILD diff --git a/MUXControls.sln b/MUXControls.sln index 4fd22e73a1..09b21383da 100644 --- a/MUXControls.sln +++ b/MUXControls.sln @@ -636,12 +636,6 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "TabView_APITests", "dev\Tab EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "NumberBox_APITests", "dev\NumberBox\APITests\NumberBox_APITests.shproj", "{80AF98CA-BC1D-4011-8460-5671799EC419}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "InfoBar", "InfoBar", "{4F935F95-BCD6-4DEF-B897-7F5D8799206A}" -EndProject -Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "InfoBar_InteractionTests", "dev\InfoBar\InteractionTests\InfoBar_InteractionTests.shproj", "{8CA62B44-3673-4037-8D9C-934D42904BB9}" -EndProject -Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "InfoBar_TestUI", "dev\InfoBar\TestUI\InfoBar_TestUI.shproj", "{ABBC2446-9B41-4400-8CF6-AF2CF8C597B2}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TestInfra", "TestInfra", "{C0215617-A17B-45DB-9CDA-C46C0923DA55}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AppTestAutomationHelpers", "test\testinfra\AppTestAutomationHelpers\AppTestAutomationHelpers.vcxproj", "{128E6F7A-578C-48DC-BD3F-750EC662C268}" @@ -671,6 +665,14 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "PagerControl_InteractionTes EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "PagerControl_APITests", "dev\PagerControl\APITests\PagerControl_APITests.shproj", "{CB2352E2-D633-41A3-8CDC-B28731A4C490}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "InfoBar", "InfoBar", "{CEFD707F-6686-4CF4-8D4C-B5FECD50D739}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InfoBar", "dev\InfoBar\InfoBar.vcxitems", "{CCC102B7-F5EF-479D-94F1-008D189448B1}" +EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "InfoBar_TestUI", "dev\InfoBar\TestUI\InfoBar_TestUI.shproj", "{32DFAF1E-C2EC-4C52-A4D8-B3A3946242B4}" +EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "InfoBar_InteractionTests", "dev\InfoBar\InteractionTests\InfoBar_InteractionTests.shproj", "{F470A64E-780E-45AA-ABB7-73A8734E51D7}" +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution dev\ComboBox\ComboBox.vcxitems*{00523caf-422a-4185-9392-d374b72a019a}*SharedItemsImports = 9 @@ -712,6 +714,7 @@ Global dev\MenuFlyout\TestUI\MenuFlyout_TestUI.projitems*{2ef860e2-8766-41fc-bde2-e6b18bb8c206}*SharedItemsImports = 13 dev\TabView\APITests\TabView_APITests.projitems*{2f4e95e9-f729-481c-b9aa-c9bec91ae395}*SharedItemsImports = 13 dev\ParallaxView\ParallaxView.vcxitems*{3095445a-afcd-5154-ac36-9770e6ec1aa5}*SharedItemsImports = 9 + dev\InfoBar\TestUI\InfoBar_TestUI.projitems*{32dfaf1e-c2ec-4c52-a4d8-b3a3946242b4}*SharedItemsImports = 13 dev\RadioMenuFlyoutItem\RadioMenuFlyoutItem.vcxitems*{3353a4a7-87b3-4e43-8f8d-43c7380d1d56}*SharedItemsImports = 9 dev\Lights\Lights.vcxitems*{3479a3ae-2854-4bec-80ab-eab0772cb90a}*SharedItemsImports = 9 dev\ScrollPresenter\ScrollPresenter.vcxitems*{359544aa-a8cd-715c-cc36-f770e6e81aa0}*SharedItemsImports = 9 @@ -771,7 +774,6 @@ Global dev\RadialGradientBrush\RadialGradientBrush.vcxitems*{8b056b8f-c1ab-4a80-bd17-deace9897e6a}*SharedItemsImports = 9 dev\MenuBar\MenuBar.vcxitems*{8bc9ceb8-8b4a-11d0-8d11-00a0c91bc942}*SharedItemsImports = 9 dev\ProgressRing\InteractionTests\ProgressRing_InteractionTests.projitems*{8c2d60af-44bc-47da-8e44-d62e639bfc0a}*SharedItemsImports = 13 - dev\InfoBar\InteractionTests\InfoBar_InteractionTests.projitems*{8ca62b44-3673-4037-8d9c-934d42904bb9}*SharedItemsImports = 13 dev\CalendarDatePicker\TestUI\CalendarDatePicker_TestUI.projitems*{8cd16537-aad0-4905-aa85-3face7f99034}*SharedItemsImports = 13 dev\TwoPaneView\TwoPaneView.vcxitems*{8d0e4610-b51d-45c1-8b82-240bd2f73a92}*SharedItemsImports = 9 dev\Repeater\APITests\Repeater_APITests.projitems*{8d2da979-6313-49e2-8cf3-b568436d2944}*SharedItemsImports = 13 @@ -794,7 +796,6 @@ Global dev\Materials\Acrylic\TestUI\AcrylicBrush_TestUI.projitems*{a800e818-7212-4fd7-ae3a-1dcab539db87}*SharedItemsImports = 13 dev\CalendarView\APITests\CalendarView_APITests.projitems*{aa73fbeb-6b3b-490c-b582-3993f0040061}*SharedItemsImports = 13 dev\PagerControl\PagerControl.vcxitems*{ab3261a7-9a8d-4a27-aea2-3aac0419c889}*SharedItemsImports = 9 - dev\InfoBar\TestUI\InfoBar_TestUI.projitems*{abbc2446-9b41-4400-8cf6-af2cf8c597b2}*SharedItemsImports = 13 dev\AnimatedVisualPlayer\AnimatedVisualPlayer.vcxitems*{ad0c90b0-4845-4d4b-88f1-86f653f8171b}*SharedItemsImports = 4 dev\AutoSuggestBox\AutoSuggestBox.vcxitems*{ad0c90b0-4845-4d4b-88f1-86f653f8171b}*SharedItemsImports = 4 dev\CalendarDatePicker\CalendarDatePicker.vcxitems*{ad0c90b0-4845-4d4b-88f1-86f653f8171b}*SharedItemsImports = 4 @@ -812,6 +813,7 @@ Global dev\Effects\Microsoft.UI.Composition.Effects.vcxitems*{ad0c90b0-4845-4d4b-88f1-86f653f8171b}*SharedItemsImports = 4 dev\FlipView\FlipView.vcxitems*{ad0c90b0-4845-4d4b-88f1-86f653f8171b}*SharedItemsImports = 4 dev\IconSource\IconSource.vcxitems*{ad0c90b0-4845-4d4b-88f1-86f653f8171b}*SharedItemsImports = 4 + dev\InfoBar\InfoBar.vcxitems*{ad0c90b0-4845-4d4b-88f1-86f653f8171b}*SharedItemsImports = 4 dev\Interactions\ButtonInteraction\ButtonInteraction.vcxitems*{ad0c90b0-4845-4d4b-88f1-86f653f8171b}*SharedItemsImports = 4 dev\Interactions\SliderInteraction\SliderInteraction.vcxitems*{ad0c90b0-4845-4d4b-88f1-86f653f8171b}*SharedItemsImports = 4 dev\LayoutPanel\LayoutPanel.vcxitems*{ad0c90b0-4845-4d4b-88f1-86f653f8171b}*SharedItemsImports = 4 @@ -879,6 +881,7 @@ Global dev\ComboBox\APITests\ComboBox_APITests.projitems*{ca704a8c-2624-4630-89a0-d86cb1ee409a}*SharedItemsImports = 13 dev\PagerControl\APITests\PagerControl_APITests.projitems*{cb2352e2-d633-41a3-8cdc-b28731a4c490}*SharedItemsImports = 13 dev\AnimatedVisualPlayer\InteractionTests\AnimatedVisualPlayer_InteractionTests.projitems*{cbaaccf6-a27d-40b3-980b-adf51a2ebb89}*SharedItemsImports = 13 + dev\InfoBar\InfoBar.vcxitems*{ccc102b7-f5ef-479d-94f1-008d189448b1}*SharedItemsImports = 9 dev\LayoutPanel\APITests\LayoutPanel_APITests.projitems*{cddf46ef-aa2d-4bb3-b33e-98b3dbb3c41b}*SharedItemsImports = 13 dev\Interactions\SliderInteraction\SliderInteraction.vcxitems*{d097a4d5-6b61-424d-99f0-f335eff41665}*SharedItemsImports = 9 dev\TabView\InteractionTests\TabView_InteractionTests.projitems*{d1e297b4-5e5b-4807-8624-4141c817a98a}*SharedItemsImports = 13 @@ -982,6 +985,7 @@ Global dev\PullToRefresh\RefreshVisualizer\RefreshVisualizer.vcxitems*{ed7dba65-8f09-44f3-8d25-7bb5a7a89609}*SharedItemsImports = 9 dev\TreeView\TreeView.vcxitems*{eeb38379-3a5c-439f-bb5e-535d75f2b6c1}*SharedItemsImports = 9 dev\PullToRefresh\RefreshContainer\InteractionTests\RefreshContainer_InteractionTests.projitems*{f30fe0d3-2e44-405e-8519-ec3ab098c41f}*SharedItemsImports = 13 + dev\InfoBar\InteractionTests\InfoBar_InteractionTests.projitems*{f470a64e-780e-45aa-abb7-73a8734e51d7}*SharedItemsImports = 13 dev\SplitView\SplitView.vcxitems*{f567d0a2-9c61-4793-ae79-12da915ac11f}*SharedItemsImports = 9 dev\Materials\Acrylic\InteractionTests\AcrylicBrush_InteractionTests.projitems*{f601284a-00c1-49f9-99b3-70d45585f784}*SharedItemsImports = 13 dev\SplitButton\SplitButton.vcxitems*{faf114dd-af1f-4d9f-a511-354c19912aad}*SharedItemsImports = 9 @@ -1677,9 +1681,6 @@ Global {74D18B1B-5F6B-4534-945B-131E8E3206FB} = {0115F80C-AB97-412D-85D9-33A5188F8907} {2F4E95E9-F729-481C-B9AA-C9BEC91AE395} = {B3E64837-A5E4-49CB-97FF-A365307B9191} {80AF98CA-BC1D-4011-8460-5671799EC419} = {B45B3F3E-6761-4CFC-9A8F-90F232DD28F2} - {4F935F95-BCD6-4DEF-B897-7F5D8799206A} = {67599AD5-51EC-44CB-85CE-B60CD8CBA270} - {8CA62B44-3673-4037-8D9C-934D42904BB9} = {4F935F95-BCD6-4DEF-B897-7F5D8799206A} - {ABBC2446-9B41-4400-8CF6-AF2CF8C597B2} = {4F935F95-BCD6-4DEF-B897-7F5D8799206A} {C0215617-A17B-45DB-9CDA-C46C0923DA55} = {D3327F36-E161-4FED-A0F4-56F2B735827E} {128E6F7A-578C-48DC-BD3F-750EC662C268} = {C0215617-A17B-45DB-9CDA-C46C0923DA55} {107794D7-4BE0-407E-A76C-EFA46D1E9F93} = {C0215617-A17B-45DB-9CDA-C46C0923DA55} @@ -1691,6 +1692,10 @@ Global {225C4174-3141-49B8-ADE2-C7D3408D5103} = {11DC7B03-88FB-4985-BF77-2BB3A13C75A8} {4F64C819-664F-436A-BCDB-8AB3019B9DD5} = {11DC7B03-88FB-4985-BF77-2BB3A13C75A8} {CB2352E2-D633-41A3-8CDC-B28731A4C490} = {11DC7B03-88FB-4985-BF77-2BB3A13C75A8} + {CEFD707F-6686-4CF4-8D4C-B5FECD50D739} = {67599AD5-51EC-44CB-85CE-B60CD8CBA270} + {CCC102B7-F5EF-479D-94F1-008D189448B1} = {CEFD707F-6686-4CF4-8D4C-B5FECD50D739} + {32DFAF1E-C2EC-4C52-A4D8-B3A3946242B4} = {CEFD707F-6686-4CF4-8D4C-B5FECD50D739} + {F470A64E-780E-45AA-ABB7-73A8734E51D7} = {CEFD707F-6686-4CF4-8D4C-B5FECD50D739} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {D93836AB-52D3-4DE2-AE25-23F26F55ECED} diff --git a/MUXControlsInnerLoop.sln b/MUXControlsInnerLoop.sln index 543323cd75..e55d4456bc 100644 --- a/MUXControlsInnerLoop.sln +++ b/MUXControlsInnerLoop.sln @@ -480,6 +480,14 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "PagerControl_InteractionTes EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "PagerControl_APITests", "dev\PagerControl\APITests\PagerControl_APITests.shproj", "{CB2352E2-D633-41A3-8CDC-B28731A4C490}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "InfoBar", "InfoBar", "{1AD0CB4F-47F0-432B-8D4F-CE33FA3EB8A9}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InfoBar", "dev\InfoBar\InfoBar.vcxitems", "{CCC102B7-F5EF-479D-94F1-008D189448B1}" +EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "InfoBar_InteractionTests", "dev\InfoBar\InteractionTests\InfoBar_InteractionTests.shproj", "{F470A64E-780E-45AA-ABB7-73A8734E51D7}" +EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "InfoBar_TestUI", "dev\InfoBar\TestUI\InfoBar_TestUI.shproj", "{32DFAF1E-C2EC-4C52-A4D8-B3A3946242B4}" +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution dev\ComboBox\ComboBox.vcxitems*{00523caf-422a-4185-9392-d374b72a019a}*SharedItemsImports = 9 @@ -518,6 +526,7 @@ Global dev\Repeater\TestUI\Repeater_TestUI.projitems*{2ed883f5-20db-4445-8c96-517a21e5e657}*SharedItemsImports = 13 dev\MenuFlyout\TestUI\MenuFlyout_TestUI.projitems*{2ef860e2-8766-41fc-bde2-e6b18bb8c206}*SharedItemsImports = 13 dev\ParallaxView\ParallaxView.vcxitems*{3095445a-afcd-5154-ac36-9770e6ec1aa5}*SharedItemsImports = 9 + dev\InfoBar\TestUI\InfoBar_TestUI.projitems*{32dfaf1e-c2ec-4c52-a4d8-b3a3946242b4}*SharedItemsImports = 13 dev\RadioMenuFlyoutItem\RadioMenuFlyoutItem.vcxitems*{3353a4a7-87b3-4e43-8f8d-43c7380d1d56}*SharedItemsImports = 9 dev\Lights\Lights.vcxitems*{3479a3ae-2854-4bec-80ab-eab0772cb90a}*SharedItemsImports = 9 dev\ScrollPresenter\ScrollPresenter.vcxitems*{359544aa-a8cd-715c-cc36-f770e6e81aa0}*SharedItemsImports = 9 @@ -601,9 +610,12 @@ Global dev\DropDownButton\DropDownButton.vcxitems*{ad0c90b0-4845-4d4b-88f1-86f653f8171b}*SharedItemsImports = 4 dev\Effects\Microsoft.UI.Composition.Effects.vcxitems*{ad0c90b0-4845-4d4b-88f1-86f653f8171b}*SharedItemsImports = 4 dev\IconSource\IconSource.vcxitems*{ad0c90b0-4845-4d4b-88f1-86f653f8171b}*SharedItemsImports = 4 + dev\InfoBar\InfoBar.vcxitems*{ad0c90b0-4845-4d4b-88f1-86f653f8171b}*SharedItemsImports = 4 dev\Lights\Lights.vcxitems*{ad0c90b0-4845-4d4b-88f1-86f653f8171b}*SharedItemsImports = 4 dev\Materials\Acrylic\AcrylicBrush.vcxitems*{ad0c90b0-4845-4d4b-88f1-86f653f8171b}*SharedItemsImports = 4 dev\Materials\Reveal\RevealBrush.vcxitems*{ad0c90b0-4845-4d4b-88f1-86f653f8171b}*SharedItemsImports = 4 + dev\NumberBox\NumberBox.vcxitems*{ad0c90b0-4845-4d4b-88f1-86f653f8171b}*SharedItemsImports = 4 + dev\Repeater\Repeater.vcxitems*{ad0c90b0-4845-4d4b-88f1-86f653f8171b}*SharedItemsImports = 4 dev\ResourceHelper\ResourceHelper.vcxitems*{ad0c90b0-4845-4d4b-88f1-86f653f8171b}*SharedItemsImports = 4 dev\SplitButton\SplitButton.vcxitems*{ad0c90b0-4845-4d4b-88f1-86f653f8171b}*SharedItemsImports = 4 dev\Telemetry\Telemetry.vcxitems*{ad0c90b0-4845-4d4b-88f1-86f653f8171b}*SharedItemsImports = 4 @@ -632,6 +644,7 @@ Global dev\CheckBox\CheckBox.vcxitems*{c5c4a801-1f48-461c-a817-233d5fbd77aa}*SharedItemsImports = 9 dev\PagerControl\APITests\PagerControl_APITests.projitems*{cb2352e2-d633-41a3-8cdc-b28731a4c490}*SharedItemsImports = 13 dev\AnimatedVisualPlayer\InteractionTests\AnimatedVisualPlayer_InteractionTests.projitems*{cbaaccf6-a27d-40b3-980b-adf51a2ebb89}*SharedItemsImports = 13 + dev\InfoBar\InfoBar.vcxitems*{ccc102b7-f5ef-479d-94f1-008d189448b1}*SharedItemsImports = 9 dev\LayoutPanel\APITests\LayoutPanel_APITests.projitems*{cddf46ef-aa2d-4bb3-b33e-98b3dbb3c41b}*SharedItemsImports = 13 dev\Interactions\SliderInteraction\SliderInteraction.vcxitems*{d097a4d5-6b61-424d-99f0-f335eff41665}*SharedItemsImports = 9 dev\TabView\InteractionTests\TabView_InteractionTests.projitems*{d1e297b4-5e5b-4807-8624-4141c817a98a}*SharedItemsImports = 13 @@ -643,6 +656,9 @@ Global dev\TreeView\APITests\TreeView_APITests.projitems*{de885c66-929c-464e-bac4-3e076ec46483}*SharedItemsImports = 13 dev\Pivot\TestUI\Pivot_TestUI.projitems*{deb3fa60-e4a7-4735-89f2-363c7c56b428}*SharedItemsImports = 13 dev\CommonManaged\CommonManaged.projitems*{dedc1e4f-cfa5-4443-83eb-e79d425df7e7}*SharedItemsImports = 4 + dev\InfoBar\TestUI\InfoBar_TestUI.projitems*{dedc1e4f-cfa5-4443-83eb-e79d425df7e7}*SharedItemsImports = 4 + dev\NumberBox\APITests\NumberBox_APITests.projitems*{dedc1e4f-cfa5-4443-83eb-e79d425df7e7}*SharedItemsImports = 4 + dev\NumberBox\TestUI\NumberBox_TestUI.projitems*{dedc1e4f-cfa5-4443-83eb-e79d425df7e7}*SharedItemsImports = 4 test\TestAppUtils\TestAppUtils.projitems*{dedc1e4f-cfa5-4443-83eb-e79d425df7e7}*SharedItemsImports = 4 dev\SplitButton\InteractionTests\SplitButton_InteractionTests.projitems*{e1c861e2-c4d9-41e1-aed7-5e203451bd4d}*SharedItemsImports = 13 dev\DatePicker\TestUI\DatePicker_TestUI.projitems*{e20f725c-3a53-463b-ada9-ff2088aaca4d}*SharedItemsImports = 13 @@ -655,9 +671,13 @@ Global dev\PullToRefresh\RefreshVisualizer\RefreshVisualizer.vcxitems*{ed7dba65-8f09-44f3-8d25-7bb5a7a89609}*SharedItemsImports = 9 dev\TreeView\TreeView.vcxitems*{eeb38379-3a5c-439f-bb5e-535d75f2b6c1}*SharedItemsImports = 9 dev\PullToRefresh\RefreshContainer\InteractionTests\RefreshContainer_InteractionTests.projitems*{f30fe0d3-2e44-405e-8519-ec3ab098c41f}*SharedItemsImports = 13 + dev\InfoBar\InteractionTests\InfoBar_InteractionTests.projitems*{f470a64e-780e-45aa-abb7-73a8734e51d7}*SharedItemsImports = 13 dev\Materials\Acrylic\InteractionTests\AcrylicBrush_InteractionTests.projitems*{f601284a-00c1-49f9-99b3-70d45585f784}*SharedItemsImports = 13 dev\SplitButton\SplitButton.vcxitems*{faf114dd-af1f-4d9f-a511-354c19912aad}*SharedItemsImports = 9 dev\CommonManaged\CommonManaged.projitems*{fbc396f5-26dd-4ca3-981e-c7bc9fea4546}*SharedItemsImports = 4 + dev\InfoBar\TestUI\InfoBar_TestUI.projitems*{fbc396f5-26dd-4ca3-981e-c7bc9fea4546}*SharedItemsImports = 4 + dev\NumberBox\APITests\NumberBox_APITests.projitems*{fbc396f5-26dd-4ca3-981e-c7bc9fea4546}*SharedItemsImports = 4 + dev\NumberBox\TestUI\NumberBox_TestUI.projitems*{fbc396f5-26dd-4ca3-981e-c7bc9fea4546}*SharedItemsImports = 4 test\TestAppUtils\TestAppUtils.projitems*{fbc396f5-26dd-4ca3-981e-c7bc9fea4546}*SharedItemsImports = 4 dev\Slider\Slider.vcxitems*{fc2178ca-7f72-40f0-916c-a2b3750bbb6c}*SharedItemsImports = 9 dev\LayoutPanel\LayoutPanel.vcxitems*{fd3c1a00-0d07-4849-a3b9-646f0ff21d7b}*SharedItemsImports = 9 @@ -1110,6 +1130,14 @@ Global {225C4174-3141-49B8-ADE2-C7D3408D5103} = {E7C2104F-770D-4375-8D3A-D173F222273A} {4F64C819-664F-436A-BCDB-8AB3019B9DD5} = {E7C2104F-770D-4375-8D3A-D173F222273A} {CB2352E2-D633-41A3-8CDC-B28731A4C490} = {E7C2104F-770D-4375-8D3A-D173F222273A} + {0EC260CC-03C7-4790-B16A-43428EBCF5AD} = {67599AD5-51EC-44CB-85CE-B60CD8CBA270} + {3566798E-9E24-44EF-B89D-2A62AE8F697A} = {0EC260CC-03C7-4790-B16A-43428EBCF5AD} + {675121BF-CABC-48E7-9C9D-4571BC507406} = {0EC260CC-03C7-4790-B16A-43428EBCF5AD} + {675373CE-6ACD-4C4B-A009-09A3C9B218E6} = {0EC260CC-03C7-4790-B16A-43428EBCF5AD} + {1AD0CB4F-47F0-432B-8D4F-CE33FA3EB8A9} = {67599AD5-51EC-44CB-85CE-B60CD8CBA270} + {CCC102B7-F5EF-479D-94F1-008D189448B1} = {1AD0CB4F-47F0-432B-8D4F-CE33FA3EB8A9} + {F470A64E-780E-45AA-ABB7-73A8734E51D7} = {1AD0CB4F-47F0-432B-8D4F-CE33FA3EB8A9} + {32DFAF1E-C2EC-4C52-A4D8-B3A3946242B4} = {1AD0CB4F-47F0-432B-8D4F-CE33FA3EB8A9} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {D93836AB-52D3-4DE2-AE25-23F26F55ECED} diff --git a/dev/Generated/CloseButtonClickEventArgs.properties.cpp b/dev/Generated/CloseButtonClickEventArgs.properties.cpp new file mode 100644 index 0000000000..78a73ce19b --- /dev/null +++ b/dev/Generated/CloseButtonClickEventArgs.properties.cpp @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +// DO NOT EDIT! This file was generated by CustomTasks.DependencyPropertyCodeGen +#include "pch.h" +#include "common.h" +#include "CloseButtonClickEventArgs.h" + +namespace winrt::Microsoft::UI::Xaml::Controls +{ + CppWinRTActivatableClassWithBasicFactory(CloseButtonClickEventArgs) +} + +#include "CloseButtonClickEventArgs.g.cpp" + + diff --git a/dev/Generated/InfoBar.properties.cpp b/dev/Generated/InfoBar.properties.cpp new file mode 100644 index 0000000000..2ba3cbf7f5 --- /dev/null +++ b/dev/Generated/InfoBar.properties.cpp @@ -0,0 +1,465 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +// DO NOT EDIT! This file was generated by CustomTasks.DependencyPropertyCodeGen +#include "pch.h" +#include "common.h" +#include "InfoBar.h" + +namespace winrt::Microsoft::UI::Xaml::Controls +{ + CppWinRTActivatableClassWithDPFactory(InfoBar) +} + +#include "InfoBar.g.cpp" + +GlobalDependencyProperty InfoBarProperties::s_ActionButtonProperty{ nullptr }; +GlobalDependencyProperty InfoBarProperties::s_CloseButtonCommandProperty{ nullptr }; +GlobalDependencyProperty InfoBarProperties::s_CloseButtonCommandParameterProperty{ nullptr }; +GlobalDependencyProperty InfoBarProperties::s_CloseButtonStyleProperty{ nullptr }; +GlobalDependencyProperty InfoBarProperties::s_ContentProperty{ nullptr }; +GlobalDependencyProperty InfoBarProperties::s_ContentTemplateProperty{ nullptr }; +GlobalDependencyProperty InfoBarProperties::s_IconSourceProperty{ nullptr }; +GlobalDependencyProperty InfoBarProperties::s_IsClosableProperty{ nullptr }; +GlobalDependencyProperty InfoBarProperties::s_IsIconVisibleProperty{ nullptr }; +GlobalDependencyProperty InfoBarProperties::s_IsOpenProperty{ nullptr }; +GlobalDependencyProperty InfoBarProperties::s_MessageProperty{ nullptr }; +GlobalDependencyProperty InfoBarProperties::s_SeverityProperty{ nullptr }; +GlobalDependencyProperty InfoBarProperties::s_TemplateSettingsProperty{ nullptr }; +GlobalDependencyProperty InfoBarProperties::s_TitleProperty{ nullptr }; + +InfoBarProperties::InfoBarProperties() + : m_closeButtonClickEventSource{static_cast(this)} + , m_closedEventSource{static_cast(this)} + , m_closingEventSource{static_cast(this)} +{ + EnsureProperties(); +} + +void InfoBarProperties::EnsureProperties() +{ + if (!s_ActionButtonProperty) + { + s_ActionButtonProperty = + InitializeDependencyProperty( + L"ActionButton", + winrt::name_of(), + winrt::name_of(), + false /* isAttached */, + ValueHelper::BoxedDefaultValue(), + nullptr); + } + if (!s_CloseButtonCommandProperty) + { + s_CloseButtonCommandProperty = + InitializeDependencyProperty( + L"CloseButtonCommand", + winrt::name_of(), + winrt::name_of(), + false /* isAttached */, + ValueHelper::BoxedDefaultValue(), + nullptr); + } + if (!s_CloseButtonCommandParameterProperty) + { + s_CloseButtonCommandParameterProperty = + InitializeDependencyProperty( + L"CloseButtonCommandParameter", + winrt::name_of(), + winrt::name_of(), + false /* isAttached */, + ValueHelper::BoxedDefaultValue(), + nullptr); + } + if (!s_CloseButtonStyleProperty) + { + s_CloseButtonStyleProperty = + InitializeDependencyProperty( + L"CloseButtonStyle", + winrt::name_of(), + winrt::name_of(), + false /* isAttached */, + ValueHelper::BoxedDefaultValue(), + nullptr); + } + if (!s_ContentProperty) + { + s_ContentProperty = + InitializeDependencyProperty( + L"Content", + winrt::name_of(), + winrt::name_of(), + false /* isAttached */, + ValueHelper::BoxedDefaultValue(), + nullptr); + } + if (!s_ContentTemplateProperty) + { + s_ContentTemplateProperty = + InitializeDependencyProperty( + L"ContentTemplate", + winrt::name_of(), + winrt::name_of(), + false /* isAttached */, + ValueHelper::BoxedDefaultValue(), + nullptr); + } + if (!s_IconSourceProperty) + { + s_IconSourceProperty = + InitializeDependencyProperty( + L"IconSource", + winrt::name_of(), + winrt::name_of(), + false /* isAttached */, + ValueHelper::BoxedDefaultValue(), + winrt::PropertyChangedCallback(&OnIconSourcePropertyChanged)); + } + if (!s_IsClosableProperty) + { + s_IsClosableProperty = + InitializeDependencyProperty( + L"IsClosable", + winrt::name_of(), + winrt::name_of(), + false /* isAttached */, + ValueHelper::BoxValueIfNecessary(true), + winrt::PropertyChangedCallback(&OnIsClosablePropertyChanged)); + } + if (!s_IsIconVisibleProperty) + { + s_IsIconVisibleProperty = + InitializeDependencyProperty( + L"IsIconVisible", + winrt::name_of(), + winrt::name_of(), + false /* isAttached */, + ValueHelper::BoxValueIfNecessary(true), + winrt::PropertyChangedCallback(&OnIsIconVisiblePropertyChanged)); + } + if (!s_IsOpenProperty) + { + s_IsOpenProperty = + InitializeDependencyProperty( + L"IsOpen", + winrt::name_of(), + winrt::name_of(), + false /* isAttached */, + ValueHelper::BoxValueIfNecessary(false), + winrt::PropertyChangedCallback(&OnIsOpenPropertyChanged)); + } + if (!s_MessageProperty) + { + s_MessageProperty = + InitializeDependencyProperty( + L"Message", + winrt::name_of(), + winrt::name_of(), + false /* isAttached */, + ValueHelper::BoxedDefaultValue(), + nullptr); + } + if (!s_SeverityProperty) + { + s_SeverityProperty = + InitializeDependencyProperty( + L"Severity", + winrt::name_of(), + winrt::name_of(), + false /* isAttached */, + ValueHelper::BoxValueIfNecessary(winrt::InfoBarSeverity::Informational), + winrt::PropertyChangedCallback(&OnSeverityPropertyChanged)); + } + if (!s_TemplateSettingsProperty) + { + s_TemplateSettingsProperty = + InitializeDependencyProperty( + L"TemplateSettings", + winrt::name_of(), + winrt::name_of(), + false /* isAttached */, + ValueHelper::BoxedDefaultValue(), + nullptr); + } + if (!s_TitleProperty) + { + s_TitleProperty = + InitializeDependencyProperty( + L"Title", + winrt::name_of(), + winrt::name_of(), + false /* isAttached */, + ValueHelper::BoxedDefaultValue(), + nullptr); + } +} + +void InfoBarProperties::ClearProperties() +{ + s_ActionButtonProperty = nullptr; + s_CloseButtonCommandProperty = nullptr; + s_CloseButtonCommandParameterProperty = nullptr; + s_CloseButtonStyleProperty = nullptr; + s_ContentProperty = nullptr; + s_ContentTemplateProperty = nullptr; + s_IconSourceProperty = nullptr; + s_IsClosableProperty = nullptr; + s_IsIconVisibleProperty = nullptr; + s_IsOpenProperty = nullptr; + s_MessageProperty = nullptr; + s_SeverityProperty = nullptr; + s_TemplateSettingsProperty = nullptr; + s_TitleProperty = nullptr; +} + +void InfoBarProperties::OnIconSourcePropertyChanged( + winrt::DependencyObject const& sender, + winrt::DependencyPropertyChangedEventArgs const& args) +{ + auto owner = sender.as(); + winrt::get_self(owner)->OnIconSourcePropertyChanged(args); +} + +void InfoBarProperties::OnIsClosablePropertyChanged( + winrt::DependencyObject const& sender, + winrt::DependencyPropertyChangedEventArgs const& args) +{ + auto owner = sender.as(); + winrt::get_self(owner)->OnIsClosablePropertyChanged(args); +} + +void InfoBarProperties::OnIsIconVisiblePropertyChanged( + winrt::DependencyObject const& sender, + winrt::DependencyPropertyChangedEventArgs const& args) +{ + auto owner = sender.as(); + winrt::get_self(owner)->OnIsIconVisiblePropertyChanged(args); +} + +void InfoBarProperties::OnIsOpenPropertyChanged( + winrt::DependencyObject const& sender, + winrt::DependencyPropertyChangedEventArgs const& args) +{ + auto owner = sender.as(); + winrt::get_self(owner)->OnIsOpenPropertyChanged(args); +} + +void InfoBarProperties::OnSeverityPropertyChanged( + winrt::DependencyObject const& sender, + winrt::DependencyPropertyChangedEventArgs const& args) +{ + auto owner = sender.as(); + winrt::get_self(owner)->OnSeverityPropertyChanged(args); +} + +void InfoBarProperties::ActionButton(winrt::ButtonBase const& value) +{ + [[gsl::suppress(con)]] + { + static_cast(this)->SetValue(s_ActionButtonProperty, ValueHelper::BoxValueIfNecessary(value)); + } +} + +winrt::ButtonBase InfoBarProperties::ActionButton() +{ + return ValueHelper::CastOrUnbox(static_cast(this)->GetValue(s_ActionButtonProperty)); +} + +void InfoBarProperties::CloseButtonCommand(winrt::ICommand const& value) +{ + [[gsl::suppress(con)]] + { + static_cast(this)->SetValue(s_CloseButtonCommandProperty, ValueHelper::BoxValueIfNecessary(value)); + } +} + +winrt::ICommand InfoBarProperties::CloseButtonCommand() +{ + return ValueHelper::CastOrUnbox(static_cast(this)->GetValue(s_CloseButtonCommandProperty)); +} + +void InfoBarProperties::CloseButtonCommandParameter(winrt::IInspectable const& value) +{ + [[gsl::suppress(con)]] + { + static_cast(this)->SetValue(s_CloseButtonCommandParameterProperty, ValueHelper::BoxValueIfNecessary(value)); + } +} + +winrt::IInspectable InfoBarProperties::CloseButtonCommandParameter() +{ + return ValueHelper::CastOrUnbox(static_cast(this)->GetValue(s_CloseButtonCommandParameterProperty)); +} + +void InfoBarProperties::CloseButtonStyle(winrt::Style const& value) +{ + [[gsl::suppress(con)]] + { + static_cast(this)->SetValue(s_CloseButtonStyleProperty, ValueHelper::BoxValueIfNecessary(value)); + } +} + +winrt::Style InfoBarProperties::CloseButtonStyle() +{ + return ValueHelper::CastOrUnbox(static_cast(this)->GetValue(s_CloseButtonStyleProperty)); +} + +void InfoBarProperties::Content(winrt::IInspectable const& value) +{ + [[gsl::suppress(con)]] + { + static_cast(this)->SetValue(s_ContentProperty, ValueHelper::BoxValueIfNecessary(value)); + } +} + +winrt::IInspectable InfoBarProperties::Content() +{ + return ValueHelper::CastOrUnbox(static_cast(this)->GetValue(s_ContentProperty)); +} + +void InfoBarProperties::ContentTemplate(winrt::DataTemplate const& value) +{ + [[gsl::suppress(con)]] + { + static_cast(this)->SetValue(s_ContentTemplateProperty, ValueHelper::BoxValueIfNecessary(value)); + } +} + +winrt::DataTemplate InfoBarProperties::ContentTemplate() +{ + return ValueHelper::CastOrUnbox(static_cast(this)->GetValue(s_ContentTemplateProperty)); +} + +void InfoBarProperties::IconSource(winrt::IconSource const& value) +{ + [[gsl::suppress(con)]] + { + static_cast(this)->SetValue(s_IconSourceProperty, ValueHelper::BoxValueIfNecessary(value)); + } +} + +winrt::IconSource InfoBarProperties::IconSource() +{ + return ValueHelper::CastOrUnbox(static_cast(this)->GetValue(s_IconSourceProperty)); +} + +void InfoBarProperties::IsClosable(bool value) +{ + [[gsl::suppress(con)]] + { + static_cast(this)->SetValue(s_IsClosableProperty, ValueHelper::BoxValueIfNecessary(value)); + } +} + +bool InfoBarProperties::IsClosable() +{ + return ValueHelper::CastOrUnbox(static_cast(this)->GetValue(s_IsClosableProperty)); +} + +void InfoBarProperties::IsIconVisible(bool value) +{ + [[gsl::suppress(con)]] + { + static_cast(this)->SetValue(s_IsIconVisibleProperty, ValueHelper::BoxValueIfNecessary(value)); + } +} + +bool InfoBarProperties::IsIconVisible() +{ + return ValueHelper::CastOrUnbox(static_cast(this)->GetValue(s_IsIconVisibleProperty)); +} + +void InfoBarProperties::IsOpen(bool value) +{ + [[gsl::suppress(con)]] + { + static_cast(this)->SetValue(s_IsOpenProperty, ValueHelper::BoxValueIfNecessary(value)); + } +} + +bool InfoBarProperties::IsOpen() +{ + return ValueHelper::CastOrUnbox(static_cast(this)->GetValue(s_IsOpenProperty)); +} + +void InfoBarProperties::Message(winrt::hstring const& value) +{ + [[gsl::suppress(con)]] + { + static_cast(this)->SetValue(s_MessageProperty, ValueHelper::BoxValueIfNecessary(value)); + } +} + +winrt::hstring InfoBarProperties::Message() +{ + return ValueHelper::CastOrUnbox(static_cast(this)->GetValue(s_MessageProperty)); +} + +void InfoBarProperties::Severity(winrt::InfoBarSeverity const& value) +{ + [[gsl::suppress(con)]] + { + static_cast(this)->SetValue(s_SeverityProperty, ValueHelper::BoxValueIfNecessary(value)); + } +} + +winrt::InfoBarSeverity InfoBarProperties::Severity() +{ + return ValueHelper::CastOrUnbox(static_cast(this)->GetValue(s_SeverityProperty)); +} + +void InfoBarProperties::TemplateSettings(winrt::InfoBarTemplateSettings const& value) +{ + [[gsl::suppress(con)]] + { + static_cast(this)->SetValue(s_TemplateSettingsProperty, ValueHelper::BoxValueIfNecessary(value)); + } +} + +winrt::InfoBarTemplateSettings InfoBarProperties::TemplateSettings() +{ + return ValueHelper::CastOrUnbox(static_cast(this)->GetValue(s_TemplateSettingsProperty)); +} + +void InfoBarProperties::Title(winrt::hstring const& value) +{ + [[gsl::suppress(con)]] + { + static_cast(this)->SetValue(s_TitleProperty, ValueHelper::BoxValueIfNecessary(value)); + } +} + +winrt::hstring InfoBarProperties::Title() +{ + return ValueHelper::CastOrUnbox(static_cast(this)->GetValue(s_TitleProperty)); +} + +winrt::event_token InfoBarProperties::CloseButtonClick(winrt::TypedEventHandler const& value) +{ + return m_closeButtonClickEventSource.add(value); +} + +void InfoBarProperties::CloseButtonClick(winrt::event_token const& token) +{ + m_closeButtonClickEventSource.remove(token); +} + +winrt::event_token InfoBarProperties::Closed(winrt::TypedEventHandler const& value) +{ + return m_closedEventSource.add(value); +} + +void InfoBarProperties::Closed(winrt::event_token const& token) +{ + m_closedEventSource.remove(token); +} + +winrt::event_token InfoBarProperties::Closing(winrt::TypedEventHandler const& value) +{ + return m_closingEventSource.add(value); +} + +void InfoBarProperties::Closing(winrt::event_token const& token) +{ + m_closingEventSource.remove(token); +} diff --git a/dev/Generated/InfoBar.properties.h b/dev/Generated/InfoBar.properties.h new file mode 100644 index 0000000000..c0350ff35a --- /dev/null +++ b/dev/Generated/InfoBar.properties.h @@ -0,0 +1,117 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +// DO NOT EDIT! This file was generated by CustomTasks.DependencyPropertyCodeGen +#pragma once + +class InfoBarProperties +{ +public: + InfoBarProperties(); + + void ActionButton(winrt::ButtonBase const& value); + winrt::ButtonBase ActionButton(); + + void CloseButtonCommand(winrt::ICommand const& value); + winrt::ICommand CloseButtonCommand(); + + void CloseButtonCommandParameter(winrt::IInspectable const& value); + winrt::IInspectable CloseButtonCommandParameter(); + + void CloseButtonStyle(winrt::Style const& value); + winrt::Style CloseButtonStyle(); + + void Content(winrt::IInspectable const& value); + winrt::IInspectable Content(); + + void ContentTemplate(winrt::DataTemplate const& value); + winrt::DataTemplate ContentTemplate(); + + void IconSource(winrt::IconSource const& value); + winrt::IconSource IconSource(); + + void IsClosable(bool value); + bool IsClosable(); + + void IsIconVisible(bool value); + bool IsIconVisible(); + + void IsOpen(bool value); + bool IsOpen(); + + void Message(winrt::hstring const& value); + winrt::hstring Message(); + + void Severity(winrt::InfoBarSeverity const& value); + winrt::InfoBarSeverity Severity(); + + void TemplateSettings(winrt::InfoBarTemplateSettings const& value); + winrt::InfoBarTemplateSettings TemplateSettings(); + + void Title(winrt::hstring const& value); + winrt::hstring Title(); + + static winrt::DependencyProperty ActionButtonProperty() { return s_ActionButtonProperty; } + static winrt::DependencyProperty CloseButtonCommandProperty() { return s_CloseButtonCommandProperty; } + static winrt::DependencyProperty CloseButtonCommandParameterProperty() { return s_CloseButtonCommandParameterProperty; } + static winrt::DependencyProperty CloseButtonStyleProperty() { return s_CloseButtonStyleProperty; } + static winrt::DependencyProperty ContentProperty() { return s_ContentProperty; } + static winrt::DependencyProperty ContentTemplateProperty() { return s_ContentTemplateProperty; } + static winrt::DependencyProperty IconSourceProperty() { return s_IconSourceProperty; } + static winrt::DependencyProperty IsClosableProperty() { return s_IsClosableProperty; } + static winrt::DependencyProperty IsIconVisibleProperty() { return s_IsIconVisibleProperty; } + static winrt::DependencyProperty IsOpenProperty() { return s_IsOpenProperty; } + static winrt::DependencyProperty MessageProperty() { return s_MessageProperty; } + static winrt::DependencyProperty SeverityProperty() { return s_SeverityProperty; } + static winrt::DependencyProperty TemplateSettingsProperty() { return s_TemplateSettingsProperty; } + static winrt::DependencyProperty TitleProperty() { return s_TitleProperty; } + + static GlobalDependencyProperty s_ActionButtonProperty; + static GlobalDependencyProperty s_CloseButtonCommandProperty; + static GlobalDependencyProperty s_CloseButtonCommandParameterProperty; + static GlobalDependencyProperty s_CloseButtonStyleProperty; + static GlobalDependencyProperty s_ContentProperty; + static GlobalDependencyProperty s_ContentTemplateProperty; + static GlobalDependencyProperty s_IconSourceProperty; + static GlobalDependencyProperty s_IsClosableProperty; + static GlobalDependencyProperty s_IsIconVisibleProperty; + static GlobalDependencyProperty s_IsOpenProperty; + static GlobalDependencyProperty s_MessageProperty; + static GlobalDependencyProperty s_SeverityProperty; + static GlobalDependencyProperty s_TemplateSettingsProperty; + static GlobalDependencyProperty s_TitleProperty; + + winrt::event_token CloseButtonClick(winrt::TypedEventHandler const& value); + void CloseButtonClick(winrt::event_token const& token); + winrt::event_token Closed(winrt::TypedEventHandler const& value); + void Closed(winrt::event_token const& token); + winrt::event_token Closing(winrt::TypedEventHandler const& value); + void Closing(winrt::event_token const& token); + + event_source> m_closeButtonClickEventSource; + event_source> m_closedEventSource; + event_source> m_closingEventSource; + + static void EnsureProperties(); + static void ClearProperties(); + + static void OnIconSourcePropertyChanged( + winrt::DependencyObject const& sender, + winrt::DependencyPropertyChangedEventArgs const& args); + + static void OnIsClosablePropertyChanged( + winrt::DependencyObject const& sender, + winrt::DependencyPropertyChangedEventArgs const& args); + + static void OnIsIconVisiblePropertyChanged( + winrt::DependencyObject const& sender, + winrt::DependencyPropertyChangedEventArgs const& args); + + static void OnIsOpenPropertyChanged( + winrt::DependencyObject const& sender, + winrt::DependencyPropertyChangedEventArgs const& args); + + static void OnSeverityPropertyChanged( + winrt::DependencyObject const& sender, + winrt::DependencyPropertyChangedEventArgs const& args); +}; diff --git a/dev/Generated/InfoBarAutomationPeer.properties.cpp b/dev/Generated/InfoBarAutomationPeer.properties.cpp new file mode 100644 index 0000000000..354a5c2f48 --- /dev/null +++ b/dev/Generated/InfoBarAutomationPeer.properties.cpp @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +// DO NOT EDIT! This file was generated by CustomTasks.DependencyPropertyCodeGen +#include "pch.h" +#include "common.h" +#include "InfoBarAutomationPeer.h" + +namespace winrt::Microsoft::UI::Xaml::Automation::Peers +{ + CppWinRTActivatableClassWithBasicFactory(InfoBarAutomationPeer) +} + +#include "InfoBarAutomationPeer.g.cpp" + + diff --git a/dev/Generated/InfoBarClosedEventArgs.properties.cpp b/dev/Generated/InfoBarClosedEventArgs.properties.cpp new file mode 100644 index 0000000000..2a59172059 --- /dev/null +++ b/dev/Generated/InfoBarClosedEventArgs.properties.cpp @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +// DO NOT EDIT! This file was generated by CustomTasks.DependencyPropertyCodeGen +#include "pch.h" +#include "common.h" +#include "InfoBarClosedEventArgs.h" + +namespace winrt::Microsoft::UI::Xaml::Controls +{ + CppWinRTActivatableClassWithBasicFactory(InfoBarClosedEventArgs) +} + +#include "InfoBarClosedEventArgs.g.cpp" + + diff --git a/dev/Generated/InfoBarClosingEventArgs.properties.cpp b/dev/Generated/InfoBarClosingEventArgs.properties.cpp new file mode 100644 index 0000000000..b92a9fb4e0 --- /dev/null +++ b/dev/Generated/InfoBarClosingEventArgs.properties.cpp @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +// DO NOT EDIT! This file was generated by CustomTasks.DependencyPropertyCodeGen +#include "pch.h" +#include "common.h" +#include "InfoBarClosingEventArgs.h" + +namespace winrt::Microsoft::UI::Xaml::Controls +{ + CppWinRTActivatableClassWithBasicFactory(InfoBarClosingEventArgs) +} + +#include "InfoBarClosingEventArgs.g.cpp" + + diff --git a/dev/Generated/InfoBarPanel.properties.cpp b/dev/Generated/InfoBarPanel.properties.cpp new file mode 100644 index 0000000000..520c74027f --- /dev/null +++ b/dev/Generated/InfoBarPanel.properties.cpp @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +// DO NOT EDIT! This file was generated by CustomTasks.DependencyPropertyCodeGen +#include "pch.h" +#include "common.h" +#include "InfoBarPanel.h" + +namespace winrt::Microsoft::UI::Xaml::Controls::Primitives +{ + CppWinRTActivatableClassWithDPFactory(InfoBarPanel) +} + +#include "InfoBarPanel.g.cpp" + +GlobalDependencyProperty InfoBarPanelProperties::s_HorizontalMarginProperty{ nullptr }; +GlobalDependencyProperty InfoBarPanelProperties::s_VerticalMarginProperty{ nullptr }; + +InfoBarPanelProperties::InfoBarPanelProperties() +{ + EnsureProperties(); +} + +void InfoBarPanelProperties::EnsureProperties() +{ + if (!s_HorizontalMarginProperty) + { + s_HorizontalMarginProperty = + InitializeDependencyProperty( + L"HorizontalMargin", + winrt::name_of(), + winrt::name_of(), + true /* isAttached */, + ValueHelper::BoxedDefaultValue(), + nullptr); + } + if (!s_VerticalMarginProperty) + { + s_VerticalMarginProperty = + InitializeDependencyProperty( + L"VerticalMargin", + winrt::name_of(), + winrt::name_of(), + true /* isAttached */, + ValueHelper::BoxedDefaultValue(), + nullptr); + } +} + +void InfoBarPanelProperties::ClearProperties() +{ + s_HorizontalMarginProperty = nullptr; + s_VerticalMarginProperty = nullptr; +} + + +void InfoBarPanelProperties::SetHorizontalMargin(winrt::DependencyObject const& target, winrt::Thickness const& value) +{ + target.SetValue(s_HorizontalMarginProperty, ValueHelper::BoxValueIfNecessary(value)); +} + +winrt::Thickness InfoBarPanelProperties::GetHorizontalMargin(winrt::DependencyObject const& target) +{ + return ValueHelper::CastOrUnbox(target.GetValue(s_HorizontalMarginProperty)); +} + + +void InfoBarPanelProperties::SetVerticalMargin(winrt::DependencyObject const& target, winrt::Thickness const& value) +{ + target.SetValue(s_VerticalMarginProperty, ValueHelper::BoxValueIfNecessary(value)); +} + +winrt::Thickness InfoBarPanelProperties::GetVerticalMargin(winrt::DependencyObject const& target) +{ + return ValueHelper::CastOrUnbox(target.GetValue(s_VerticalMarginProperty)); +} diff --git a/dev/Generated/InfoBarPanel.properties.h b/dev/Generated/InfoBarPanel.properties.h new file mode 100644 index 0000000000..5ba874f11b --- /dev/null +++ b/dev/Generated/InfoBarPanel.properties.h @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +// DO NOT EDIT! This file was generated by CustomTasks.DependencyPropertyCodeGen +#pragma once + +class InfoBarPanelProperties +{ +public: + InfoBarPanelProperties(); + + static void SetHorizontalMargin(winrt::DependencyObject const& target, winrt::Thickness const& value); + static winrt::Thickness GetHorizontalMargin(winrt::DependencyObject const& target); + + static void SetVerticalMargin(winrt::DependencyObject const& target, winrt::Thickness const& value); + static winrt::Thickness GetVerticalMargin(winrt::DependencyObject const& target); + + static winrt::DependencyProperty HorizontalMarginProperty() { return s_HorizontalMarginProperty; } + static winrt::DependencyProperty VerticalMarginProperty() { return s_VerticalMarginProperty; } + + static GlobalDependencyProperty s_HorizontalMarginProperty; + static GlobalDependencyProperty s_VerticalMarginProperty; + + static void EnsureProperties(); + static void ClearProperties(); +}; diff --git a/dev/Generated/InfoBarTemplateSettings.properties.cpp b/dev/Generated/InfoBarTemplateSettings.properties.cpp new file mode 100644 index 0000000000..b255b262fa --- /dev/null +++ b/dev/Generated/InfoBarTemplateSettings.properties.cpp @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +// DO NOT EDIT! This file was generated by CustomTasks.DependencyPropertyCodeGen +#include "pch.h" +#include "common.h" +#include "InfoBarTemplateSettings.h" + +namespace winrt::Microsoft::UI::Xaml::Controls +{ + CppWinRTActivatableClassWithDPFactory(InfoBarTemplateSettings) +} + +#include "InfoBarTemplateSettings.g.cpp" + +GlobalDependencyProperty InfoBarTemplateSettingsProperties::s_IconElementProperty{ nullptr }; + +InfoBarTemplateSettingsProperties::InfoBarTemplateSettingsProperties() +{ + EnsureProperties(); +} + +void InfoBarTemplateSettingsProperties::EnsureProperties() +{ + if (!s_IconElementProperty) + { + s_IconElementProperty = + InitializeDependencyProperty( + L"IconElement", + winrt::name_of(), + winrt::name_of(), + false /* isAttached */, + ValueHelper::BoxedDefaultValue(), + nullptr); + } +} + +void InfoBarTemplateSettingsProperties::ClearProperties() +{ + s_IconElementProperty = nullptr; +} + +void InfoBarTemplateSettingsProperties::IconElement(winrt::IconElement const& value) +{ + [[gsl::suppress(con)]] + { + static_cast(this)->SetValue(s_IconElementProperty, ValueHelper::BoxValueIfNecessary(value)); + } +} + +winrt::IconElement InfoBarTemplateSettingsProperties::IconElement() +{ + return ValueHelper::CastOrUnbox(static_cast(this)->GetValue(s_IconElementProperty)); +} diff --git a/dev/Generated/InfoBarTemplateSettings.properties.h b/dev/Generated/InfoBarTemplateSettings.properties.h new file mode 100644 index 0000000000..9a584bf6cb --- /dev/null +++ b/dev/Generated/InfoBarTemplateSettings.properties.h @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +// DO NOT EDIT! This file was generated by CustomTasks.DependencyPropertyCodeGen +#pragma once + +class InfoBarTemplateSettingsProperties +{ +public: + InfoBarTemplateSettingsProperties(); + + void IconElement(winrt::IconElement const& value); + winrt::IconElement IconElement(); + + static winrt::DependencyProperty IconElementProperty() { return s_IconElementProperty; } + + static GlobalDependencyProperty s_IconElementProperty; + + static void EnsureProperties(); + static void ClearProperties(); +}; diff --git a/dev/InfoBar/InfoBar.cpp b/dev/InfoBar/InfoBar.cpp new file mode 100644 index 0000000000..c9cbd8ad61 --- /dev/null +++ b/dev/InfoBar/InfoBar.cpp @@ -0,0 +1,236 @@ +// 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 "common.h" +#include "InfoBar.h" +#include "InfoBarClosingEventArgs.h" +#include "InfoBarClosedEventArgs.h" +#include "InfoBarTemplateSettings.h" +#include "InfoBarAutomationPeer.h" +#include "RuntimeProfiler.h" +#include "ResourceAccessor.h" +#include "../ResourceHelper/Utils.h" + +static constexpr wstring_view c_closeButtonName{ L"CloseButton"sv }; +static constexpr wstring_view c_contentRootName{ L"ContentRoot"sv }; + +InfoBar::InfoBar() +{ + __RP_Marker_ClassById(RuntimeProfiler::ProfId_InfoBar); + + SetValue(s_TemplateSettingsProperty, winrt::make<::InfoBarTemplateSettings>()); + + RegisterPropertyChangedCallback(winrt::Control::ForegroundProperty(), { this, &InfoBar::OnForegroundChanged }); + + SetDefaultStyleKey(this); +} + +winrt::AutomationPeer InfoBar::OnCreateAutomationPeer() +{ + return winrt::make(*this); +} + +void InfoBar::OnApplyTemplate() +{ + m_applyTemplateCalled = true; + + winrt::IControlProtected controlProtected{ *this }; + + if (const auto closeButton = GetTemplateChildT(c_closeButtonName, controlProtected)) + { + m_closeButtonClickRevoker = closeButton.Click(winrt::auto_revoke, { this, &InfoBar::OnCloseButtonClick }); + + // Do localization for the close button + if (winrt::AutomationProperties::GetName(closeButton).empty()) + { + const auto closeButtonName = ResourceAccessor::GetLocalizedStringResource(SR_InfoBarCloseButtonName); + winrt::AutomationProperties::SetName(closeButton, closeButtonName); + } + + // Setup the tooltip for the close button + auto tooltip = winrt::ToolTip(); + const auto closeButtonTooltipText = ResourceAccessor::GetLocalizedStringResource(SR_InfoBarCloseButtonTooltip); + tooltip.Content(box_value(closeButtonTooltipText)); + winrt::ToolTipService::SetToolTip(closeButton, tooltip); + } + + if (auto&& contentRootGrid = GetTemplateChildT(c_contentRootName, controlProtected)) + { + winrt::AutomationProperties::SetLocalizedLandmarkType(contentRootGrid, ResourceAccessor::GetLocalizedStringResource(SR_InfoBarCustomLandmarkName)); + } + + UpdateVisibility(m_notifyOpen, true); + m_notifyOpen = false; + + UpdateSeverity(); + UpdateIcon(); + UpdateIconVisibility(); + UpdateCloseButton(); + UpdateForeground(); +} + +void InfoBar::OnCloseButtonClick(winrt::IInspectable const& sender, winrt::RoutedEventArgs const& args) +{ + m_closeButtonClickEventSource(*this, nullptr); + m_lastCloseReason = winrt::InfoBarCloseReason::CloseButton; + IsOpen(false); +} + +void InfoBar::RaiseClosingEvent() +{ + auto const args = winrt::make_self(); + args->Reason(m_lastCloseReason); + + m_closingEventSource(*this, *args); + + if (!args->Cancel()) + { + UpdateVisibility(); + RaiseClosedEvent(); + } + else + { + // The developer has changed the Cancel property to true, + // so we need to revert the IsOpen property to true. + IsOpen(true); + } +} + +void InfoBar::RaiseClosedEvent() +{ + auto const args = winrt::make_self(); + args->Reason(m_lastCloseReason); + m_closedEventSource(*this, *args); +} + +void InfoBar::OnIsOpenPropertyChanged(const winrt::DependencyPropertyChangedEventArgs& args) +{ + if (IsOpen()) + { + //Reset the close reason to the default value of programmatic. + m_lastCloseReason = winrt::InfoBarCloseReason::Programmatic; + + UpdateVisibility(); + } + else + { + RaiseClosingEvent(); + } +} + +void InfoBar::OnSeverityPropertyChanged(const winrt::DependencyPropertyChangedEventArgs& args) +{ + UpdateSeverity(); +} + +void InfoBar::OnIconSourcePropertyChanged(const winrt::DependencyPropertyChangedEventArgs& args) +{ + UpdateIcon(); + UpdateIconVisibility(); +} + +void InfoBar::OnIsIconVisiblePropertyChanged(const winrt::DependencyPropertyChangedEventArgs& args) +{ + UpdateIconVisibility(); +} + +void InfoBar::OnIsClosablePropertyChanged(const winrt::DependencyPropertyChangedEventArgs& args) +{ + UpdateCloseButton(); +} + +void InfoBar::UpdateVisibility(bool notify, bool force) +{ + auto const peer = winrt::FrameworkElementAutomationPeer::FromElement(*this).try_as(); + if (!m_applyTemplateCalled) + { + // ApplyTemplate() hasn't been called yet but IsOpen has already been set. + // Since this method will be called again shortly from ApplyTemplate, we'll just wait and send a notification then. + m_notifyOpen = true; + } + else + { + // Don't do any work if nothing has changed (unless we are forcing a update) + if (force || IsOpen() != m_isVisible) + { + if (IsOpen()) + { + if (notify && peer) + { + auto const notificationString = StringUtil::FormatString( + ResourceAccessor::GetLocalizedStringResource(SR_InfoBarOpenedNotification), + Title().data(), + Message().data()); + + winrt::get_self(peer)->RaiseOpenedEvent(Severity(), notificationString); + } + + winrt::VisualStateManager::GoToState(*this, L"InfoBarVisible", false); + winrt::AutomationProperties::SetAccessibilityView(*this, winrt::AccessibilityView::Control); + m_isVisible = true; + } + else + { + if (notify && peer) + { + auto const notificationString = ResourceAccessor::GetLocalizedStringResource(SR_InfoBarClosedNotification); + + winrt::get_self(peer)->RaiseClosedEvent(Severity(), notificationString); + } + + winrt::VisualStateManager::GoToState(*this, L"InfoBarCollapsed", false); + winrt::AutomationProperties::SetAccessibilityView(*this, winrt::AccessibilityView::Raw); + m_isVisible = false; + } + } + } +} + +void InfoBar::UpdateSeverity() +{ + auto severityState = L"Informational"; + + switch (Severity()) + { + case winrt::InfoBarSeverity::Success: severityState = L"Success"; break; + case winrt::InfoBarSeverity::Warning: severityState = L"Warning"; break; + case winrt::InfoBarSeverity::Error: severityState = L"Error"; break; + }; + + winrt::VisualStateManager::GoToState(*this, severityState, false); +} + +void InfoBar::UpdateIcon() +{ + auto const templateSettings = winrt::get_self<::InfoBarTemplateSettings>(TemplateSettings()); + if (auto const source = IconSource()) + { + templateSettings->IconElement(SharedHelpers::MakeIconElementFrom(source)); + } + else + { + templateSettings->IconElement(nullptr); + } +} + +void InfoBar::UpdateIconVisibility() +{ + winrt::VisualStateManager::GoToState(*this, IsIconVisible() ? (IconSource() ? L"UserIconVisible" : L"StandardIconVisible") : L"NoIconVisible", false); +} + +void InfoBar::UpdateCloseButton() +{ + winrt::VisualStateManager::GoToState(*this, IsClosable() ? L"CloseButtonVisible" : L"CloseButtonCollapsed", false); +} + +void InfoBar::OnForegroundChanged(const winrt::DependencyObject& sender, const winrt::DependencyProperty& args) +{ + UpdateForeground(); +} + +void InfoBar::UpdateForeground() +{ + // If Foreground is set, then change Title and Message Foreground to match. + winrt::VisualStateManager::GoToState(*this, ReadLocalValue(winrt::Control::ForegroundProperty()) == winrt::DependencyProperty::UnsetValue() ? L"ForegroundNotSet" : L"ForegroundSet", false); +} diff --git a/dev/InfoBar/InfoBar.h b/dev/InfoBar/InfoBar.h new file mode 100644 index 0000000000..1581c34983 --- /dev/null +++ b/dev/InfoBar/InfoBar.h @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#pragma once + +#include "pch.h" +#include "common.h" + +#include "InfoBar.g.h" +#include "InfoBar.properties.h" + +class InfoBar : + public ReferenceTracker, + public InfoBarProperties +{ + +public: + InfoBar(); + ~InfoBar() {} + + // IFrameworkElement + void OnApplyTemplate(); + + // UIElement + winrt::AutomationPeer OnCreateAutomationPeer(); + + // Property change handlers + void OnIsOpenPropertyChanged(const winrt::DependencyPropertyChangedEventArgs& args); + void OnSeverityPropertyChanged(const winrt::DependencyPropertyChangedEventArgs& args); + void OnIconSourcePropertyChanged(const winrt::DependencyPropertyChangedEventArgs& args); + void OnIsIconVisiblePropertyChanged(const winrt::DependencyPropertyChangedEventArgs& args); + void OnIsClosablePropertyChanged(const winrt::DependencyPropertyChangedEventArgs& args); + +private: + void OnCloseButtonClick(winrt::IInspectable const& sender, winrt::RoutedEventArgs const& args); + + void RaiseClosingEvent(); + void RaiseClosedEvent(); + + void UpdateVisibility(bool notify = true, bool force = false); + void UpdateSeverity(); + void UpdateIcon(); + void UpdateIconVisibility(); + void UpdateCloseButton(); + void UpdateForeground(); + + void OnForegroundChanged(const winrt::DependencyObject& sender, const winrt::DependencyProperty& args); + + winrt::InfoBarCloseReason m_lastCloseReason{ winrt::InfoBarCloseReason::Programmatic }; + + winrt::Button::Click_revoker m_closeButtonClickRevoker{}; + + bool m_applyTemplateCalled{ false }; + bool m_notifyOpen{ false }; + bool m_isVisible{ false }; +}; diff --git a/dev/InfoBar/InfoBar.idl b/dev/InfoBar/InfoBar.idl new file mode 100644 index 0000000000..fd0d164e74 --- /dev/null +++ b/dev/InfoBar/InfoBar.idl @@ -0,0 +1,143 @@ +namespace MU_XC_NAMESPACE +{ + +[WUXC_VERSION_MUXONLY] +[webhosthidden] +enum InfoBarCloseReason +{ + CloseButton = 0, + Programmatic = 1 +}; + +[WUXC_VERSION_MUXONLY] +[webhosthidden] +enum InfoBarSeverity +{ + Informational = 0, + Success = 1, + Warning = 2, + Error = 3, +}; + +[WUXC_VERSION_MUXONLY] +[webhosthidden] +unsealed runtimeclass InfoBarClosedEventArgs +{ + InfoBarCloseReason Reason { get; }; +} + +[WUXC_VERSION_MUXONLY] +[webhosthidden] +unsealed runtimeclass InfoBarClosingEventArgs +{ + InfoBarCloseReason Reason { get; }; + Boolean Cancel { get; set; }; +} + +[WUXC_VERSION_MUXONLY] +[webhosthidden] +unsealed runtimeclass InfoBarTemplateSettings : Windows.UI.Xaml.DependencyObject +{ + InfoBarTemplateSettings(); + + Windows.UI.Xaml.Controls.IconElement IconElement; + + static Windows.UI.Xaml.DependencyProperty IconElementProperty{ get; }; +} + +[WUXC_VERSION_MUXONLY] +[webhosthidden] +[contentproperty("Content")] +unsealed runtimeclass InfoBar : Windows.UI.Xaml.Controls.Control +{ + InfoBar(); + + [MUX_DEFAULT_VALUE("false")] + [MUX_PROPERTY_CHANGED_CALLBACK(TRUE)] + Boolean IsOpen{ get; set; }; + + String Title{ get; set; }; + String Message{ get; set; }; + + [MUX_DEFAULT_VALUE("winrt::InfoBarSeverity::Informational")] + [MUX_PROPERTY_CHANGED_CALLBACK(TRUE)] + InfoBarSeverity Severity{ get; set; }; + + [MUX_PROPERTY_CHANGED_CALLBACK(TRUE)] + IconSource IconSource{ get; set; }; + + [MUX_DEFAULT_VALUE("true")] + [MUX_PROPERTY_CHANGED_CALLBACK(TRUE)] + Boolean IsIconVisible{ get; set; }; + + [MUX_DEFAULT_VALUE("true")] + [MUX_PROPERTY_CHANGED_CALLBACK(TRUE)] + Boolean IsClosable{ get; set; }; + + Windows.UI.Xaml.Style CloseButtonStyle{ get; set; }; + Windows.UI.Xaml.Input.ICommand CloseButtonCommand{ get; set; }; + Object CloseButtonCommandParameter{ get; set; }; + + Windows.UI.Xaml.Controls.Primitives.ButtonBase ActionButton{ get; set; }; + + Object Content{ get; set; }; + Windows.UI.Xaml.DataTemplate ContentTemplate{ get; set; }; + + InfoBarTemplateSettings TemplateSettings{ get; }; + + event Windows.Foundation.TypedEventHandler CloseButtonClick; + event Windows.Foundation.TypedEventHandler Closing; + event Windows.Foundation.TypedEventHandler Closed; + + static Windows.UI.Xaml.DependencyProperty IsOpenProperty{ get; }; + static Windows.UI.Xaml.DependencyProperty TitleProperty{ get; }; + static Windows.UI.Xaml.DependencyProperty MessageProperty{ get; }; + static Windows.UI.Xaml.DependencyProperty SeverityProperty{ get; }; + static Windows.UI.Xaml.DependencyProperty IconSourceProperty{ get; }; + static Windows.UI.Xaml.DependencyProperty IsIconVisibleProperty{ get; }; + static Windows.UI.Xaml.DependencyProperty IsClosableProperty{ get; }; + static Windows.UI.Xaml.DependencyProperty CloseButtonStyleProperty{ get; }; + static Windows.UI.Xaml.DependencyProperty CloseButtonCommandProperty{ get; }; + static Windows.UI.Xaml.DependencyProperty CloseButtonCommandParameterProperty{ get; }; + static Windows.UI.Xaml.DependencyProperty ActionButtonProperty{ get; }; + static Windows.UI.Xaml.DependencyProperty ContentProperty{ get; }; + static Windows.UI.Xaml.DependencyProperty ContentTemplateProperty{ get; }; + + static Windows.UI.Xaml.DependencyProperty TemplateSettingsProperty{ get; }; +} + +} + +namespace MU_XCP_NAMESPACE +{ + +[WUXC_VERSION_MUXONLY] +[webhosthidden] +unsealed runtimeclass InfoBarPanel : Windows.UI.Xaml.Controls.Panel +{ + InfoBarPanel(); + + static Windows.UI.Xaml.DependencyProperty HorizontalMarginProperty{ get; }; + static void SetHorizontalMargin(Windows.UI.Xaml.DependencyObject object, Windows.UI.Xaml.Thickness value); + static Windows.UI.Xaml.Thickness GetHorizontalMargin(Windows.UI.Xaml.DependencyObject object); + + static Windows.UI.Xaml.DependencyProperty VerticalMarginProperty{ get; }; + static void SetVerticalMargin(Windows.UI.Xaml.DependencyObject object, Windows.UI.Xaml.Thickness value); + static Windows.UI.Xaml.Thickness GetVerticalMargin(Windows.UI.Xaml.DependencyObject object); +} + +} + + +namespace MU_XAP_NAMESPACE +{ + +[WUXC_VERSION_MUXONLY] +[webhosthidden] +unsealed runtimeclass InfoBarAutomationPeer : Windows.UI.Xaml.Automation.Peers.FrameworkElementAutomationPeer +{ + InfoBarAutomationPeer(MU_XC_NAMESPACE.InfoBar owner); +} + +} + diff --git a/dev/InfoBar/InfoBar.vcxitems b/dev/InfoBar/InfoBar.vcxitems new file mode 100644 index 0000000000..aa25ab29dc --- /dev/null +++ b/dev/InfoBar/InfoBar.vcxitems @@ -0,0 +1,52 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + {CCC102B7-F5EF-479D-94F1-008D189448B1} + + + + %(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory) + %(PreprocessorDefinitions);INFOBAR_INCLUDED + + + + + + + + + + + + + + + + + + + + + + + + + + + RS1 + DefaultStyle + + + RS1 + ThemeResources + + + + + + + + + \ No newline at end of file diff --git a/dev/InfoBar/InfoBar.xaml b/dev/InfoBar/InfoBar.xaml new file mode 100644 index 0000000000..b28413012c --- /dev/null +++ b/dev/InfoBar/InfoBar.xaml @@ -0,0 +1,219 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/InfoBar/InfoBarAutomationPeer.cpp b/dev/InfoBar/InfoBarAutomationPeer.cpp new file mode 100644 index 0000000000..54493e5533 --- /dev/null +++ b/dev/InfoBar/InfoBarAutomationPeer.cpp @@ -0,0 +1,68 @@ +#include "pch.h" +#include "common.h" +#include "ResourceAccessor.h" +#include "InfoBarAutomationPeer.h" +#include +#include + +#include "InfoBarAutomationPeer.properties.cpp" + +InfoBarAutomationPeer::InfoBarAutomationPeer(winrt::InfoBar const& owner) : ReferenceTracker(owner) +{ +} + +winrt::AutomationControlType InfoBarAutomationPeer::GetAutomationControlTypeCore() +{ + return winrt::AutomationControlType::StatusBar; +} + +winrt::hstring InfoBarAutomationPeer::GetClassNameCore() +{ + return winrt::hstring_name_of(); +} + +void InfoBarAutomationPeer::RaiseOpenedEvent(winrt::InfoBarSeverity severity, wstring_view const& displayString) +{ + if (winrt::IAutomationPeer7 automationPeer7 = *this) + { + automationPeer7.RaiseNotificationEvent( + winrt::Automation::Peers::AutomationNotificationKind::Other, + GetProcessingForSeverity(severity), + displayString, + L"InfoBarOpenedActivityId"); + } +} + +void InfoBarAutomationPeer::RaiseClosedEvent(winrt::InfoBarSeverity severity, wstring_view const& displayString) +{ + const winrt::Peers::AutomationNotificationProcessing processing = winrt::Peers::AutomationNotificationProcessing::CurrentThenMostRecent; + + if (winrt::IAutomationPeer7 automationPeer7 = *this) + { + automationPeer7.RaiseNotificationEvent( + winrt::Automation::Peers::AutomationNotificationKind::Other, + GetProcessingForSeverity(severity), + displayString, + L"InfoBarClosedActivityId"); + } +} + + +winrt::Peers::AutomationNotificationProcessing InfoBarAutomationPeer::GetProcessingForSeverity(winrt::InfoBarSeverity severity) +{ + winrt::Peers::AutomationNotificationProcessing processing = winrt::Peers::AutomationNotificationProcessing::CurrentThenMostRecent; + + if (severity == winrt::InfoBarSeverity::Error + || severity == winrt::InfoBarSeverity::Warning) + { + processing = winrt::Peers::AutomationNotificationProcessing::ImportantAll; + } + + return processing; +} + +winrt::InfoBar InfoBarAutomationPeer::GetInfoBar() +{ + winrt::UIElement owner = Owner(); + return owner.as(); +} diff --git a/dev/InfoBar/InfoBarAutomationPeer.h b/dev/InfoBar/InfoBarAutomationPeer.h new file mode 100644 index 0000000000..0b9f7db9cd --- /dev/null +++ b/dev/InfoBar/InfoBarAutomationPeer.h @@ -0,0 +1,22 @@ +#pragma once +#include "InfoBar.h" +#include "InfoBarAutomationPeer.g.h" + +class InfoBarAutomationPeer : + public ReferenceTracker +{ + +public: + InfoBarAutomationPeer(winrt::InfoBar const& owner); + + // IAutomationPeerOverrides + winrt::AutomationControlType GetAutomationControlTypeCore(); + winrt::hstring GetClassNameCore(); + + void RaiseClosedEvent(winrt::InfoBarSeverity severity, wstring_view const& displayString); + void RaiseOpenedEvent(winrt::InfoBarSeverity severity, wstring_view const& displayString); + +private: + winrt::InfoBar GetInfoBar(); + winrt::Peers::AutomationNotificationProcessing GetProcessingForSeverity(winrt::InfoBarSeverity severity); +}; diff --git a/dev/InfoBar/InfoBarClosedEventArgs.cpp b/dev/InfoBar/InfoBarClosedEventArgs.cpp new file mode 100644 index 0000000000..e65dcaf530 --- /dev/null +++ b/dev/InfoBar/InfoBarClosedEventArgs.cpp @@ -0,0 +1,13 @@ +#include "pch.h" +#include "common.h" +#include "InfoBarClosedEventArgs.h" + +winrt::InfoBarCloseReason InfoBarClosedEventArgs::Reason() +{ + return m_reason; +} + +void InfoBarClosedEventArgs::Reason(const winrt::InfoBarCloseReason& reason) +{ + m_reason = reason; +} diff --git a/dev/InfoBar/InfoBarClosedEventArgs.h b/dev/InfoBar/InfoBarClosedEventArgs.h new file mode 100644 index 0000000000..e74d50de61 --- /dev/null +++ b/dev/InfoBar/InfoBarClosedEventArgs.h @@ -0,0 +1,14 @@ +#pragma once + +#include "InfoBarClosedEventArgs.g.h" + +class InfoBarClosedEventArgs : + public winrt::implementation::InfoBarClosedEventArgsT +{ +public: + winrt::InfoBarCloseReason Reason(); + void Reason(const winrt::InfoBarCloseReason& reason); + +private: + winrt::InfoBarCloseReason m_reason{ winrt::InfoBarCloseReason::CloseButton }; +}; diff --git a/dev/InfoBar/InfoBarClosingEventArgs.cpp b/dev/InfoBar/InfoBarClosingEventArgs.cpp new file mode 100644 index 0000000000..7b0085c0e7 --- /dev/null +++ b/dev/InfoBar/InfoBarClosingEventArgs.cpp @@ -0,0 +1,23 @@ +#include "pch.h" +#include "common.h" +#include "InfoBarClosingEventArgs.h" + +winrt::InfoBarCloseReason InfoBarClosingEventArgs::Reason() +{ + return m_reason; +} + +void InfoBarClosingEventArgs::Reason(const winrt::InfoBarCloseReason& reason) +{ + m_reason = reason; +} + +bool InfoBarClosingEventArgs::Cancel() +{ + return m_cancel; +} + +void InfoBarClosingEventArgs::Cancel(const bool cancel) +{ + m_cancel = cancel; +} diff --git a/dev/InfoBar/InfoBarClosingEventArgs.h b/dev/InfoBar/InfoBarClosingEventArgs.h new file mode 100644 index 0000000000..452838e22e --- /dev/null +++ b/dev/InfoBar/InfoBarClosingEventArgs.h @@ -0,0 +1,18 @@ +#pragma once +#pragma once + +#include "InfoBarClosingEventArgs.g.h" + +class InfoBarClosingEventArgs : + public ReferenceTracker +{ +public: + winrt::InfoBarCloseReason Reason(); + void Reason(const winrt::InfoBarCloseReason& reason); + bool Cancel(); + void Cancel(const bool cancel); + +private: + winrt::InfoBarCloseReason m_reason{ winrt::InfoBarCloseReason::CloseButton }; + bool m_cancel{ false }; +}; diff --git a/dev/InfoBar/InfoBarPanel.cpp b/dev/InfoBar/InfoBarPanel.cpp new file mode 100644 index 0000000000..61f7ff4688 --- /dev/null +++ b/dev/InfoBar/InfoBarPanel.cpp @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#include +#include +#include "InfoBarPanel.h" + +winrt::Size InfoBarPanel::MeasureOverride(winrt::Size const& availableSize) +{ + winrt::Size desiredSize{}; + + float totalWidth = 0; + float totalHeight = 0; + float widthOfWidest = 0; + float heightOfTallest = 0; + float heightOfTallestInHorizontal = 0; + int nItems = 0; + + const auto parent = this->Parent().try_as(); + const float minHeight = !parent ? 0.0f : (float)(parent.MinHeight() - (Margin().Top + Margin().Bottom)); + + for (winrt::UIElement const& child : Children()) + { + child.Measure(availableSize); + const auto childDesiredSize = child.DesiredSize(); + + if (childDesiredSize.Width != 0 && childDesiredSize.Height != 0) + { + // Add up the width of all items if they were laid out horizontally + const auto horizontalMargin = winrt::InfoBarPanel::GetHorizontalMargin(child); + totalWidth += childDesiredSize.Width + (nItems > 0 ? (float)horizontalMargin.Left : 0) + (float)horizontalMargin.Right; + + // Add up the height of all items if they were laid out vertically + const auto verticalMargin = winrt::InfoBarPanel::GetVerticalMargin(child); + totalHeight += childDesiredSize.Height + (nItems > 0 ? (float)verticalMargin.Top : 0) + (float)verticalMargin.Bottom; + + if (childDesiredSize.Width > widthOfWidest) + { + widthOfWidest = childDesiredSize.Width; + } + + if (childDesiredSize.Height > heightOfTallest) + { + heightOfTallest = childDesiredSize.Height; + } + + const float childHeightInHorizontal = childDesiredSize.Height + (float)horizontalMargin.Top + float(horizontalMargin.Bottom); + if (childHeightInHorizontal > heightOfTallestInHorizontal) + { + heightOfTallestInHorizontal = childHeightInHorizontal; + } + + nItems++; + } + } + + // Since this panel is inside a *-sized grid column, availableSize.Width should not be infinite + // If there is only one item inside the panel, we will count it as vertical (the margins work out better that way) + // Also, if the height of any item is taller than the desired min height of the InfoBar, + // the items should be laid out vertically even though they may seem to fit due to text wrapping. + if (nItems == 1 || totalWidth > availableSize.Width || (minHeight > 0 && heightOfTallestInHorizontal > minHeight)) + { + m_isVertical = true; + const auto verticalMargin = winrt::InfoBarPanel::GetVerticalMargin(*this); + + desiredSize.Width = widthOfWidest; + desiredSize.Height = totalHeight + (float)verticalMargin.Top + (float)verticalMargin.Bottom; + } + else + { + m_isVertical = false; + const auto horizontalMargin = winrt::InfoBarPanel::GetHorizontalMargin(*this); + + desiredSize.Width = totalWidth + (float)horizontalMargin.Left + (float)horizontalMargin.Right; + desiredSize.Height = heightOfTallest; + } + + return desiredSize; +} + +winrt::Size InfoBarPanel::ArrangeOverride(winrt::Size const& finalSize) +{ + winrt::Size result = finalSize; + + if (m_isVertical) + { + // Layout elements vertically + float verticalOffset = (float)winrt::InfoBarPanel::GetVerticalMargin(*this).Top; + bool hasPreviousElement = false; + for (winrt::UIElement const& child : Children()) + { + if (auto childAsFe = child.try_as()) + { + auto const desiredSize = child.DesiredSize(); + if (desiredSize.Width != 0 && desiredSize.Height != 0) + { + const auto verticalMargin = winrt::InfoBarPanel::GetVerticalMargin(child); + + verticalOffset += hasPreviousElement ? (float)verticalMargin.Top : 0; + child.Arrange(winrt::Rect{ (float)verticalMargin.Left, verticalOffset, desiredSize.Width, desiredSize.Height }); + verticalOffset += desiredSize.Height + (float)verticalMargin.Bottom; + + hasPreviousElement = true; + } + } + } + } + else + { + // Layout elements horizontally + float horizontalOffset = (float)winrt::InfoBarPanel::GetHorizontalMargin(*this).Left; + bool hasPreviousElement = false; + for (winrt::UIElement const& child : Children()) + { + if (auto childAsFe = child.try_as()) + { + auto const desiredSize = child.DesiredSize(); + if (desiredSize.Width != 0 && desiredSize.Height != 0) + { + auto horizontalMargin = winrt::InfoBarPanel::GetHorizontalMargin(child); + + horizontalOffset += hasPreviousElement ? (float)horizontalMargin.Left : 0; + child.Arrange(winrt::Rect{ horizontalOffset, (float)horizontalMargin.Top, desiredSize.Width, finalSize.Height }); + horizontalOffset += desiredSize.Width + (float)horizontalMargin.Right; + + hasPreviousElement = true; + } + } + } + } + + return result; +} + diff --git a/dev/InfoBar/InfoBarPanel.h b/dev/InfoBar/InfoBarPanel.h new file mode 100644 index 0000000000..5dfa676057 --- /dev/null +++ b/dev/InfoBar/InfoBarPanel.h @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#pragma once +#include "InfoBarPanel.g.h" +#include "InfoBarPanel.properties.h" + +class InfoBarPanel : + public ReferenceTracker, + public InfoBarPanelProperties +{ +public: + winrt::Size MeasureOverride(winrt::Size const& availableSize); + winrt::Size ArrangeOverride(winrt::Size const& finalSize); + +private: + bool m_isVertical{ false }; +}; diff --git a/dev/InfoBar/InfoBarTemplateSettings.cpp b/dev/InfoBar/InfoBarTemplateSettings.cpp new file mode 100644 index 0000000000..ce9c1a5096 --- /dev/null +++ b/dev/InfoBar/InfoBarTemplateSettings.cpp @@ -0,0 +1,11 @@ +// 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 "common.h" +#include "InfoBarTemplateSettings.h" + +InfoBarTemplateSettings::InfoBarTemplateSettings() +{ + EnsureProperties(); +} diff --git a/dev/InfoBar/InfoBarTemplateSettings.h b/dev/InfoBar/InfoBarTemplateSettings.h new file mode 100644 index 0000000000..dc4361b792 --- /dev/null +++ b/dev/InfoBar/InfoBarTemplateSettings.h @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#pragma once + +#include "InfoBarTemplateSettings.g.h" +#include "InfoBarTemplateSettings.properties.h" + +class InfoBarTemplateSettings : + public winrt::implementation::InfoBarTemplateSettingsT, + public InfoBarTemplateSettingsProperties +{ +public: + InfoBarTemplateSettings(); +}; diff --git a/dev/InfoBar/InfoBar_themeresources.xaml b/dev/InfoBar/InfoBar_themeresources.xaml new file mode 100644 index 0000000000..dfc0429ece --- /dev/null +++ b/dev/InfoBar/InfoBar_themeresources.xaml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + + + + + + + + + + + + + + + 0 + + + + + + + + + + + + + + + + + + + 2 + + + + 14 + SemiBold + + 14 + Normal + + 40 + + 32 + 16 + + + + + + + 12,0,0,0 + + 0,10,10,10 + 20 + + 0,0,12,0 + 0,0,0,0 + 0,10,0,10 + + 0,10,0,0 + 0,10,0,0 + + 8,10,0,0 + 0,4,0,0 + + 12,8,0,0 + 0,12,0,0 + + 96 + 24 + 8,0,8,1 + 2 + + 14 + 24 + 0,0,0,1 + + Cancel + + + + diff --git a/dev/InfoBar/InteractionTests/InfoBarTests.cs b/dev/InfoBar/InteractionTests/InfoBarTests.cs index 1d8b4eb900..ea41eb8faa 100644 --- a/dev/InfoBar/InteractionTests/InfoBarTests.cs +++ b/dev/InfoBar/InteractionTests/InfoBarTests.cs @@ -41,5 +41,168 @@ public void TestCleanup() { TestCleanupHelper.Cleanup(); } + + [TestMethod] + public void IsClosableTest() + { + using (var setup = new TestSetupHelper("InfoBar Tests")) + { + StatusBar infoBar = FindElement.ByName("TestInfoBar"); + + Button closeButton = FindCloseButton(infoBar); + Verify.IsNotNull(closeButton, "Close button should be visible by default"); + + Uncheck("IsClosableCheckBox"); + ElementCache.Clear(); + closeButton = FindCloseButton(infoBar); + Verify.IsNull(closeButton, "Close button should not be visible when IsClosable=false"); + + Check("IsClosableCheckBox"); + ElementCache.Clear(); + closeButton = FindCloseButton(infoBar); + Verify.IsNotNull(closeButton, "Close button should be visible when IsClosable=true"); + } + } + + [TestMethod] + public void CloseTest() + { + using (var setup = new TestSetupHelper("InfoBar Tests")) + { + StatusBar infoBar = FindElement.ByName("TestInfoBar"); + + Log.Comment("Clicking the close button"); + Button closeButton = FindCloseButton(infoBar); + closeButton.InvokeAndWait(); + + ListBox events = FindElement.ByName("EventListBox"); + Verify.AreEqual(3, events.Items.Count); + Verify.AreEqual("CloseButtonClick", events.Items[0].Name, "First event should be the CloseButtonClick event"); + Verify.AreEqual("Closing: CloseButton", events.Items[1].Name, "Second event should be the Closing event, reason=CloseButton"); + Verify.AreEqual("Closed: CloseButton", events.Items[2].Name, "Third event should be the Closed event, reason=CloseButton"); + + CheckBox isOpenCheckBox = FindElement.ByName("IsOpenCheckBox"); + Verify.AreEqual(ToggleState.Off, isOpenCheckBox.ToggleState); + + // reopen + isOpenCheckBox.Check(); + Check("CancelCheckBox"); + Button listBoxClearButton = FindElement.ByName