From 513ed8267007c8e0b3055c6b924e2c2c58601503 Mon Sep 17 00:00:00 2001 From: Stephen L Peters Date: Tue, 24 Nov 2020 15:15:41 -0800 Subject: [PATCH] Add ImageIcon (#3629) * Add ImageIcon * Respond to feedback and use an svg image with an MIT license. * Fix broken test * Platform check the IsLoaded check which was introduced in RS5 --- FeatureAreas.props | 4 ++ MUXControls.sln | 32 +++++++-- MUXControlsInnerLoop.sln | 47 +++++++------ dev/Generated/ImageIcon.properties.cpp | 62 +++++++++++++++++ dev/Generated/ImageIcon.properties.h | 25 +++++++ dev/Generated/ImageIconSource.properties.cpp | 56 +++++++++++++++ dev/Generated/ImageIconSource.properties.h | 21 ++++++ dev/IconSource/APITests/IconSourceApiTests.cs | 37 ++++++++++ dev/IconSource/IconSource.idl | 11 +++ dev/IconSource/IconSource.vcxitems | 3 + dev/IconSource/ImageIconSource.cpp | 8 +++ dev/IconSource/ImageIconSource.h | 17 +++++ dev/ImageIcon/APITests/ImageIconTests.cs | 69 +++++++++++++++++++ .../APITests/ImageIcon_APITests.projitems | 14 ++++ .../APITests/ImageIcon_APITests.shproj | 13 ++++ dev/ImageIcon/ImageIcon.cpp | 36 ++++++++++ dev/ImageIcon/ImageIcon.h | 29 ++++++++ dev/ImageIcon/ImageIcon.idl | 16 +++++ dev/ImageIcon/ImageIcon.vcxitems | 37 ++++++++++ dev/ImageIcon/ImageIcon.xaml | 10 +++ dev/ImageIcon/ImageIcon_themeresources.xaml | 7 ++ .../InteractionTests/ImageIconTests.cs | 51 ++++++++++++++ .../ImageIcon_InteractionTests.projitems | 15 ++++ .../ImageIcon_InteractionTests.shproj | 14 ++++ dev/ImageIcon/TestUI/ImageIconPage.xaml | 54 +++++++++++++++ dev/ImageIcon/TestUI/ImageIconPage.xaml.cs | 39 +++++++++++ .../TestUI/ImageIcon_TestUI.projitems | 23 +++++++ dev/ImageIcon/TestUI/ImageIcon_TestUI.shproj | 14 ++++ dev/Telemetry/RuntimeProfiler.h | 2 + dev/dll/Microsoft.UI.Xaml.vcxproj | 9 +-- dev/dll/SharedHelpers.cpp | 13 ++++ dev/inc/CppWinRTHelpers.h | 17 +++++ .../MUXControls.Test.Shared.targets | 1 + .../Assets/libre-camera-panorama.svg | 9 +++ .../MUXControlsTestApp.Shared.projitems | 1 + .../MUXControlsTestApp.Shared.targets | 2 + 36 files changed, 788 insertions(+), 30 deletions(-) create mode 100644 dev/Generated/ImageIcon.properties.cpp create mode 100644 dev/Generated/ImageIcon.properties.h create mode 100644 dev/Generated/ImageIconSource.properties.cpp create mode 100644 dev/Generated/ImageIconSource.properties.h create mode 100644 dev/IconSource/ImageIconSource.cpp create mode 100644 dev/IconSource/ImageIconSource.h create mode 100644 dev/ImageIcon/APITests/ImageIconTests.cs create mode 100644 dev/ImageIcon/APITests/ImageIcon_APITests.projitems create mode 100644 dev/ImageIcon/APITests/ImageIcon_APITests.shproj create mode 100644 dev/ImageIcon/ImageIcon.cpp create mode 100644 dev/ImageIcon/ImageIcon.h create mode 100644 dev/ImageIcon/ImageIcon.idl create mode 100644 dev/ImageIcon/ImageIcon.vcxitems create mode 100644 dev/ImageIcon/ImageIcon.xaml create mode 100644 dev/ImageIcon/ImageIcon_themeresources.xaml create mode 100644 dev/ImageIcon/InteractionTests/ImageIconTests.cs create mode 100644 dev/ImageIcon/InteractionTests/ImageIcon_InteractionTests.projitems create mode 100644 dev/ImageIcon/InteractionTests/ImageIcon_InteractionTests.shproj create mode 100644 dev/ImageIcon/TestUI/ImageIconPage.xaml create mode 100644 dev/ImageIcon/TestUI/ImageIconPage.xaml.cs create mode 100644 dev/ImageIcon/TestUI/ImageIcon_TestUI.projitems create mode 100644 dev/ImageIcon/TestUI/ImageIcon_TestUI.shproj create mode 100644 test/MUXControlsTestApp/Assets/libre-camera-panorama.svg diff --git a/FeatureAreas.props b/FeatureAreas.props index 9a43e2ca20..87d2acb705 100644 --- a/FeatureAreas.props +++ b/FeatureAreas.props @@ -210,6 +210,9 @@ + + + true @@ -268,6 +271,7 @@ true true true + true $(DefineConstants);FEATURE_SCROLLPRESENTER_ENABLED diff --git a/MUXControls.sln b/MUXControls.sln index 279388a5a6..e5226c5942 100644 --- a/MUXControls.sln +++ b/MUXControls.sln @@ -681,6 +681,16 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "InfoBar_TestUI", "dev\InfoB EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "InfoBar_InteractionTests", "dev\InfoBar\InteractionTests\InfoBar_InteractionTests.shproj", "{F470A64E-780E-45AA-ABB7-73A8734E51D7}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ImageIcon", "ImageIcon", "{BB791907-485F-4A16-9612-7FE07FCD1D21}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ImageIcon", "dev\ImageIcon\ImageIcon.vcxitems", "{9FB38577-696E-47BA-8AE2-F48A3C84A7CA}" +EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "ImageIcon_APITests", "dev\ImageIcon\APITests\ImageIcon_APITests.shproj", "{27AAE2E5-9687-4120-822F-CDB68B9A65B7}" +EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "ImageIcon_TestUI", "dev\ImageIcon\TestUI\ImageIcon_TestUI.shproj", "{DDE1C022-6F9A-4067-89C2-81F2EEAF249F}" +EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "ImageIcon_InteractionTests", "dev\ImageIcon\InteractionTests\ImageIcon_InteractionTests.shproj", "{F14FB632-E705-44BC-9415-75B539F483E1}" +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution dev\ComboBox\ComboBox.vcxitems*{00523caf-422a-4185-9392-d374b72a019a}*SharedItemsImports = 9 @@ -717,6 +727,7 @@ Global dev\ColorPicker\ColorPicker.vcxitems*{248cc96d-67a2-4359-a4e3-ab0dad110a1e}*SharedItemsImports = 9 dev\ContentDialog\ContentDialog.vcxitems*{2749c23c-0c58-4b0a-b48a-00fd4c1224d0}*SharedItemsImports = 9 dev\RatingControl\APITests\RatingControl_APITests.projitems*{274b93f7-cd18-4ed9-b569-0640529d187b}*SharedItemsImports = 13 + dev\ImageIcon\APITests\ImageIcon_APITests.projitems*{27aae2e5-9687-4120-822f-cdb68b9a65b7}*SharedItemsImports = 13 dev\SplitButton\TestUI\SplitButton_TestUI.projitems*{280c91f4-96b5-4bde-9e02-e573e1def583}*SharedItemsImports = 13 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 @@ -798,6 +809,7 @@ Global dev\SwipeControl\SwipeControl_InteractionTests\SwipeControl_InteractionTests.projitems*{9a8da438-193c-4950-a046-2952de2d3b0b}*SharedItemsImports = 13 dev\TwoPaneView\TestUI\TwoPaneView_TestUI.projitems*{9c533ec3-f8fa-4b0e-ba1b-3323932cdfcb}*SharedItemsImports = 13 dev\NumberBox\NumberBox.vcxitems*{9d23c997-1f46-444a-8c07-4a4bff7e4e63}*SharedItemsImports = 9 + dev\ImageIcon\ImageIcon.vcxitems*{9fb38577-696e-47ba-8ae2-f48a3c84a7ca}*SharedItemsImports = 9 dev\Repeater\Repeater.vcxitems*{a0aa8919-2140-42db-beb1-b2c3ace594f4}*SharedItemsImports = 9 dev\CommonStyles\InteractionTests\CommonStyles_InteractionTests.projitems*{a25ae312-7c11-4e30-ae35-2e31c744a250}*SharedItemsImports = 13 dev\ColorPicker\InteractionTests\ColorPicker_InteractionTests.projitems*{a4d2fae8-e7fc-4100-91ff-2202fac91c70}*SharedItemsImports = 13 @@ -823,6 +835,7 @@ Global dev\Expander\Expander.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\ImageIcon\ImageIcon.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 @@ -902,6 +915,7 @@ Global dev\DropDownButton\InteractionTests\DropDownButton_InteractionTests.projitems*{d9ac3716-5608-40d0-999f-26f4b544be33}*SharedItemsImports = 13 dev\AnimatedVisualPlayer\TestUI\AnimatedVisualPlayer_TestUI.projitems*{dbec0be4-ba3f-41c9-a303-af98201be6dc}*SharedItemsImports = 13 dev\PullToRefresh\RefreshContainer\TestUI\RefreshContainer_TestUI.projitems*{ddb468e4-7b64-4301-8fcb-1bebbb1e689f}*SharedItemsImports = 13 + dev\ImageIcon\TestUI\ImageIcon_TestUI.projitems*{dde1c022-6f9a-4067-89c2-81f2eeaf249f}*SharedItemsImports = 13 dev\CommonManaged\CommonManaged.projitems*{de061ed1-947e-487c-81b8-32e92e85b95f}*SharedItemsImports = 13 test\IXMPTestApp\IXMPTestApp.Shared.projitems*{de061ed1-947e-487c-81b8-32e92e85b95f}*SharedItemsImports = 13 dev\TreeView\APITests\TreeView_APITests.projitems*{de885c66-929c-464e-bac4-3e076ec46483}*SharedItemsImports = 13 @@ -928,6 +942,8 @@ Global dev\Expander\TestUI\Expander_TestUI.projitems*{dedc1e4f-cfa5-4443-83eb-e79d425df7e7}*SharedItemsImports = 4 dev\FlipView\TestUI\FlipView_TestUI.projitems*{dedc1e4f-cfa5-4443-83eb-e79d425df7e7}*SharedItemsImports = 4 dev\IconSource\APITests\IconSource_APITests.projitems*{dedc1e4f-cfa5-4443-83eb-e79d425df7e7}*SharedItemsImports = 4 + dev\ImageIcon\APITests\ImageIcon_APITests.projitems*{dedc1e4f-cfa5-4443-83eb-e79d425df7e7}*SharedItemsImports = 4 + dev\ImageIcon\TestUI\ImageIcon_TestUI.projitems*{dedc1e4f-cfa5-4443-83eb-e79d425df7e7}*SharedItemsImports = 4 dev\InfoBar\TestUI\InfoBar_TestUI.projitems*{dedc1e4f-cfa5-4443-83eb-e79d425df7e7}*SharedItemsImports = 4 dev\LayoutPanel\APITests\LayoutPanel_APITests.projitems*{dedc1e4f-cfa5-4443-83eb-e79d425df7e7}*SharedItemsImports = 4 dev\Materials\Acrylic\APITests\AcrylicBrush_ApiTests.projitems*{dedc1e4f-cfa5-4443-83eb-e79d425df7e7}*SharedItemsImports = 4 @@ -997,6 +1013,7 @@ Global dev\AutoSuggestBox\InteractionTests\AutoSuggestBox_InteractionTests.projitems*{ed3e2182-d259-4dc0-b7bb-9b4219762f4c}*SharedItemsImports = 13 dev\PullToRefresh\RefreshVisualizer\RefreshVisualizer.vcxitems*{ed7dba65-8f09-44f3-8d25-7bb5a7a89609}*SharedItemsImports = 9 dev\TreeView\TreeView.vcxitems*{eeb38379-3a5c-439f-bb5e-535d75f2b6c1}*SharedItemsImports = 9 + dev\ImageIcon\InteractionTests\ImageIcon_InteractionTests.projitems*{f14fb632-e705-44bc-9415-75b539f483e1}*SharedItemsImports = 13 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 @@ -1025,6 +1042,8 @@ Global dev\Expander\TestUI\Expander_TestUI.projitems*{fbc396f5-26dd-4ca3-981e-c7bc9fea4546}*SharedItemsImports = 4 dev\FlipView\TestUI\FlipView_TestUI.projitems*{fbc396f5-26dd-4ca3-981e-c7bc9fea4546}*SharedItemsImports = 4 dev\IconSource\APITests\IconSource_APITests.projitems*{fbc396f5-26dd-4ca3-981e-c7bc9fea4546}*SharedItemsImports = 4 + dev\ImageIcon\APITests\ImageIcon_APITests.projitems*{fbc396f5-26dd-4ca3-981e-c7bc9fea4546}*SharedItemsImports = 4 + dev\ImageIcon\TestUI\ImageIcon_TestUI.projitems*{fbc396f5-26dd-4ca3-981e-c7bc9fea4546}*SharedItemsImports = 4 dev\InfoBar\TestUI\InfoBar_TestUI.projitems*{fbc396f5-26dd-4ca3-981e-c7bc9fea4546}*SharedItemsImports = 4 dev\LayoutPanel\APITests\LayoutPanel_APITests.projitems*{fbc396f5-26dd-4ca3-981e-c7bc9fea4546}*SharedItemsImports = 4 dev\Materials\Acrylic\APITests\AcrylicBrush_ApiTests.projitems*{fbc396f5-26dd-4ca3-981e-c7bc9fea4546}*SharedItemsImports = 4 @@ -1701,19 +1720,24 @@ Global {DB2DBB48-C807-4F7C-943E-385E77DF7BDE} = {C0215617-A17B-45DB-9CDA-C46C0923DA55} {6B4C9F2E-6A2C-48AD-944B-49B9E9BF028D} = {C0215617-A17B-45DB-9CDA-C46C0923DA55} {10183D43-1785-443E-AEB7-C426FDF14964} = {05CB5DBD-A481-4DFF-B1A3-642F049D165C} - {84BB4F12-73FD-4E4A-8724-C2C060DF5E82} = {67599AD5-51EC-44CB-85CE-B60CD8CBA270} - {EC3B6F65-32C6-4BC8-8902-EE0B397E2787} = {84BB4F12-73FD-4E4A-8724-C2C060DF5E82} - {50C1F1D3-20AA-49A8-9E4C-CF4E5811A1D8} = {84BB4F12-73FD-4E4A-8724-C2C060DF5E82} - {D6DF4AB9-FACC-4E51-8C57-6B1F96919365} = {84BB4F12-73FD-4E4A-8724-C2C060DF5E82} {11DC7B03-88FB-4985-BF77-2BB3A13C75A8} = {67599AD5-51EC-44CB-85CE-B60CD8CBA270} {AB3261A7-9A8D-4A27-AEA2-3AAC0419C889} = {11DC7B03-88FB-4985-BF77-2BB3A13C75A8} {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} + {84BB4F12-73FD-4E4A-8724-C2C060DF5E82} = {67599AD5-51EC-44CB-85CE-B60CD8CBA270} + {EC3B6F65-32C6-4BC8-8902-EE0B397E2787} = {84BB4F12-73FD-4E4A-8724-C2C060DF5E82} + {50C1F1D3-20AA-49A8-9E4C-CF4E5811A1D8} = {84BB4F12-73FD-4E4A-8724-C2C060DF5E82} + {D6DF4AB9-FACC-4E51-8C57-6B1F96919365} = {84BB4F12-73FD-4E4A-8724-C2C060DF5E82} {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} + {BB791907-485F-4A16-9612-7FE07FCD1D21} = {67599AD5-51EC-44CB-85CE-B60CD8CBA270} + {9FB38577-696E-47BA-8AE2-F48A3C84A7CA} = {BB791907-485F-4A16-9612-7FE07FCD1D21} + {27AAE2E5-9687-4120-822F-CDB68B9A65B7} = {BB791907-485F-4A16-9612-7FE07FCD1D21} + {DDE1C022-6F9A-4067-89C2-81F2EEAF249F} = {BB791907-485F-4A16-9612-7FE07FCD1D21} + {F14FB632-E705-44BC-9415-75B539F483E1} = {BB791907-485F-4A16-9612-7FE07FCD1D21} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {D93836AB-52D3-4DE2-AE25-23F26F55ECED} diff --git a/MUXControlsInnerLoop.sln b/MUXControlsInnerLoop.sln index a70b9742e6..225d5ff516 100644 --- a/MUXControlsInnerLoop.sln +++ b/MUXControlsInnerLoop.sln @@ -1,4 +1,4 @@ - + Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.29009.5 @@ -496,6 +496,16 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "InfoBar_InteractionTests", EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "InfoBar_TestUI", "dev\InfoBar\TestUI\InfoBar_TestUI.shproj", "{32DFAF1E-C2EC-4C52-A4D8-B3A3946242B4}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ImageIcon", "ImageIcon", "{21638B33-D4DE-4D10-84F8-3E2DACF975C7}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ImageIcon", "dev\ImageIcon\ImageIcon.vcxitems", "{9FB38577-696E-47BA-8AE2-F48A3C84A7CA}" +EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "ImageIcon_APITests", "dev\ImageIcon\APITests\ImageIcon_APITests.shproj", "{27AAE2E5-9687-4120-822F-CDB68B9A65B7}" +EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "ImageIcon_TestUI", "dev\ImageIcon\TestUI\ImageIcon_TestUI.shproj", "{DDE1C022-6F9A-4067-89C2-81F2EEAF249F}" +EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "ImageIcon_InteractionTests", "dev\ImageIcon\InteractionTests\ImageIcon_InteractionTests.shproj", "{F14FB632-E705-44BC-9415-75B539F483E1}" +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution dev\ComboBox\ComboBox.vcxitems*{00523caf-422a-4185-9392-d374b72a019a}*SharedItemsImports = 9 @@ -530,6 +540,7 @@ Global dev\Interactions\ButtonInteraction\ButtonInteraction.vcxitems*{2459bc06-2ae5-4c65-ba73-ab28090b6fab}*SharedItemsImports = 9 dev\ColorPicker\ColorPicker.vcxitems*{248cc96d-67a2-4359-a4e3-ab0dad110a1e}*SharedItemsImports = 9 dev\RatingControl\APITests\RatingControl_APITests.projitems*{274b93f7-cd18-4ed9-b569-0640529d187b}*SharedItemsImports = 13 + dev\ImageIcon\APITests\ImageIcon_APITests.projitems*{27aae2e5-9687-4120-822f-cdb68b9a65b7}*SharedItemsImports = 13 dev\SplitButton\TestUI\SplitButton_TestUI.projitems*{280c91f4-96b5-4bde-9e02-e573e1def583}*SharedItemsImports = 13 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 @@ -607,6 +618,7 @@ Global dev\SwipeControl\SwipeControl_InteractionTests\SwipeControl_InteractionTests.projitems*{9a8da438-193c-4950-a046-2952de2d3b0b}*SharedItemsImports = 13 dev\TwoPaneView\TestUI\TwoPaneView_TestUI.projitems*{9c533ec3-f8fa-4b0e-ba1b-3323932cdfcb}*SharedItemsImports = 13 dev\NumberBox\NumberBox.vcxitems*{9d23c997-1f46-444a-8c07-4a4bff7e4e63}*SharedItemsImports = 9 + dev\ImageIcon\ImageIcon.vcxitems*{9fb38577-696e-47ba-8ae2-f48a3c84a7ca}*SharedItemsImports = 9 dev\Repeater\Repeater.vcxitems*{a0aa8919-2140-42db-beb1-b2c3ace594f4}*SharedItemsImports = 9 dev\CommonStyles\InteractionTests\CommonStyles_InteractionTests.projitems*{a25ae312-7c11-4e30-ae35-2e31c744a250}*SharedItemsImports = 13 dev\ColorPicker\InteractionTests\ColorPicker_InteractionTests.projitems*{a4d2fae8-e7fc-4100-91ff-2202fac91c70}*SharedItemsImports = 13 @@ -618,14 +630,10 @@ Global dev\Common\Common.vcxitems*{ad0c90b0-4845-4d4b-88f1-86f653f8171b}*SharedItemsImports = 4 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\Expander\Expander.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 @@ -664,13 +672,10 @@ Global dev\DropDownButton\InteractionTests\DropDownButton_InteractionTests.projitems*{d9ac3716-5608-40d0-999f-26f4b544be33}*SharedItemsImports = 13 dev\AnimatedVisualPlayer\TestUI\AnimatedVisualPlayer_TestUI.projitems*{dbec0be4-ba3f-41c9-a303-af98201be6dc}*SharedItemsImports = 13 dev\PullToRefresh\RefreshContainer\TestUI\RefreshContainer_TestUI.projitems*{ddb468e4-7b64-4301-8fcb-1bebbb1e689f}*SharedItemsImports = 13 + dev\ImageIcon\TestUI\ImageIcon_TestUI.projitems*{dde1c022-6f9a-4067-89c2-81f2eeaf249f}*SharedItemsImports = 13 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\Expander\TestUI\Expander_TestUI.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 @@ -683,15 +688,12 @@ Global dev\Expander\Expander.vcxitems*{ec3b6f65-32c6-4bc8-8902-ee0b397e2787}*SharedItemsImports = 9 dev\PullToRefresh\RefreshVisualizer\RefreshVisualizer.vcxitems*{ed7dba65-8f09-44f3-8d25-7bb5a7a89609}*SharedItemsImports = 9 dev\TreeView\TreeView.vcxitems*{eeb38379-3a5c-439f-bb5e-535d75f2b6c1}*SharedItemsImports = 9 + dev\ImageIcon\InteractionTests\ImageIcon_InteractionTests.projitems*{f14fb632-e705-44bc-9415-75b539f483e1}*SharedItemsImports = 13 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\Expander\TestUI\Expander_TestUI.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 @@ -1139,25 +1141,26 @@ Global {990BBC65-1114-435D-B5CC-1EB8AAAD72DD} = {633B8D7A-3207-4BD3-8159-B65710AEA6FF} {128E6F7A-578C-48DC-BD3F-750EC662C268} = {633B8D7A-3207-4BD3-8159-B65710AEA6FF} {6F7831A4-48F8-41E8-A573-C567A1223CB5} = {05CB5DBD-A481-4DFF-B1A3-642F049D165C} - {93FAB536-1139-4FD1-B0BF-97C0C6FAB378} = {67599AD5-51EC-44CB-85CE-B60CD8CBA270} - {EC3B6F65-32C6-4BC8-8902-EE0B397E2787} = {93FAB536-1139-4FD1-B0BF-97C0C6FAB378} - {50C1F1D3-20AA-49A8-9E4C-CF4E5811A1D8} = {93FAB536-1139-4FD1-B0BF-97C0C6FAB378} - {D6DF4AB9-FACC-4E51-8C57-6B1F96919365} = {93FAB536-1139-4FD1-B0BF-97C0C6FAB378} {E7C2104F-770D-4375-8D3A-D173F222273A} = {67599AD5-51EC-44CB-85CE-B60CD8CBA270} {AB3261A7-9A8D-4A27-AEA2-3AAC0419C889} = {E7C2104F-770D-4375-8D3A-D173F222273A} {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} + {93FAB536-1139-4FD1-B0BF-97C0C6FAB378} = {67599AD5-51EC-44CB-85CE-B60CD8CBA270} + {EC3B6F65-32C6-4BC8-8902-EE0B397E2787} = {93FAB536-1139-4FD1-B0BF-97C0C6FAB378} + {50C1F1D3-20AA-49A8-9E4C-CF4E5811A1D8} = {93FAB536-1139-4FD1-B0BF-97C0C6FAB378} + {D6DF4AB9-FACC-4E51-8C57-6B1F96919365} = {93FAB536-1139-4FD1-B0BF-97C0C6FAB378} {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} + {21638B33-D4DE-4D10-84F8-3E2DACF975C7} = {67599AD5-51EC-44CB-85CE-B60CD8CBA270} + {9FB38577-696E-47BA-8AE2-F48A3C84A7CA} = {21638B33-D4DE-4D10-84F8-3E2DACF975C7} + {27AAE2E5-9687-4120-822F-CDB68B9A65B7} = {21638B33-D4DE-4D10-84F8-3E2DACF975C7} + {DDE1C022-6F9A-4067-89C2-81F2EEAF249F} = {21638B33-D4DE-4D10-84F8-3E2DACF975C7} + {F14FB632-E705-44BC-9415-75B539F483E1} = {21638B33-D4DE-4D10-84F8-3E2DACF975C7} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {D93836AB-52D3-4DE2-AE25-23F26F55ECED} EndGlobalSection -EndGlobal \ No newline at end of file +EndGlobal diff --git a/dev/Generated/ImageIcon.properties.cpp b/dev/Generated/ImageIcon.properties.cpp new file mode 100644 index 0000000000..f6bde6d4ac --- /dev/null +++ b/dev/Generated/ImageIcon.properties.cpp @@ -0,0 +1,62 @@ +// 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 "ImageIcon.h" + +namespace winrt::Microsoft::UI::Xaml::Controls +{ + CppWinRTActivatableClassWithDPFactory(ImageIcon) +} + +#include "ImageIcon.g.cpp" + +GlobalDependencyProperty ImageIconProperties::s_SourceProperty{ nullptr }; + +ImageIconProperties::ImageIconProperties() +{ + EnsureProperties(); +} + +void ImageIconProperties::EnsureProperties() +{ + if (!s_SourceProperty) + { + s_SourceProperty = + InitializeDependencyProperty( + L"Source", + winrt::name_of(), + winrt::name_of(), + false /* isAttached */, + ValueHelper::BoxedDefaultValue(), + winrt::PropertyChangedCallback(&OnSourcePropertyChanged)); + } +} + +void ImageIconProperties::ClearProperties() +{ + s_SourceProperty = nullptr; +} + +void ImageIconProperties::OnSourcePropertyChanged( + winrt::DependencyObject const& sender, + winrt::DependencyPropertyChangedEventArgs const& args) +{ + auto owner = sender.as(); + winrt::get_self(owner)->OnSourcePropertyChanged(args); +} + +void ImageIconProperties::Source(winrt::ImageSource const& value) +{ + [[gsl::suppress(con)]] + { + static_cast(this)->SetValue(s_SourceProperty, ValueHelper::BoxValueIfNecessary(value)); + } +} + +winrt::ImageSource ImageIconProperties::Source() +{ + return ValueHelper::CastOrUnbox(static_cast(this)->GetValue(s_SourceProperty)); +} diff --git a/dev/Generated/ImageIcon.properties.h b/dev/Generated/ImageIcon.properties.h new file mode 100644 index 0000000000..4250123eed --- /dev/null +++ b/dev/Generated/ImageIcon.properties.h @@ -0,0 +1,25 @@ +// 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 ImageIconProperties +{ +public: + ImageIconProperties(); + + void Source(winrt::ImageSource const& value); + winrt::ImageSource Source(); + + static winrt::DependencyProperty SourceProperty() { return s_SourceProperty; } + + static GlobalDependencyProperty s_SourceProperty; + + static void EnsureProperties(); + static void ClearProperties(); + + static void OnSourcePropertyChanged( + winrt::DependencyObject const& sender, + winrt::DependencyPropertyChangedEventArgs const& args); +}; diff --git a/dev/Generated/ImageIconSource.properties.cpp b/dev/Generated/ImageIconSource.properties.cpp new file mode 100644 index 0000000000..0bda61de85 --- /dev/null +++ b/dev/Generated/ImageIconSource.properties.cpp @@ -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. + +// DO NOT EDIT! This file was generated by CustomTasks.DependencyPropertyCodeGen +#include "pch.h" +#include "common.h" +#include "ImageIconSource.h" + +namespace winrt::Microsoft::UI::Xaml::Controls +{ + CppWinRTActivatableClassWithDPFactory(ImageIconSource) +} + +#include "ImageIconSource.g.cpp" + +GlobalDependencyProperty ImageIconSourceProperties::s_ImageSourceProperty{ nullptr }; + +ImageIconSourceProperties::ImageIconSourceProperties() +{ + EnsureProperties(); +} + +void ImageIconSourceProperties::EnsureProperties() +{ + IconSource::EnsureProperties(); + if (!s_ImageSourceProperty) + { + s_ImageSourceProperty = + InitializeDependencyProperty( + L"ImageSource", + winrt::name_of(), + winrt::name_of(), + false /* isAttached */, + ValueHelper::BoxedDefaultValue(), + nullptr); + } +} + +void ImageIconSourceProperties::ClearProperties() +{ + s_ImageSourceProperty = nullptr; + IconSource::ClearProperties(); +} + +void ImageIconSourceProperties::ImageSource(winrt::ImageSource const& value) +{ + [[gsl::suppress(con)]] + { + static_cast(this)->SetValue(s_ImageSourceProperty, ValueHelper::BoxValueIfNecessary(value)); + } +} + +winrt::ImageSource ImageIconSourceProperties::ImageSource() +{ + return ValueHelper::CastOrUnbox(static_cast(this)->GetValue(s_ImageSourceProperty)); +} diff --git a/dev/Generated/ImageIconSource.properties.h b/dev/Generated/ImageIconSource.properties.h new file mode 100644 index 0000000000..394639351a --- /dev/null +++ b/dev/Generated/ImageIconSource.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 ImageIconSourceProperties +{ +public: + ImageIconSourceProperties(); + + void ImageSource(winrt::ImageSource const& value); + winrt::ImageSource ImageSource(); + + static winrt::DependencyProperty ImageSourceProperty() { return s_ImageSourceProperty; } + + static GlobalDependencyProperty s_ImageSourceProperty; + + static void EnsureProperties(); + static void ClearProperties(); +}; diff --git a/dev/IconSource/APITests/IconSourceApiTests.cs b/dev/IconSource/APITests/IconSourceApiTests.cs index dc79be9187..024f1c04e0 100644 --- a/dev/IconSource/APITests/IconSourceApiTests.cs +++ b/dev/IconSource/APITests/IconSourceApiTests.cs @@ -23,8 +23,11 @@ using SymbolIconSource = Microsoft.UI.Xaml.Controls.SymbolIconSource; using FontIconSource = Microsoft.UI.Xaml.Controls.FontIconSource; using BitmapIconSource = Microsoft.UI.Xaml.Controls.BitmapIconSource; +using ImageIconSource = Microsoft.UI.Xaml.Controls.ImageIconSource; using PathIconSource = Microsoft.UI.Xaml.Controls.PathIconSource; using XamlControlsXamlMetaDataProvider = Microsoft.UI.Xaml.XamlTypeInfo.XamlControlsXamlMetaDataProvider; +using Microsoft.UI.Xaml.Controls; +using Windows.UI.Xaml.Media.Imaging; namespace Windows.UI.Xaml.Tests.MUXControls.ApiTests { @@ -156,6 +159,40 @@ public void BitmapIconSourceTest() }); } + [TestMethod] + public void ImageIconSourceTest() + { + ImageIconSource iconSource = null; + var uri = new Uri("ms-appx:///Assets/Nuclear_symbol.svg"); + + RunOnUIThread.Execute(() => + { + iconSource = new ImageIconSource(); + + // IconSource.Foreground should be null to allow foreground inheritance from + // the parent to work. + Verify.AreEqual(iconSource.Foreground, null); + + Log.Comment("Validate the defaults match BitmapIcon."); + + var icon = new ImageIcon(); + Verify.AreEqual(icon.Source, iconSource.ImageSource); + + Log.Comment("Validate that you can change the properties."); + + iconSource.Foreground = new SolidColorBrush(Windows.UI.Colors.Red); + iconSource.ImageSource = new SvgImageSource(uri); + }); + IdleSynchronizer.Wait(); + + RunOnUIThread.Execute(() => + { + Verify.IsTrue(iconSource.Foreground is SolidColorBrush); + Verify.AreEqual(Windows.UI.Colors.Red, (iconSource.Foreground as SolidColorBrush).Color); + Verify.AreEqual(uri, ((SvgImageSource)iconSource.ImageSource).UriSource); + }); + } + [TestMethod] public void PathIconSourceTest() { diff --git a/dev/IconSource/IconSource.idl b/dev/IconSource/IconSource.idl index 3b0e30c076..bbe0908e29 100644 --- a/dev/IconSource/IconSource.idl +++ b/dev/IconSource/IconSource.idl @@ -90,4 +90,15 @@ unsealed runtimeclass PathIconSource : IconSource static Windows.UI.Xaml.DependencyProperty DataProperty { get; }; } +[WUXC_VERSION_PREVIEW] +[webhosthidden] +unsealed runtimeclass ImageIconSource : IconSource +{ + ImageIconSource(); + + Windows.UI.Xaml.Media.ImageSource ImageSource{ get; set; }; + + static Windows.UI.Xaml.DependencyProperty ImageSourceProperty{ get; }; +} + } diff --git a/dev/IconSource/IconSource.vcxitems b/dev/IconSource/IconSource.vcxitems index 866f6dd552..e4bf8a8ec3 100644 --- a/dev/IconSource/IconSource.vcxitems +++ b/dev/IconSource/IconSource.vcxitems @@ -18,11 +18,13 @@ + + @@ -30,6 +32,7 @@ + diff --git a/dev/IconSource/ImageIconSource.cpp b/dev/IconSource/ImageIconSource.cpp new file mode 100644 index 0000000000..3102d197b1 --- /dev/null +++ b/dev/IconSource/ImageIconSource.cpp @@ -0,0 +1,8 @@ +// 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 "IconSource.h" +#include "ImageIconSource.h" diff --git a/dev/IconSource/ImageIconSource.h b/dev/IconSource/ImageIconSource.h new file mode 100644 index 0000000000..b19c5204a3 --- /dev/null +++ b/dev/IconSource/ImageIconSource.h @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#pragma once + +#include "IconSource.h" +#include "ImageIconSource.g.h" +#include "ImageIconSource.properties.h" + +class ImageIconSource : + public ReferenceTracker, + public ImageIconSourceProperties +{ +public: + using ImageIconSourceProperties::EnsureProperties; + using ImageIconSourceProperties::ClearProperties; +}; diff --git a/dev/ImageIcon/APITests/ImageIconTests.cs b/dev/ImageIcon/APITests/ImageIconTests.cs new file mode 100644 index 0000000000..c4393cc3bd --- /dev/null +++ b/dev/ImageIcon/APITests/ImageIconTests.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System; +using Common; +using System.Collections.Generic; +using Microsoft.UI.Xaml.Controls; +using MUXControlsTestApp.Utilities; +using Windows.UI.Xaml.Media.Imaging; +using Windows.UI.Xaml.Media; +using Windows.UI.Xaml.Controls; + +#if USING_TAEF +using WEX.TestExecution; +using WEX.TestExecution.Markup; +using WEX.Logging.Interop; +#else +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestTools.UnitTesting.Logging; +#endif + +namespace Windows.UI.Xaml.Tests.MUXControls.ApiTests +{ + + [TestClass] + public class ImageIconTests : ApiTestBase + { + [TestMethod] + public void ImageIconTest() + { + ImageIcon imageIcon = null; + var uri = new Uri("ms-appx:///Assets/Nuclear_symbol.svg"); + + RunOnUIThread.Execute(() => + { + imageIcon = new ImageIcon(); + var theme = Application.Current.RequestedTheme; + if (theme == ApplicationTheme.Dark) + { + Verify.AreEqual(((SolidColorBrush)imageIcon.Foreground).Color, Colors.White); + } + else + { + Verify.AreEqual(((SolidColorBrush)imageIcon.Foreground).Color, Colors.Black); + } + + Log.Comment("Validate that you can change the properties."); + + imageIcon.Foreground = new SolidColorBrush(Windows.UI.Colors.Red); + imageIcon.Source = new SvgImageSource(uri); + Content = imageIcon; + Content.UpdateLayout(); + }); + IdleSynchronizer.Wait(); + + RunOnUIThread.Execute(() => + { + Verify.IsTrue(imageIcon.Foreground is SolidColorBrush); + Verify.AreEqual(Windows.UI.Colors.Red, (imageIcon.Foreground as SolidColorBrush).Color); + Verify.AreEqual(uri, ((SvgImageSource)imageIcon.Source).UriSource); + if (PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone5)) + { + var image = ((Image)VisualTreeHelper.GetChild(VisualTreeHelper.GetChild(imageIcon, 0), 0)); + Verify.IsTrue(image.IsLoaded); + } + }); + } + } +} diff --git a/dev/ImageIcon/APITests/ImageIcon_APITests.projitems b/dev/ImageIcon/APITests/ImageIcon_APITests.projitems new file mode 100644 index 0000000000..9e193cd08b --- /dev/null +++ b/dev/ImageIcon/APITests/ImageIcon_APITests.projitems @@ -0,0 +1,14 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + cb2352e2-d633-41a3-8cdc-b28731a4c490 + + + ImageIcon_APITests + + + + + diff --git a/dev/ImageIcon/APITests/ImageIcon_APITests.shproj b/dev/ImageIcon/APITests/ImageIcon_APITests.shproj new file mode 100644 index 0000000000..21e9af9f32 --- /dev/null +++ b/dev/ImageIcon/APITests/ImageIcon_APITests.shproj @@ -0,0 +1,13 @@ + + + + {27AAE2E5-9687-4120-822F-CDB68B9A65B7} + 14.0 + + + + + + + + \ No newline at end of file diff --git a/dev/ImageIcon/ImageIcon.cpp b/dev/ImageIcon/ImageIcon.cpp new file mode 100644 index 0000000000..05ade7e2e4 --- /dev/null +++ b/dev/ImageIcon/ImageIcon.cpp @@ -0,0 +1,36 @@ +// 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 "ImageIcon.h" +#include "RuntimeProfiler.h" +#include "ResourceAccessor.h" + +ImageIcon::ImageIcon() +{ + __RP_Marker_ClassById(RuntimeProfiler::ProfId_ImageIcon); +} + +void ImageIcon::OnApplyTemplate() +{ + winrt::IInspectable diagnostics{}; + if (auto const grid = winrt::VisualTreeHelper::GetChild(*this, 0).as()) + { + auto const image = winrt::VisualTreeHelper::GetChild(grid, 0).as(); + image.Source(Source()); + m_rootImage.set(image); + } + else + { + m_rootImage.set(nullptr); + } +} + +void ImageIcon::OnSourcePropertyChanged(const winrt::DependencyPropertyChangedEventArgs& args) +{ + if (auto const image = m_rootImage.get()) + { + image.Source(Source()); + } +} diff --git a/dev/ImageIcon/ImageIcon.h b/dev/ImageIcon/ImageIcon.h new file mode 100644 index 0000000000..21f2dd837d --- /dev/null +++ b/dev/ImageIcon/ImageIcon.h @@ -0,0 +1,29 @@ +// 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 "ImageIcon.g.h" +#include "ImageIcon.properties.h" + +class ImageIcon : + public ReferenceTracker, + public ImageIconProperties +{ + +public: + ImageIcon(); + ~ImageIcon() {} + + // IFrameworkElement + void OnApplyTemplate(); + + void OnSourcePropertyChanged(const winrt::DependencyPropertyChangedEventArgs& args); + +private: + + tracker_ref m_rootImage{ this }; +}; diff --git a/dev/ImageIcon/ImageIcon.idl b/dev/ImageIcon/ImageIcon.idl new file mode 100644 index 0000000000..6516cc6c41 --- /dev/null +++ b/dev/ImageIcon/ImageIcon.idl @@ -0,0 +1,16 @@ +namespace MU_XC_NAMESPACE +{ + +[WUXC_VERSION_PREVIEW] +[webhosthidden] +unsealed runtimeclass ImageIcon : Windows.UI.Xaml.Controls.IconElement +{ + ImageIcon(); + + [MUX_PROPERTY_CHANGED_CALLBACK(TRUE)] + Windows.UI.Xaml.Media.ImageSource Source{ get; set; }; + + static Windows.UI.Xaml.DependencyProperty SourceProperty{ get; }; +} + +} diff --git a/dev/ImageIcon/ImageIcon.vcxitems b/dev/ImageIcon/ImageIcon.vcxitems new file mode 100644 index 0000000000..f74f27d02c --- /dev/null +++ b/dev/ImageIcon/ImageIcon.vcxitems @@ -0,0 +1,37 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + {9FB38577-696E-47BA-8AE2-F48A3C84A7CA} + + + + %(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory) + %(PreprocessorDefinitions);IMAGEICON_INCLUDED + + + + + + + + + + + + + + + RS1 + DefaultStyle + + + RS1 + ThemeResources + + + + + + \ No newline at end of file diff --git a/dev/ImageIcon/ImageIcon.xaml b/dev/ImageIcon/ImageIcon.xaml new file mode 100644 index 0000000000..bdd42aee5f --- /dev/null +++ b/dev/ImageIcon/ImageIcon.xaml @@ -0,0 +1,10 @@ + + + + + + diff --git a/dev/ImageIcon/ImageIcon_themeresources.xaml b/dev/ImageIcon/ImageIcon_themeresources.xaml new file mode 100644 index 0000000000..ceaa145ec4 --- /dev/null +++ b/dev/ImageIcon/ImageIcon_themeresources.xaml @@ -0,0 +1,7 @@ + + + + diff --git a/dev/ImageIcon/InteractionTests/ImageIconTests.cs b/dev/ImageIcon/InteractionTests/ImageIconTests.cs new file mode 100644 index 0000000000..371ed6ec17 --- /dev/null +++ b/dev/ImageIcon/InteractionTests/ImageIconTests.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System; +using Common; +using Windows.UI.Xaml.Tests.MUXControls.InteractionTests.Infra; +using Windows.UI.Xaml.Tests.MUXControls.InteractionTests.Common; +using System.Collections.Generic; + +#if USING_TAEF +using WEX.TestExecution; +using WEX.TestExecution.Markup; +using WEX.Logging.Interop; +#else +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestTools.UnitTesting.Logging; +#endif + +using Microsoft.Windows.Apps.Test.Automation; +using Microsoft.Windows.Apps.Test.Foundation; +using Microsoft.Windows.Apps.Test.Foundation.Controls; +using Microsoft.Windows.Apps.Test.Foundation.Patterns; +using Microsoft.Windows.Apps.Test.Foundation.Waiters; + +namespace Windows.UI.Xaml.Tests.MUXControls.InteractionTests +{ + [TestClass] + public class ImageIconTests + { + [ClassInitialize] + [TestProperty("RunAs", "User")] + [TestProperty("Classification", "Integration")] + [TestProperty("Platform", "Any")] + [TestProperty("MUXControlsTestSuite", "SuiteB")] + public static void ClassInitialize(TestContext testContext) + { + TestEnvironment.Initialize(testContext); + } + + public void TestCleanup() + { + TestCleanupHelper.Cleanup(); + } + + [TestMethod] + public void BasicTest() + { + Log.Comment("ImageIcon Basic Test"); + } + } +} diff --git a/dev/ImageIcon/InteractionTests/ImageIcon_InteractionTests.projitems b/dev/ImageIcon/InteractionTests/ImageIcon_InteractionTests.projitems new file mode 100644 index 0000000000..1b4bd2f366 --- /dev/null +++ b/dev/ImageIcon/InteractionTests/ImageIcon_InteractionTests.projitems @@ -0,0 +1,15 @@ + + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + A1553559-5786-4B44-AB9E-94AB95C86D4D + + + ImageIcon_InteractionTests + + + + + diff --git a/dev/ImageIcon/InteractionTests/ImageIcon_InteractionTests.shproj b/dev/ImageIcon/InteractionTests/ImageIcon_InteractionTests.shproj new file mode 100644 index 0000000000..b29ef36f5e --- /dev/null +++ b/dev/ImageIcon/InteractionTests/ImageIcon_InteractionTests.shproj @@ -0,0 +1,14 @@ + + + + + {F14FB632-E705-44BC-9415-75B539F483E1} + 15.0 + + + + + + + + \ No newline at end of file diff --git a/dev/ImageIcon/TestUI/ImageIconPage.xaml b/dev/ImageIcon/TestUI/ImageIconPage.xaml new file mode 100644 index 0000000000..6c27d223cd --- /dev/null +++ b/dev/ImageIcon/TestUI/ImageIconPage.xaml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/ImageIcon/TestUI/ImageIconPage.xaml.cs b/dev/ImageIcon/TestUI/ImageIconPage.xaml.cs new file mode 100644 index 0000000000..138ece7cf8 --- /dev/null +++ b/dev/ImageIcon/TestUI/ImageIconPage.xaml.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Controls.Primitives; +using Windows.UI.Xaml.Media; +using Windows.UI.Xaml.Markup; +using Windows.UI; +using System.Windows.Input; + +using ImageIcon = Microsoft.UI.Xaml.Controls.ImageIcon; +using Windows.UI.Xaml.Media.Imaging; + +namespace MUXControlsTestApp +{ + [TopLevelTestPage(Name = "ImageIcon")] + public sealed partial class ImageIconPage : TestPage + { + public ImageIconPage() + { + this.InitializeComponent(); + } + + private void ToggleButton_Checked(object sender, RoutedEventArgs e) + { + this.ImageIcon.Source = new SvgImageSource(new Uri("ms-appx:///Assets/libre-camera-panorama.svg")); + } + private void ToggleButton_Unchecked(object sender, RoutedEventArgs e) + { + BitmapImage bitmapImage = new BitmapImage(); + Uri uri = new Uri("ms-appx:///Assets/ingredient2.png"); + bitmapImage.UriSource = uri; + + this.ImageIcon.Source = bitmapImage; + } + } +} diff --git a/dev/ImageIcon/TestUI/ImageIcon_TestUI.projitems b/dev/ImageIcon/TestUI/ImageIcon_TestUI.projitems new file mode 100644 index 0000000000..77de7178e8 --- /dev/null +++ b/dev/ImageIcon/TestUI/ImageIcon_TestUI.projitems @@ -0,0 +1,23 @@ + + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + 280C91F4-96B5-4BDE-9E02-E573E1DEF583 + + + ImageIcon_TestUI + + + + Designer + MSBuild:Compile + + + + + ImageIconPage.xaml + + + diff --git a/dev/ImageIcon/TestUI/ImageIcon_TestUI.shproj b/dev/ImageIcon/TestUI/ImageIcon_TestUI.shproj new file mode 100644 index 0000000000..9b5177601b --- /dev/null +++ b/dev/ImageIcon/TestUI/ImageIcon_TestUI.shproj @@ -0,0 +1,14 @@ + + + + + {DDE1C022-6F9A-4067-89C2-81F2EEAF249F} + 15.0 + + + + + + + + \ No newline at end of file diff --git a/dev/Telemetry/RuntimeProfiler.h b/dev/Telemetry/RuntimeProfiler.h index f3da752d16..70d3ad2c28 100644 --- a/dev/Telemetry/RuntimeProfiler.h +++ b/dev/Telemetry/RuntimeProfiler.h @@ -50,6 +50,7 @@ namespace RuntimeProfiler ProfId_InfoBar, ProfId_Expander, ProfId_PagerControl, + ProfId_ImageIcon, ProfId_Size // ProfId_Size is the last always. } ProfilerClassId; @@ -87,3 +88,4 @@ namespace RuntimeProfiler } \ } + diff --git a/dev/dll/Microsoft.UI.Xaml.vcxproj b/dev/dll/Microsoft.UI.Xaml.vcxproj index 4b7e681468..cbe00d9ab7 100644 --- a/dev/dll/Microsoft.UI.Xaml.vcxproj +++ b/dev/dll/Microsoft.UI.Xaml.vcxproj @@ -1,4 +1,4 @@ - + @@ -138,9 +138,10 @@ - - - + + + + diff --git a/dev/dll/SharedHelpers.cpp b/dev/dll/SharedHelpers.cpp index 8fedba719d..012ff859db 100644 --- a/dev/dll/SharedHelpers.cpp +++ b/dev/dll/SharedHelpers.cpp @@ -565,6 +565,19 @@ winrt::IconElement SharedHelpers::MakeIconElementFrom(winrt::IconSource const& i } return bitmapIcon; } + else if (auto imageIconSource = iconSource.try_as()) + { + winrt::ImageIcon imageIcon; + if (const auto imageSource = imageIconSource.ImageSource()) + { + imageIcon.Source(imageSource); + } + if (const auto newForeground = imageIconSource.Foreground()) + { + imageIcon.Foreground(newForeground); + } + return imageIcon; + } else if (auto pathIconSource = iconSource.try_as()) { winrt::PathIcon pathIcon; diff --git a/dev/inc/CppWinRTHelpers.h b/dev/inc/CppWinRTHelpers.h index ab95a950bd..0b3a6834f3 100644 --- a/dev/inc/CppWinRTHelpers.h +++ b/dev/inc/CppWinRTHelpers.h @@ -279,6 +279,23 @@ struct __declspec(empty_bases) DeriveFromPanelHelper_base : winrt::Windows::UI:: } }; +template +struct __declspec(empty_bases)DeriveFromBitmapIconHelper_base : winrt::Windows::UI::Xaml::Controls::BitmapIconT, winrt::composable, I...> +{ + using composable = T; + using class_type = typename T; + + operator class_type() const noexcept + { + return static_cast(*this).as(); + } + + hstring GetRuntimeClassName() const + { + return hstring{ winrt::name_of() }; + } +}; + // // An awaitable object. Completes when the CompleteAwaits() method is called. // cf. .NET's TaskCompletionSource. diff --git a/test/MUXControls.Test/MUXControls.Test.Shared.targets b/test/MUXControls.Test/MUXControls.Test.Shared.targets index fc0449955d..33ce6c21e0 100644 --- a/test/MUXControls.Test/MUXControls.Test.Shared.targets +++ b/test/MUXControls.Test/MUXControls.Test.Shared.targets @@ -41,4 +41,5 @@ + \ No newline at end of file diff --git a/test/MUXControlsTestApp/Assets/libre-camera-panorama.svg b/test/MUXControlsTestApp/Assets/libre-camera-panorama.svg new file mode 100644 index 0000000000..0133a2f0b3 --- /dev/null +++ b/test/MUXControlsTestApp/Assets/libre-camera-panorama.svg @@ -0,0 +1,9 @@ + diff --git a/test/MUXControlsTestApp/MUXControlsTestApp.Shared.projitems b/test/MUXControlsTestApp/MUXControlsTestApp.Shared.projitems index 322597f433..52fc39ddb7 100644 --- a/test/MUXControlsTestApp/MUXControlsTestApp.Shared.projitems +++ b/test/MUXControlsTestApp/MUXControlsTestApp.Shared.projitems @@ -152,6 +152,7 @@ + diff --git a/test/MUXControlsTestApp/MUXControlsTestApp.Shared.targets b/test/MUXControlsTestApp/MUXControlsTestApp.Shared.targets index 1e40196b51..328212188c 100644 --- a/test/MUXControlsTestApp/MUXControlsTestApp.Shared.targets +++ b/test/MUXControlsTestApp/MUXControlsTestApp.Shared.targets @@ -89,4 +89,6 @@ + + \ No newline at end of file