From 274492be9708ee1f7eed68a6a0b786394ff6481f Mon Sep 17 00:00:00 2001 From: Alexandre Zollinger Chohfi Date: Fri, 14 Aug 2020 15:30:25 -0700 Subject: [PATCH 1/8] Removed TabView/TabViewItem, HeaderedTextBlock, LightBehavior/AnimationExtensions.Light, and some other smaller methods marked as Obsolete. --- .../Services/LinkedIn/LinkedInDataProvider.cs | 11 - .../Services/LinkedIn/LinkedInService.cs | 9 - .../Services/Twitter/TwitterDataProvider.cs | 11 - .../Services/Twitter/TwitterService.cs | 9 - .../Services/Weibo/WeiboDataProvider.cs | 11 - .../Services/Weibo/WeiboService.cs | 9 - .../Microsoft.Toolkit.Uwp.SampleApp.csproj | 30 - .../HeaderedTextBlock/HeaderedTextBlock.png | Bin 3308 -> 0 bytes .../HeaderedTextBlockCode.bind | 16 - .../HeaderedTextBlockPage.xaml | 9 - .../HeaderedTextBlockPage.xaml.cs | 18 - .../SamplePages/Light/LightBehavior.png | Bin 6164 -> 0 bytes .../SamplePages/Light/LightBehaviorCode.bind | 8 - .../SamplePages/Light/LightBehaviorPage.xaml | 39 - .../Light/LightBehaviorPage.xaml.cs | 52 -- .../SamplePages/Light/LightBehaviorXaml.bind | 25 - .../SamplePages/TabView/TabView.png | Bin 1392 -> 0 bytes .../SamplePages/TabView/TabViewPage.xaml | 19 - .../SamplePages/TabView/TabViewPage.xaml.cs | 73 -- .../SamplePages/TabView/TabViewXaml.bind | 97 --- .../SamplePages/samples.json | 37 - .../Behaviors/Light.cs | 69 -- .../ConnectedAnimations/Connected.cs | 16 - .../Extensions/AnimationExtensions.Light.cs | 210 +---- .../HeaderedTextBlockMetadata.cs | 49 -- ...soft.Toolkit.Uwp.UI.Controls.Design.csproj | 3 - .../TabViewItemMetadata.cs | 43 - .../TabViewMetadata.cs | 54 -- .../HeaderedTextBlock.Properties.cs | 172 ---- .../HeaderedTextBlock/HeaderedTextBlock.cs | 76 -- .../HeaderedTextBlock/HeaderedTextBlock.xaml | 60 -- .../Microsoft.Toolkit.Uwp.UI.Controls.csproj | 1 - ...Toolkit.Uwp.UI.Controls.csproj.DotSettings | 1 - .../Strings/en-US/Resources.resw | 8 - .../TabView/TabClosingEventArgs.cs | 36 - .../TabView/TabDraggedOutsideEventArgs.cs | 35 - .../TabView/TabView.HeaderLayout.cs | 221 ------ .../TabView/TabView.ItemSources.cs | 115 --- .../TabView/TabView.Properties.cs | 245 ------ .../TabView/TabView.cs | 320 -------- .../TabView/TabView.xaml | 736 ------------------ .../TabView/TabViewItem.Properties.cs | 79 -- .../TabView/TabViewItem.cs | 116 --- .../TabView/TabWidthMode.cs | 36 - .../Themes/Generic.xaml | 2 - .../TileControl/TileControl.cs | 7 - .../VisualStudioToolsManifest.xml | 3 - .../Extensions/StringExtensions.cs | 8 - 48 files changed, 4 insertions(+), 3200 deletions(-) delete mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedTextBlock/HeaderedTextBlock.png delete mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedTextBlock/HeaderedTextBlockCode.bind delete mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedTextBlock/HeaderedTextBlockPage.xaml delete mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedTextBlock/HeaderedTextBlockPage.xaml.cs delete mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Light/LightBehavior.png delete mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Light/LightBehaviorCode.bind delete mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Light/LightBehaviorPage.xaml delete mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Light/LightBehaviorPage.xaml.cs delete mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Light/LightBehaviorXaml.bind delete mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabView/TabView.png delete mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabView/TabViewPage.xaml delete mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabView/TabViewPage.xaml.cs delete mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabView/TabViewXaml.bind delete mode 100644 Microsoft.Toolkit.Uwp.UI.Animations/Behaviors/Light.cs delete mode 100644 Microsoft.Toolkit.Uwp.UI.Controls.Design/HeaderedTextBlockMetadata.cs delete mode 100644 Microsoft.Toolkit.Uwp.UI.Controls.Design/TabViewItemMetadata.cs delete mode 100644 Microsoft.Toolkit.Uwp.UI.Controls.Design/TabViewMetadata.cs delete mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/HeaderedTextBlock/HeaderedTextBlock.Properties.cs delete mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/HeaderedTextBlock/HeaderedTextBlock.cs delete mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/HeaderedTextBlock/HeaderedTextBlock.xaml delete mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabClosingEventArgs.cs delete mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabDraggedOutsideEventArgs.cs delete mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.HeaderLayout.cs delete mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.ItemSources.cs delete mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.Properties.cs delete mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.cs delete mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.xaml delete mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabViewItem.Properties.cs delete mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabViewItem.cs delete mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabWidthMode.cs diff --git a/Microsoft.Toolkit.Services/Services/LinkedIn/LinkedInDataProvider.cs b/Microsoft.Toolkit.Services/Services/LinkedIn/LinkedInDataProvider.cs index f852688bc57..27c7739c333 100644 --- a/Microsoft.Toolkit.Services/Services/LinkedIn/LinkedInDataProvider.cs +++ b/Microsoft.Toolkit.Services/Services/LinkedIn/LinkedInDataProvider.cs @@ -154,17 +154,6 @@ public async Task LoginAsync() return false; } - /// - /// Log user out of LinkedIn. - /// - [Obsolete("Logout is deprecated, please use LogoutAsync instead.", true)] - public void Logout() - { -#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed - LogoutAsync(); -#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed - } - /// /// Log user out of LinkedIn. /// diff --git a/Microsoft.Toolkit.Services/Services/LinkedIn/LinkedInService.cs b/Microsoft.Toolkit.Services/Services/LinkedIn/LinkedInService.cs index 251e5fb711d..7a79b8fc344 100644 --- a/Microsoft.Toolkit.Services/Services/LinkedIn/LinkedInService.cs +++ b/Microsoft.Toolkit.Services/Services/LinkedIn/LinkedInService.cs @@ -92,15 +92,6 @@ public Task ShareActivityAsync(LinkedInShareRequest share return Provider.ShareDataAsync(shareRequest); } - /// - /// Log user out of LinkedIn. - /// - [Obsolete("Logout is deprecated, please use LogoutAsync instead.", true)] - public void Logout() - { - Provider.Logout(); - } - /// /// Log user out of LinkedIn. /// diff --git a/Microsoft.Toolkit.Services/Services/Twitter/TwitterDataProvider.cs b/Microsoft.Toolkit.Services/Services/Twitter/TwitterDataProvider.cs index a6eda59f07e..41db01d748b 100644 --- a/Microsoft.Toolkit.Services/Services/Twitter/TwitterDataProvider.cs +++ b/Microsoft.Toolkit.Services/Services/Twitter/TwitterDataProvider.cs @@ -273,17 +273,6 @@ public async Task LoginAsync() return false; } - /// - /// Log user out of Twitter. - /// - [Obsolete("Logout is deprecated, please use LogoutAsync instead.", true)] - public void Logout() - { -#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed - LogoutAsync(); -#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed - } - /// /// Log user out of Twitter. /// diff --git a/Microsoft.Toolkit.Services/Services/Twitter/TwitterService.cs b/Microsoft.Toolkit.Services/Services/Twitter/TwitterService.cs index 703657cf2fb..b461458ce8d 100644 --- a/Microsoft.Toolkit.Services/Services/Twitter/TwitterService.cs +++ b/Microsoft.Toolkit.Services/Services/Twitter/TwitterService.cs @@ -400,15 +400,6 @@ public Task LoginAsync() return Provider.LoginAsync(); } - /// - /// Log user out of Twitter. - /// - [Obsolete("Logout is deprecated, please use LogoutAsync instead.", true)] - public void Logout() - { - Provider.Logout(); - } - /// /// Log user out of Twitter. /// diff --git a/Microsoft.Toolkit.Services/Services/Weibo/WeiboDataProvider.cs b/Microsoft.Toolkit.Services/Services/Weibo/WeiboDataProvider.cs index 3dd6d59a8ac..6975a33d005 100644 --- a/Microsoft.Toolkit.Services/Services/Weibo/WeiboDataProvider.cs +++ b/Microsoft.Toolkit.Services/Services/Weibo/WeiboDataProvider.cs @@ -163,17 +163,6 @@ public async Task LoginAsync() return false; } - /// - /// Log user out of Weibo. - /// - [Obsolete("Logout is deprecated, please use LogoutAsync instead.", true)] - public void Logout() - { -#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed - LogoutAsync(); -#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed - } - /// /// Log user out of Weibo. /// diff --git a/Microsoft.Toolkit.Services/Services/Weibo/WeiboService.cs b/Microsoft.Toolkit.Services/Services/Weibo/WeiboService.cs index f5f8dd7ec99..ea2f6cea3b1 100644 --- a/Microsoft.Toolkit.Services/Services/Weibo/WeiboService.cs +++ b/Microsoft.Toolkit.Services/Services/Weibo/WeiboService.cs @@ -183,15 +183,6 @@ public Task LoginAsync() return Provider.LoginAsync(); } - /// - /// Log user out of Weibo. - /// - [Obsolete("Logout is deprecated, please use LogoutAsync instead.", true)] - public void Logout() - { - Provider.Logout(); - } - /// /// Log user out of Weibo. /// diff --git a/Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj b/Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj index 6426c03d171..4291bcd25b3 100644 --- a/Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj +++ b/Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj @@ -280,7 +280,6 @@ - @@ -318,7 +317,6 @@ - @@ -327,7 +325,6 @@ - @@ -369,7 +366,6 @@ - @@ -429,8 +425,6 @@ - - Designer @@ -512,9 +506,6 @@ - - Designer - @@ -656,9 +647,6 @@ - - TabViewPage.xaml - UniformGridPage.xaml @@ -867,9 +855,6 @@ - - LightBehaviorPage.xaml - LinkedInPage.xaml @@ -921,9 +906,6 @@ FadeBehaviorPage.xaml - - HeaderedTextBlockPage.xaml - ImageExPage.xaml @@ -1056,10 +1038,6 @@ Designer MSBuild:Compile - - MSBuild:Compile - Designer - MSBuild:Compile Designer @@ -1352,10 +1330,6 @@ MSBuild:Compile Designer - - Designer - MSBuild:Compile - Designer MSBuild:Compile @@ -1424,10 +1398,6 @@ MSBuild:Compile Designer - - Designer - MSBuild:Compile - MSBuild:Compile Designer diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedTextBlock/HeaderedTextBlock.png b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedTextBlock/HeaderedTextBlock.png deleted file mode 100644 index 4b495ab237ab617b406082956fa4df6764313695..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3308 zcmeH~**6=C7RE!&Lrtfps8CaTYN&%!Eipt@kydpu#nhIVrIa2af{KI|HIy1^o|V#| z#&Ag0P%+Q5LyRdWGMKM*|AV{MeYg*Iul3t|KYb71!?)MQJ%F0<^N8~R004f|yO4(f z0E_h5-p0jo)(gJ0)}0MDe?!wpTxS)+^&ATT@a3CA3?9AC+@AHtO42TM?bZ_&pUMlc zio3@h=)1=x=nuF=iKt-~BC$pCwht0Cu3TMhXMf{l43Z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$~0rRsg07MSAnB+zwd#+H=^bD+VhE(_f9!uYP7w2 TO!KSG-WPzWF%(j1=oIlU(~cTl diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedTextBlock/HeaderedTextBlockCode.bind b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedTextBlock/HeaderedTextBlockCode.bind deleted file mode 100644 index a2db4b8dc80..00000000000 --- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedTextBlock/HeaderedTextBlockCode.bind +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedTextBlock/HeaderedTextBlockPage.xaml b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedTextBlock/HeaderedTextBlockPage.xaml deleted file mode 100644 index a5795898a0e..00000000000 --- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedTextBlock/HeaderedTextBlockPage.xaml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedTextBlock/HeaderedTextBlockPage.xaml.cs b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedTextBlock/HeaderedTextBlockPage.xaml.cs deleted file mode 100644 index 77cdba59f3e..00000000000 --- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedTextBlock/HeaderedTextBlockPage.xaml.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Toolkit.Uwp.SampleApp.Models; - -using Windows.UI.Xaml.Navigation; - -namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages -{ - public sealed partial class HeaderedTextBlockPage - { - public HeaderedTextBlockPage() - { - InitializeComponent(); - } - } -} \ No newline at end of file diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Light/LightBehavior.png b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Light/LightBehavior.png deleted file mode 100644 index b2235f1b9e4577a48af0b24d219f8485b2a71878..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6164 zcmZ9QcQl*r8^@DaF`JayBSuRrwEEhs5hB)W#0)}PlvZh#m{qg(Y|$DaX4EXAX3=4k zB34qfLlIJ=W?R+%^8WjK{&=3}+~?f)ea@|sr>nD zBb@pSO=Xcoc^X?Jv2w9hyZp#udlnKkApBQS0A-^=-~O2Sw*!Ah07a;dI>8@tDWqsS zvO-WcZOMQ#g$?zS%|vSs`r1H8)S{*az6DI&3zEMrXUdSy;e!JA-Sl`>p*MZypSqm` z(Q&_S&|w87QrGrDP{hajHkQH3UkjWS7X^U(k)5Zt34xpJtcw#uDS%&mo3Ue$uTnXA zU(?Nv0D3OC=pP9fKiaE3`HKeo2qf$|BB=nPYi$4q_~=1jzs>C|UXn@j z7X$|N)`OI|zG7_d@a4*UP99o%#{n5Uc(p5R?%?v(UG+?{z!QaIKt zfv17X#EbyAT16NpW-PaFSUY#<1CJfJj2i{OkqEG##vyj+yUH#N$0kAM;2@vg;23WW zVog{L$B0icIIRp;CidTQV=&@62l4WEiJvlCY{}@DY#>yc%)DHG5txI!J6Bn~Y;aA0 zxfWCoCO*J-NnWhtx0wBrBy%?ROlBV#X!Dl0NzPXgI9;o_Xuv;krsl?^6JZU(D5wwLPs$++zphG(nR4~VxmV711D zyz*|dt;tAz@VYYH@Y?kQ7vi%{X=F9?sHzM1J6{DlhULA>4Y-2!j%%-kS5Sn_Aix}& z@{e!+=;IK@jR({RtadgKC{idDFuZQ|!3vsnnhqIGaaMWHcCNvADB-yA~-AD$L0ItVa)BL%4~9p7JGrJ&-;bOa<)X zIqrA%O`X_0FmjOGUp`PsdvN~9LCkp)iex%(#_pljxpUmb@3A)C=M(bWCRkRly@gSp z<=u3X@=5|U=i<2}uC4=&g_6nwJbrv!$1cn5IQc|XJ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!BTCS4}FxRm~rqJ3B{5v4og@eoj%XN(C-A=5OmYL5ftGX@4;7U^7t?6@2 zmR;IqR%>a3;{+ksn7lf&qyb*vb5k~I%J~_Sh4#37{H<3~11=Iu0)#(Vy0=r8ObN>e z6OYX1>plX`#jZl2h_&^bB}q_qj#NO|0F1S|aG$owO;p%$g(3t{i&a*fhm9_d1~${# azb+0$RdwfQyenj4et;>;(x?G>HTHj)(0CpI diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Light/LightBehaviorCode.bind b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Light/LightBehaviorCode.bind deleted file mode 100644 index 4019e9a2ce7..00000000000 --- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Light/LightBehaviorCode.bind +++ /dev/null @@ -1,8 +0,0 @@ -// XAML UIElement - - -// C# - Light can be applied to any UIElement. In this case it is an image called ToolkitLogo. -using Microsoft.Toolkit.Uwp.UI.Animations; - -var lightAnimationSet = ToolkitLogo.Light(distance: 10, duration: 500, delay: 0, color: Colors.Red); -await lightAnimationSet.StartAsync(); \ No newline at end of file diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Light/LightBehaviorPage.xaml b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Light/LightBehaviorPage.xaml deleted file mode 100644 index 8eba95bedbd..00000000000 --- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Light/LightBehaviorPage.xaml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Light/LightBehaviorPage.xaml.cs b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Light/LightBehaviorPage.xaml.cs deleted file mode 100644 index fd59ec7d5be..00000000000 --- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Light/LightBehaviorPage.xaml.cs +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Linq; -using Microsoft.Toolkit.Uwp.UI.Animations; -using Microsoft.Toolkit.Uwp.UI.Animations.Behaviors; -using Microsoft.Toolkit.Uwp.UI.Extensions; -using Microsoft.Xaml.Interactivity; -using Windows.UI.Xaml; - -namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages -{ - /// - /// A page that shows how to use the light behavior. - /// - public sealed partial class LightBehaviorPage : IXamlRenderListener - { -#pragma warning disable CS0618 // Type or member is obsolete - private Light _lightBehavior; -#pragma warning restore CS0618 // Type or member is obsolete - - /// - /// Initializes a new instance of the class. - /// - public LightBehaviorPage() - { - this.InitializeComponent(); - - if (!AnimationExtensions.IsLightingSupported) - { - WarningText.Visibility = Visibility.Visible; - } - - SampleController.Current.RegisterNewCommand("Apply", (s, e) => - { - _lightBehavior?.StartAnimation(); - }); - } - - public void OnXamlRendered(FrameworkElement control) - { - if (control.FindChildByName("EffectElement") is FrameworkElement element) - { - var behaviors = Interaction.GetBehaviors(element); -#pragma warning disable CS0618 // Type or member is obsolete - _lightBehavior = behaviors.FirstOrDefault(item => item is Light) as Light; -#pragma warning restore CS0618 // Type or member is obsolete - } - } - } -} \ No newline at end of file diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Light/LightBehaviorXaml.bind b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Light/LightBehaviorXaml.bind deleted file mode 100644 index 2ca51bf1cfc..00000000000 --- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Light/LightBehaviorXaml.bind +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabView/TabView.png b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabView/TabView.png deleted file mode 100644 index 9aeebd1d673de8670b59cb522700c93f1c75b887..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1392 zcmeAS@N?(olHy`uVBq!ia0y~yU{nCI4{)#n$t4^1Z39v)>5jgR3=A9lx&I`x0{NT; z9+AZi3_@Vc*rT+Q9VjSK;u=vBoS#-wo>-L1P>`6JSE84fTB2a0XQ*fNOZn_apgHe6 zT^vIy;@;jkn3<9;(sHr$a7C&>Me2+jB8``VnSxjjMP@u{{Ps+A*_%VZT#Kdr^5tW8 z?PLG@_VH)g2NUMU?`QbaU-$RJ?e_cje?B@kH25n!957^Jks+S?oXJ@AJU_4Ksap8< z*>{W?tq%CEyYu8#+2m?92lgE&r_PSKn^$z6vX!n@AaI&`f&Rut(%&YBXu(h{8E`O?i>b#Gwa0B+aHTQB0Y2Yh>nZ-My5VNg$EMEQ9q9}FxG6!zhBS5Tj$4m^~aMNz|xVy)78&qol`;+ E0K}H&HUIzs diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabView/TabViewPage.xaml b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabView/TabViewPage.xaml deleted file mode 100644 index 32f465f2c64..00000000000 --- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabView/TabViewPage.xaml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabView/TabViewPage.xaml.cs b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabView/TabViewPage.xaml.cs deleted file mode 100644 index 74d9a3db253..00000000000 --- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabView/TabViewPage.xaml.cs +++ /dev/null @@ -1,73 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections.ObjectModel; -using Microsoft.Toolkit.Uwp.UI.Controls; -using Microsoft.Toolkit.Uwp.UI.Extensions; -using Windows.UI.Popups; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; - -namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages -{ - public sealed partial class TabViewPage : Page, IXamlRenderListener - { - #pragma warning disable CS0618 // Type or member is obsolete - private TabView _tabs; - - private int _counter = 1; - - public TabViewPage() - { - this.InitializeComponent(); - } - - public void OnXamlRendered(FrameworkElement control) - { - _tabs = control.FindChildByName("Tabs") as TabView; - if (_tabs != null) - { - _tabs.TabDraggedOutside += Tabs_TabDraggedOutside; - _tabs.TabClosing += Tabs_TabClosing; - } - - var btn = control.FindDescendantByName("AddTabButtonUpper") as Button; - if (btn != null) - { - btn.Click += AddUpperTabClick; - } - } - - private void AddUpperTabClick(object sender, RoutedEventArgs e) - { - _tabs.Items.Add(new TabViewItem() - { - Header = "Untitled " + _counter, - Icon = new SymbolIcon(Symbol.Document), - Content = "This is new tab #" + _counter++ + "." - }); - } - - private void Tabs_TabClosing(object sender, TabClosingEventArgs e) - { - TabViewNotification.Show("You're closing the '" + e.Tab.Header + "' tab.", 2000); - } - - private void Tabs_TabDraggedOutside(object sender, TabDraggedOutsideEventArgs e) - { - // The sample app let's you drag items from a static TabView with TabViewItem's pre-defined. - // In the case of data bound scenarios e.Item should be your data item, and e.Tab should always be the TabViewItem. - var str = e.Item.ToString(); - - if (e.Tab != null) - { - str = e.Tab.Header.ToString(); - } - - TabViewNotification.Show("Tore Tab '" + str + "' Outside of TabView.", 2000); - } - #pragma warning restore CS0618 // Type or member is obsolete - } -} diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabView/TabViewXaml.bind b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabView/TabViewXaml.bind deleted file mode 100644 index e81732aa2a3..00000000000 --- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabView/TabViewXaml.bind +++ /dev/null @@ -1,97 +0,0 @@ - - - - - - - - - - 40 - 48 - 200 - - - - - - - - - - - The TabView control has multiple uses. - - - It has a lot of versitility out of the box for different scenarios. - - - You can enable drag-and-drop and reorder the tabs too. - - - This tab isn't closable because its IsClosable property is set to False, even when CanCloseTabs is True. - - - - - - - - - - - - - - - - - diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/samples.json b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/samples.json index 7cba82117d9..1856644c3df 100644 --- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/samples.json +++ b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/samples.json @@ -14,18 +14,6 @@ "Icon": "/SamplePages/TextToolbar/TextToolbar.png", "DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/controls/TextToolbar.md" }, - { - "Name": "TabView", - "Type": "TabViewPage", - "Subcategory": "Layout", - "BadgeUpdateVersionRequired": "DEPRECATED", - "DeprecatedWarning": "Please migrate to the TabView control from WinUI, this control will be removed in a future release. https://aka.ms/winui", - "About": "A control for displaying multiple items in the same space and allows a user to easily switch between them.", - "CodeUrl": "https://github.com/windows-toolkit/WindowsCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI.Controls/TabView", - "XamlCodeFile": "TabViewXaml.bind", - "Icon": "/SamplePages/TabView/TabView.png", - "DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/controls/TabView.md" - }, { "Name": "DataGrid", "Type": "DataGridPage", @@ -86,18 +74,6 @@ "Icon": "/SamplePages/ImageEx/ImageEx.png", "DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/controls/ImageEx.md" }, - { - "Name": "HeaderedTextBlock", - "Type": "HeaderedTextBlockPage", - "Subcategory": "Layout", - "About": "The HeaderedTextBlock control is designed to provide a header for read only text. This control is useful for displaying read only forms.", - "CodeUrl": "https://github.com/windows-toolkit/WindowsCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI.Controls/HeaderedTextBlock", - "XamlCodeFile": "HeaderedTextBlockCode.bind", - "Icon": "/SamplePages/HeaderedTextBlock/HeaderedTextBlock.png", - "DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/controls/HeaderedTextBlock.md", - "BadgeUpdateVersionRequired": "DEPRECATED", - "DeprecatedWarning": "The HeaderedTextBlock has been replaced with the HeaderedContentControl and will be removed in a future major release." - }, { "Name": "MasterDetailsView", "Type": "MasterDetailsViewPage", @@ -532,19 +508,6 @@ "BadgeUpdateVersionRequired": "Anniversary Update required", "DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/animations/Saturation.md" }, - { - "Name": "Light", - "Type": "LightBehaviorPage", - "Subcategory": "Behavior", - "About": "The Light effect will be removed in a future major release", - "BadgeUpdateVersionRequired": "DEPRECATED", - "DeprecatedWarning": "The Light effect will be removed in a future major release", - "CodeUrl": "https://github.com/windows-toolkit/WindowsCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI.Animations/Behaviors", - "CodeFile": "LightBehaviorCode.bind", - "XamlCodeFile": "LightBehaviorXaml.bind", - "Icon": "/SamplePages/Light/LightBehavior.png", - "DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/animations/Light.md" - }, { "Name": "FadeHeader", "Type": "FadeHeaderBehaviorPage", diff --git a/Microsoft.Toolkit.Uwp.UI.Animations/Behaviors/Light.cs b/Microsoft.Toolkit.Uwp.UI.Animations/Behaviors/Light.cs deleted file mode 100644 index 8940f3eb630..00000000000 --- a/Microsoft.Toolkit.Uwp.UI.Animations/Behaviors/Light.cs +++ /dev/null @@ -1,69 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using Windows.UI; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Media; - -namespace Microsoft.Toolkit.Uwp.UI.Animations.Behaviors -{ - /// - /// Applies a basic point light to a UIElement. You control the intensity by setting the distance of the light. - /// - /// - /// - [Obsolete("The Light effect will be removed in a future major release. Please use XamlLight instead")] - - public class Light : CompositionBehaviorBase - { - /// - /// The Blur value of the associated object - /// - public static readonly DependencyProperty DistanceProperty = DependencyProperty.Register(nameof(Distance), typeof(double), typeof(Light), new PropertyMetadata(0d, PropertyChangedCallback)); - - /// - /// The Color of the spotlight no the associated object. - /// - public static readonly DependencyProperty ColorProperty = DependencyProperty.Register("Color", typeof(Brush), typeof(Light), new PropertyMetadata(new SolidColorBrush(Colors.White))); - - /// - /// Gets or sets the Blur. - /// - /// - /// The Blur. - /// - public double Distance - { - get { return (double)GetValue(DistanceProperty); } - set { SetValue(DistanceProperty, value); } - } - - /// - /// Gets or sets the color of the spotlight. - /// - public Brush Color - { - get { return (Brush)GetValue(ColorProperty); } - set { SetValue(ColorProperty, value); } - } - - /// - /// Starts the animation. - /// - public override void StartAnimation() - { - if (AnimationExtensions.IsLightingSupported) - { - AssociatedObject?.Light( - duration: Duration, - delay: Delay, - easingType: EasingType, - easingMode: EasingMode, - distance: (float)Distance, - color: ((SolidColorBrush)Color).Color)?.Start(); - } - } - } -} diff --git a/Microsoft.Toolkit.Uwp.UI.Animations/ConnectedAnimations/Connected.cs b/Microsoft.Toolkit.Uwp.UI.Animations/ConnectedAnimations/Connected.cs index a0e5afa756d..999ea1d40c4 100644 --- a/Microsoft.Toolkit.Uwp.UI.Animations/ConnectedAnimations/Connected.cs +++ b/Microsoft.Toolkit.Uwp.UI.Animations/ConnectedAnimations/Connected.cs @@ -361,22 +361,6 @@ public static void UnregisterListItemForConnectedAnimation(this Page page, ListV } } - /// - /// Sets the object that will be used during next Frame navigation for - /// Connected Animation involving a list control (item must be an element of - /// ListViewBase.ItemsSource collection). - /// Useful if the parameter used during page navigation is different from the - /// data item in the list control. Also useful during back navigation if the - /// item navigating back to is different from the item that was navigated from. - /// - /// The Frame handling the navigation - /// The data item from a list control to be animated during next frame navigation - [Obsolete("Method is replaced by SetListDataItemForNextConnectedAnimation")] - public static void SetListDataItemForNextConnectedAnnimation(this Frame frame, object item) - { - GetConnectedAnimationHelper(frame)?.SetParameterForNextFrameNavigation(item); - } - /// /// Sets the object that will be used during next Frame navigation for /// Connected Animation involving a list control (item must be an element of diff --git a/Microsoft.Toolkit.Uwp.UI.Animations/Extensions/AnimationExtensions.Light.cs b/Microsoft.Toolkit.Uwp.UI.Animations/Extensions/AnimationExtensions.Light.cs index 0949dd235dd..3bc0da11259 100644 --- a/Microsoft.Toolkit.Uwp.UI.Animations/Extensions/AnimationExtensions.Light.cs +++ b/Microsoft.Toolkit.Uwp.UI.Animations/Extensions/AnimationExtensions.Light.cs @@ -3,16 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; -using Microsoft.Graphics.Canvas; -using Microsoft.Graphics.Canvas.Effects; -using Microsoft.Toolkit.Uwp.Helpers; -using Windows.UI; -using Windows.UI.Composition; -using Windows.UI.Composition.Effects; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Hosting; -using Windows.UI.Xaml.Media.Animation; namespace Microsoft.Toolkit.Uwp.UI.Animations { @@ -22,204 +12,12 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations public static partial class AnimationExtensions { /// - /// Stores all the point lights along with the visuals that they are applied to. - /// This is to stop multiplication of point lights on a single visual. - /// - private static Dictionary pointLights = new Dictionary(); - - /// - /// Gets a value indicating whether this instance is lighting supported. + /// Gets a value indicating whether this instance is lighting supported. Deprecated. Will always return true. /// /// - /// true if this instance is lighting supported; otherwise, false. + /// Deprecated. Will always returns true. /// - public static bool IsLightingSupported - { - get - { - bool lightingSupported = true; - - if (!Windows.Foundation.Metadata.ApiInformation.IsMethodPresent("Windows.UI.Xaml.Hosting.ElementCompositionPreview", "SetElementChildVisual")) - { - lightingSupported = false; - } - - if (!Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.Composition.CompositionSurfaceBrush")) - { - lightingSupported = false; - } - - return lightingSupported; - } - } - - /// - /// Animates a point light and it's distance. - /// - /// The associated object. - /// The value. - /// The duration. - /// The delay. - /// The color of the spotlight. - /// The easing function - /// The easing mode - /// An animation set. - [Obsolete("The Light effect will be removed in a future major release. Please use XamlLight instead")] - public static AnimationSet Light( - this FrameworkElement associatedObject, - double distance = 0d, - double duration = 500d, - double delay = 0d, - Color? color = null, - EasingType easingType = EasingType.Default, - EasingMode easingMode = EasingMode.EaseOut) - { - if (associatedObject == null) - { - return null; - } - - var animationSet = new AnimationSet(associatedObject); - return animationSet.Light(distance, duration, delay, color, easingType, easingMode); - } - - /// - /// Animates a point light and it's distance. - /// - /// The animation set. - /// The distance of the light. - /// The duration in milliseconds. - /// The delay. (ignored if duration == 0) - /// The color of the spotlight. - /// The easing function - /// The easing mode - /// - /// - /// An Animation Set. - /// - [Obsolete("The Light effect will be removed in a future major release. Please use XamlLight instead")] - public static AnimationSet Light( - this AnimationSet animationSet, - double distance = 0d, - double duration = 500d, - double delay = 0d, - Color? color = null, - EasingType easingType = EasingType.Default, - EasingMode easingMode = EasingMode.EaseOut) - { - if (!IsLightingSupported) - { - return null; - } - - if (animationSet == null) - { - return null; - } - - var visual = animationSet.Visual; - var associatedObject = animationSet.Element as FrameworkElement; - - if (associatedObject == null) - { - return animationSet; - } - - var compositor = visual?.Compositor; - if (compositor == null) - { - return null; - } - - var task = new AnimationTask(); - task.AnimationSet = animationSet; - - task.Task = DispatcherHelper.ExecuteOnUIThreadAsync( - () => - { - const string sceneName = "PointLightScene"; - PointLight pointLight; - CompositionDrawingSurface normalMap = null; - - if (!pointLights.ContainsKey(visual)) - { - SurfaceLoader.Initialize(compositor); - normalMap = SurfaceLoader.LoadText(string.Empty, new Windows.Foundation.Size(512, 512), new Graphics.Canvas.Text.CanvasTextFormat(), Colors.Transparent, Colors.Transparent); - } - - if (pointLights.ContainsKey(visual)) - { - pointLight = pointLights[visual]; - } - else - { - pointLight = compositor.CreatePointLight(); - - var normalBrush = compositor.CreateSurfaceBrush(normalMap); - normalBrush.Stretch = CompositionStretch.Fill; - - // check to see if the visual already has a point light applied. - var spriteVisual = ElementCompositionPreview.GetElementChildVisual(associatedObject) as SpriteVisual; - var normalsBrush = spriteVisual?.Brush as CompositionEffectBrush; - - if (normalsBrush == null || normalsBrush.Comment != sceneName) - { - var lightEffect = new CompositeEffect() - { - Mode = CanvasComposite.Add, - Sources = - { - new CompositionEffectSourceParameter("ImageSource"), - new SceneLightingEffect() - { - Name = sceneName, - AmbientAmount = 0, - DiffuseAmount = 0.5f, - SpecularAmount = 0, - NormalMapSource = new CompositionEffectSourceParameter("NormalMap"), - } - } - }; - - var effectFactory = compositor.CreateEffectFactory(lightEffect); - var brush = effectFactory.CreateBrush(); - brush.SetSourceParameter("NormalMap", normalBrush); - - var sprite = compositor.CreateSpriteVisual(); - sprite.Size = visual.Size; - sprite.Brush = brush; - sprite.Comment = sceneName; - - ElementCompositionPreview.SetElementChildVisual(task.AnimationSet.Element, sprite); - - pointLight.CoordinateSpace = visual; - pointLight.Targets.Add(visual); - } - } - - pointLight.Color = color ?? Colors.White; - var delayTime = task.Delay != null ? task.Delay.Value : TimeSpan.FromMilliseconds(delay); - var durationTime = task.Duration != null ? task.Duration.Value : TimeSpan.FromMilliseconds(duration); - - if (durationTime.TotalMilliseconds <= 0) - { - task.AnimationSet.AddEffectDirectPropertyChange(pointLight, (float)distance, nameof(pointLight.Offset)); - } - else - { - var diffuseAnimation = compositor.CreateVector3KeyFrameAnimation(); - diffuseAnimation.InsertKeyFrame(1f, new System.Numerics.Vector3(visual.Size.X / 2, visual.Size.Y / 2, (float)distance), GetCompositionEasingFunction(easingType, compositor, easingMode)); - diffuseAnimation.Duration = durationTime; - diffuseAnimation.DelayTime = delayTime; - - task.AnimationSet.AddCompositionEffectAnimation(pointLight, diffuseAnimation, nameof(pointLight.Offset)); - } - - pointLights[visual] = pointLight; - }, Windows.UI.Core.CoreDispatcherPriority.Normal); - - animationSet.AddAnimationThroughTask(task); - return animationSet; - } + [Obsolete("This method is deprecated and will always return true")] + public static bool IsLightingSupported => true; } } diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.Design/HeaderedTextBlockMetadata.cs b/Microsoft.Toolkit.Uwp.UI.Controls.Design/HeaderedTextBlockMetadata.cs deleted file mode 100644 index 3cba40e11f1..00000000000 --- a/Microsoft.Toolkit.Uwp.UI.Controls.Design/HeaderedTextBlockMetadata.cs +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Toolkit.Uwp.UI.Controls.Design.Common; -using Microsoft.Windows.Design; -using Microsoft.Windows.Design.Features; -using Microsoft.Windows.Design.Metadata; -using Microsoft.Windows.Design.Model; -using Microsoft.Windows.Design.PropertyEditing; -using System.ComponentModel; - -namespace Microsoft.Toolkit.Uwp.UI.Controls.Design -{ - internal class HeaderedTextBlockDefaults : DefaultInitializer - { - public override void InitializeDefaults(ModelItem item) - { - item.Properties[nameof(HeaderedTextBlock.Header)].SetValue(string.Empty); - item.Properties[nameof(HeaderedTextBlock.Text)].SetValue(string.Empty); - } - } - internal class HeaderedTextBlockMetadata : AttributeTableBuilder - { - public HeaderedTextBlockMetadata() - : base() - { - AddCallback(typeof(Microsoft.Toolkit.Uwp.UI.Controls.HeaderedTextBlock), - b => - { - b.AddCustomAttributes(new FeatureAttribute(typeof(HeaderedTextBlockDefaults))); - b.AddCustomAttributes(nameof(HeaderedTextBlock.HeaderTemplate), - new CategoryAttribute(Properties.Resources.CategoryAppearance), - new EditorBrowsableAttribute(EditorBrowsableState.Advanced) - ); - b.AddCustomAttributes(nameof(HeaderedTextBlock.TextStyle), - new CategoryAttribute(Properties.Resources.CategoryAppearance), - new EditorBrowsableAttribute(EditorBrowsableState.Advanced) - ); - b.AddCustomAttributes(nameof(HeaderedTextBlock.Header), new CategoryAttribute(Properties.Resources.CategoryCommon)); - b.AddCustomAttributes(nameof(HeaderedTextBlock.Text), new CategoryAttribute(Properties.Resources.CategoryCommon)); - b.AddCustomAttributes(nameof(HeaderedTextBlock.Orientation), new CategoryAttribute(Properties.Resources.CategoryAppearance)); - b.AddCustomAttributes(nameof(HeaderedTextBlock.HideTextIfEmpty), new CategoryAttribute(Properties.Resources.CategoryAppearance)); - b.AddCustomAttributes(new ToolboxCategoryAttribute(ToolboxCategoryPaths.Toolkit, false)); - } - ); - } - } -} diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.Design/Microsoft.Toolkit.Uwp.UI.Controls.Design.csproj b/Microsoft.Toolkit.Uwp.UI.Controls.Design/Microsoft.Toolkit.Uwp.UI.Controls.Design.csproj index b611399dd13..b7b241a6403 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls.Design/Microsoft.Toolkit.Uwp.UI.Controls.Design.csproj +++ b/Microsoft.Toolkit.Uwp.UI.Controls.Design/Microsoft.Toolkit.Uwp.UI.Controls.Design.csproj @@ -85,7 +85,6 @@ - @@ -93,7 +92,6 @@ - @@ -105,7 +103,6 @@ - Code diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.Design/TabViewItemMetadata.cs b/Microsoft.Toolkit.Uwp.UI.Controls.Design/TabViewItemMetadata.cs deleted file mode 100644 index 6ed6bc37bf8..00000000000 --- a/Microsoft.Toolkit.Uwp.UI.Controls.Design/TabViewItemMetadata.cs +++ /dev/null @@ -1,43 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Toolkit.Uwp.UI.Controls.Design.Common; -using Microsoft.Windows.Design; -using Microsoft.Windows.Design.Features; -using Microsoft.Windows.Design.Metadata; -using Microsoft.Windows.Design.Model; -using Microsoft.Windows.Design.PropertyEditing; -using System.ComponentModel; - -namespace Microsoft.Toolkit.Uwp.UI.Controls.Design -{ - - internal class TabViewItemMetadata : AttributeTableBuilder - { - public TabViewItemMetadata() - : base() - { - AddCallback(typeof(TabViewItem), - b => - { - b.AddCustomAttributes(nameof(TabViewItem.Header), - new CategoryAttribute(Properties.Resources.CategoryCommon) - ); - b.AddCustomAttributes(nameof(TabViewItem.HeaderTemplate), - new CategoryAttribute(Properties.Resources.CategoryCommon), - new EditorBrowsableAttribute(EditorBrowsableState.Advanced) - ); - b.AddCustomAttributes(nameof(TabViewItem.IsClosable), - new CategoryAttribute(Properties.Resources.CategoryCommon) - ); - b.AddCustomAttributes(nameof(TabViewItem.Icon), - new CategoryAttribute(Properties.Resources.CategoryCommon) - ); - - b.AddCustomAttributes(new ToolboxCategoryAttribute(ToolboxCategoryPaths.Toolkit, false)); - } - ); - } - } -} \ No newline at end of file diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.Design/TabViewMetadata.cs b/Microsoft.Toolkit.Uwp.UI.Controls.Design/TabViewMetadata.cs deleted file mode 100644 index 7bfa77541db..00000000000 --- a/Microsoft.Toolkit.Uwp.UI.Controls.Design/TabViewMetadata.cs +++ /dev/null @@ -1,54 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Toolkit.Uwp.UI.Controls.Design.Common; -using Microsoft.Windows.Design; -using Microsoft.Windows.Design.Metadata; -using Microsoft.Windows.Design.PropertyEditing; -using System.ComponentModel; - -namespace Microsoft.Toolkit.Uwp.UI.Controls.Design -{ - internal class TabViewMetadata : AttributeTableBuilder - { - public TabViewMetadata() - : base() - { - AddCallback(typeof(Microsoft.Toolkit.Uwp.UI.Controls.TabView), - b => - { - // Layout - b.AddCustomAttributes(nameof(TabView.TabWidthBehavior), new CategoryAttribute(Properties.Resources.CategoryLayout)); - b.AddCustomAttributes(nameof(TabView.SelectedTabWidth), new CategoryAttribute(Properties.Resources.CategoryLayout)); - b.AddCustomAttributes(nameof(TabView.IsCloseButtonOverlay), new CategoryAttribute(Properties.Resources.CategoryLayout)); - - // Interactions - b.AddCustomAttributes(nameof(TabView.CanCloseTabs), new CategoryAttribute(Properties.Resources.CategoryCommon)); - - // Templates - b.AddCustomAttributes(nameof(TabView.ItemHeaderTemplate), - new CategoryAttribute(Properties.Resources.CategoryCommon), - new EditorBrowsableAttribute(EditorBrowsableState.Advanced) - ); - b.AddCustomAttributes(nameof(TabView.TabActionHeader), new CategoryAttribute(Properties.Resources.CategoryCommon)); - b.AddCustomAttributes(nameof(TabView.TabActionHeaderTemplate), - new CategoryAttribute(Properties.Resources.CategoryCommon), - new EditorBrowsableAttribute(EditorBrowsableState.Advanced) - ); - b.AddCustomAttributes(nameof(TabView.TabEndHeader), new CategoryAttribute(Properties.Resources.CategoryCommon)); - b.AddCustomAttributes(nameof(TabView.TabEndHeaderTemplate), - new CategoryAttribute(Properties.Resources.CategoryCommon), - new EditorBrowsableAttribute(EditorBrowsableState.Advanced) - ); - b.AddCustomAttributes(nameof(TabView.TabStartHeader), new CategoryAttribute(Properties.Resources.CategoryCommon)); - b.AddCustomAttributes(nameof(TabView.TabStartHeaderTemplate), - new CategoryAttribute(Properties.Resources.CategoryCommon), - new EditorBrowsableAttribute(EditorBrowsableState.Advanced) - ); - b.AddCustomAttributes(new ToolboxCategoryAttribute(ToolboxCategoryPaths.Toolkit, false)); - } - ); - } - } -} diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/HeaderedTextBlock/HeaderedTextBlock.Properties.cs b/Microsoft.Toolkit.Uwp.UI.Controls/HeaderedTextBlock/HeaderedTextBlock.Properties.cs deleted file mode 100644 index 7528591fc2b..00000000000 --- a/Microsoft.Toolkit.Uwp.UI.Controls/HeaderedTextBlock/HeaderedTextBlock.Properties.cs +++ /dev/null @@ -1,172 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; - -namespace Microsoft.Toolkit.Uwp.UI.Controls -{ - /// - /// Defines the properties for the control. - /// - public partial class HeaderedTextBlock - { - /// - /// Defines the dependency property. - /// - public static readonly DependencyProperty HeaderTemplateProperty = DependencyProperty.Register( - nameof(HeaderTemplate), - typeof(DataTemplate), - typeof(HeaderedTextBlock), - new PropertyMetadata(null)); - - /// - /// Defines the dependency property. - /// - public static readonly DependencyProperty TextStyleProperty = DependencyProperty.Register( - nameof(TextStyle), - typeof(Style), - typeof(HeaderedTextBlock), - new PropertyMetadata(null)); - - /// - /// Defines the dependency property. - /// - public static readonly DependencyProperty HeaderProperty = DependencyProperty.Register( - nameof(Header), - typeof(string), - typeof(HeaderedTextBlock), - new PropertyMetadata(null, (d, e) => { ((HeaderedTextBlock)d).UpdateVisibility(); })); - - /// - /// Defines the dependency property. - /// - public static readonly DependencyProperty TextProperty = DependencyProperty.Register( - nameof(Text), - typeof(string), - typeof(HeaderedTextBlock), - new PropertyMetadata(null, (d, e) => { ((HeaderedTextBlock)d).UpdateVisibility(); })); - - /// - /// Defines the dependency property. - /// - public static readonly DependencyProperty OrientationProperty = DependencyProperty.Register( - nameof(Orientation), - typeof(Orientation), - typeof(HeaderedTextBlock), - new PropertyMetadata(Orientation.Vertical, (d, e) => { ((HeaderedTextBlock)d).UpdateForOrientation((Orientation)e.NewValue); })); - - /// - /// Defines the dependency property. - /// - public static readonly DependencyProperty HideTextIfEmptyProperty = DependencyProperty.Register( - nameof(HideTextIfEmpty), - typeof(bool), - typeof(HeaderedTextBlock), - new PropertyMetadata(false, (d, e) => { ((HeaderedTextBlock)d).UpdateVisibility(); })); - - /// - /// Gets or sets the header style. - /// - public DataTemplate HeaderTemplate - { - get - { - return (DataTemplate)GetValue(HeaderTemplateProperty); - } - - set - { - SetValue(HeaderTemplateProperty, value); - } - } - - /// - /// Gets or sets the text style. - /// - public Style TextStyle - { - get - { - return (Style)GetValue(TextStyleProperty); - } - - set - { - SetValue(TextStyleProperty, value); - } - } - - /// - /// Gets or sets the header. - /// - public string Header - { - get - { - return (string)GetValue(HeaderProperty); - } - - set - { - SetValue(HeaderProperty, value); - } - } - - /// - /// Gets or sets the text. - /// - public string Text - { - get - { - return (string)GetValue(TextProperty); - } - - set - { - SetValue(TextProperty, value); - } - } - - /// - /// Gets the collection of inline text elements within a Windows.UI.Xaml.Controls.TextBlock. - /// - /// - /// A collection that holds all inline text elements from the Windows.UI.Xaml.Controls.TextBlock. The default is an empty collection. - public InlineCollectionWrapper Inlines { get; } = new InlineCollectionWrapper(); - - /// - /// Gets or sets the orientation. - /// - public Orientation Orientation - { - get - { - return (Orientation)GetValue(OrientationProperty); - } - - set - { - SetValue(OrientationProperty, value); - } - } - - /// - /// Gets or sets a value indicating whether the Text TextBlock is hidden if its value is empty - /// - public bool HideTextIfEmpty - { - get - { - return (bool)GetValue(HideTextIfEmptyProperty); - } - - set - { - SetValue(HideTextIfEmptyProperty, value); - } - } - } -} \ No newline at end of file diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/HeaderedTextBlock/HeaderedTextBlock.cs b/Microsoft.Toolkit.Uwp.UI.Controls/HeaderedTextBlock/HeaderedTextBlock.cs deleted file mode 100644 index b30dfea1d3d..00000000000 --- a/Microsoft.Toolkit.Uwp.UI.Controls/HeaderedTextBlock/HeaderedTextBlock.cs +++ /dev/null @@ -1,76 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Markup; - -namespace Microsoft.Toolkit.Uwp.UI.Controls -{ - /// - /// Defines a control for providing a header for read-only text. - /// - [TemplatePart(Name = "HeaderContentPresenter", Type = typeof(ContentPresenter))] - [ContentProperty(Name = nameof(Inlines))] - [Obsolete("The HeaderedTextBlock has been replaced with the more generic HeaderedContentControl.")] - public partial class HeaderedTextBlock : Control - { - private ContentPresenter _headerContentPresenter; - private TextBlock _textContent; - - /// - /// Initializes a new instance of the class. - /// - public HeaderedTextBlock() - { - DefaultStyleKey = typeof(HeaderedTextBlock); - } - - /// - /// Called when applying the control template. - /// - protected override void OnApplyTemplate() - { - base.OnApplyTemplate(); - - _headerContentPresenter = GetTemplateChild("HeaderContentPresenter") as ContentPresenter; - _textContent = GetTemplateChild("TextContent") as TextBlock; - - UpdateVisibility(); - Inlines.AddItemsToTextBlock(_textContent); - UpdateForOrientation(this.Orientation); - } - - private void UpdateVisibility() - { - if (_headerContentPresenter != null) - { - _headerContentPresenter.Visibility = _headerContentPresenter.Content == null - ? Visibility.Collapsed - : Visibility.Visible; - } - - if (_textContent != null) - { - _textContent.Visibility = string.IsNullOrWhiteSpace(_textContent.Text) && HideTextIfEmpty - ? Visibility.Collapsed - : Visibility.Visible; - } - } - - private void UpdateForOrientation(Orientation orientationValue) - { - switch (orientationValue) - { - case Orientation.Vertical: - VisualStateManager.GoToState(this, "Vertical", true); - break; - case Orientation.Horizontal: - VisualStateManager.GoToState(this, "Horizontal", true); - break; - } - } - } -} \ No newline at end of file diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/HeaderedTextBlock/HeaderedTextBlock.xaml b/Microsoft.Toolkit.Uwp.UI.Controls/HeaderedTextBlock/HeaderedTextBlock.xaml deleted file mode 100644 index 6f94a07ba82..00000000000 --- a/Microsoft.Toolkit.Uwp.UI.Controls/HeaderedTextBlock/HeaderedTextBlock.xaml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/Microsoft.Toolkit.Uwp.UI.Controls.csproj b/Microsoft.Toolkit.Uwp.UI.Controls/Microsoft.Toolkit.Uwp.UI.Controls.csproj index 6174415e0f3..9b240477475 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls/Microsoft.Toolkit.Uwp.UI.Controls.csproj +++ b/Microsoft.Toolkit.Uwp.UI.Controls/Microsoft.Toolkit.Uwp.UI.Controls.csproj @@ -17,7 +17,6 @@ - GridSplitter: A the control that redistributes space between columns or rows of a Grid control. - HeaderedContentControl: Provides a header to content. - HeaderedItemsControl: Provides a header to items. - - HeaderedTextBlock: Provide a header for read-only text. - ImageCropper: ImageCropper control allows user to crop image freely. - ImageEx: Images are downloaded asynchronously showing a load indicator and can be stored in a local cache. - InAppNotification: Show local notifications in your application. diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/Microsoft.Toolkit.Uwp.UI.Controls.csproj.DotSettings b/Microsoft.Toolkit.Uwp.UI.Controls/Microsoft.Toolkit.Uwp.UI.Controls.csproj.DotSettings index 0dd5cea5b9e..8a263d98309 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls/Microsoft.Toolkit.Uwp.UI.Controls.csproj.DotSettings +++ b/Microsoft.Toolkit.Uwp.UI.Controls/Microsoft.Toolkit.Uwp.UI.Controls.csproj.DotSettings @@ -5,7 +5,6 @@ True True True - True True True True diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/Strings/en-US/Resources.resw b/Microsoft.Toolkit.Uwp.UI.Controls/Strings/en-US/Resources.resw index 66cce5b66ab..d3b003e8b80 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls/Strings/en-US/Resources.resw +++ b/Microsoft.Toolkit.Uwp.UI.Controls/Strings/en-US/Resources.resw @@ -213,14 +213,6 @@ Notification The landmark name for the InAppNotification control. It is said by the narrator when using landmark navigation. - - Close tab - Narrator Resource for TabView Close Button. - - - Close tab - Tooltip for TabView Close Button. - Remove Label for TokenizingTextBox MenuFlyout 'Remove' option. diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabClosingEventArgs.cs b/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabClosingEventArgs.cs deleted file mode 100644 index 893776ff0be..00000000000 --- a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabClosingEventArgs.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.ComponentModel; - -namespace Microsoft.Toolkit.Uwp.UI.Controls -{ - /// - /// Event arguments for event. - /// - public class TabClosingEventArgs : CancelEventArgs - { - /// - /// Initializes a new instance of the class. - /// - /// Item being closed. - /// container being closed. - public TabClosingEventArgs(object item, TabViewItem tab) - { - Item = item; - Tab = tab; - } - - /// - /// Gets the Item being closed. - /// - public object Item { get; private set; } - - /// - /// Gets the Tab being closed. - /// - public TabViewItem Tab { get; private set; } - } -} \ No newline at end of file diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabDraggedOutsideEventArgs.cs b/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabDraggedOutsideEventArgs.cs deleted file mode 100644 index dcf351aab9b..00000000000 --- a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabDraggedOutsideEventArgs.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; - -namespace Microsoft.Toolkit.Uwp.UI.Controls -{ - /// - /// A class used by the TabDraggedOutside Event - /// - public class TabDraggedOutsideEventArgs : EventArgs - { - /// - /// Initializes a new instance of the class. - /// - /// data context of element dragged - /// container being dragged. - public TabDraggedOutsideEventArgs(object item, TabViewItem tab) - { - Item = item; - Tab = tab; - } - - /// - /// Gets or sets the Item/Data Context of the item being dragged outside of the . - /// - public object Item { get; set; } - - /// - /// Gets the Tab being dragged outside of the . - /// - public TabViewItem Tab { get; private set; } - } -} diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.HeaderLayout.cs b/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.HeaderLayout.cs deleted file mode 100644 index 16885700b35..00000000000 --- a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.HeaderLayout.cs +++ /dev/null @@ -1,221 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Linq; -using Windows.UI.Xaml; - -namespace Microsoft.Toolkit.Uwp.UI.Controls -{ - /// - /// TabView methods related to calculating the width of the Headers. - /// - public partial class TabView - { - // Attached property for storing widths of tabs if set by other means during layout. - private static double GetOriginalWidth(TabViewItem obj) - { - return (double)obj.GetValue(OriginalWidthProperty); - } - - private static void SetOriginalWidth(TabViewItem obj, double value) - { - obj.SetValue(OriginalWidthProperty, value); - } - - // Using a DependencyProperty as the backing store for MyProperty. This enables animation, styling, binding, etc... - private static readonly DependencyProperty OriginalWidthProperty = - DependencyProperty.RegisterAttached("OriginalWidth", typeof(double), typeof(TabView), new PropertyMetadata(null)); - - private static void OnLayoutEffectingPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args) - { - var tabview = sender as TabView; - if (tabview != null && tabview._hasLoaded) - { - tabview.TabView_SizeChanged(tabview, null); - } - } - - private void TabView_SizeChanged(object sender, SizeChangedEventArgs e) - { - // We need to do this calculation here in Size Changed as the - // Columns don't have their Actual Size calculated in Measure or Arrange. - if (_hasLoaded && _tabViewContainer != null) - { - // Look for our special columns to calculate size of other 'stuff' - var taken = _tabViewContainer.ColumnDefinitions.Sum(cd => GetIgnoreColumn(cd) ? 0 : cd.ActualWidth); - - // Get the column we want to work on for available space - var tabc = _tabViewContainer.ColumnDefinitions.FirstOrDefault(cd => GetConstrainColumn(cd)); - if (tabc != null) - { - var available = ActualWidth - taken; - var required = 0.0; - var mintabwidth = double.MaxValue; - - if (TabWidthBehavior == TabWidthMode.Actual) - { - if (_tabScroller != null) - { - // If we have a scroll container, get its size. - required = _tabScroller.ExtentWidth; - } - - // Restore original widths - foreach (var item in Items) - { - var tab = ContainerFromItem(item) as TabViewItem; - if (tab == null) - { - continue; // container not generated yet - } - - if (tab.ReadLocalValue(OriginalWidthProperty) != DependencyProperty.UnsetValue) - { - tab.Width = GetOriginalWidth(tab); - } - } - } - else if (available > 0) - { - // Calculate the width for each tab from the provider and determine how much space they take. - foreach (var item in Items) - { - var tab = ContainerFromItem(item) as TabViewItem; - if (tab == null) - { - continue; // container not generated yet - } - - mintabwidth = Math.Min(mintabwidth, tab.MinWidth); - - double width = double.NaN; - - switch (TabWidthBehavior) - { - case TabWidthMode.Equal: - width = ProvideEqualWidth(tab, item, available); - break; - case TabWidthMode.Compact: - width = ProvideCompactWidth(tab, item, available); - break; - } - - if (tab.ReadLocalValue(OriginalWidthProperty) == DependencyProperty.UnsetValue) - { - SetOriginalWidth(tab, tab.Width); - } - - if (width > double.Epsilon) - { - tab.Width = width; - required += Math.Max(Math.Min(width, tab.MaxWidth), tab.MinWidth); - } - else - { - tab.Width = GetOriginalWidth(tab); - required += tab.ActualWidth; - } - } - } - else - { - // Fix negative bounds. - available = 0.0; - - // Still need to determine a 'minimum' width (if available) - // TODO: Consolidate this logic with above better? - foreach (var item in Items) - { - var tab = ContainerFromItem(item) as TabViewItem; - if (tab == null) - { - continue; // container not generated yet - } - - mintabwidth = Math.Min(mintabwidth, tab.MinWidth); - } - } - - if (!(mintabwidth < double.MaxValue)) - { - mintabwidth = 0.0; // No Containers, no visual, 0 size. - } - - if (available > mintabwidth) - { - // Constrain the column based on our required and available space - tabc.MaxWidth = available; - } - - //// TODO: If it's less, should we move the selected tab to only be the one shown by default? - - if (available <= mintabwidth || Math.Abs(available - mintabwidth) < double.Epsilon) - { - tabc.Width = new GridLength(mintabwidth); - } - else if (required >= available) - { - // Fix size as we don't have enough space for all the tabs. - tabc.Width = new GridLength(available); - } - else - { - // We haven't filled up our space, so we want to expand to take as much as needed. - tabc.Width = GridLength.Auto; - } - } - } - } - - private double ProvideEqualWidth(TabViewItem tab, object item, double availableWidth) - { - if (double.IsNaN(SelectedTabWidth)) - { - if (Items.Count <= 1) - { - return availableWidth; - } - - return Math.Max(tab.MinWidth, availableWidth / Items.Count); - } - else if (Items.Count() <= 1) - { - // Default case of a single tab, make it full size. - return Math.Min(SelectedTabWidth, availableWidth); - } - else - { - var width = (availableWidth - SelectedTabWidth) / (Items.Count - 1); - - // Constrain between Min and Selected (Max) - if (width < tab.MinWidth) - { - width = tab.MinWidth; - } - else if (width > SelectedTabWidth) - { - width = SelectedTabWidth; - } - - // If it's selected make it full size, otherwise whatever the size should be. - return tab.IsSelected - ? Math.Min(SelectedTabWidth, availableWidth) - : width; - } - } - - private double ProvideCompactWidth(TabViewItem tab, object item, double availableWidth) - { - // If we're selected and have a value for that, then just return that. - if (tab.IsSelected && !double.IsNaN(SelectedTabWidth)) - { - return SelectedTabWidth; - } - - // Otherwise use min size. - return tab.MinWidth; - } - } -} diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.ItemSources.cs b/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.ItemSources.cs deleted file mode 100644 index 61f61623b6f..00000000000 --- a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.ItemSources.cs +++ /dev/null @@ -1,115 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Reflection; -using Windows.Foundation.Collections; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls.Primitives; - -namespace Microsoft.Toolkit.Uwp.UI.Controls -{ - /// - /// TabView methods related to tracking Items and ItemsSource changes. - /// - public partial class TabView - { - // Temporary tracking of previous collections for removing events. - private MethodInfo _removeItemsSourceMethod; - - /// - protected override void OnItemsChanged(object e) - { - IVectorChangedEventArgs args = (IVectorChangedEventArgs)e; - - base.OnItemsChanged(e); - - if (args.CollectionChange == CollectionChange.ItemRemoved && SelectedIndex == -1) - { - // If we remove the selected item we should select the previous item - int startIndex = (int)args.Index + 1; - if (startIndex > Items.Count) - { - startIndex = 0; - } - - SelectedIndex = FindNextTabIndex(startIndex, -1); - } - - // Update Sizing (in case there are less items now) - TabView_SizeChanged(this, null); - } - - private void ItemContainerGenerator_ItemsChanged(object sender, ItemsChangedEventArgs e) - { - var action = (CollectionChange)e.Action; - if (action == CollectionChange.Reset) - { - // Reset collection to reload later. - _hasLoaded = false; - } - } - - private void SetInitialSelection() - { - if (SelectedItem == null) - { - // If we have an index, but didn't get the selection, make the selection - if (SelectedIndex >= 0 && SelectedIndex < Items.Count) - { - SelectedItem = Items[SelectedIndex]; - } - - // Otherwise, select the first item by default - else if (Items.Count >= 1) - { - SelectedItem = Items[0]; - } - } - } - - // Finds the next visible & enabled tab index. - private int FindNextTabIndex(int startIndex, int direction) - { - int index = startIndex; - if (direction != 0) - { - for (int i = 0; i < Items.Count; i++) - { - index += direction; - - if (index >= Items.Count) - { - index = 0; - } - else if (index < 0) - { - index = Items.Count - 1; - } - - var tabItem = ContainerFromIndex(index) as TabViewItem; - if (tabItem != null && tabItem.IsEnabled && tabItem.Visibility == Visibility.Visible) - { - break; - } - } - } - - return index; - } - - private void ItemsSource_PropertyChanged(DependencyObject sender, DependencyProperty dp) - { - // Use reflection to store a 'Remove' method of any possible collection in ItemsSource - // Cache for efficiency later. - if (ItemsSource != null) - { - _removeItemsSourceMethod = ItemsSource.GetType().GetMethod("Remove"); - } - else - { - _removeItemsSourceMethod = null; - } - } - } -} diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.Properties.cs b/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.Properties.cs deleted file mode 100644 index 5d33b33f1cc..00000000000 --- a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.Properties.cs +++ /dev/null @@ -1,245 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; - -namespace Microsoft.Toolkit.Uwp.UI.Controls -{ - /// - /// TabView properties. - /// - public partial class TabView - { - /// - /// Gets or sets the content to appear to the left or above the tab strip. - /// - public object TabStartHeader - { - get { return (object)GetValue(TabStartHeaderProperty); } - set { SetValue(TabStartHeaderProperty, value); } - } - - /// - /// Identifies the dependency property. - /// - /// The identifier for the dependency property. - public static readonly DependencyProperty TabStartHeaderProperty = - DependencyProperty.Register(nameof(TabStartHeader), typeof(object), typeof(TabView), new PropertyMetadata(null, OnLayoutEffectingPropertyChanged)); - - /// - /// Gets or sets the for the . - /// - public DataTemplate TabStartHeaderTemplate - { - get { return (DataTemplate)GetValue(TabStartHeaderTemplateProperty); } - set { SetValue(TabStartHeaderTemplateProperty, value); } - } - - /// - /// Identifies the dependency property. - /// - /// The identifier for the dependency property. - public static readonly DependencyProperty TabStartHeaderTemplateProperty = - DependencyProperty.Register(nameof(TabStartHeaderTemplate), typeof(DataTemplate), typeof(TabView), new PropertyMetadata(null, OnLayoutEffectingPropertyChanged)); - - /// - /// Gets or sets the content to appear next to the tab strip. - /// - public object TabActionHeader - { - get { return (object)GetValue(TabActionHeaderProperty); } - set { SetValue(TabActionHeaderProperty, value); } - } - - /// - /// Identifies the dependency property. - /// - /// The identifier for the dependency property. - public static readonly DependencyProperty TabActionHeaderProperty = - DependencyProperty.Register(nameof(TabActionHeader), typeof(object), typeof(TabView), new PropertyMetadata(null, OnLayoutEffectingPropertyChanged)); - - /// - /// Gets or sets the for the . - /// - public DataTemplate TabActionHeaderTemplate - { - get { return (DataTemplate)GetValue(TabActionHeaderTemplateProperty); } - set { SetValue(TabActionHeaderTemplateProperty, value); } - } - - /// - /// Identifies the dependency property. - /// - /// The identifier for the dependency property. - public static readonly DependencyProperty TabActionHeaderTemplateProperty = - DependencyProperty.Register(nameof(TabActionHeaderTemplate), typeof(DataTemplate), typeof(TabView), new PropertyMetadata(null, OnLayoutEffectingPropertyChanged)); - - /// - /// Gets or sets the content to appear to the right or below the tab strip. - /// - public object TabEndHeader - { - get { return (object)GetValue(TabEndHeaderProperty); } - set { SetValue(TabEndHeaderProperty, value); } - } - - /// - /// Identifies the dependency property. - /// - /// The identifier for the dependency property. - public static readonly DependencyProperty TabEndHeaderProperty = - DependencyProperty.Register(nameof(TabEndHeader), typeof(object), typeof(TabView), new PropertyMetadata(null, OnLayoutEffectingPropertyChanged)); - - /// - /// Gets or sets the for the . - /// - public DataTemplate TabEndHeaderTemplate - { - get { return (DataTemplate)GetValue(TabEndHeaderTemplateProperty); } - set { SetValue(TabEndHeaderTemplateProperty, value); } - } - - /// - /// Identifies the dependency property. - /// - /// The identifier for the dependency property. - public static readonly DependencyProperty TabEndHeaderTemplateProperty = - DependencyProperty.Register(nameof(TabEndHeaderTemplate), typeof(DataTemplate), typeof(TabView), new PropertyMetadata(null, OnLayoutEffectingPropertyChanged)); - - /// - /// Gets or sets the default for the . - /// - public DataTemplate ItemHeaderTemplate - { - get { return (DataTemplate)GetValue(ItemHeaderTemplateProperty); } - set { SetValue(ItemHeaderTemplateProperty, value); } - } - - /// - /// Identifies the dependency property. - /// - /// The identifier for the dependency property. - public static readonly DependencyProperty ItemHeaderTemplateProperty = - DependencyProperty.Register(nameof(ItemHeaderTemplate), typeof(DataTemplate), typeof(TabView), new PropertyMetadata(null, OnLayoutEffectingPropertyChanged)); - - /// - /// Gets or sets a value indicating whether by default a Tab can be closed or not if no value to is provided. - /// - public bool CanCloseTabs - { - get { return (bool)GetValue(CanCloseTabsProperty); } - set { SetValue(CanCloseTabsProperty, value); } - } - - /// - /// Identifies the dependency property. - /// - /// The identifier for the dependency property. - public static readonly DependencyProperty CanCloseTabsProperty = - DependencyProperty.Register(nameof(CanCloseTabs), typeof(bool), typeof(TabView), new PropertyMetadata(false, OnLayoutEffectingPropertyChanged)); - - /// - /// Gets or sets a value indicating whether a Close Button should be included in layout calculations. - /// - public bool IsCloseButtonOverlay - { - get { return (bool)GetValue(IsCloseButtonOverlayProperty); } - set { SetValue(IsCloseButtonOverlayProperty, value); } - } - - /// - /// Identifies the dependency property. - /// - /// The identifier for the dependency property. - public static readonly DependencyProperty IsCloseButtonOverlayProperty = - DependencyProperty.Register(nameof(IsCloseButtonOverlay), typeof(bool), typeof(TabView), new PropertyMetadata(false, OnLayoutEffectingPropertyChanged)); - - /// - /// Gets or sets a value indicating the size of the selected tab. By default this is set to Auto and the selected tab size doesn't change. - /// - public double SelectedTabWidth - { - get { return (double)GetValue(SelectedTabWidthProperty); } - set { SetValue(SelectedTabWidthProperty, value); } - } - - /// - /// Identifies the dependency property. - /// - /// The identifier for the dependency property. - public static readonly DependencyProperty SelectedTabWidthProperty = - DependencyProperty.Register(nameof(SelectedTabWidth), typeof(double), typeof(TabView), new PropertyMetadata(double.NaN, OnLayoutEffectingPropertyChanged)); - - /// - /// Gets or sets the current which determins how tab headers' width behave. - /// - public TabWidthMode TabWidthBehavior - { - get { return (TabWidthMode)GetValue(TabWidthBehaviorProperty); } - set { SetValue(TabWidthBehaviorProperty, value); } - } - - /// - /// Identifies the dependency property. - /// - /// The identifier for the dependency property. - public static readonly DependencyProperty TabWidthBehaviorProperty = - DependencyProperty.Register(nameof(TabWidthBehavior), typeof(TabWidthMode), typeof(TabView), new PropertyMetadata(TabWidthMode.Actual, OnLayoutEffectingPropertyChanged)); - - /// - /// Gets the attached property value to indicate if this grid column should be ignored when calculating header sizes. - /// - /// Grid Column. - /// Boolean indicating if this column is ignored by TabViewHeader logic. - public static bool GetIgnoreColumn(ColumnDefinition obj) - { - return (bool)obj.GetValue(IgnoreColumnProperty); - } - - /// - /// Sets the attached property value for - /// - /// Grid Column. - /// Boolean value - public static void SetIgnoreColumn(ColumnDefinition obj, bool value) - { - obj.SetValue(IgnoreColumnProperty, value); - } - - /// - /// Identifies the attached property. - /// - /// The identifier for the IgnoreColumn attached property. - public static readonly DependencyProperty IgnoreColumnProperty = - DependencyProperty.RegisterAttached("IgnoreColumn", typeof(bool), typeof(TabView), new PropertyMetadata(false)); - - /// - /// Gets the attached value indicating this column should be restricted for the headers. - /// - /// Grid Column. - /// True if this column should be constrained. - public static bool GetConstrainColumn(ColumnDefinition obj) - { - return (bool)obj.GetValue(ConstrainColumnProperty); - } - - /// - /// Sets the attached property value for the - /// - /// Grid Column. - /// Boolean value. - public static void SetConstrainColumn(ColumnDefinition obj, bool value) - { - obj.SetValue(ConstrainColumnProperty, value); - } - - /// - /// Identifies the attached property. - /// - /// The identifier for the ConstrainColumn attached property. - public static readonly DependencyProperty ConstrainColumnProperty = - DependencyProperty.RegisterAttached("ConstrainColumn", typeof(bool), typeof(TabView), new PropertyMetadata(false)); - } -} diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.cs b/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.cs deleted file mode 100644 index 0e86ab398f5..00000000000 --- a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.cs +++ /dev/null @@ -1,320 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.ComponentModel; -using System.Linq; -using Microsoft.Toolkit.Uwp.UI.Extensions; -using Windows.ApplicationModel.DataTransfer; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Controls.Primitives; -using Windows.UI.Xaml.Data; - -namespace Microsoft.Toolkit.Uwp.UI.Controls -{ - /// - /// TabView is a control for displaying a set of tabs and their content. - /// - [Obsolete("Please migrate to the TabView control from WinUI, this control will be removed in a future release. https://aka.ms/winui")] - [TemplatePart(Name = TabContentPresenterName, Type = typeof(ContentPresenter))] - [TemplatePart(Name = TabViewContainerName, Type = typeof(Grid))] - [TemplatePart(Name = TabsItemsPresenterName, Type = typeof(ItemsPresenter))] - [TemplatePart(Name = TabsScrollViewerName, Type = typeof(ScrollViewer))] - [TemplatePart(Name = TabsScrollBackButtonName, Type = typeof(ButtonBase))] - [TemplatePart(Name = TabsScrollForwardButtonName, Type = typeof(ButtonBase))] - public partial class TabView : ListViewBase - { - private const int ScrollAmount = 50; // TODO: Should this be based on TabWidthMode - - private const string TabContentPresenterName = "TabContentPresenter"; - private const string TabViewContainerName = "TabViewContainer"; - private const string TabsItemsPresenterName = "TabsItemsPresenter"; - private const string TabsScrollViewerName = "ScrollViewer"; - private const string TabsScrollBackButtonName = "ScrollBackButton"; - private const string TabsScrollForwardButtonName = "ScrollForwardButton"; - - private ContentPresenter _tabContentPresenter; - private Grid _tabViewContainer; - private ItemsPresenter _tabItemsPresenter; - private ScrollViewer _tabScroller; - private ButtonBase _tabScrollBackButton; - private ButtonBase _tabScrollForwardButton; - - private bool _hasLoaded; - private bool _isDragging; - - /// - /// Initializes a new instance of the class. - /// - public TabView() - { - DefaultStyleKey = typeof(TabView); - - // Container Generation Hooks - RegisterPropertyChangedCallback(ItemsSourceProperty, ItemsSource_PropertyChanged); - ItemContainerGenerator.ItemsChanged += ItemContainerGenerator_ItemsChanged; - - // Drag and Layout Hooks - DragItemsStarting += TabView_DragItemsStarting; - DragItemsCompleted += TabView_DragItemsCompleted; - SizeChanged += TabView_SizeChanged; - - // Selection Hook - SelectionChanged += TabView_SelectionChanged; - } - - /// - /// Occurs when a tab is dragged by the user outside of the . Generally, this paradigm is used to create a new-window with the torn-off tab. - /// The creation and handling of the new-window is left to the app's developer. - /// - public event EventHandler TabDraggedOutside; - - /// - /// Occurs when a tab's Close button is clicked. Set to true to prevent automatic Tab Closure. - /// - public event EventHandler TabClosing; - - /// - protected override DependencyObject GetContainerForItemOverride() => new TabViewItem(); - - /// - protected override bool IsItemItsOwnContainerOverride(object item) - { - return item is TabViewItem; - } - - /// - protected override void OnApplyTemplate() - { - base.OnApplyTemplate(); - - if (_tabItemsPresenter != null) - { - _tabItemsPresenter.SizeChanged -= TabView_SizeChanged; - } - - if (_tabScroller != null) - { - _tabScroller.Loaded -= ScrollViewer_Loaded; - } - - _tabContentPresenter = GetTemplateChild(TabContentPresenterName) as ContentPresenter; - _tabViewContainer = GetTemplateChild(TabViewContainerName) as Grid; - _tabItemsPresenter = GetTemplateChild(TabsItemsPresenterName) as ItemsPresenter; - _tabScroller = GetTemplateChild(TabsScrollViewerName) as ScrollViewer; - - if (_tabItemsPresenter != null) - { - _tabItemsPresenter.SizeChanged += TabView_SizeChanged; - } - - if (_tabScroller != null) - { - _tabScroller.Loaded += ScrollViewer_Loaded; - } - } - - private void ScrollViewer_Loaded(object sender, RoutedEventArgs e) - { - _tabScroller.Loaded -= ScrollViewer_Loaded; - - if (_tabScrollBackButton != null) - { - _tabScrollBackButton.Click -= ScrollTabBackButton_Click; - } - - if (_tabScrollForwardButton != null) - { - _tabScrollForwardButton.Click -= ScrollTabForwardButton_Click; - } - - _tabScrollBackButton = _tabScroller.FindDescendantByName(TabsScrollBackButtonName) as ButtonBase; - _tabScrollForwardButton = _tabScroller.FindDescendantByName(TabsScrollForwardButtonName) as ButtonBase; - - if (_tabScrollBackButton != null) - { - _tabScrollBackButton.Click += ScrollTabBackButton_Click; - } - - if (_tabScrollForwardButton != null) - { - _tabScrollForwardButton.Click += ScrollTabForwardButton_Click; - } - } - - private void ScrollTabBackButton_Click(object sender, RoutedEventArgs e) - { - _tabScroller.ChangeView(Math.Max(0, _tabScroller.HorizontalOffset - ScrollAmount), null, null); - } - - private void ScrollTabForwardButton_Click(object sender, RoutedEventArgs e) - { - _tabScroller.ChangeView(Math.Min(_tabScroller.ScrollableWidth, _tabScroller.HorizontalOffset + ScrollAmount), null, null); - } - - private void TabView_SelectionChanged(object sender, SelectionChangedEventArgs e) - { - if (_isDragging) - { - // Skip if we're dragging, we'll reset when we're done. - return; - } - - if (_tabContentPresenter != null) - { - if (SelectedItem == null) - { - _tabContentPresenter.Content = null; - _tabContentPresenter.ContentTemplate = null; - } - else - { - if (ContainerFromItem(SelectedItem) is TabViewItem container) - { - _tabContentPresenter.Content = container.Content; - _tabContentPresenter.ContentTemplate = container.ContentTemplate; - } - } - } - - // If our width can be effected by the selection, need to run algorithm. - if (!double.IsNaN(SelectedTabWidth)) - { - TabView_SizeChanged(sender, null); - } - } - - /// - protected override void PrepareContainerForItemOverride(DependencyObject element, object item) - { - base.PrepareContainerForItemOverride(element, item); - - var tabitem = element as TabViewItem; - - tabitem.Loaded -= TabViewItem_Loaded; - tabitem.Closing -= TabViewItem_Closing; - tabitem.Loaded += TabViewItem_Loaded; - tabitem.Closing += TabViewItem_Closing; - - if (tabitem.Header == null) - { - tabitem.Header = item; - } - - if (tabitem.HeaderTemplate == null) - { - var headertemplatebinding = new Binding() - { - Source = this, - Path = new PropertyPath(nameof(ItemHeaderTemplate)), - Mode = BindingMode.OneWay - }; - tabitem.SetBinding(TabViewItem.HeaderTemplateProperty, headertemplatebinding); - } - - if (tabitem.IsClosable != true && tabitem.ReadLocalValue(TabViewItem.IsClosableProperty) == DependencyProperty.UnsetValue) - { - var iscloseablebinding = new Binding() - { - Source = this, - Path = new PropertyPath(nameof(CanCloseTabs)), - Mode = BindingMode.OneWay, - }; - tabitem.SetBinding(TabViewItem.IsClosableProperty, iscloseablebinding); - } - } - - private void TabViewItem_Loaded(object sender, RoutedEventArgs e) - { - var tabitem = sender as TabViewItem; - - tabitem.Loaded -= TabViewItem_Loaded; - - // Only need to do this once. - if (!_hasLoaded) - { - _hasLoaded = true; - - // Need to set a tab's selection on load, otherwise ListView resets to null. - SetInitialSelection(); - - // Need to make sure ContentPresenter is set to content based on selection. - TabView_SelectionChanged(this, null); - - // Need to make sure we've registered our removal method. - ItemsSource_PropertyChanged(this, null); - - // Make sure we complete layout now. - TabView_SizeChanged(this, null); - } - } - - private void TabViewItem_Closing(object sender, TabClosingEventArgs e) - { - var item = ItemFromContainer(e.Tab); - - var args = new TabClosingEventArgs(item, e.Tab); - TabClosing?.Invoke(this, args); - - if (!args.Cancel) - { - if (ItemsSource != null) - { - _removeItemsSourceMethod?.Invoke(ItemsSource, new object[] { item }); - } - else - { - Items.Remove(item); - } - } - } - - private void TabView_DragItemsStarting(object sender, DragItemsStartingEventArgs e) - { - // Keep track of drag so we don't modify content until done. - _isDragging = true; - } - - private void TabView_DragItemsCompleted(ListViewBase sender, DragItemsCompletedEventArgs args) - { - _isDragging = false; - - // args.DropResult == None when outside of area (e.g. create new window) - if (args.DropResult == DataPackageOperation.None) - { - var item = args.Items.FirstOrDefault(); - var tab = ContainerFromItem(item) as TabViewItem; - - if (tab == null && item is FrameworkElement fe) - { - tab = fe.FindParent(); - } - - if (tab == null) - { - // We still don't have a TabViewItem, most likely is a static TabViewItem in the template being dragged and not selected. - // This is a fallback scenario for static tabs. - // Note: This can be wrong if two TabViewItems share the exact same Content (i.e. a string), this should be unlikely in any practical scenario. - for (int i = 0; i < Items.Count; i++) - { - var tabItem = ContainerFromIndex(i) as TabViewItem; - if (ReferenceEquals(tabItem.Content, item)) - { - tab = tabItem; - break; - } - } - } - - TabDraggedOutside?.Invoke(this, new TabDraggedOutsideEventArgs(item, tab)); - } - else - { - // If dragging the active tab, there's an issue with the CP blanking. - TabView_SelectionChanged(this, null); - } - } - } -} diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.xaml b/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.xaml deleted file mode 100644 index d3310aadf06..00000000000 --- a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.xaml +++ /dev/null @@ -1,736 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 - 0,0,8,0 - 8,0,-8,0 - 0,1,1,0 - 16 - 48 - 40 - NaN - 32 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabViewItem.Properties.cs b/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabViewItem.Properties.cs deleted file mode 100644 index 3ce0f3e5483..00000000000 --- a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabViewItem.Properties.cs +++ /dev/null @@ -1,79 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; - -namespace Microsoft.Toolkit.Uwp.UI.Controls -{ - /// - /// Item Container for a . - /// - public partial class TabViewItem - { - /// - /// Gets or sets the header content for the tab. - /// - public object Header - { - get { return (object)GetValue(HeaderProperty); } - set { SetValue(HeaderProperty, value); } - } - - /// - /// Identifies the dependency property. - /// - /// The identifier for the dependency property. - public static readonly DependencyProperty HeaderProperty = - DependencyProperty.Register(nameof(Header), typeof(object), typeof(TabViewItem), new PropertyMetadata(null)); - - /// - /// Gets or sets the icon to appear in the tab header. - /// - public IconElement Icon - { - get { return (IconElement)GetValue(IconProperty); } - set { SetValue(IconProperty, value); } - } - - /// - /// Identifies the dependency property. - /// - /// The identifier for the dependency property. - public static readonly DependencyProperty IconProperty = - DependencyProperty.Register(nameof(Icon), typeof(IconElement), typeof(TabViewItem), new PropertyMetadata(null)); - - /// - /// Gets or sets the template to override for the tab header. - /// - public DataTemplate HeaderTemplate - { - get { return (DataTemplate)GetValue(HeaderTemplateProperty); } - set { SetValue(HeaderTemplateProperty, value); } - } - - /// - /// Identifies the dependency property. - /// - /// The identifier for the dependency property. - public static readonly DependencyProperty HeaderTemplateProperty = - DependencyProperty.Register(nameof(HeaderTemplate), typeof(DataTemplate), typeof(TabViewItem), new PropertyMetadata(null)); - - /// - /// Gets or sets a value indicating whether the tab can be closed by the user with the close button. - /// - public bool IsClosable - { - get { return (bool)GetValue(IsClosableProperty); } - set { SetValue(IsClosableProperty, value); } - } - - /// - /// Identifies the dependency property. - /// - /// The identifier for the dependency property. - public static readonly DependencyProperty IsClosableProperty = - DependencyProperty.Register(nameof(IsClosable), typeof(bool), typeof(TabViewItem), new PropertyMetadata(null)); - } -} diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabViewItem.cs b/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabViewItem.cs deleted file mode 100644 index 69a968fd839..00000000000 --- a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabViewItem.cs +++ /dev/null @@ -1,116 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using Windows.Devices.Input; -using Windows.System; -using Windows.UI.Core; -using Windows.UI.Input; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Controls.Primitives; -using Windows.UI.Xaml.Input; - -namespace Microsoft.Toolkit.Uwp.UI.Controls -{ - /// - /// Item Container for a . - /// - [TemplatePart(Name = TabCloseButtonName, Type = typeof(ButtonBase))] - public partial class TabViewItem : ListViewItem - { - private const string TabCloseButtonName = "CloseButton"; - - private ButtonBase _tabCloseButton; - - private bool _isMiddleClick; - - /// - /// Initializes a new instance of the class. - /// - public TabViewItem() - { - DefaultStyleKey = typeof(TabViewItem); - } - - /// - /// Fired when the Tab's close button is clicked. - /// - public event EventHandler Closing; - - /// - protected override void OnApplyTemplate() - { - base.OnApplyTemplate(); - - if (_tabCloseButton != null) - { - _tabCloseButton.Click -= TabCloseButton_Click; - } - - _tabCloseButton = GetTemplateChild(TabCloseButtonName) as ButtonBase; - - if (_tabCloseButton != null) - { - _tabCloseButton.Click += TabCloseButton_Click; - } - } - - /// - protected override void OnPointerPressed(PointerRoutedEventArgs e) - { - _isMiddleClick = false; - - if (e.Pointer.PointerDeviceType == PointerDeviceType.Mouse) - { - PointerPoint pointerPoint = e.GetCurrentPoint(this); - - // Record if middle button is pressed - if (pointerPoint.Properties.IsMiddleButtonPressed) - { - _isMiddleClick = true; - } - - // Disable unwanted behaviour inherited by ListViewItem: - // Disable "Ctrl + Left click" to deselect tab - // Or variant like "Ctrl + Shift + Left click" - // Or "Ctrl + Alt + Left click" - if (pointerPoint.Properties.IsLeftButtonPressed) - { - var ctrl = Window.Current.CoreWindow.GetKeyState(VirtualKey.Control); - if (ctrl.HasFlag(CoreVirtualKeyStates.Down)) - { - // return here so the event won't be picked up by the base class - // but keep this event unhandled so it can be picked up further - return; - } - } - } - - base.OnPointerPressed(e); - } - - /// - protected override void OnPointerReleased(PointerRoutedEventArgs e) - { - base.OnPointerReleased(e); - - // Close on Middle-Click - if (_isMiddleClick) - { - TabCloseButton_Click(this, null); - } - - _isMiddleClick = false; - } - - private void TabCloseButton_Click(object sender, RoutedEventArgs e) - { - if (IsClosable) - { - Closing?.Invoke(this, new TabClosingEventArgs(Content, this)); - } - } - } -} diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabWidthMode.cs b/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabWidthMode.cs deleted file mode 100644 index 65b1ce03844..00000000000 --- a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabWidthMode.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Windows.UI.Xaml; - -namespace Microsoft.Toolkit.Uwp.UI.Controls -{ - /// - /// Possible modes for how to layout a Header's Width in the . - /// - public enum TabWidthMode - { - /// - /// Each tab header takes up as much space as it needs. This is similar to how WPF and Visual Studio Code behave. - /// Suggest to keep set to false. - /// is ignored. - /// In this scenario, tab width behavior is effectively turned off. This can be useful when using custom styling or a custom panel for layout of as well. - /// - Actual, - - /// - /// Each tab header will use the minimal space set by on the . - /// Suggest to set the to show more content for the selected item. - /// - Compact, - - /// - /// Each tab header will fill to fit the available space. If is set, that will be used as a Maximum Width. - /// This is similar to how Microsoft Edge behaves when used with the . - /// Suggest to set to true. - /// Suggest to set to 200 and the TabViewItemHeaderMinWidth Resource to 90. - /// - Equal, - } -} diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/Themes/Generic.xaml b/Microsoft.Toolkit.Uwp.UI.Controls/Themes/Generic.xaml index 592fbb45626..9c17a3717bd 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls/Themes/Generic.xaml +++ b/Microsoft.Toolkit.Uwp.UI.Controls/Themes/Generic.xaml @@ -9,7 +9,6 @@ - @@ -27,7 +26,6 @@ - diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/TileControl/TileControl.cs b/Microsoft.Toolkit.Uwp.UI.Controls/TileControl/TileControl.cs index 6799439d67a..cdc4af642c5 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls/TileControl/TileControl.cs +++ b/Microsoft.Toolkit.Uwp.UI.Controls/TileControl/TileControl.cs @@ -181,13 +181,6 @@ public class TileControl : ContentControl /// public event EventHandler ImageLoaded; - /// - /// Gets a value indicating whether the platform supports Composition. - /// - [Obsolete("This property is now obsolete and will be removed in a future version of the Toolkit.")] - public static bool IsCompositionSupported => !DesignTimeHelpers.IsRunningInLegacyDesignerMode && - ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 3); // SDK >= 14393 - /// /// Initializes a new instance of the class. /// diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/VisualStudioToolsManifest.xml b/Microsoft.Toolkit.Uwp.UI.Controls/VisualStudioToolsManifest.xml index e2bc71350ef..27fe2b2f0bc 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls/VisualStudioToolsManifest.xml +++ b/Microsoft.Toolkit.Uwp.UI.Controls/VisualStudioToolsManifest.xml @@ -13,7 +13,6 @@ - @@ -33,8 +32,6 @@ - - diff --git a/Microsoft.Toolkit/Extensions/StringExtensions.cs b/Microsoft.Toolkit/Extensions/StringExtensions.cs index 5e81855f128..a39030a11a4 100644 --- a/Microsoft.Toolkit/Extensions/StringExtensions.cs +++ b/Microsoft.Toolkit/Extensions/StringExtensions.cs @@ -86,14 +86,6 @@ public static bool IsDecimal(this string str) /// true if the string contains only letters; otherwise, false. public static bool IsCharacterString(this string str) => Regex.IsMatch(str, CharactersRegex); - /// - /// Returns a string representation of an object. - /// - /// The object to convert. - /// String representation of the object. - [Obsolete("Use value?.ToString() instead. This will be removed in the next release of the toolkit.")] - public static string ToSafeString(this object value) => value?.ToString(); - /// /// Returns a string with HTML comments, scripts, styles, and tags removed. /// From 7921fa74dac63109fa11f0ca862f03347607c095 Mon Sep 17 00:00:00 2001 From: Alexandre Zollinger Chohfi Date: Mon, 17 Aug 2020 11:55:03 -0700 Subject: [PATCH 2/8] Removed deprecated FacebookService, and the Microsoft.Toolkit.Uwp.Services project. --- .../Microsoft.Toolkit.Uwp.SampleApp.csproj | 2 - .../Facebook Service/FacebookCode.bind | 23 - .../Facebook Service/FacebookLogo.png | Bin 1301 -> 0 bytes .../SamplePages/Facebook Service/icon.png | Bin 871 -> 0 bytes .../SamplePages/samples.json | 10 - .../Microsoft.Toolkit.Uwp.Services.csproj | 19 - ...ft.Toolkit.Uwp.Services.csproj.DotSettings | 4 - .../Microsoft.Toolkit.Uwp.Services.rd.xml | 5 - .../Services/Facebook/FacebookAlbum.cs | 42 -- .../Services/Facebook/FacebookDataConfig.cs | 32 -- .../Services/Facebook/FacebookDataHost.cs | 18 - .../Services/Facebook/FacebookOAuthTokens.cs | 22 - .../Services/Facebook/FacebookPermissions.cs | 120 ---- .../Services/Facebook/FacebookPhoto.cs | 55 -- .../Services/Facebook/FacebookPicture.cs | 32 -- .../Services/Facebook/FacebookPictureData.cs | 17 - .../Facebook/FacebookPlatformImageSource.cs | 32 -- .../Services/Facebook/FacebookPost.cs | 44 -- .../Facebook/FacebookRequestSource.cs | 121 ---- .../Services/Facebook/FacebookService.cs | 515 ------------------ Windows Community Toolkit.sln | 34 +- readme.md | 3 +- 22 files changed, 4 insertions(+), 1146 deletions(-) delete mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Facebook Service/FacebookCode.bind delete mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Facebook Service/FacebookLogo.png delete mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Facebook Service/icon.png delete mode 100644 Microsoft.Toolkit.Uwp.Services/Microsoft.Toolkit.Uwp.Services.csproj delete mode 100644 Microsoft.Toolkit.Uwp.Services/Microsoft.Toolkit.Uwp.Services.csproj.DotSettings delete mode 100644 Microsoft.Toolkit.Uwp.Services/Properties/Microsoft.Toolkit.Uwp.Services.rd.xml delete mode 100644 Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookAlbum.cs delete mode 100644 Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookDataConfig.cs delete mode 100644 Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookDataHost.cs delete mode 100644 Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookOAuthTokens.cs delete mode 100644 Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookPermissions.cs delete mode 100644 Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookPhoto.cs delete mode 100644 Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookPicture.cs delete mode 100644 Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookPictureData.cs delete mode 100644 Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookPlatformImageSource.cs delete mode 100644 Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookPost.cs delete mode 100644 Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookRequestSource.cs delete mode 100644 Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookService.cs diff --git a/Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj b/Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj index 4291bcd25b3..18981c05b81 100644 --- a/Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj +++ b/Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj @@ -300,7 +300,6 @@ - @@ -365,7 +364,6 @@ - diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Facebook Service/FacebookCode.bind b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Facebook Service/FacebookCode.bind deleted file mode 100644 index 43f08e37c4a..00000000000 --- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Facebook Service/FacebookCode.bind +++ /dev/null @@ -1,23 +0,0 @@ -// Initialize service -FacebookService.Instance.Initialize(AppIDText.Text); - -// Login to Facebook -if (!await FacebookService.Instance.LoginAsync()) -{ - return; -} - -// Get user's feed -ListView.ItemsSource = await FacebookService.Instance.RequestAsync(FacebookDataConfig.MyFeed, 50); - -// Get current user profile picture -ProfileImage.DataContext = await FacebookService.Instance.GetUserPictureInfoAsync(); - -// Post a message on your wall using Facebook Dialog -await FacebookService.Instance.PostToFeedWithDialogAsync(TitleText.Text, DescriptionText.Text, UrlText.Text); - -// Get current user's photo albums -await FacebookService.Instance.GetUserAlbumsAsync(); - -// Get current user's photos by album Id -await FacebookService.Instance.GetUserPhotosByAlbumIdAsync(addedItem.Id); \ No newline at end of file diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Facebook Service/FacebookLogo.png b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Facebook Service/FacebookLogo.png deleted file mode 100644 index 0222a8325a3ec3c2c1716a27702c80845aaf048e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1301 zcmeAS@N?(olHy`uVBq!ia0y~yU{nCI4{)#n$t4^1Z39v)#ZI0f96(URkAJ?Y_KV}wo_RpHwt)bezFtBAtYxjY(3VEvk8L#IpNzE-W6ma~( z-=esM%QNPR(j5`b!vP(uLrR3Wj&nCpU)Qmg>&$ZNif482=KQW&%XY4R=l#uP(i_Mh;t(6%QZZc zvEQ|SSy|p%U+H6)7O&}gdVBAz{W~I#KRdV7eW7BRgKpuU7yo9>ym#-`kC4#ZTLxjq zmv6uRaq;iVz>E%ttw*k$Tl-RwEp5uVt#4UYsNUN1`RD#XtLxi@(E{gKbH|!h_vY>{ zP5l`5w=Q?(zdbu+)c5~;*=X9%?{oE8@A>f1tH0mpto(kjuJl5(kdniiE}-hI1uxy^ zS{cXN>&H~TxwU@Z-2d<2E4P2+y1*f*AhrF<%WE$;bANATm2+#zxDvEHdj8x$4?B0u zttb+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8e27cba22 100644 --- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/samples.json +++ b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/samples.json @@ -621,16 +621,6 @@ "Name": "Services", "Icon": "Icons/Services.png", "Samples": [ - { - "Name": "Facebook Service", - "About": "The Facebook Service allows you to retrieve or publish data to Facebook graph.", - "CodeUrl": "https://github.com/windows-toolkit/WindowsCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.Services/Services/Facebook", - "CodeFile": "FacebookCode.bind", - "Icon": "/SamplePages/Facebook Service/FacebookLogo.png", - "BadgeUpdateVersionRequired": "DEPRECATED", - "DeprecatedWarning": "The underlying library, winsdkfb, which the FacebookService relies on is not currently maintained.", - "DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/services/Facebook.md" - }, { "Name": "Microsoft Graph Service", "About": "These providers help you easily authenticate and connect to the Microsoft Graph.", diff --git a/Microsoft.Toolkit.Uwp.Services/Microsoft.Toolkit.Uwp.Services.csproj b/Microsoft.Toolkit.Uwp.Services/Microsoft.Toolkit.Uwp.Services.csproj deleted file mode 100644 index b8407c5f573..00000000000 --- a/Microsoft.Toolkit.Uwp.Services/Microsoft.Toolkit.Uwp.Services.csproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - uap10.0.16299 - Windows Community Toolkit Services - This library enables access to Facebook. It is part of the Windows Community Toolkit. - UWP Toolkit Windows OAuth Facebook - - - - - - - - - - - - diff --git a/Microsoft.Toolkit.Uwp.Services/Microsoft.Toolkit.Uwp.Services.csproj.DotSettings b/Microsoft.Toolkit.Uwp.Services/Microsoft.Toolkit.Uwp.Services.csproj.DotSettings deleted file mode 100644 index 32e2a35dca4..00000000000 --- a/Microsoft.Toolkit.Uwp.Services/Microsoft.Toolkit.Uwp.Services.csproj.DotSettings +++ /dev/null @@ -1,4 +0,0 @@ - - True - True - True \ No newline at end of file diff --git a/Microsoft.Toolkit.Uwp.Services/Properties/Microsoft.Toolkit.Uwp.Services.rd.xml b/Microsoft.Toolkit.Uwp.Services/Properties/Microsoft.Toolkit.Uwp.Services.rd.xml deleted file mode 100644 index 154280e96c9..00000000000 --- a/Microsoft.Toolkit.Uwp.Services/Properties/Microsoft.Toolkit.Uwp.Services.rd.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookAlbum.cs b/Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookAlbum.cs deleted file mode 100644 index 2c61e42396f..00000000000 --- a/Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookAlbum.cs +++ /dev/null @@ -1,42 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Toolkit.Uwp.Services.Facebook -{ - /// - /// Strongly types Facebook Album object. Partial for extending properties. - /// - public partial class FacebookAlbum - { - /// - /// Gets a string description of the strongly typed properties in this model. - /// - public static string Fields => "id, name, description, cover_photo, picture"; - - /// - /// Gets or sets id property. - /// - public string Id { get; set; } - - /// - /// Gets or sets name property. - /// - public string Name { get; set; } - - /// - /// Gets or sets description property. - /// - public string Description { get; set; } - - /// - /// Gets or sets cover_photo property. - /// - public FacebookPhoto Cover_Photo { get; set; } - - /// - /// Gets or sets picture property. - /// - public FacebookPictureData Picture { get; set; } - } -} diff --git a/Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookDataConfig.cs b/Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookDataConfig.cs deleted file mode 100644 index 06dbd8a9ec6..00000000000 --- a/Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookDataConfig.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Toolkit.Uwp.Services.Facebook -{ - /// - /// Configuration object for specifying richer query information. - /// - public class FacebookDataConfig - { - /// - /// Gets a predefined config to get user feed. The feed of posts (including status updates) and links published by this person, or by others on this person's profile - /// - public static FacebookDataConfig MyFeed => new FacebookDataConfig { Query = "/me/feed" }; - - /// - /// Gets a predefined config to show only the posts that were published by this person - /// - public static FacebookDataConfig MyPosts => new FacebookDataConfig { Query = "/me/posts" }; - - /// - /// Gets a predefined config to show only the posts that this person was tagged in - /// - public static FacebookDataConfig MyTagged => new FacebookDataConfig { Query = "/me/tagged" }; - - /// - /// Gets or sets the query string for filtering service results. - /// - public string Query { get; set; } - } -} diff --git a/Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookDataHost.cs b/Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookDataHost.cs deleted file mode 100644 index e2a292487e2..00000000000 --- a/Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookDataHost.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Toolkit.Uwp.Services.Facebook -{ - /// - /// Class used to store JSON data response from Facebook - /// - /// Type of the inner data - internal class FacebookDataHost - { - /// - /// Gets or sets internal data. - /// - public T Data { get; set; } - } -} diff --git a/Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookOAuthTokens.cs b/Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookOAuthTokens.cs deleted file mode 100644 index b3db6536110..00000000000 --- a/Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookOAuthTokens.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Toolkit.Uwp.Services.Facebook -{ - /// - /// Facebook OAuth tokens. - /// - public class FacebookOAuthTokens - { - /// - /// Gets or sets facebook AppId. - /// - public string AppId { get; set; } - - /// - /// Gets or sets Windows Store ID. - /// - public string WindowsStoreId { get; set; } - } -} diff --git a/Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookPermissions.cs b/Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookPermissions.cs deleted file mode 100644 index 907a4135fa1..00000000000 --- a/Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookPermissions.cs +++ /dev/null @@ -1,120 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; - -namespace Microsoft.Toolkit.Uwp.Services.Facebook -{ - /// - /// List of user related data permissions - /// - [Flags] - public enum FacebookPermissions - { - /// - /// Public profile - /// - PublicProfile = 1, - - /// - /// Email - /// - Email = 2, - - /// - /// Publish actions - /// - PublishActions = 4, - - /// - /// About me - /// - UserAboutMe = 8, - - /// - /// Birthday - /// - UserBirthday = 16, - - /// - /// Education history - /// - UserEducationHistory = 32, - - /// - /// Friends - /// - UserFriends = 64, - - /// - /// Games activity - /// - UserGamesActivity = 128, - - /// - /// Hometown - /// - UserHometown = 256, - - /// - /// Likes - /// - UserLikes = 512, - - /// - /// Location - /// - UserLocation = 1024, - - /// - /// Photos - /// - UserPhotos = 2048, - - /// - /// Posts - /// - UserPosts = 4096, - - /// - /// Relationship details - /// - UserRelationshipDetails = 8192, - - /// - /// Relationships - /// - UserRelationships = 16384, - - /// - /// Religion and politics - /// - UserReligionPolitics = 32768, - - /// - /// Status - /// - UserStatus = 65536, - - /// - /// Tagged places - /// - UserTaggedPlaces = 131072, - - /// - /// Videos - /// - UserVideos = 262144, - - /// - /// Website - /// - UserWebsite = 524288, - - /// - /// WorkHistory - /// - UserWorkHistory = 1048576 - } -} diff --git a/Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookPhoto.cs b/Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookPhoto.cs deleted file mode 100644 index 0d1a0c9870d..00000000000 --- a/Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookPhoto.cs +++ /dev/null @@ -1,55 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections.Generic; - -namespace Microsoft.Toolkit.Uwp.Services.Facebook -{ - /// - /// Strongly types Facebook Photo object. Partial for extending properties. - /// - public partial class FacebookPhoto - { - /// - /// Gets a string description of the strongly typed properties in this model. - /// - public static string Fields => "id, album, link, created_time, name, images, picture"; - - /// - /// Gets or sets id property. - /// - public string Id { get; set; } - - /// - /// Gets or sets album property. - /// - public FacebookAlbum Album { get; set; } - - /// - /// Gets or sets a link to the entity instance. - /// - public string Link { get; set; } - - /// - /// Gets or sets time the entity instance was created. - /// - public DateTime Created_Time { get; set; } - - /// - /// Gets or sets name property. - /// - public string Name { get; set; } - - /// - /// Gets or sets images property. - /// - public List Images { get; set; } - - /// - /// Gets or sets picture property. - /// - public string Picture { get; set; } - } -} diff --git a/Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookPicture.cs b/Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookPicture.cs deleted file mode 100644 index ccd38a0f874..00000000000 --- a/Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookPicture.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Toolkit.Uwp.Services.Facebook -{ - /// - /// Strongly typed object for presenting picture data returned from service provider. - /// - public class FacebookPicture - { - /// - /// Gets or sets a value indicating whether the picture is a silhouette or not. - /// - public bool Is_Silhouette { get; set; } - - /// - /// Gets or sets an url to the picture. - /// - public string Url { get; set; } - - /// - /// Gets or sets the ID of the picture. - /// - public string Id { get; set; } - - /// - /// Gets or sets the url of the page with the picture. - /// - public string Link { get; set; } - } -} diff --git a/Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookPictureData.cs b/Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookPictureData.cs deleted file mode 100644 index fb5398acfa1..00000000000 --- a/Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookPictureData.cs +++ /dev/null @@ -1,17 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Toolkit.Uwp.Services.Facebook -{ - /// - /// Strongly types Facebook Picture object. Partial for extending properties. - /// - public partial class FacebookPictureData - { - /// - /// Gets or sets data property. - /// - public FacebookPicture Data { get; set; } - } -} diff --git a/Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookPlatformImageSource.cs b/Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookPlatformImageSource.cs deleted file mode 100644 index 61e8077edec..00000000000 --- a/Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookPlatformImageSource.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Toolkit.Uwp.Services.Facebook -{ - /// - /// Strongly types Facebook PlatformImageSource object. Partial for extending properties. - /// - public partial class FacebookPlatformImageSource - { - /// - /// Gets a string description of the strongly typed properties in this model. - /// - public static string Fields => "height, source, width"; - - /// - /// Gets or sets height property. - /// - public string Height { get; set; } - - /// - /// Gets or sets source property. - /// - public string Source { get; set; } - - /// - /// Gets or sets width property. - /// - public string Width { get; set; } - } -} diff --git a/Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookPost.cs b/Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookPost.cs deleted file mode 100644 index a452db85a94..00000000000 --- a/Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookPost.cs +++ /dev/null @@ -1,44 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; - -namespace Microsoft.Toolkit.Uwp.Services.Facebook -{ - /// - /// Strongly typed object for presenting post data returned from service provider. - /// - public class FacebookPost - { - /// - /// Gets a string description of the strongly typed properties in this model. - /// - public static string Fields => "id, message, created_time, link, full_picture"; - - /// - /// Gets or sets id property. - /// - public string Id { get; set; } - - /// - /// Gets or sets message or post text. - /// - public string Message { get; set; } - - /// - /// Gets or sets time the entity instance was created. - /// - public DateTime Created_Time { get; set; } - - /// - /// Gets or sets a link to the entity instance. - /// - public string Link { get; set; } - - /// - /// Gets or sets a link to the accompanying image. - /// - public string Full_Picture { get; set; } - } -} diff --git a/Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookRequestSource.cs b/Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookRequestSource.cs deleted file mode 100644 index a53679b9a4a..00000000000 --- a/Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookRequestSource.cs +++ /dev/null @@ -1,121 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; -using Newtonsoft.Json; -using Windows.Foundation.Collections; -using winsdkfb; -using winsdkfb.Graph; - -namespace Microsoft.Toolkit.Uwp.Services.Facebook -{ - /// - /// Type to handle paged requests to Facebook Graph. - /// - /// Strong type to return. - public class FacebookRequestSource : Collections.IIncrementalSource - { - private bool _isFirstCall = true; - - private FBPaginatedArray _paginatedArray; - - private FacebookDataConfig _config; - - private string _fields; - - private PropertySet _propertySet; - - private FBJsonClassFactory _factory; - - private string _limit; - - private int _maxPages; - - /// - /// Initializes a new instance of the class. - /// - public FacebookRequestSource() - { - } - - /// - /// Initializes a new instance of the class. - /// - /// Config containing query information. - /// Comma-separated list of properties expected in the JSON response. Accompanying properties must be found on the strong-typed T. - /// A string representation of the number of records for page - i.e. pageSize. - /// Upper limit of pages to return. - public FacebookRequestSource(FacebookDataConfig config, string fields, string limit, int maxPages) - { - _config = config; - _fields = fields; - _limit = limit; - _maxPages = maxPages; - - _propertySet = new PropertySet { { "fields", _fields }, { "limit", _limit } }; - - _factory = new FBJsonClassFactory(s => JsonConvert.DeserializeObject(s, typeof(T))); - - // FBPaginatedArray does not allow us to set page size per request so we must go with first supplied - see https://github.com/Microsoft/winsdkfb/issues/221 - _paginatedArray = new FBPaginatedArray(_config.Query, _propertySet, _factory); - } - - /// - /// Returns strong typed page of data. - /// - /// Page number. - /// Size of page. - /// Cancellation token. - /// Strong typed page of data. - public async Task> GetPagedItemsAsync(int pageIndex, int pageSize, CancellationToken cancellationToken = default(CancellationToken)) - { - if (_isFirstCall) - { - var result = await _paginatedArray.FirstAsync(); - - return ProcessResult(result); - } - else - { - if (cancellationToken.IsCancellationRequested) - { - return null; - } - - if (_paginatedArray.HasNext && (pageIndex < _maxPages)) - { - var result = await _paginatedArray.NextAsync(); - return ProcessResult(result); - } - else - { - return null; - } - } - } - - private IEnumerable ProcessResult(FBResult result) - { - List items = new List(); - - if (result.Succeeded) - { - IReadOnlyList processedResults = (IReadOnlyList)result.Object; - - foreach (T processedResult in processedResults) - { - items.Add(processedResult); - } - - _isFirstCall = false; - return items; - } - - throw new Exception(result.ErrorInfo?.Message); - } - } -} diff --git a/Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookService.cs b/Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookService.cs deleted file mode 100644 index fb3bedd36aa..00000000000 --- a/Microsoft.Toolkit.Uwp.Services/Services/Facebook/FacebookService.cs +++ /dev/null @@ -1,515 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Text; -using System.Threading.Tasks; -using Newtonsoft.Json; -using Windows.Foundation; -using Windows.Foundation.Collections; -using Windows.Foundation.Metadata; -using Windows.Security.Authentication.Web; -using Windows.Storage.Streams; -using winsdkfb; -using winsdkfb.Graph; - -namespace Microsoft.Toolkit.Uwp.Services.Facebook -{ - /// - /// Class for connecting to Facebook. - /// - [Obsolete("The underlying library, winsdkfb, which the FacebookService relies on is not currently maintained.")] - public class FacebookService - { - /// - /// Field for tracking initialization status. - /// - private bool isInitialized; - - /// - /// List of permissions required by the app. - /// - private FBPermissions permissions; - - /// - /// Gets a Windows Store ID associated with the current app - /// - public string WindowsStoreId => WebAuthenticationBroker.GetCurrentApplicationCallbackUri().ToString(); - - /// - /// Initializes a new instance of the class. - /// - public FacebookService() - { - } - - /// - /// Initialize underlying provider with relevant token information. - /// - /// Token instance. - /// List of required required permissions. public_profile and user_posts permissions will be used by default. - /// Success or failure. - public bool Initialize(FacebookOAuthTokens oAuthTokens, FacebookPermissions requiredPermissions = FacebookPermissions.PublicProfile | FacebookPermissions.UserPosts) - { - if (oAuthTokens == null) - { - throw new ArgumentNullException(nameof(oAuthTokens)); - } - - return Initialize(oAuthTokens.AppId, requiredPermissions, oAuthTokens.WindowsStoreId); - } - - /// - /// Initialize underlying provider with relevant token information. - /// - /// Application ID (Provided by Facebook developer site) - /// List of required required permissions. public_profile and user_posts permissions will be used by default. - /// Windows Store SID - /// Success or failure. - public bool Initialize(string appId, FacebookPermissions requiredPermissions = FacebookPermissions.PublicProfile | FacebookPermissions.UserPosts, string windowsStoreId = null) - { - if (string.IsNullOrEmpty(appId)) - { - throw new ArgumentNullException(nameof(appId)); - } - - if (string.IsNullOrEmpty(windowsStoreId)) - { - windowsStoreId = WindowsStoreId; - } - - isInitialized = true; - - Provider.FBAppId = appId; - Provider.WinAppId = windowsStoreId; - - // Permissions - var permissionList = new List(); - - foreach (FacebookPermissions value in Enum.GetValues(typeof(FacebookPermissions))) - { - if ((requiredPermissions & value) != 0) - { - var name = value.ToString(); - var finalName = new StringBuilder(); - - foreach (var c in name) - { - if (char.IsUpper(c)) - { - if (finalName.Length > 0) - { - finalName.Append('_'); - } - - finalName.Append(char.ToLower(c)); - } - else - { - finalName.Append(c); - } - } - - permissionList.Add(finalName.ToString()); - } - } - - permissions = new FBPermissions(permissionList); - - return true; - } - - /// - /// Private singleton field. - /// - private static FacebookService instance; - - /// - /// Gets public singleton property. - /// - public static FacebookService Instance => instance ?? (instance = new FacebookService()); - - /// - /// Gets a reference to an instance of the underlying data provider. - /// - public FBSession Provider - { - get - { - if (!isInitialized) - { - throw new InvalidOperationException("Provider not initialized."); - } - - return FBSession.ActiveSession; - } - } - - /// - /// Gets the current logged user name. - /// - public string LoggedUser => !Provider.LoggedIn ? null : FBSession.ActiveSession.User.Name; - - /// - /// Login with set of required requiredPermissions. - /// - /// Success or failure. - public async Task LoginAsync() - { - if (Provider != null) - { - var result = await Provider.LoginAsync(permissions, SessionLoginBehavior.WebView); - - if (result.Succeeded) - { - return true; - } - - if (result.ErrorInfo != null) - { - Debug.WriteLine(string.Format("Error logging in: {0}", result.ErrorInfo.Message)); - } - - return false; - } - - Debug.WriteLine("Error logging in - no Active session found"); - return false; - } - - /// - /// Log out of the underlying service instance. - /// - /// Task to support await of async call. - public Task LogoutAsync() - { - return Provider.LogoutAsync().AsTask(); - } - - /// - /// Request list data from service provider based upon a given config / query. - /// - /// FacebookDataConfig instance. - /// Upper limit of records to return. - /// Strongly typed list of data returned from the service. - public Task> RequestAsync(FacebookDataConfig config, int maxRecords = 20) - { - return RequestAsync(config, maxRecords, FacebookPost.Fields); - } - - /// - /// Request list data from service provider based upon a given config / query. - /// - /// Strong type of model. - /// FacebookDataConfig instance. - /// Upper limit of records to return. - /// A comma separated string of required fields, which will have strongly typed representation in the model passed in. - /// Strongly typed list of data returned from the service. - public async Task> RequestAsync(FacebookDataConfig config, int maxRecords = 20, string fields = "id,message,from,created_time,link,full_picture") - { - if (Provider.LoggedIn) - { - var requestSource = new FacebookRequestSource(config, fields, maxRecords.ToString(), 1); - - var list = await requestSource.GetPagedItemsAsync(0, maxRecords); - - return new List(list); - } - - var isLoggedIn = await LoginAsync(); - if (isLoggedIn) - { - return await RequestAsync(config, maxRecords, fields); - } - - return null; - } - - /// - /// Request list data from service provider based upon a given config / query. - /// - /// FacebookDataConfig instance. - /// Upper limit of records to return. - /// Upper limit of pages to return. - /// Strongly typed list of data returned from the service. - public Task, FacebookPost>> RequestAsync(FacebookDataConfig config, int pageSize, int maxPages) - { - return RequestAsync(config, pageSize, maxPages, FacebookPost.Fields); - } - - /// - /// Request generic list data from service provider based upon a given config / query. - /// - /// Strong type of model. - /// FacebookDataConfig instance. - /// Upper limit of records to return. - /// Upper limit of pages to return. - /// A comma separated string of required fields, which will have strongly typed representation in the model passed in. - /// Strongly typed list of data returned from the service. - public async Task, T>> RequestAsync(FacebookDataConfig config, int pageSize, int maxPages, string fields = "id,message,from,created_time,link,full_picture") - { - if (Provider.LoggedIn) - { - var requestSource = new FacebookRequestSource(config, fields, pageSize.ToString(), maxPages); - - return new IncrementalLoadingCollection, T>(requestSource); - } - - var isLoggedIn = await LoginAsync(); - if (isLoggedIn) - { - return await RequestAsync(config, pageSize, maxPages, fields); - } - - return null; - } - - /// - /// Returns the object associated with the logged user - /// - /// A object - public async Task GetUserPictureInfoAsync() - { - if (Provider.LoggedIn) - { - var factory = new FBJsonClassFactory(JsonConvert.DeserializeObject>); - - PropertySet propertySet = new PropertySet { { "redirect", "0" } }; - var singleValue = new FBSingleValue("/me/picture", propertySet, factory); - - var result = await singleValue.GetAsync(); - - if (result.Succeeded) - { - return ((FacebookDataHost)result.Object).Data; - } - - throw new Exception(result.ErrorInfo?.Message); - } - - var isLoggedIn = await LoginAsync(); - if (isLoggedIn) - { - return await GetUserPictureInfoAsync(); - } - - return null; - } - - /// - /// Retrieves list of user photo albums. - /// - /// Upper limit of records to return. - /// Custom list of Album fields to retrieve. - /// List of User Photo Albums. - public async Task> GetUserAlbumsAsync(int maxRecords = 20, string fields = null) - { - fields = fields ?? FacebookAlbum.Fields; - var config = new FacebookDataConfig { Query = "/me/albums" }; - - return await RequestAsync(config, maxRecords, fields); - } - - /// - /// Retrieves list of user photo albums. - /// - /// Number of records to retrieve per page. - /// Upper limit of pages to return. - /// Custom list of Album fields to retrieve. - /// List of User Photo Albums. - public async Task, FacebookAlbum>> GetUserAlbumsAsync(int pageSize, int maxPages, string fields = null) - { - fields = fields ?? FacebookAlbum.Fields; - var config = new FacebookDataConfig { Query = "/me/albums" }; - - return await RequestAsync(config, pageSize, maxPages, fields); - } - - /// - /// Retrieves list of user photos by album id. - /// - /// Albums Id for photos. - /// Upper limit of records to return - /// Custom list of Photo fields to retrieve. - /// List of User Photos. - public async Task> GetUserPhotosByAlbumIdAsync(string albumId, int maxRecords = 20, string fields = null) - { - fields = fields ?? FacebookPhoto.Fields; - var config = new FacebookDataConfig { Query = $"/{albumId}/photos" }; - - return await RequestAsync(config, maxRecords, fields); - } - - /// - /// Retrieves list of user photos by album id. - /// - /// Albums Id for photos. - /// Number of records to retrieve per page. - /// Upper limit of pages to return. - /// Custom list of Photo fields to retrieve. - /// List of User Photos. - public async Task, FacebookPhoto>> GetUserPhotosByAlbumIdAsync(string albumId, int pageSize, int maxPages, string fields = null) - { - fields = fields ?? FacebookPhoto.Fields; - var config = new FacebookDataConfig { Query = $"/{albumId}/photos" }; - - return await RequestAsync(config, pageSize, maxPages, fields); - } - - /// - /// Retrieves a photo by id. - /// - /// Photo Id for the photo. - /// A single photo. - public async Task GetPhotoByPhotoIdAsync(string photoId) - { - if (Provider.LoggedIn) - { - var factory = new FBJsonClassFactory(JsonConvert.DeserializeObject); - - PropertySet propertySet = new PropertySet { { "fields", "images" } }; - var singleValue = new FBSingleValue($"/{photoId}", propertySet, factory); - - var result = await singleValue.GetAsync(); - - if (result.Succeeded) - { - return (FacebookPhoto)result.Object; - } - - throw new Exception(result.ErrorInfo?.Message); - } - - var isLoggedIn = await LoginAsync(); - if (isLoggedIn) - { - return await GetPhotoByPhotoIdAsync(photoId); - } - - return null; - } - - /// - /// Enables direct posting data to the timeline. - /// - /// Link contained as part of the post. Cannot be null. - /// Task to support await of async call. - [Deprecated("The underlying publish_action permission is no longer supported by Facebook. Please see https://developers.facebook.com/blog/post/2018/04/24/new-facebook-platform-product-changes-policy-updates/ for details.", DeprecationType.Deprecate, 4)] - public async Task PostToFeedAsync(string link) - { - if (Provider.LoggedIn) - { - var parameters = new PropertySet { { "link", link } }; - - string path = FBSession.ActiveSession.User.Id + "/feed"; - var factory = new FBJsonClassFactory(JsonConvert.DeserializeObject); - - var singleValue = new FBSingleValue(path, parameters, factory); - var result = await singleValue.PostAsync(); - if (result.Succeeded) - { - var postResponse = result.Object as FacebookPost; - if (postResponse != null) - { - return true; - } - } - - Debug.WriteLine(string.Format("Could not post. {0}", result.ErrorInfo?.ErrorUserMessage)); - return false; - } - - var isLoggedIn = await LoginAsync(); - if (isLoggedIn) - { - return await PostToFeedAsync(link); - } - - return false; - } - - /// - /// Enables posting data to the timeline using Facebook dialog. - /// - /// Link contained as part of the post. Cannot be null. - /// Task to support await of async call. - public async Task PostToFeedWithDialogAsync(string link) - { - if (Provider.LoggedIn) - { - var parameters = new PropertySet { { "link", link } }; - - var result = await Provider.ShowFeedDialogAsync(parameters); - - if (result.Succeeded) - { - return true; - } - - Debug.WriteLine(string.Format("Could not post. {0}", result.ErrorInfo?.ErrorUserMessage)); - return false; - } - - var isLoggedIn = await LoginAsync(); - if (isLoggedIn) - { - return await PostToFeedWithDialogAsync(link); - } - - return false; - } - - /// - /// Enables posting a picture to the timeline - /// - /// Title of the post. - /// Picture name. - /// Picture stream to upload. - /// Return ID of the picture - [Deprecated("The underlying publish_action permission is no longer supported by Facebook. Please see https://developers.facebook.com/blog/post/2018/04/24/new-facebook-platform-product-changes-policy-updates/ for details.", DeprecationType.Deprecate, 4)] - public async Task PostPictureToFeedAsync(string title, string pictureName, IRandomAccessStreamWithContentType pictureStream) - { - if (pictureStream == null) - { - return null; - } - - if (Provider.LoggedIn) - { - var facebookPictureStream = new FBMediaStream(pictureName, pictureStream); - var parameters = new PropertySet - { - { "source", facebookPictureStream }, - { "name", title } - }; - - string path = FBSession.ActiveSession.User.Id + "/photos"; - var factory = new FBJsonClassFactory(JsonConvert.DeserializeObject); - - var singleValue = new FBSingleValue(path, parameters, factory); - var result = await singleValue.PostAsync(); - if (result.Succeeded) - { - var photoResponse = result.Object as FacebookPicture; - if (photoResponse != null) - { - return photoResponse.Id; - } - } - - return null; - } - - var isLoggedIn = await LoginAsync(); - if (isLoggedIn) - { - return await PostPictureToFeedAsync(title, pictureName, pictureStream); - } - - return null; - } - } -} diff --git a/Windows Community Toolkit.sln b/Windows Community Toolkit.sln index d8e5f4ccbee..b9f6ee4728f 100644 --- a/Windows Community Toolkit.sln +++ b/Windows Community Toolkit.sln @@ -19,8 +19,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "UI", "UI", "{F1AFFFA7-28FE- EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{B30036C4-D514-4E5B-A323-587A061772CE}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Toolkit.Uwp.Services", "Microsoft.Toolkit.Uwp.Services\Microsoft.Toolkit.Uwp.Services.csproj", "{7189A42D-6F1A-4FA3-8E00-E2C14FDF167A}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Toolkit.Uwp.UI.Controls", "Microsoft.Toolkit.Uwp.UI.Controls\Microsoft.Toolkit.Uwp.UI.Controls.csproj", "{E9FAABFB-D726-42C1-83C1-CB46A29FEA81}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Toolkit.Uwp.UI.Controls.DataGrid", "Microsoft.Toolkit.Uwp.UI.Controls.DataGrid\Microsoft.Toolkit.Uwp.UI.Controls.DataGrid.csproj", "{DAEB9CEC-C817-33B2-74B2-BC379380DB72}" @@ -90,7 +88,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GazeInputTest", "GazeInputT EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Toolkit.Uwp.UI.Media", "Microsoft.Toolkit.Uwp.UI.Media\Microsoft.Toolkit.Uwp.UI.Media.csproj", "{75F9EE44-3EFA-47BC-AEDD-351B9834A0AF}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Toolkit.Mvvm", "Microsoft.Toolkit.Mvvm\Microsoft.Toolkit.Mvvm.csproj", "{D82AE6E1-E612-434E-ACB2-363EE48738D3}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Toolkit.Mvvm", "Microsoft.Toolkit.Mvvm\Microsoft.Toolkit.Mvvm.csproj", "{D82AE6E1-E612-434E-ACB2-363EE48738D3}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "UnitTests.Shared", "UnitTests\UnitTests.Shared\UnitTests.Shared.shproj", "{4E9466D1-D5AA-46AC-801B-C8FDAB79F0D4}" EndProject @@ -128,12 +126,11 @@ EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution UnitTests\UnitTests.Shared\UnitTests.Shared.projitems*{4e9466d1-d5aa-46ac-801b-c8fdab79f0d4}*SharedItemsImports = 13 - UnitTests\UnitTests.Shared\UnitTests.Shared.projitems*{7878cd00-85e8-4d02-9757-8a43db4c6510}*SharedItemsImports = 5 - UnitTests\UnitTests.Notifications.Shared\UnitTests.Notifications.Shared.projitems*{982cc826-aacd-4855-9075-430bb6ce40a9}*SharedItemsImports = 13 - UnitTests\UnitTests.Shared\UnitTests.Shared.projitems*{a139968e-ad78-4e8c-93b8-9a5523bcac89}*SharedItemsImports = 4 UnitTests\UnitTests.HighPerformance.Shared\UnitTests.HighPerformance.Shared.projitems*{5524523e-db0f-41f7-a0d4-43128422a342}*SharedItemsImports = 4 + UnitTests\UnitTests.Shared\UnitTests.Shared.projitems*{7878cd00-85e8-4d02-9757-8a43db4c6510}*SharedItemsImports = 5 UnitTests\UnitTests.Notifications.Shared\UnitTests.Notifications.Shared.projitems*{982cc826-aacd-4855-9075-430bb6ce40a9}*SharedItemsImports = 13 UnitTests\UnitTests.HighPerformance.Shared\UnitTests.HighPerformance.Shared.projitems*{9b3a94a6-0d29-4523-880b-6938e2efeef7}*SharedItemsImports = 13 + UnitTests\UnitTests.Shared\UnitTests.Shared.projitems*{a139968e-ad78-4e8c-93b8-9a5523bcac89}*SharedItemsImports = 4 UnitTests\UnitTests.Notifications.Shared\UnitTests.Notifications.Shared.projitems*{bab1caf4-c400-4a7f-a987-c576de63cffd}*SharedItemsImports = 4 UnitTests\UnitTests.HighPerformance.Shared\UnitTests.HighPerformance.Shared.projitems*{d9bdbc68-3d0a-47fc-9c88-0bf769101644}*SharedItemsImports = 5 UnitTests\UnitTests.Notifications.Shared\UnitTests.Notifications.Shared.projitems*{efa96b3c-857e-4659-b942-6bef7719f4ca}*SharedItemsImports = 4 @@ -297,31 +294,6 @@ Global {B24A296C-B3EB-4E06-A64E-74AC2D1ACC91}.Release|x64.Build.0 = Release|Any CPU {B24A296C-B3EB-4E06-A64E-74AC2D1ACC91}.Release|x86.ActiveCfg = Release|Any CPU {B24A296C-B3EB-4E06-A64E-74AC2D1ACC91}.Release|x86.Build.0 = Release|Any CPU - {7189A42D-6F1A-4FA3-8E00-E2C14FDF167A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7189A42D-6F1A-4FA3-8E00-E2C14FDF167A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7189A42D-6F1A-4FA3-8E00-E2C14FDF167A}.Debug|ARM.ActiveCfg = Debug|Any CPU - {7189A42D-6F1A-4FA3-8E00-E2C14FDF167A}.Debug|ARM.Build.0 = Debug|Any CPU - {7189A42D-6F1A-4FA3-8E00-E2C14FDF167A}.Debug|ARM64.ActiveCfg = Debug|Any CPU - {7189A42D-6F1A-4FA3-8E00-E2C14FDF167A}.Debug|ARM64.Build.0 = Debug|Any CPU - {7189A42D-6F1A-4FA3-8E00-E2C14FDF167A}.Debug|x64.ActiveCfg = Debug|Any CPU - {7189A42D-6F1A-4FA3-8E00-E2C14FDF167A}.Debug|x64.Build.0 = Debug|Any CPU - {7189A42D-6F1A-4FA3-8E00-E2C14FDF167A}.Debug|x86.ActiveCfg = Debug|Any CPU - {7189A42D-6F1A-4FA3-8E00-E2C14FDF167A}.Debug|x86.Build.0 = Debug|Any CPU - {7189A42D-6F1A-4FA3-8E00-E2C14FDF167A}.Native|Any CPU.ActiveCfg = Release|Any CPU - {7189A42D-6F1A-4FA3-8E00-E2C14FDF167A}.Native|ARM.ActiveCfg = Release|Any CPU - {7189A42D-6F1A-4FA3-8E00-E2C14FDF167A}.Native|ARM64.ActiveCfg = Release|Any CPU - {7189A42D-6F1A-4FA3-8E00-E2C14FDF167A}.Native|x64.ActiveCfg = Release|Any CPU - {7189A42D-6F1A-4FA3-8E00-E2C14FDF167A}.Native|x86.ActiveCfg = Release|Any CPU - {7189A42D-6F1A-4FA3-8E00-E2C14FDF167A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7189A42D-6F1A-4FA3-8E00-E2C14FDF167A}.Release|Any CPU.Build.0 = Release|Any CPU - {7189A42D-6F1A-4FA3-8E00-E2C14FDF167A}.Release|ARM.ActiveCfg = Release|Any CPU - {7189A42D-6F1A-4FA3-8E00-E2C14FDF167A}.Release|ARM.Build.0 = Release|Any CPU - {7189A42D-6F1A-4FA3-8E00-E2C14FDF167A}.Release|ARM64.ActiveCfg = Release|Any CPU - {7189A42D-6F1A-4FA3-8E00-E2C14FDF167A}.Release|ARM64.Build.0 = Release|Any CPU - {7189A42D-6F1A-4FA3-8E00-E2C14FDF167A}.Release|x64.ActiveCfg = Release|Any CPU - {7189A42D-6F1A-4FA3-8E00-E2C14FDF167A}.Release|x64.Build.0 = Release|Any CPU - {7189A42D-6F1A-4FA3-8E00-E2C14FDF167A}.Release|x86.ActiveCfg = Release|Any CPU - {7189A42D-6F1A-4FA3-8E00-E2C14FDF167A}.Release|x86.Build.0 = Release|Any CPU {E9FAABFB-D726-42C1-83C1-CB46A29FEA81}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E9FAABFB-D726-42C1-83C1-CB46A29FEA81}.Debug|Any CPU.Build.0 = Debug|Any CPU {E9FAABFB-D726-42C1-83C1-CB46A29FEA81}.Debug|ARM.ActiveCfg = Debug|Any CPU diff --git a/readme.md b/readme.md index 0db48418d7e..aef7bc42f2b 100644 --- a/readme.md +++ b/readme.md @@ -36,11 +36,10 @@ Once you do a search, you should see a list similar to the one below (versions m | Microsoft.Toolkit | .NET Standard NuGet package containing common code | | Microsoft.Toolkit.HighPerformance | .NET Standard and .NET Core NuGet package with performance oriented helpers, extensions, etc. | | Microsoft.Toolkit.Parsers | .NET Standard NuGet package containing cross-platform parsers, such as Markdown and RSS | -| Microsoft.Toolkit.Services | .NET Standard NuGet package containing cross-platform services | +| Microsoft.Toolkit.Services | .NET Standard NuGet package containing cross-platform services helpers, such as LinkedIn, Microsoft Graph, Twitter and more | | Microsoft.Toolkit.Uwp | Main NuGet package includes code only helpers such as Colors conversion tool, Storage file handling, a Stream helper class, etc. | | Microsoft.Toolkit.Uwp.Notifications | Notifications Package - Generate tile, toast, and badge notifications for Windows 10 via code. Includes intellisense support to avoid having to use the XML syntax | | Microsoft.Toolkit.Uwp.Notifications.Javascript | Notification Packages for JavaScript | -| Microsoft.Toolkit.Uwp.Services | Services Package - This NuGet package includes the service helpers for Facebook, LinkedIn, Microsoft Graph, Twitter and more | | Microsoft.Toolkit.Uwp.UI | UI Packages - XAML converters, Visual tree extensions, and other extensions and helpers for your XAML UI | | Microsoft.Toolkit.Uwp.UI.Animations | Animations and Composition behaviors such as Blur, Fade, Rotate, etc. | | Microsoft.Toolkit.Uwp.UI.Controls | XAML Controls such as RadialGauge, RangeSelector, etc. | From 3fc7dc7b4c18d7ee1ae7a740e00a004dc97492db Mon Sep 17 00:00:00 2001 From: Alexandre Zollinger Chohfi Date: Mon, 17 Aug 2020 11:55:34 -0700 Subject: [PATCH 3/8] Removed deprecated NotifyTaskCompletion and Singleton classes. --- .../Helpers/NotifyTaskCompletion.cs | 141 ------------------ Microsoft.Toolkit/Helpers/Singleton.cs | 43 ------ 2 files changed, 184 deletions(-) delete mode 100644 Microsoft.Toolkit/Helpers/NotifyTaskCompletion.cs delete mode 100644 Microsoft.Toolkit/Helpers/Singleton.cs diff --git a/Microsoft.Toolkit/Helpers/NotifyTaskCompletion.cs b/Microsoft.Toolkit/Helpers/NotifyTaskCompletion.cs deleted file mode 100644 index 0f9fb1f0610..00000000000 --- a/Microsoft.Toolkit/Helpers/NotifyTaskCompletion.cs +++ /dev/null @@ -1,141 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.ComponentModel; -using System.Threading.Tasks; - -namespace Microsoft.Toolkit.Helpers -{ - /// - /// Helper class to wrap around a Task to provide more information usable for UI data binding scenarios. As discussed in MSDN Magazine: https://msdn.microsoft.com/magazine/dn605875. - /// - /// Type of result returned by task. - [Obsolete("This helper will be removed in a future release, use the ObservableObject base class from Microsoft.Toolkit.Mvvm and the SetAndNotifyOnCompletion method")] - public sealed class NotifyTaskCompletion : INotifyPropertyChanged - { - /// - /// Initializes a new instance of the class. - /// - /// Task to wait on. - public NotifyTaskCompletion(Task task) - { - Task = task; - if (!task.IsCompleted) - { - TaskCompletion = WatchTaskAsync(task); - } - } - - private async Task WatchTaskAsync(Task task) - { - try - { - await task; - } - catch - { - } - - if (PropertyChanged == null) - { - return; - } - - PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(Status))); - PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(IsCompleted))); - PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(IsNotCompleted))); - - if (task.IsCanceled) - { - PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(IsCanceled))); - } - else if (task.IsFaulted) - { - PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(IsFaulted))); - PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(Exception))); - PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(InnerException))); - PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(ErrorMessage))); - } - else - { - PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(IsSuccessfullyCompleted))); - PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(Result))); - } - } - - /// - /// Gets the task that is being waited on. - /// - public Task Task { get; private set; } - - /// - /// Gets the task wrapper task. - /// - public Task TaskCompletion { get; private set; } - - /// - /// Gets the result of the given task. - /// - public TResult Result - { - get - { - return (Task.Status == TaskStatus.RanToCompletion) ? - Task.Result : - default(TResult); - } - } - - /// - /// Gets the status of the task. - /// - public TaskStatus Status => Task.Status; - - /// - /// Gets a value indicating whether the task is completed. - /// - public bool IsCompleted => Task.IsCompleted; - - /// - /// Gets a value indicating whether the task is not completed. - /// - public bool IsNotCompleted => !Task.IsCompleted; - - /// - /// Gets a value indicating whether the task was successfully completed. - /// - public bool IsSuccessfullyCompleted => Task.Status == TaskStatus.RanToCompletion; - - /// - /// Gets a value indicating whether the task was cancelled. - /// - public bool IsCanceled => Task.IsCanceled; - - /// - /// Gets a value indicating whether there was an error with the task. - /// - public bool IsFaulted => Task.IsFaulted; - - /// - /// Gets the exception which occurred on the task (if one occurred). - /// - public AggregateException Exception => Task.Exception; - - /// - /// Gets the inner exception of the task. - /// - public Exception InnerException => Exception?.InnerException; - - /// - /// Gets the error message of the task. - /// - public string ErrorMessage => InnerException?.Message ?? Exception.Message; - - /// - /// PropertyChanged event. - /// - public event PropertyChangedEventHandler PropertyChanged; - } -} diff --git a/Microsoft.Toolkit/Helpers/Singleton.cs b/Microsoft.Toolkit/Helpers/Singleton.cs deleted file mode 100644 index 63bd7044005..00000000000 --- a/Microsoft.Toolkit/Helpers/Singleton.cs +++ /dev/null @@ -1,43 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections.Concurrent; - -namespace Microsoft.Toolkit.Helpers -{ - /// - /// Obsolete see https://github.com/windows-toolkit/WindowsCommunityToolkit/issues/3134. - /// - /// The type to be used for creating the Singleton instance. - /// - /// Instead of this helper, migrate your code to this pattern instead: - /// - /// // Setup Singleton - /// public class MyClass - /// { - /// public static MyClass Instance { get; } = new MyClass(); - /// } - /// - /// - [Obsolete("This helper will be removed in a future release, see example tag for code replacement. https://github.com/windows-toolkit/WindowsCommunityToolkit/issues/3134")] - public static class Singleton - where T : new() - { - // Use ConcurrentDictionary for thread safety. - private static readonly ConcurrentDictionary _instances = new ConcurrentDictionary(); - - /// - /// Gets the instance of the Singleton class. - /// - public static T Instance - { - get - { - // Safely creates the first instance or retrieves the existing instance across threads. - return _instances.GetOrAdd(typeof(T), (t) => new T()); - } - } - } -} From 5b7d04b70d7c15bd4f8b4b05365a674aaef58f10 Mon Sep 17 00:00:00 2001 From: Alexandre Zollinger Chohfi Date: Tue, 18 Aug 2020 16:33:24 -0700 Subject: [PATCH 4/8] Remove Toolkit Platform Analyzers (fixes #3396). --- .../App.config | 6 - .../DifferencesGen.csproj | 65 ---- .../Program.cs | 256 ------------- .../Analyzer.cs | 357 ------------------ .../Differences-6.0.0.0.gz | Bin 7609 -> 0 bytes .../Differences-7.0.0.0.gz | Bin 7949 -> 0 bytes .../HowToGuard.cs | 32 -- ...oolkit.Uwp.PlatformSpecificAnalyzer.csproj | 36 -- .../NewMember.cs | 46 --- .../Platform.cs | 69 ---- .../PlatformKind.cs | 27 -- .../PlatformSpecificAnalyzerCS.cs | 230 ----------- .../PlatformSpecificAnalyzerVB.cs | 254 ------------- .../PlatformSpecificFixerCS.cs | 168 --------- .../PlatformSpecificFixerVB.cs | 168 --------- .../tools/install.ps1 | 58 --- .../tools/uninstall.ps1 | 65 ---- .../SamplePages/samples.json | 8 - Windows Community Toolkit.sln | 57 --- 19 files changed, 1902 deletions(-) delete mode 100644 Microsoft.Toolkit.Uwp.PlatformDifferencesGen/App.config delete mode 100644 Microsoft.Toolkit.Uwp.PlatformDifferencesGen/DifferencesGen.csproj delete mode 100644 Microsoft.Toolkit.Uwp.PlatformDifferencesGen/Program.cs delete mode 100644 Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/Analyzer.cs delete mode 100644 Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/Differences-6.0.0.0.gz delete mode 100644 Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/Differences-7.0.0.0.gz delete mode 100644 Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/HowToGuard.cs delete mode 100644 Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer.csproj delete mode 100644 Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/NewMember.cs delete mode 100644 Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/Platform.cs delete mode 100644 Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/PlatformKind.cs delete mode 100644 Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/PlatformSpecificAnalyzerCS.cs delete mode 100644 Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/PlatformSpecificAnalyzerVB.cs delete mode 100644 Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/PlatformSpecificFixerCS.cs delete mode 100644 Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/PlatformSpecificFixerVB.cs delete mode 100644 Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/tools/install.ps1 delete mode 100644 Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/tools/uninstall.ps1 diff --git a/Microsoft.Toolkit.Uwp.PlatformDifferencesGen/App.config b/Microsoft.Toolkit.Uwp.PlatformDifferencesGen/App.config deleted file mode 100644 index 731f6de6c29..00000000000 --- a/Microsoft.Toolkit.Uwp.PlatformDifferencesGen/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/Microsoft.Toolkit.Uwp.PlatformDifferencesGen/DifferencesGen.csproj b/Microsoft.Toolkit.Uwp.PlatformDifferencesGen/DifferencesGen.csproj deleted file mode 100644 index e2726cf8cc5..00000000000 --- a/Microsoft.Toolkit.Uwp.PlatformDifferencesGen/DifferencesGen.csproj +++ /dev/null @@ -1,65 +0,0 @@ - - - - - Debug - AnyCPU - {292D34E8-0F01-4FA8-951D-8232F75A88D5} - Exe - DifferencesGen - DifferencesGen - v4.6.1 - 512 - true - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - bin\Release\DifferencesGen.xml - 1591 - - - - - - - - - - - - - - - - - - - - - - - - 10.0.3 - - - - - - - \ No newline at end of file diff --git a/Microsoft.Toolkit.Uwp.PlatformDifferencesGen/Program.cs b/Microsoft.Toolkit.Uwp.PlatformDifferencesGen/Program.cs deleted file mode 100644 index 1cfaef00249..00000000000 --- a/Microsoft.Toolkit.Uwp.PlatformDifferencesGen/Program.cs +++ /dev/null @@ -1,256 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.IO; -using System.IO.Compression; -using System.Linq; -using System.Reflection; -using System.Runtime.InteropServices.WindowsRuntime; -using System.Text; - -namespace DifferencesGen -{ - public class Program - { - private static HashSet enumTypes = new HashSet(); - private static HashSet typeEvents = new HashSet(); - - public static void Main(string[] args) - { - string min = null; - string max = null; - - foreach (var arg in args) - { - if (arg.StartsWith("/min:")) - { - min = arg.Replace("/min:", string.Empty); - } - else if (arg.StartsWith("/max:")) - { - max = arg.Replace("/max:", string.Empty); - } - } - - Version.TryParse(min, out Version minVersion); - Version.TryParse(max, out Version maxVersion); - - if (minVersion == null || maxVersion == null) - { - Console.WriteLine("The differences generator needs to be run as follows:"); - Console.WriteLine("DifferencesGen /min:4.0.0.0 /max:5.0.0.0"); - - return; - } - - string folderPath = @"C:\Program Files (x86)\Windows Kits\10\References"; - - string universalApiFile = "Windows.Foundation.UniversalApiContract.winmd"; - - string universalApiDifferencesCompressedFile = "Differences-{0}.gz"; - - AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += (sender, eventArgs) => Assembly.ReflectionOnlyLoad(eventArgs.Name); - WindowsRuntimeMetadata.ReflectionOnlyNamespaceResolve += (sender, eventArgs) => - { - string path = - WindowsRuntimeMetadata.ResolveNamespace(eventArgs.NamespaceName, Enumerable.Empty()) - .FirstOrDefault(); - if (path == null) - { - return; - } - - eventArgs.ResolvedAssemblies.Add(Assembly.ReflectionOnlyLoadFrom(path)); - }; - - DirectoryInfo directoryInfo = new DirectoryInfo(folderPath); - - FileInfo[] files = directoryInfo.GetFiles(universalApiFile, SearchOption.AllDirectories); - - List> assemblyList = new List>(); - - if (files.Length > 0) - { - foreach (var file in files) - { - var assembly = Assembly.ReflectionOnlyLoadFrom(file.FullName); - - var nameParts = assembly.FullName.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries); - - var versionParts = nameParts[1].Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries); - - var version = Version.Parse(versionParts[1]); - - if (version >= minVersion && version <= maxVersion) - { - assemblyList.Add(new Tuple(version, assembly)); - } - } - } - - if (assemblyList.Count >= 2) - { - var orderedList = assemblyList.OrderBy(t => t.Item1).ToList(); - - for (int i = 1; i < orderedList.Count; i++) - { - var previousVersionAssembly = orderedList[i - 1].Item2; - var newerVersionAssembly = orderedList[i].Item2; - - var version = orderedList[i].Item1; - - var previousVersionTypes = ProcessAssembly(previousVersionAssembly); - var newerVersionTypes = ProcessAssembly(newerVersionAssembly); - - var addedTypes = new Dictionary>(); - - foreach (var type in newerVersionTypes) - { - if (!previousVersionTypes.ContainsKey(type.Key)) - { - addedTypes.Add(type.Key, null); - - if (enumTypes.Contains(type.Key)) - { - System.Diagnostics.Debug.WriteLine($"New enum {type.Key}"); - } - - continue; - } - - HashSet previousVersionTypeMembers = new HashSet(previousVersionTypes[type.Key]); - HashSet newerVersionTypeMembers = new HashSet(type.Value); - - newerVersionTypeMembers.ExceptWith(previousVersionTypeMembers); - - if (newerVersionTypeMembers.Count == 0) - { - continue; - } - - if (enumTypes.Contains(type.Key)) - { - System.Diagnostics.Debug.WriteLine($"Enum {type.Key} has new members: {string.Join(",", newerVersionTypeMembers)}"); - } - - foreach (var member in newerVersionTypeMembers) - { - if (typeEvents.Contains($"{type.Key}-{member}")) - { - System.Diagnostics.Debug.WriteLine($"Type {type.Key} has new event: {member}"); - } - } - - addedTypes.Add(type.Key, newerVersionTypeMembers.ToList()); - } - - StringBuilder stringBuilder = new StringBuilder(); - - using (var compressedFS = File.Create(Path.Combine(AssemblyDirectory, string.Format(universalApiDifferencesCompressedFile, version.ToString())))) - { - using (var compressionFS = new GZipStream(compressedFS, CompressionMode.Compress)) - { - using (var writer = new StreamWriter(compressionFS)) - { - foreach (var addedType in addedTypes) - { - stringBuilder.Clear(); - - stringBuilder.Append(addedType.Key); - - if (addedType.Value != null && addedType.Value.Count > 0) - { - stringBuilder.Append(':'); - stringBuilder.Append(string.Join(",", addedType.Value)); - } - - writer.WriteLine(stringBuilder.ToString()); - } - } - } - } - - stringBuilder.Length = 0; - } - } - } - - public static string AssemblyDirectory - { - get - { - string codeBase = Assembly.GetExecutingAssembly().CodeBase; - UriBuilder uri = new UriBuilder(codeBase); - string path = Uri.UnescapeDataString(uri.Path); - return Path.GetDirectoryName(path); - } - } - - private static Dictionary> ProcessAssembly(Assembly assembly) - { - var types = new Dictionary>(); - - foreach (var exportedType in assembly.ExportedTypes) - { - var members = new List(); - - if (exportedType.IsEnum) - { - if (!enumTypes.Contains(exportedType.FullName)) - { - enumTypes.Add(exportedType.FullName); - } - - foreach (var member in exportedType.GetFields()) - { - if (member.Name.Equals("value__")) - { - continue; - } - - members.Add(member.Name); - } - } - else - { - foreach (var methodInfo in exportedType.GetMethods()) - { - if (!methodInfo.IsPublic) - { - continue; - } - - if (methodInfo.Name.StartsWith("get_") || - methodInfo.Name.StartsWith("set_") || - methodInfo.Name.StartsWith("put_") || - methodInfo.Name.StartsWith("add_") || - methodInfo.Name.StartsWith("remove_")) - { - continue; - } - - members.Add($"{methodInfo.Name}#{methodInfo.GetParameters().Length}"); - } - - foreach (var propertyInfo in exportedType.GetProperties()) - { - members.Add(propertyInfo.Name); - } - - foreach (var eventInfo in exportedType.GetEvents()) - { - typeEvents.Add($"{exportedType.FullName}-{eventInfo.Name}"); - members.Add(eventInfo.Name); - } - } - - types.Add(exportedType.FullName, members); - } - - return types; - } - } -} diff --git a/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/Analyzer.cs b/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/Analyzer.cs deleted file mode 100644 index ebc19cd548b..00000000000 --- a/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/Analyzer.cs +++ /dev/null @@ -1,357 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.IO; -using System.IO.Compression; -using System.Linq; -using System.Reflection; -using Microsoft.CodeAnalysis; - -namespace Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer -{ - /// - /// This class offers loads platform differences for use by Code Analyzer and Code Fixer. - /// - public static class Analyzer - { - internal enum TypePresenceIndicator - { - New, - Changes, - NotFound, - } - - private static Dictionary>> _differencesDictionary = null; - - /// - /// Embedded differences between API contract version 4 and 5. - /// - public const string N1DifferencesRes = "Differences-5.0.0.0.gz"; - - /// - /// Embedded differences between API contract version 5 and 6. - /// - public const string N0DifferencesRes = "Differences-6.0.0.0.gz"; - - /// - /// Earliest supported SDK version. - /// - public const string N2SDKVersion = "15063"; - - /// - /// Intermediate SDK version. - /// - public const string N1SDKVersion = "16299"; - - /// - /// Latest SDK version. - /// - public const string N0SDKVersion = "17134"; - - /// - /// Platform related diagnostic descriptor - /// - public static readonly DiagnosticDescriptor PlatformRule = new DiagnosticDescriptor("UWP001", "Platform-specific", "Platform-specific code detected. Consider using ApiInformation.IsTypePresent to guard against failure", "Safety", DiagnosticSeverity.Warning, true); - - /// - /// Version related diagnostic descriptor - /// - public static readonly DiagnosticDescriptor VersionRule = new DiagnosticDescriptor("UWP002", "Version-specific", "Version-specific code detected. Consider using ApiInformation.IsTypePresent / ApiInformation.IsMethodPresent / ApiInformation.IsPropertyPresent to guard against failure", "Safety", DiagnosticSeverity.Warning, true); - - private static char[] typeMemberSeparator = { ':' }; - private static char[] memberSeparator = { ',' }; - - static Analyzer() - { - _differencesDictionary = new Dictionary>>(); - _differencesDictionary.Add(N0DifferencesRes, GetApiAdditions(N0DifferencesRes)); - _differencesDictionary.Add(N1DifferencesRes, GetApiAdditions(N1DifferencesRes)); - } - - /// - /// Gets the API differences from specified resource. - /// - /// name of embedded resource - /// Dictionary with Fully qualified name of type as key and list of new members as value - public static Dictionary> GetUniversalApiAdditions(string resourceName) - { - return _differencesDictionary[resourceName]; - } - - private static Dictionary> GetApiAdditions(string resourceName) - { - Dictionary> apiAdditionsDictionary = new Dictionary>(); - - Assembly assembly = typeof(Analyzer).GetTypeInfo().Assembly; - - var resource = assembly.GetManifestResourceStream("Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer." + resourceName); - - if (resource == null) - { - System.Diagnostics.Debug.WriteLine($"Resource {resourceName} not found."); - return new Dictionary>(); - } - - System.Diagnostics.Debug.WriteLine($"Resource {resourceName} found."); - Dictionary> differencesDictionary = new Dictionary>(); - - using (GZipStream decompressionStream = new GZipStream(resource, CompressionMode.Decompress)) - { - using (StreamReader reader = new StreamReader(decompressionStream)) - { - while (!reader.EndOfStream) - { - var typeDetails = reader.ReadLine(); - - var typeMemberParts = typeDetails.Split(typeMemberSeparator, StringSplitOptions.RemoveEmptyEntries); - - if (typeMemberParts.Length == 1) - { - differencesDictionary.Add(typeMemberParts[0], null); - - continue; - } - - var membersAddedToType = typeMemberParts[1].Split(memberSeparator, StringSplitOptions.RemoveEmptyEntries); - - differencesDictionary.Add(typeMemberParts[0], new List(membersAddedToType)); - } - } - } - - if (differencesDictionary == null) - { - return apiAdditionsDictionary; - } - - foreach (var kvp in differencesDictionary) - { - var list = new List(); - if (kvp.Value != null) - { - list.AddRange(kvp.Value.Select(v => new NewMember(v))); - } - - apiAdditionsDictionary.Add(kvp.Key, list); - } - - return apiAdditionsDictionary; - } - - /// - /// This function tells which version/platform the symbol is from. - /// - /// represents a compiler - /// instance of - public static Platform GetPlatformForSymbol(ISymbol symbol) - { - if (symbol == null) - { - return new Platform(PlatformKind.Unchecked); - } - - if (symbol.ContainingNamespace != null && symbol.ContainingNamespace.ToDisplayString().StartsWith("Windows.")) - { - var assembly = symbol.ContainingAssembly.Name; - var version = symbol.ContainingAssembly.Identity.Version.Major; - - // Any call to ApiInformation.* is allowed without warning - if (symbol.ContainingType?.Name == "ApiInformation") - { - return new Platform(PlatformKind.Uwp, Analyzer.N2SDKVersion); - } - - // Don't want to give warning when analyzing code in an PCL project. - // In those two targets, every Windows type is found in Windows.winmd, so that's how we'll suppress it: - if (assembly == "Windows") - { - return new Platform(PlatformKind.Unchecked); - } - - // Some WinRT types like Windows.UI.Color get projected to come from .NET assemblies, always present: - if (assembly.StartsWith("System.Runtime.")) - { - return new Platform(PlatformKind.Uwp, Analyzer.N2SDKVersion); - } - - // Some things are emphatically part of UWP.10240 - if (assembly == "Windows.Foundation.FoundationContract" || (assembly == "Windows.Foundation.UniversalApiContract" && version == 1)) - { - return new Platform(PlatformKind.Uwp, Analyzer.N2SDKVersion); - } - - if (assembly == "Windows.Foundation.UniversalApiContract") - { - var isType = symbol.Kind == SymbolKind.NamedType; - - var typeName = isType ? symbol.ToDisplayString() : symbol.ContainingType.ToDisplayString(); - - TypePresenceIndicator presentInN0ApiDiff = CheckCollectionForType(Analyzer.GetUniversalApiAdditions(Analyzer.N0DifferencesRes), typeName, symbol); - - if (presentInN0ApiDiff == TypePresenceIndicator.New) - { - // the entire type was found in Target Version - return new Platform(PlatformKind.Uwp, Analyzer.N0SDKVersion); - } - else if (presentInN0ApiDiff == TypePresenceIndicator.Changes) - { - // the entire type was found in Target Version with matching parameter lengths - return new Platform(PlatformKind.Uwp, Analyzer.N0SDKVersion, true); - } - else - { - TypePresenceIndicator presentInN1ApiDiff = CheckCollectionForType(Analyzer.GetUniversalApiAdditions(Analyzer.N1DifferencesRes), typeName, symbol); - - if (presentInN1ApiDiff == TypePresenceIndicator.New) - { - // the entire type was found in Target Version - return new Platform(PlatformKind.Uwp, Analyzer.N1SDKVersion); - } - else if (presentInN1ApiDiff == TypePresenceIndicator.Changes) - { - // the entire type was found in Target Version with matching parameter lengths - return new Platform(PlatformKind.Uwp, Analyzer.N1SDKVersion, true); - } - else - { - // the type was in Min version - return new Platform(PlatformKind.Uwp, Analyzer.N2SDKVersion); - } - } - } - - // All other Windows.* types come from platform-specific extensions - return new Platform(PlatformKind.ExtensionSDK); - } - else - { - return new Platform(PlatformKind.Unchecked); - } - } - - /// - /// returns instance of for - /// - /// instance of - /// instance of - public static HowToGuard GetGuardForSymbol(ISymbol target) - { - var plat = Analyzer.GetPlatformForSymbol(target); - - switch (plat.Kind) - { - case PlatformKind.ExtensionSDK: - return new HowToGuard() - { - TypeToCheck = target.Kind == SymbolKind.NamedType ? target.ToDisplayString() : target.ContainingType.ToDisplayString(), - KindOfCheck = "IsTypePresent" - }; - case PlatformKind.Uwp: - if (target.Kind == SymbolKind.NamedType) - { - return new HowToGuard() - { - TypeToCheck = target.ToDisplayString(), - KindOfCheck = "IsTypePresent" - }; - } - else - { - var g = new HowToGuard - { - TypeToCheck = target.ContainingType.ToDisplayString() - }; - - var d0 = Analyzer.GetUniversalApiAdditions(Analyzer.N0DifferencesRes); - var d1 = Analyzer.GetUniversalApiAdditions(Analyzer.N1DifferencesRes); - - if (!d0.TryGetValue(g.TypeToCheck, out List newMembers)) - { - d1.TryGetValue(g.TypeToCheck, out newMembers); - } - - if (newMembers == null) - { - throw new InvalidOperationException("oops! expected this UWP version API to be in the dictionary of new things"); - } - - g.MemberToCheck = target.Name; - - if (target.Kind == SymbolKind.Field) - { - // the only fields in WinRT are enum fields - g.KindOfCheck = "IsEnumNamedValuePresent"; - } - else if (target.Kind == SymbolKind.Event) - { - g.KindOfCheck = "IsEventPresent"; - } - else if (target.Kind == SymbolKind.Property) - { - // TODO: if SDK starts introducing additional accessors on properties, we'll have to change this - g.KindOfCheck = "IsPropertyPresent"; - } - else if (target.Kind == SymbolKind.Method) - { - g.KindOfCheck = "IsMethodPresent"; - - if (target.Kind == SymbolKind.Method && plat.ByParameterCount) - { - g.ParameterCountToCheck = (target as IMethodSymbol).Parameters.Length; - } - } - - return g; - } - - default: - throw new InvalidOperationException("oops! don't know why I was asked to check something that's fine"); - } - } - - private static TypePresenceIndicator CheckCollectionForType(Dictionary> collection, string typeName, ISymbol symbol) - { - if (!collection.TryGetValue(typeName, out var newMembers)) - { - return TypePresenceIndicator.NotFound; - } - - if (newMembers == null || newMembers.Count == 0) - { - return TypePresenceIndicator.New; - } - - if (symbol.Kind == SymbolKind.NamedType) - { - return TypePresenceIndicator.NotFound; - } - - var memberName = symbol.Name; - - foreach (var newMember in newMembers) - { - if (memberName == newMember.Name && !newMember.ParameterCount.HasValue) - { - return TypePresenceIndicator.New; - } - - // this member was new in collection - if (symbol.Kind != SymbolKind.Method) - { - // TODO: Continue For... Warning!!! not translated - } - - if (memberName == newMember.Name && ((IMethodSymbol)symbol).Parameters.Length == newMember.ParameterCount) - { - return TypePresenceIndicator.Changes; - } - } - - // this member existed in a different collection - return TypePresenceIndicator.NotFound; - } - } -} diff --git a/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/Differences-6.0.0.0.gz b/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/Differences-6.0.0.0.gz deleted file mode 100644 index 90a9ae8fef7274eb886055cefa294a378db06ee0..0000000000000000000000000000000000000000 GIT binary patch literal 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Toolkit.Uwp.PlatformSpecificAnalyzer/Differences-7.0.0.0.gz deleted file mode 100644 index 53e84c4e98e074cd625c0c3f4642a9f46d518259..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7949 zcmV+oAM)TIiwFP!000040PS5}bK@$~zTc|-6?5xKoik^zeCOEtaBV)kmM8Ppxx*5% z*~mf*QWBqE|8@iVvSeEln#^v7i@kC9HdBvJoONlex(WC^44o{`tKvJ!ab2w9wjtN;LTi`7grHkhco~obGhVX z$D&P<1pJ2OJ4?2YF&0+>PKMXiYE%`KrBG zRLW}#)PgSQe^M%wvk*1$_R8=Sy+I2qg1u6)$8TxJ{!(-^{uYIt1V}%aAdjcQw-X0?m4H5;YN4tS z(?Y0!f|rL2)XVXLMJv7{@?}lLd7-IUlJZyUSvWe_>4B7L2|{3 zOdfc`o=b%rP5CayE;%stja2q^%f^~1iA>5h7n3mjCaD+zI@9Tn0iO-MOp_UhDpVl) zKuGHq99_LbUlZU^zKaRlMDw5>@S}pk9wfyvbo=UWJ;Q&JCVU6nJ`nA*4{Z`l^^$GZK$ACQ3$|6>0(9S6ZId|FIxrmAj3?<~V1njQ zJ=C%_NDIMsM8GE|eZf@C+wm>A&Z!+WR6OEo%Qio>%}&y`R|iFky?D14R&3X4r20^3 zzQ1U9_Q#m&@vDpKS2??Af|rVC(iXuL5gXdFNSYS9dI=6y`|cIT_Ak*wg2&Y9G_nrM+XDZ2}UWpMhLn%P@AOm$C=tVbol(DKqXTcxT?cqxLeo_Z5$T`nbH20Aus%BfMM6gIj z%q49o&4RNid3^S$z~_rgB7B@=@zEg=<@svxjGkCPxpDDwckHalX-L?P235)9X$a-% z$*g%#K-?^3O5}DX$Xn;!3&x%~-?50AF1%ybCC;9C-;+%QpMmcsU?qZrlAv?_n?&?1 z&4Np?Tcf0N84AX(Im6)d3W_TZblW&`=E;1xW9TzLtF^(` zR8aI(3Xt=axaJqXAA8ZeP##Ux3>eLtgMC;tct2AI^voiEPTq*1E5SCK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&4ZI_)peEd{4wn8ed$eVTjN7G$8@> zDDXkQ;+c?>1U|ZT+H@_u;hf{cCA{-|=mTbqY$AY}`3=~XIad3a9v!vtC%VjBf1+v# zI&oI&F)_g`F88`FJ3Wuaf&GP3-kn+qn=AQQR0-)f`x0X^DFzzT}#smnkF361_ zuh4;7%TZ^JHr?=}`%w!4*s^0S#dP0Un;#PjbqesXraqc7-$B>Xhw+X@ln9%wm-LmA z(1J6!kt}4W+0Q=w9)|{0ho*MpE}Hz}T992y1&*FTi8cZ$&7?L^Y)OpggWw-$)zpEx z3PToK99I2_p~3Ii;Zny1FVk_jG~mL+{lBf^Fm`5O7t!jBHU=sJ0mfYM!*Vf3Z z%6Xt~`hDHWMhAL^(O-guUw#|qlxHL^sMs-yTQt$(8qaq-Dx?AS?|=J$;Bl4Kx@Z9a D)>T_G diff --git a/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/HowToGuard.cs b/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/HowToGuard.cs deleted file mode 100644 index 6827975ab9e..00000000000 --- a/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/HowToGuard.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer -{ - /// - /// The struct provides guard related info. - /// - public struct HowToGuard - { - /// - /// Type being checked - /// - public string TypeToCheck; - - /// - /// Member being checked - /// - public string MemberToCheck; - - /// - /// Whether parameter count will be used for the check - /// - public int? ParameterCountToCheck; - - /// - /// Type of check - /// - public string KindOfCheck; - } -} diff --git a/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer.csproj b/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer.csproj deleted file mode 100644 index f0661505dd3..00000000000 --- a/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer.csproj +++ /dev/null @@ -1,36 +0,0 @@ - - - - netstandard2.0 - Windows Community Toolkit UWP Platform Specific Analyzer - This standard library provides code analysis and code fixers (on CS and VB) to ensure that version / platform specific code is well guarded. - UWP Toolkit Windows Platform Specific Analyzer - - false - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/NewMember.cs b/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/NewMember.cs deleted file mode 100644 index 9596e4109be..00000000000 --- a/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/NewMember.cs +++ /dev/null @@ -1,46 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; - -namespace Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer -{ - /// - /// This class wraps a new data members - /// - public struct NewMember - { - private static char[] methodCountSeparator = { '#' }; - - /// - /// Member name - /// - public string Name; - - /// - /// Parameter count (if its a method) - /// - public int? ParameterCount; - - /// - /// Initializes a new instance of the struct. - /// - /// data containing name and optionally parameter count - public NewMember(string s) - { - string[] parts = s.Split(methodCountSeparator, StringSplitOptions.RemoveEmptyEntries); - - if (parts.Length == 2) - { - Name = parts[0]; - ParameterCount = int.Parse(parts[1]); - } - else - { - Name = s; - ParameterCount = null; - } - } - } -} diff --git a/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/Platform.cs b/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/Platform.cs deleted file mode 100644 index d6a3f876d2d..00000000000 --- a/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/Platform.cs +++ /dev/null @@ -1,69 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; - -namespace Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer -{ - /// - /// Simple struct to hold platform / version / param count info for given symbol - /// - public struct Platform - { - /// - /// Platform Kind - /// - public PlatformKind Kind; - - /// - /// For UWP, this is version 15063 or 16299etc. For User, the fully qualified name of the attribute in use - /// - public string Version; - - /// - /// For UWP only - /// - public bool ByParameterCount; - - /// - /// Initializes a new instance of the struct. - /// - /// - /// version - /// boolean - public Platform(PlatformKind kind, string version = null, bool byParameterCount = false) - { - Kind = kind; - Version = version; - ByParameterCount = byParameterCount; - - switch (kind) - { - case PlatformKind.Unchecked: - if (version != null) - { - throw new ArgumentException("No version expected"); - } - - break; - - case PlatformKind.Uwp: - break; - - case PlatformKind.ExtensionSDK: - if (version != null) - { - throw new ArgumentException("Don't specify versions for extension SDKs"); - } - - break; - } - - if (byParameterCount && kind != PlatformKind.Uwp) - { - throw new ArgumentException("Only UWP can be distinguished by parameter count"); - } - } - } -} diff --git a/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/PlatformKind.cs b/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/PlatformKind.cs deleted file mode 100644 index c38de8ed495..00000000000 --- a/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/PlatformKind.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer -{ - /// - /// Platform kind enum - /// - public enum PlatformKind - { - /// - /// .NET and Pre-UWP WinRT - /// - Unchecked, - - /// - /// Core UWP platform - /// - Uwp, - - /// - /// Desktop, Mobile, IOT, Xbox extension SDK - /// - ExtensionSDK - } -} diff --git a/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/PlatformSpecificAnalyzerCS.cs b/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/PlatformSpecificAnalyzerCS.cs deleted file mode 100644 index ea7b344a626..00000000000 --- a/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/PlatformSpecificAnalyzerCS.cs +++ /dev/null @@ -1,230 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Collections.Immutable; -using System.Linq; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp; -using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.CodeAnalysis.Diagnostics; - -namespace Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer -{ - /// - /// This class is a Roslyn code analyzer that checks for types / members that should be guarded against. - /// - [DiagnosticAnalyzer(LanguageNames.CSharp)] - public class PlatformSpecificAnalyzerCS : DiagnosticAnalyzer - { - /// - /// Gets supported diagnostics - /// - public override ImmutableArray SupportedDiagnostics - { - get { return ImmutableArray.Create(Analyzer.PlatformRule, Analyzer.VersionRule); } - } - - /// - /// Gets instance of symbol from syntax node - /// - /// instance of - /// - /// - public static ISymbol GetTargetOfNode(SyntaxNode node, SemanticModel semanticModel) - { - var parentKind = node.Parent.Kind(); - - if (parentKind == SyntaxKind.InvocationExpression && node == ((InvocationExpressionSyntax)node.Parent).Expression) - { - // (...) - // points to the method after overload resolution - return semanticModel.GetSymbolInfo((InvocationExpressionSyntax)node.Parent).Symbol; - } - else if (parentKind == SyntaxKind.ObjectCreationExpression && node == ((ObjectCreationExpressionSyntax)node.Parent).Type) - { - // New - var objectCreationExpression = (ObjectCreationExpressionSyntax)node.Parent; - var target = semanticModel.GetSymbolInfo(objectCreationExpression).Symbol; - - // points to the constructor after overload resolution - return target; - } - else - { - // f(...) - // x = ... - // Action x = -- note that following code does pick the right overload - // += delegate -- the following code does recognize events - // nameof() -- I think it's nicer to report on this, even if not technically needed - // Field access? I'll disallow it for enum values, and allow it for everything else - var target = semanticModel.GetSymbolInfo(node).Symbol; - - if (target == null) - { - return null; - } - - var targetKind = target.Kind; - - if (targetKind == SymbolKind.Method || targetKind == SymbolKind.Event || targetKind == SymbolKind.Property || targetKind == SymbolKind.NamedType) - { - return target; - } - - if (targetKind == SymbolKind.Field && target.ContainingType.TypeKind == TypeKind.Enum) - { - return target; - } - - return null; - } - } - - /// - /// Initializes the analyzer, registering for code analysis. - /// - /// - public override void Initialize(AnalysisContext context) - { - ConcurrentDictionary reportsDictionary = new ConcurrentDictionary(); - - context.RegisterSyntaxNodeAction((c) => AnalyzeExpression(c, reportsDictionary), SyntaxKind.VariableDeclaration, SyntaxKind.FieldDeclaration, SyntaxKind.IdentifierName, SyntaxKind.SimpleMemberAccessExpression, SyntaxKind.QualifiedName); - } - - private static IEnumerable GetGuards(SyntaxNode node, SemanticModel semanticModel) - { - foreach (var condition in GetConditions(node)) - { - // First check for invocations of ApiInformation.IsTypePresent - foreach (var invocation in condition.DescendantNodesAndSelf(i => i is InvocationExpressionSyntax)) - { - var targetMethod = semanticModel.GetSymbolInfo(invocation).Symbol; - - if (targetMethod?.ContainingType?.Name == "ApiInformation") - { - yield return targetMethod; - } - } - - // Next check for any property/field access - var accesses1 = condition.DescendantNodesAndSelf(d => d is MemberAccessExpressionSyntax).Select(n => semanticModel.GetSymbolInfo(n).Symbol); - var accesses2 = condition.DescendantNodesAndSelf(d => d is IdentifierNameSyntax).Select(n => semanticModel.GetSymbolInfo(n).Symbol); - - foreach (var symbol in accesses1.Concat(accesses2)) - { - var symbolKind = symbol.Kind; - - if (symbolKind == SymbolKind.Field || symbolKind == SymbolKind.Property) - { - yield return symbol; - } - } - } - } - - private static IEnumerable GetConditions(SyntaxNode node) - { - var check = node.FirstAncestorOrSelf(); - - while (check != null) - { - yield return check.Condition; - check = check.Parent.FirstAncestorOrSelf(); - } - } - - private void AnalyzeExpression(SyntaxNodeAnalysisContext context, ConcurrentDictionary reports) - { - var parentKind = context.Node.Parent.Kind(); - - // will be handled at higher level - if (parentKind == SyntaxKind.SimpleMemberAccessExpression || parentKind == SyntaxKind.QualifiedName) - { - return; - } - - var target = GetTargetOfNode(context.Node, context.SemanticModel); - - if (target == null) - { - return; - } - - var platform = Analyzer.GetPlatformForSymbol(target); - - // Some quick escapes - if (platform.Kind == PlatformKind.Unchecked) - { - return; - } - - if (platform.Kind == PlatformKind.Uwp && platform.Version == Analyzer.N2SDKVersion) - { - return; - } - - // Is this expression inside a method/constructor/property that claims to be specific? - var containingBlock = context.Node.FirstAncestorOrSelf(); - - // for constructors and methods - MemberDeclarationSyntax containingMember = containingBlock?.FirstAncestorOrSelf(); - - if (containingBlock == null || containingBlock?.Parent is AccessorDeclarationSyntax) - { - containingMember = context.Node.FirstAncestorOrSelf(); - } - - // Is this invocation properly guarded? See readme.md for explanations. - if (IsProperlyGuarded(context.Node, context.SemanticModel)) - { - return; - } - - if (containingBlock != null) - { - foreach (var ret in containingBlock.DescendantNodes().OfType()) - { - if (IsProperlyGuarded(ret, context.SemanticModel)) - { - return; - } - } - } - - // We'll report only a single diagnostic per line, the first. - var loc = context.Node.GetLocation(); - if (!loc.IsInSource) - { - return; - } - - var line = loc.GetLineSpan().StartLinePosition.Line; - if (reports.TryGetValue(line, out var diagnostic) && diagnostic.Location.SourceSpan.Start <= loc.SourceSpan.Start) - { - return; - } - - diagnostic = Diagnostic.Create(platform.Kind == PlatformKind.Uwp ? Analyzer.VersionRule : Analyzer.PlatformRule, loc); - - reports[line] = diagnostic; - - context.ReportDiagnostic(diagnostic); - } - - private bool IsProperlyGuarded(SyntaxNode node, SemanticModel semanticModel) - { - foreach (var symbol in GetGuards(node, semanticModel)) - { - if (symbol.ContainingType?.Name == "ApiInformation") - { - return true; - } - } - - return false; - } - } -} diff --git a/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/PlatformSpecificAnalyzerVB.cs b/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/PlatformSpecificAnalyzerVB.cs deleted file mode 100644 index ec67c731a74..00000000000 --- a/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/PlatformSpecificAnalyzerVB.cs +++ /dev/null @@ -1,254 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Collections.Immutable; -using System.Linq; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.Diagnostics; -using Microsoft.CodeAnalysis.VisualBasic; -using Microsoft.CodeAnalysis.VisualBasic.Syntax; - -namespace Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer -{ - /// - /// This class is a Roslyn code analyzer that checks for types / members that should be guarded against. - /// - [DiagnosticAnalyzer(LanguageNames.VisualBasic)] - public class PlatformSpecificAnalyzerVB : DiagnosticAnalyzer - { - /// - /// Gets supported diagnostics - /// - public override ImmutableArray SupportedDiagnostics - { - get { return ImmutableArray.Create(Analyzer.PlatformRule, Analyzer.VersionRule); } - } - - /// - /// Gets instance of symbol from syntax node - /// - /// instance of - /// - /// - public static ISymbol GetTargetOfNode(SyntaxNode node, SemanticModel semanticModel) - { - var parentKind = node.Parent.Kind(); - - if (parentKind == SyntaxKind.InvocationExpression && node == ((InvocationExpressionSyntax)node.Parent).Expression) - { - // (...) - // points to the method after overload resolution - return semanticModel.GetSymbolInfo((InvocationExpressionSyntax)node.Parent).Symbol; - } - else if (parentKind == SyntaxKind.AddressOfExpression) - { - // AddressOf - return semanticModel.GetSymbolInfo(node).Symbol; // points to the method after overload resolution - } - else if (parentKind == SyntaxKind.ObjectCreationExpression && node == ((ObjectCreationExpressionSyntax)node.Parent).Type) - { - // New - var objectCreationExpression = (ObjectCreationExpressionSyntax)node.Parent; - var target = semanticModel.GetSymbolInfo(objectCreationExpression).Symbol; - - // points to the constructor after overload resolution - return target; - } - else if (parentKind == SyntaxKind.AddHandlerStatement && node == ((AddRemoveHandlerStatementSyntax)node.Parent).EventExpression) - { - // AddHandler , delegate - return semanticModel.GetSymbolInfo(node).Symbol; // points to the event - } - else if (parentKind == SyntaxKind.NameOfExpression) - { - // NameOf() - return null; - } - else - { - // f(Of )(...) -- no warning - // Dim x As = ... -- no warning - // property access -- warning - // field access -- only warning on enum fields - // method access without arguments -- warning - var target = semanticModel.GetSymbolInfo(node).Symbol; - - if (target == null) - { - return null; - } - - var targetKind = target.Kind; - - if (targetKind == SymbolKind.Method || targetKind == SymbolKind.Property || targetKind == SymbolKind.NamedType) - { - return target; - } - - if (targetKind == SymbolKind.Field && target.ContainingType.TypeKind == TypeKind.Enum) - { - return target; - } - - return null; - } - } - - /// - /// Initializes the analyzer, registering for code analysis. - /// - /// - public override void Initialize(AnalysisContext context) - { - ConcurrentDictionary reportsDictionary = new ConcurrentDictionary(); - - context.RegisterSyntaxNodeAction((c) => AnalyzeExpression(c, reportsDictionary), SyntaxKind.LocalDeclarationStatement, SyntaxKind.IdentifierName, SyntaxKind.SimpleMemberAccessExpression, SyntaxKind.QualifiedName); - } - - private static IEnumerable GetGuards(SyntaxNode node, SemanticModel semanticModel) - { - foreach (var condition in GetConditions(node)) - { - // First check for invocations of ApiInformation.IsTypePresent - foreach (var invocation in condition.DescendantNodesAndSelf(i => i is InvocationExpressionSyntax)) - { - var targetMethod = semanticModel.GetSymbolInfo(invocation).Symbol; - - if (targetMethod?.ContainingType?.Name == "ApiInformation") - { - yield return targetMethod; - } - } - - // Next check for any property/field access - var accesses1 = condition.DescendantNodesAndSelf(d => d is MemberAccessExpressionSyntax).Select(n => semanticModel.GetSymbolInfo(n).Symbol); - var accesses2 = condition.DescendantNodesAndSelf(d => d is IdentifierNameSyntax).Select(n => semanticModel.GetSymbolInfo(n).Symbol); - - foreach (var symbol in accesses1.Concat(accesses2)) - { - if (symbol == null) - { - continue; - } - - var symbolKind = symbol.Kind; - - if (symbolKind == SymbolKind.Field || symbolKind == SymbolKind.Property) - { - yield return symbol; - } - } - } - } - - private static IEnumerable GetConditions(SyntaxNode node) - { - var check1 = node.FirstAncestorOrSelf(); - - while (check1 != null) - { - yield return check1.IfStatement.Condition; - check1 = check1.Parent.FirstAncestorOrSelf(); - } - - var check2 = node.FirstAncestorOrSelf(); - - while (check2 != null) - { - yield return check2.Condition; - check2 = check2.Parent.FirstAncestorOrSelf(); - } - } - - private void AnalyzeExpression(SyntaxNodeAnalysisContext context, ConcurrentDictionary reports) - { - var parentKind = context.Node.Parent.Kind(); - - // will be handled at higher level - if (parentKind == SyntaxKind.SimpleMemberAccessExpression || parentKind == SyntaxKind.QualifiedName) - { - return; - } - - var target = GetTargetOfNode(context.Node, context.SemanticModel); - - if (target == null) - { - return; - } - - var platform = Analyzer.GetPlatformForSymbol(target); - - // Some quick escapes - if (platform.Kind == PlatformKind.Unchecked) - { - return; - } - - if (platform.Kind == PlatformKind.Uwp && platform.Version == Analyzer.N2SDKVersion) - { - return; - } - - // Is this expression inside a method/constructor/property that claims to be specific? - DeclarationStatementSyntax containingMember = context.Node.FirstAncestorOrSelf(); - - if (containingMember is AccessorBlockSyntax) - { - containingMember = containingMember.FirstAncestorOrSelf(); - } - - // Is this invocation properly guarded? See readme.md for explanations. - if (IsProperlyGuarded(context.Node, context.SemanticModel)) - { - return; - } - - if (containingMember != null) - { - foreach (var ret in containingMember.DescendantNodes().OfType()) - { - if (IsProperlyGuarded(ret, context.SemanticModel)) - { - return; - } - } - } - - // We'll report only a single diagnostic per line, the first. - var loc = context.Node.GetLocation(); - if (!loc.IsInSource) - { - return; - } - - var line = loc.GetLineSpan().StartLinePosition.Line; - if (reports.TryGetValue(line, out var diagnostic) && diagnostic.Location.SourceSpan.Start <= loc.SourceSpan.Start) - { - return; - } - - diagnostic = Diagnostic.Create(platform.Kind == PlatformKind.Uwp ? Analyzer.VersionRule : Analyzer.PlatformRule, loc); - - reports[line] = diagnostic; - - context.ReportDiagnostic(diagnostic); - } - - private bool IsProperlyGuarded(SyntaxNode node, SemanticModel semanticModel) - { - foreach (var symbol in GetGuards(node, semanticModel)) - { - if (symbol.ContainingType?.Name == "ApiInformation") - { - return true; - } - } - - return false; - } - } -} diff --git a/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/PlatformSpecificFixerCS.cs b/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/PlatformSpecificFixerCS.cs deleted file mode 100644 index 439d1958f19..00000000000 --- a/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/PlatformSpecificFixerCS.cs +++ /dev/null @@ -1,168 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using System.Collections.Immutable; -using System.Composition; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CodeActions; -using Microsoft.CodeAnalysis.CodeFixes; -using Microsoft.CodeAnalysis.CSharp; -using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.CodeAnalysis.Formatting; -using Microsoft.CodeAnalysis.Simplification; -using Microsoft.CodeAnalysis.Text; - -namespace Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer -{ - /// - /// This class provides guard suggestion and can make the suggested changes. - /// - [ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(PlatformSpecificFixerCS))] - [Shared] - public class PlatformSpecificFixerCS : CodeFixProvider - { - /// - /// Gets the list of Diagnostics that can be fixed. - /// - public sealed override ImmutableArray FixableDiagnosticIds - { - get { return ImmutableArray.Create(Analyzer.PlatformRule.Id, Analyzer.VersionRule.Id); } - } - - /// - /// Gets the Fix All provider - /// - /// - public sealed override FixAllProvider GetFixAllProvider() - { - return WellKnownFixAllProviders.BatchFixer; - } - - /// - /// Registers for code fix. - /// - /// - /// awaitable - public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context) - { - try - { - var root = await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false); - var semanticModel = await context.Document.GetSemanticModelAsync(context.CancellationToken).ConfigureAwait(false); - - // Which node are we interested in? -- if the squiggle is over A.B().C, - // then we need the largest IdentifierName/SimpleMemberAccess/QualifiedName - // that encompasses "C" itself - var diagnostic = context.Diagnostics.First(); - var span = new TextSpan(diagnostic.Location.SourceSpan.End - 1, 1); - var node = root.FindToken(span.Start).Parent; - - SyntaxKind nodeKind = node.Kind(); - - while (nodeKind != SyntaxKind.IdentifierName && nodeKind != SyntaxKind.SimpleMemberAccessExpression && nodeKind != SyntaxKind.QualifiedName) - { - node = node.Parent; - - if (node == null) - { - return; - } - - nodeKind = node.Kind(); - } - - while (true) - { - if (node.Parent?.Kind() == SyntaxKind.SimpleMemberAccessExpression) - { - node = node.Parent; - continue; - } - - if (node.Parent?.Kind() == SyntaxKind.QualifiedName) - { - node = node.Parent; - continue; - } - - break; - } - - var target = PlatformSpecificAnalyzerCS.GetTargetOfNode(node, semanticModel); - var g = Analyzer.GetGuardForSymbol(target); - - // Introduce a guard? (only if it is a method/accessor/constructor, i.e. somewhere that allows code) - var containingBlock = node.FirstAncestorOrSelf(); - if (containingBlock != null) - { - var act1 = CodeAction.Create($"Add 'If ApiInformation.{g.KindOfCheck}'", (c) => IntroduceGuardAsync(context.Document, node, g, c), "PlatformSpecificGuard"); - context.RegisterCodeFix(act1, diagnostic); - } - } - catch - { - } - } - - private async Task IntroduceGuardAsync(Document document, SyntaxNode node, HowToGuard g, CancellationToken cancellationToken) - { - // + if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent(targetContainingType)) - // { - // old-statement - // + } - try - { - var oldStatement = node.FirstAncestorOrSelf(); - var oldLeadingTrivia = oldStatement.GetLeadingTrivia(); - - var conditionReceiver = SyntaxFactory.ParseName($"Windows.Foundation.Metadata.ApiInformation.{g.KindOfCheck}").WithAdditionalAnnotations(Simplifier.Annotation); - ArgumentListSyntax conditionArgument = null; - - if (g.MemberToCheck == null) - { - var conditionString1 = SyntaxFactory.LiteralExpression(SyntaxKind.StringLiteralExpression, SyntaxFactory.Literal(g.TypeToCheck)); - conditionArgument = SyntaxFactory.ArgumentList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Argument(conditionString1))); - } - else - { - var conditionString1 = SyntaxFactory.LiteralExpression(SyntaxKind.StringLiteralExpression, SyntaxFactory.Literal(g.TypeToCheck)); - var conditionString2 = SyntaxFactory.LiteralExpression(SyntaxKind.StringLiteralExpression, SyntaxFactory.Literal(g.MemberToCheck)); - var conditionInt3 = SyntaxFactory.LiteralExpression(SyntaxKind.NumericLiteralExpression, SyntaxFactory.Literal(g.ParameterCountToCheck ?? 0)); - - IEnumerable conditions = null; - - if (g.ParameterCountToCheck.HasValue) - { - conditions = new ArgumentSyntax[] { SyntaxFactory.Argument(conditionString1), SyntaxFactory.Argument(conditionString2), SyntaxFactory.Argument(conditionInt3) }; - } - else - { - conditions = new ArgumentSyntax[] { SyntaxFactory.Argument(conditionString1), SyntaxFactory.Argument(conditionString2) }; - } - - conditionArgument = SyntaxFactory.ArgumentList(SyntaxFactory.SeparatedList(conditions)); - } - - var condition = SyntaxFactory.InvocationExpression(conditionReceiver, conditionArgument); - - var thenStatements = SyntaxFactory.Block(oldStatement.WithoutLeadingTrivia()); - var ifStatement = SyntaxFactory.IfStatement(condition, thenStatements).WithLeadingTrivia(oldLeadingTrivia).WithAdditionalAnnotations(Formatter.Annotation); - - var oldRoot = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); - var newRoot = oldRoot.ReplaceNode(oldStatement, ifStatement); - - return document.WithSyntaxRoot(newRoot); - } - catch - { - } - - return document; - } - } -} diff --git a/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/PlatformSpecificFixerVB.cs b/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/PlatformSpecificFixerVB.cs deleted file mode 100644 index e7f91129fd3..00000000000 --- a/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/PlatformSpecificFixerVB.cs +++ /dev/null @@ -1,168 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using System.Collections.Immutable; -using System.Composition; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CodeActions; -using Microsoft.CodeAnalysis.CodeFixes; -using Microsoft.CodeAnalysis.Formatting; -using Microsoft.CodeAnalysis.Simplification; -using Microsoft.CodeAnalysis.Text; -using Microsoft.CodeAnalysis.VisualBasic; -using Microsoft.CodeAnalysis.VisualBasic.Syntax; - -namespace Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer -{ - /// - /// This class provides guard suggestion and can make the suggested changes. - /// - [ExportCodeFixProvider(LanguageNames.VisualBasic, Name = nameof(PlatformSpecificFixerCS))] - [Shared] - public class PlatformSpecificFixerVB : CodeFixProvider - { - /// - /// Gets the list of Diagnostics that can be fixed. - /// - public sealed override ImmutableArray FixableDiagnosticIds - { - get { return ImmutableArray.Create(Analyzer.PlatformRule.Id, Analyzer.VersionRule.Id); } - } - - /// - /// Gets the Fix All provider - /// - /// - public sealed override FixAllProvider GetFixAllProvider() - { - return WellKnownFixAllProviders.BatchFixer; - } - - /// - /// Registers for code fix. - /// - /// - /// awaitable - public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context) - { - try - { - var root = await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false); - var semanticModel = await context.Document.GetSemanticModelAsync(context.CancellationToken).ConfigureAwait(false); - - // Which node are we interested in? -- if the squiggle is over A.B().C, - // then we need the largest IdentifierName/SimpleMemberAccess/QualifiedName - // that encompasses "C" itself - var diagnostic = context.Diagnostics.First(); - var span = new TextSpan(diagnostic.Location.SourceSpan.End - 1, 1); - var node = root.FindToken(span.Start).Parent; - - SyntaxKind nodeKind = node.Kind(); - - while (nodeKind != SyntaxKind.IdentifierName && nodeKind != SyntaxKind.SimpleMemberAccessExpression && nodeKind != SyntaxKind.QualifiedName) - { - node = node.Parent; - - if (node == null) - { - return; - } - - nodeKind = node.Kind(); - } - - while (true) - { - if (node.Parent?.Kind() == SyntaxKind.SimpleMemberAccessExpression) - { - node = node.Parent; - continue; - } - - if (node.Parent?.Kind() == SyntaxKind.QualifiedName) - { - node = node.Parent; - continue; - } - - break; - } - - var target = PlatformSpecificAnalyzerVB.GetTargetOfNode(node, semanticModel); - var g = Analyzer.GetGuardForSymbol(target); - - // Introduce a guard? (only if it is a method/accessor/constructor, i.e. somewhere that allows code) - var containingBlock = node.FirstAncestorOrSelf(); - if (containingBlock != null) - { - var act1 = CodeAction.Create($"Add 'If ApiInformation.{g.KindOfCheck}'", (c) => IntroduceGuardAsync(context.Document, node, g, c), "PlatformSpecificGuard"); - context.RegisterCodeFix(act1, diagnostic); - } - } - catch - { - } - } - - private async Task IntroduceGuardAsync(Document document, SyntaxNode node, HowToGuard g, CancellationToken cancellationToken) - { - // + If Windows.Foundation.Metadata.ApiInformation.IsTypePresent(targetContainingType) Then - // old-statement - // + End If - try - { - var oldStatement = node.FirstAncestorOrSelf(); - var oldLeadingTrivia = oldStatement.GetLeadingTrivia(); - - var conditionReceiver = SyntaxFactory.ParseName($"Windows.Foundation.Metadata.ApiInformation.{g.KindOfCheck}").WithAdditionalAnnotations(Simplifier.Annotation); - ArgumentListSyntax conditionArgument = null; - - if (g.MemberToCheck == null) - { - var conditionString1 = SyntaxFactory.StringLiteralExpression(SyntaxFactory.StringLiteralToken($"\"{g.TypeToCheck}\"", g.TypeToCheck)); - conditionArgument = SyntaxFactory.ArgumentList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.SimpleArgument(conditionString1))); - } - else - { - var conditionString1 = SyntaxFactory.StringLiteralExpression(SyntaxFactory.StringLiteralToken($"\"{g.TypeToCheck}\"", g.TypeToCheck)); - var conditionString2 = SyntaxFactory.StringLiteralExpression(SyntaxFactory.StringLiteralToken($"\"{g.MemberToCheck}\"", g.MemberToCheck)); - var conditionInt3 = SyntaxFactory.LiteralExpression(SyntaxKind.NumericLiteralExpression, SyntaxFactory.Literal(g.ParameterCountToCheck ?? 0)); - - IEnumerable conditions = null; - - if (g.ParameterCountToCheck.HasValue) - { - conditions = new ArgumentSyntax[] { SyntaxFactory.SimpleArgument(conditionString1), SyntaxFactory.SimpleArgument(conditionString2), SyntaxFactory.SimpleArgument(conditionInt3) }; - } - else - { - conditions = new ArgumentSyntax[] { SyntaxFactory.SimpleArgument(conditionString1), SyntaxFactory.SimpleArgument(conditionString2) }; - } - - conditionArgument = SyntaxFactory.ArgumentList(SyntaxFactory.SeparatedList(conditions)); - } - - var condition = SyntaxFactory.InvocationExpression(conditionReceiver, conditionArgument); - - var ifStatement = SyntaxFactory.IfStatement(condition); - var thenStatements = SyntaxFactory.SingletonList(oldStatement.WithoutLeadingTrivia()); - var ifBlock = SyntaxFactory.MultiLineIfBlock(ifStatement).WithStatements(thenStatements).WithLeadingTrivia(oldLeadingTrivia).WithAdditionalAnnotations(Formatter.Annotation); - - var oldRoot = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); - var newRoot = oldRoot.ReplaceNode(oldStatement, ifBlock); - - return document.WithSyntaxRoot(newRoot); - } - catch - { - } - - return document; - } - } -} diff --git a/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/tools/install.ps1 b/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/tools/install.ps1 deleted file mode 100644 index c1c3d88223e..00000000000 --- a/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/tools/install.ps1 +++ /dev/null @@ -1,58 +0,0 @@ -param($installPath, $toolsPath, $package, $project) - -if($project.Object.SupportsPackageDependencyResolution) -{ - if($project.Object.SupportsPackageDependencyResolution()) - { - # Do not install analyzers via install.ps1, instead let the project system handle it. - return - } -} - -$analyzersPaths = Join-Path (Join-Path (Split-Path -Path $toolsPath -Parent) "analyzers") * -Resolve - -foreach($analyzersPath in $analyzersPaths) -{ - if (Test-Path $analyzersPath) - { - # Install the language agnostic analyzers. - foreach ($analyzerFilePath in Get-ChildItem -Path "$analyzersPath\*.dll" -Exclude *.resources.dll) - { - if($project.Object.AnalyzerReferences) - { - $project.Object.AnalyzerReferences.Add($analyzerFilePath.FullName) - } - } - } -} - -# $project.Type gives the language name like (C# or VB.NET) -$languageFolder = "" -if($project.Type -eq "C#") -{ - $languageFolder = "cs" -} -if($project.Type -eq "VB.NET") -{ - $languageFolder = "vb" -} -if($languageFolder -eq "") -{ - return -} - -foreach($analyzersPath in $analyzersPaths) -{ - # Install language specific analyzers. - $languageAnalyzersPath = join-path $analyzersPath $languageFolder - if (Test-Path $languageAnalyzersPath) - { - foreach ($analyzerFilePath in Get-ChildItem -Path "$languageAnalyzersPath\*.dll" -Exclude *.resources.dll) - { - if($project.Object.AnalyzerReferences) - { - $project.Object.AnalyzerReferences.Add($analyzerFilePath.FullName) - } - } - } -} \ No newline at end of file diff --git a/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/tools/uninstall.ps1 b/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/tools/uninstall.ps1 deleted file mode 100644 index 65a86237039..00000000000 --- a/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/tools/uninstall.ps1 +++ /dev/null @@ -1,65 +0,0 @@ -param($installPath, $toolsPath, $package, $project) - -if($project.Object.SupportsPackageDependencyResolution) -{ - if($project.Object.SupportsPackageDependencyResolution()) - { - # Do not uninstall analyzers via uninstall.ps1, instead let the project system handle it. - return - } -} - -$analyzersPaths = Join-Path (Join-Path (Split-Path -Path $toolsPath -Parent) "analyzers") * -Resolve - -foreach($analyzersPath in $analyzersPaths) -{ - # Uninstall the language agnostic analyzers. - if (Test-Path $analyzersPath) - { - foreach ($analyzerFilePath in Get-ChildItem -Path "$analyzersPath\*.dll" -Exclude *.resources.dll) - { - if($project.Object.AnalyzerReferences) - { - $project.Object.AnalyzerReferences.Remove($analyzerFilePath.FullName) - } - } - } -} - -# $project.Type gives the language name like (C# or VB.NET) -$languageFolder = "" -if($project.Type -eq "C#") -{ - $languageFolder = "cs" -} -if($project.Type -eq "VB.NET") -{ - $languageFolder = "vb" -} -if($languageFolder -eq "") -{ - return -} - -foreach($analyzersPath in $analyzersPaths) -{ - # Uninstall language specific analyzers. - $languageAnalyzersPath = join-path $analyzersPath $languageFolder - if (Test-Path $languageAnalyzersPath) - { - foreach ($analyzerFilePath in Get-ChildItem -Path "$languageAnalyzersPath\*.dll" -Exclude *.resources.dll) - { - if($project.Object.AnalyzerReferences) - { - try - { - $project.Object.AnalyzerReferences.Remove($analyzerFilePath.FullName) - } - catch - { - - } - } - } - } -} \ No newline at end of file diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/samples.json b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/samples.json index 9e8e27cba22..7b4d6b3a1c6 100644 --- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/samples.json +++ b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/samples.json @@ -897,14 +897,6 @@ "Icon": "/Assets/Helpers.png", "DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/high-performance/Introduction.md" }, - { - "Name": "PlatformSpecificAnalyzer", - "Subcategory": "Developer", - "About": "Platform Specific Analyzer is a Roslyn analyzer that analyzes and suggests code fixes to ensure that any version / platform specific API are guarded by correct runtime checks", - "CodeUrl": "https://github.com/windows-toolkit/WindowsCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer", - "Icon": "/Assets/Helpers.png", - "DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/platform-specific/PlatformSpecificAnalyzer.md" - }, { "Name": "CompareStateTrigger", "Type": "CompareStateTriggerPage", diff --git a/Windows Community Toolkit.sln b/Windows Community Toolkit.sln index b9f6ee4728f..bde15545a69 100644 --- a/Windows Community Toolkit.sln +++ b/Windows Community Toolkit.sln @@ -76,12 +76,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Toolkit.Uwp.UI.Co EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Toolkit.Parsers", "Microsoft.Toolkit.Parsers\Microsoft.Toolkit.Parsers.csproj", "{42CA4935-54BE-42EA-AC19-992378C08DE6}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PlatformSpecific", "PlatformSpecific", "{096ECFD7-7035-4487-9C87-81DCE9389620}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DifferencesGen", "Microsoft.Toolkit.Uwp.PlatformDifferencesGen\DifferencesGen.csproj", "{292D34E8-0F01-4FA8-951D-8232F75A88D5}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer", "Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer\Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer.csproj", "{262BB7CE-EF42-4BF7-B90C-107E6CBB57FF}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Microsoft.Toolkit.Uwp.Input.GazeInteraction", "Microsoft.Toolkit.UWP.Input.GazeInteraction\Microsoft.Toolkit.Uwp.Input.GazeInteraction.vcxproj", "{A5E98964-45B1-442D-A07A-298A3221D81E}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GazeInputTest", "GazeInputTest\GazeInputTest.csproj", "{A122EA02-4DE7-413D-BFBF-AF7DFC668DD6}" @@ -680,55 +674,6 @@ Global {42CA4935-54BE-42EA-AC19-992378C08DE6}.Release|x64.Build.0 = Release|Any CPU {42CA4935-54BE-42EA-AC19-992378C08DE6}.Release|x86.ActiveCfg = Release|Any CPU {42CA4935-54BE-42EA-AC19-992378C08DE6}.Release|x86.Build.0 = Release|Any CPU - {292D34E8-0F01-4FA8-951D-8232F75A88D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {292D34E8-0F01-4FA8-951D-8232F75A88D5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {292D34E8-0F01-4FA8-951D-8232F75A88D5}.Debug|ARM.ActiveCfg = Debug|Any CPU - {292D34E8-0F01-4FA8-951D-8232F75A88D5}.Debug|ARM.Build.0 = Debug|Any CPU - {292D34E8-0F01-4FA8-951D-8232F75A88D5}.Debug|ARM64.ActiveCfg = Debug|Any CPU - {292D34E8-0F01-4FA8-951D-8232F75A88D5}.Debug|ARM64.Build.0 = Debug|Any CPU - {292D34E8-0F01-4FA8-951D-8232F75A88D5}.Debug|x64.ActiveCfg = Debug|Any CPU - {292D34E8-0F01-4FA8-951D-8232F75A88D5}.Debug|x64.Build.0 = Debug|Any CPU - {292D34E8-0F01-4FA8-951D-8232F75A88D5}.Debug|x86.ActiveCfg = Debug|Any CPU - {292D34E8-0F01-4FA8-951D-8232F75A88D5}.Debug|x86.Build.0 = Debug|Any CPU - {292D34E8-0F01-4FA8-951D-8232F75A88D5}.Native|Any CPU.ActiveCfg = Release|Any CPU - {292D34E8-0F01-4FA8-951D-8232F75A88D5}.Native|ARM.ActiveCfg = Release|Any CPU - {292D34E8-0F01-4FA8-951D-8232F75A88D5}.Native|ARM64.ActiveCfg = Release|Any CPU - {292D34E8-0F01-4FA8-951D-8232F75A88D5}.Native|x64.ActiveCfg = Release|Any CPU - {292D34E8-0F01-4FA8-951D-8232F75A88D5}.Native|x86.ActiveCfg = Release|Any CPU - {292D34E8-0F01-4FA8-951D-8232F75A88D5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {292D34E8-0F01-4FA8-951D-8232F75A88D5}.Release|ARM.ActiveCfg = Release|Any CPU - {292D34E8-0F01-4FA8-951D-8232F75A88D5}.Release|ARM.Build.0 = Release|Any CPU - {292D34E8-0F01-4FA8-951D-8232F75A88D5}.Release|ARM64.ActiveCfg = Release|Any CPU - {292D34E8-0F01-4FA8-951D-8232F75A88D5}.Release|ARM64.Build.0 = Release|Any CPU - {292D34E8-0F01-4FA8-951D-8232F75A88D5}.Release|x64.ActiveCfg = Release|Any CPU - {292D34E8-0F01-4FA8-951D-8232F75A88D5}.Release|x64.Build.0 = Release|Any CPU - {292D34E8-0F01-4FA8-951D-8232F75A88D5}.Release|x86.ActiveCfg = Release|Any CPU - {292D34E8-0F01-4FA8-951D-8232F75A88D5}.Release|x86.Build.0 = Release|Any CPU - {262BB7CE-EF42-4BF7-B90C-107E6CBB57FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {262BB7CE-EF42-4BF7-B90C-107E6CBB57FF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {262BB7CE-EF42-4BF7-B90C-107E6CBB57FF}.Debug|ARM.ActiveCfg = Debug|Any CPU - {262BB7CE-EF42-4BF7-B90C-107E6CBB57FF}.Debug|ARM.Build.0 = Debug|Any CPU - {262BB7CE-EF42-4BF7-B90C-107E6CBB57FF}.Debug|ARM64.ActiveCfg = Debug|Any CPU - {262BB7CE-EF42-4BF7-B90C-107E6CBB57FF}.Debug|ARM64.Build.0 = Debug|Any CPU - {262BB7CE-EF42-4BF7-B90C-107E6CBB57FF}.Debug|x64.ActiveCfg = Debug|Any CPU - {262BB7CE-EF42-4BF7-B90C-107E6CBB57FF}.Debug|x64.Build.0 = Debug|Any CPU - {262BB7CE-EF42-4BF7-B90C-107E6CBB57FF}.Debug|x86.ActiveCfg = Debug|Any CPU - {262BB7CE-EF42-4BF7-B90C-107E6CBB57FF}.Debug|x86.Build.0 = Debug|Any CPU - {262BB7CE-EF42-4BF7-B90C-107E6CBB57FF}.Native|Any CPU.ActiveCfg = Release|Any CPU - {262BB7CE-EF42-4BF7-B90C-107E6CBB57FF}.Native|ARM.ActiveCfg = Release|Any CPU - {262BB7CE-EF42-4BF7-B90C-107E6CBB57FF}.Native|ARM64.ActiveCfg = Release|Any CPU - {262BB7CE-EF42-4BF7-B90C-107E6CBB57FF}.Native|x64.ActiveCfg = Release|Any CPU - {262BB7CE-EF42-4BF7-B90C-107E6CBB57FF}.Native|x86.ActiveCfg = Release|Any CPU - {262BB7CE-EF42-4BF7-B90C-107E6CBB57FF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {262BB7CE-EF42-4BF7-B90C-107E6CBB57FF}.Release|Any CPU.Build.0 = Release|Any CPU - {262BB7CE-EF42-4BF7-B90C-107E6CBB57FF}.Release|ARM.ActiveCfg = Release|Any CPU - {262BB7CE-EF42-4BF7-B90C-107E6CBB57FF}.Release|ARM.Build.0 = Release|Any CPU - {262BB7CE-EF42-4BF7-B90C-107E6CBB57FF}.Release|ARM64.ActiveCfg = Release|Any CPU - {262BB7CE-EF42-4BF7-B90C-107E6CBB57FF}.Release|ARM64.Build.0 = Release|Any CPU - {262BB7CE-EF42-4BF7-B90C-107E6CBB57FF}.Release|x64.ActiveCfg = Release|Any CPU - {262BB7CE-EF42-4BF7-B90C-107E6CBB57FF}.Release|x64.Build.0 = Release|Any CPU - {262BB7CE-EF42-4BF7-B90C-107E6CBB57FF}.Release|x86.ActiveCfg = Release|Any CPU - {262BB7CE-EF42-4BF7-B90C-107E6CBB57FF}.Release|x86.Build.0 = Release|Any CPU {A5E98964-45B1-442D-A07A-298A3221D81E}.Debug|Any CPU.ActiveCfg = Debug|Win32 {A5E98964-45B1-442D-A07A-298A3221D81E}.Debug|Any CPU.Build.0 = Debug|Win32 {A5E98964-45B1-442D-A07A-298A3221D81E}.Debug|ARM.ActiveCfg = Debug|ARM @@ -1076,8 +1021,6 @@ Global {EFA96B3C-857E-4659-B942-6BEF7719F4CA} = {9333C63A-F64F-4797-82B3-017422668A5D} {7AEFC959-ED7C-4D96-9E92-72609B40FBE0} = {F1AFFFA7-28FE-4770-BA48-10D76F3E59BC} {6BD0BA4A-DE6D-3E87-8F83-63518C31ECD1} = {F1AFFFA7-28FE-4770-BA48-10D76F3E59BC} - {292D34E8-0F01-4FA8-951D-8232F75A88D5} = {096ECFD7-7035-4487-9C87-81DCE9389620} - {262BB7CE-EF42-4BF7-B90C-107E6CBB57FF} = {096ECFD7-7035-4487-9C87-81DCE9389620} {A122EA02-4DE7-413D-BFBF-AF7DFC668DD6} = {B30036C4-D514-4E5B-A323-587A061772CE} {75F9EE44-3EFA-47BC-AEDD-351B9834A0AF} = {F1AFFFA7-28FE-4770-BA48-10D76F3E59BC} {4E9466D1-D5AA-46AC-801B-C8FDAB79F0D4} = {B30036C4-D514-4E5B-A323-587A061772CE} From 62145a02546797c62715ac3f501186884f98c8d0 Mon Sep 17 00:00:00 2001 From: Alexandre Zollinger Chohfi Date: Wed, 19 Aug 2020 19:32:08 -0700 Subject: [PATCH 5/8] Revert "Removed TabView/TabViewItem, HeaderedTextBlock, LightBehavior/AnimationExtensions.Light, and some other smaller methods marked as Obsolete." This reverts commit 274492be9708ee1f7eed68a6a0b786394ff6481f. --- .../Services/LinkedIn/LinkedInDataProvider.cs | 11 + .../Services/LinkedIn/LinkedInService.cs | 9 + .../Services/Twitter/TwitterDataProvider.cs | 11 + .../Services/Twitter/TwitterService.cs | 9 + .../Services/Weibo/WeiboDataProvider.cs | 11 + .../Services/Weibo/WeiboService.cs | 9 + .../Microsoft.Toolkit.Uwp.SampleApp.csproj | 31 + .../HeaderedTextBlock/HeaderedTextBlock.png | Bin 0 -> 3308 bytes .../HeaderedTextBlockCode.bind | 16 + .../HeaderedTextBlockPage.xaml | 9 + .../HeaderedTextBlockPage.xaml.cs | 18 + .../SamplePages/Light/LightBehavior.png | Bin 0 -> 6164 bytes .../SamplePages/Light/LightBehaviorCode.bind | 8 + .../SamplePages/Light/LightBehaviorPage.xaml | 39 + .../Light/LightBehaviorPage.xaml.cs | 52 ++ .../SamplePages/Light/LightBehaviorXaml.bind | 25 + .../SamplePages/TabView/TabView.png | Bin 0 -> 1392 bytes .../SamplePages/TabView/TabViewPage.xaml | 19 + .../SamplePages/TabView/TabViewPage.xaml.cs | 73 ++ .../SamplePages/TabView/TabViewXaml.bind | 97 +++ .../SamplePages/samples.json | 37 + .../Behaviors/Light.cs | 69 ++ .../ConnectedAnimations/Connected.cs | 16 + .../Extensions/AnimationExtensions.Light.cs | 210 ++++- .../HeaderedTextBlockMetadata.cs | 49 ++ ...soft.Toolkit.Uwp.UI.Controls.Design.csproj | 3 + .../TabViewItemMetadata.cs | 43 + .../TabViewMetadata.cs | 54 ++ .../HeaderedTextBlock.Properties.cs | 172 ++++ .../HeaderedTextBlock/HeaderedTextBlock.cs | 76 ++ .../HeaderedTextBlock/HeaderedTextBlock.xaml | 60 ++ .../Microsoft.Toolkit.Uwp.UI.Controls.csproj | 1 + ...Toolkit.Uwp.UI.Controls.csproj.DotSettings | 1 + .../Strings/en-US/Resources.resw | 8 + .../TabView/TabClosingEventArgs.cs | 36 + .../TabView/TabDraggedOutsideEventArgs.cs | 35 + .../TabView/TabView.HeaderLayout.cs | 221 ++++++ .../TabView/TabView.ItemSources.cs | 115 +++ .../TabView/TabView.Properties.cs | 245 ++++++ .../TabView/TabView.cs | 320 ++++++++ .../TabView/TabView.xaml | 736 ++++++++++++++++++ .../TabView/TabViewItem.Properties.cs | 79 ++ .../TabView/TabViewItem.cs | 116 +++ .../TabView/TabWidthMode.cs | 36 + .../Themes/Generic.xaml | 2 + .../TileControl/TileControl.cs | 7 + .../VisualStudioToolsManifest.xml | 3 + .../Extensions/StringExtensions.cs | 8 + 48 files changed, 3201 insertions(+), 4 deletions(-) create mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedTextBlock/HeaderedTextBlock.png create mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedTextBlock/HeaderedTextBlockCode.bind create mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedTextBlock/HeaderedTextBlockPage.xaml create mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedTextBlock/HeaderedTextBlockPage.xaml.cs create mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Light/LightBehavior.png create mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Light/LightBehaviorCode.bind create mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Light/LightBehaviorPage.xaml create mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Light/LightBehaviorPage.xaml.cs create mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Light/LightBehaviorXaml.bind create mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabView/TabView.png create mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabView/TabViewPage.xaml create mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabView/TabViewPage.xaml.cs create mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabView/TabViewXaml.bind create mode 100644 Microsoft.Toolkit.Uwp.UI.Animations/Behaviors/Light.cs create mode 100644 Microsoft.Toolkit.Uwp.UI.Controls.Design/HeaderedTextBlockMetadata.cs create mode 100644 Microsoft.Toolkit.Uwp.UI.Controls.Design/TabViewItemMetadata.cs create mode 100644 Microsoft.Toolkit.Uwp.UI.Controls.Design/TabViewMetadata.cs create mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/HeaderedTextBlock/HeaderedTextBlock.Properties.cs create mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/HeaderedTextBlock/HeaderedTextBlock.cs create mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/HeaderedTextBlock/HeaderedTextBlock.xaml create mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabClosingEventArgs.cs create mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabDraggedOutsideEventArgs.cs create mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.HeaderLayout.cs create mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.ItemSources.cs create mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.Properties.cs create mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.cs create mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.xaml create mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabViewItem.Properties.cs create mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabViewItem.cs create mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabWidthMode.cs diff --git a/Microsoft.Toolkit.Services/Services/LinkedIn/LinkedInDataProvider.cs b/Microsoft.Toolkit.Services/Services/LinkedIn/LinkedInDataProvider.cs index 27c7739c333..f852688bc57 100644 --- a/Microsoft.Toolkit.Services/Services/LinkedIn/LinkedInDataProvider.cs +++ b/Microsoft.Toolkit.Services/Services/LinkedIn/LinkedInDataProvider.cs @@ -154,6 +154,17 @@ public async Task LoginAsync() return false; } + /// + /// Log user out of LinkedIn. + /// + [Obsolete("Logout is deprecated, please use LogoutAsync instead.", true)] + public void Logout() + { +#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed + LogoutAsync(); +#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed + } + /// /// Log user out of LinkedIn. /// diff --git a/Microsoft.Toolkit.Services/Services/LinkedIn/LinkedInService.cs b/Microsoft.Toolkit.Services/Services/LinkedIn/LinkedInService.cs index 7a79b8fc344..251e5fb711d 100644 --- a/Microsoft.Toolkit.Services/Services/LinkedIn/LinkedInService.cs +++ b/Microsoft.Toolkit.Services/Services/LinkedIn/LinkedInService.cs @@ -92,6 +92,15 @@ public Task ShareActivityAsync(LinkedInShareRequest share return Provider.ShareDataAsync(shareRequest); } + /// + /// Log user out of LinkedIn. + /// + [Obsolete("Logout is deprecated, please use LogoutAsync instead.", true)] + public void Logout() + { + Provider.Logout(); + } + /// /// Log user out of LinkedIn. /// diff --git a/Microsoft.Toolkit.Services/Services/Twitter/TwitterDataProvider.cs b/Microsoft.Toolkit.Services/Services/Twitter/TwitterDataProvider.cs index 41db01d748b..a6eda59f07e 100644 --- a/Microsoft.Toolkit.Services/Services/Twitter/TwitterDataProvider.cs +++ b/Microsoft.Toolkit.Services/Services/Twitter/TwitterDataProvider.cs @@ -273,6 +273,17 @@ public async Task LoginAsync() return false; } + /// + /// Log user out of Twitter. + /// + [Obsolete("Logout is deprecated, please use LogoutAsync instead.", true)] + public void Logout() + { +#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed + LogoutAsync(); +#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed + } + /// /// Log user out of Twitter. /// diff --git a/Microsoft.Toolkit.Services/Services/Twitter/TwitterService.cs b/Microsoft.Toolkit.Services/Services/Twitter/TwitterService.cs index b461458ce8d..703657cf2fb 100644 --- a/Microsoft.Toolkit.Services/Services/Twitter/TwitterService.cs +++ b/Microsoft.Toolkit.Services/Services/Twitter/TwitterService.cs @@ -400,6 +400,15 @@ public Task LoginAsync() return Provider.LoginAsync(); } + /// + /// Log user out of Twitter. + /// + [Obsolete("Logout is deprecated, please use LogoutAsync instead.", true)] + public void Logout() + { + Provider.Logout(); + } + /// /// Log user out of Twitter. /// diff --git a/Microsoft.Toolkit.Services/Services/Weibo/WeiboDataProvider.cs b/Microsoft.Toolkit.Services/Services/Weibo/WeiboDataProvider.cs index 6975a33d005..3dd6d59a8ac 100644 --- a/Microsoft.Toolkit.Services/Services/Weibo/WeiboDataProvider.cs +++ b/Microsoft.Toolkit.Services/Services/Weibo/WeiboDataProvider.cs @@ -163,6 +163,17 @@ public async Task LoginAsync() return false; } + /// + /// Log user out of Weibo. + /// + [Obsolete("Logout is deprecated, please use LogoutAsync instead.", true)] + public void Logout() + { +#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed + LogoutAsync(); +#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed + } + /// /// Log user out of Weibo. /// diff --git a/Microsoft.Toolkit.Services/Services/Weibo/WeiboService.cs b/Microsoft.Toolkit.Services/Services/Weibo/WeiboService.cs index ea2f6cea3b1..f5f8dd7ec99 100644 --- a/Microsoft.Toolkit.Services/Services/Weibo/WeiboService.cs +++ b/Microsoft.Toolkit.Services/Services/Weibo/WeiboService.cs @@ -183,6 +183,15 @@ public Task LoginAsync() return Provider.LoginAsync(); } + /// + /// Log user out of Weibo. + /// + [Obsolete("Logout is deprecated, please use LogoutAsync instead.", true)] + public void Logout() + { + Provider.Logout(); + } + /// /// Log user out of Weibo. /// diff --git a/Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj b/Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj index 18981c05b81..51c0fd428b1 100644 --- a/Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj +++ b/Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj @@ -280,6 +280,7 @@ + @@ -316,6 +317,7 @@ + @@ -324,6 +326,7 @@ + @@ -364,6 +367,8 @@ + + @@ -423,6 +428,8 @@ + + Designer @@ -504,6 +511,9 @@ + + Designer + @@ -645,6 +655,9 @@ + + TabViewPage.xaml + UniformGridPage.xaml @@ -853,6 +866,9 @@ + + LightBehaviorPage.xaml + LinkedInPage.xaml @@ -904,6 +920,9 @@ FadeBehaviorPage.xaml + + HeaderedTextBlockPage.xaml + ImageExPage.xaml @@ -1036,6 +1055,10 @@ Designer MSBuild:Compile + + MSBuild:Compile + Designer + MSBuild:Compile Designer @@ -1328,6 +1351,10 @@ MSBuild:Compile Designer + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -1396,6 +1423,10 @@ MSBuild:Compile Designer + + Designer + MSBuild:Compile + MSBuild:Compile Designer diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedTextBlock/HeaderedTextBlock.png b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedTextBlock/HeaderedTextBlock.png new file mode 100644 index 0000000000000000000000000000000000000000..4b495ab237ab617b406082956fa4df6764313695 GIT binary patch literal 3308 zcmeH~**6=C7RE!&Lrtfps8CaTYN&%!Eipt@kydpu#nhIVrIa2af{KI|HIy1^o|V#| z#&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@ppyo)+9+dMu3G!I>GjqOxfi^o0-hl(_<7hmjWt$Q?_A#1qe z+u01Zc++Enk6|X^pFA8*`JO?f1*}vjbu!#VElniGR!cel7I(2bJu(E|i&BPIR}@mE zG)qOxYmoZ3D2hzX5+=Sfjimr(E`$_}ch!O{%QSI)9>hmYT-8*GGZe^Z3(2r$~0rRsg07MSAnB+zwd#+H=^bD+VhE(_f9!uYP7w2 TO!KSG-WPzWF%(j1=oIlU(~cTl literal 0 HcmV?d00001 diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedTextBlock/HeaderedTextBlockCode.bind b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedTextBlock/HeaderedTextBlockCode.bind new file mode 100644 index 00000000000..a2db4b8dc80 --- /dev/null +++ b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedTextBlock/HeaderedTextBlockCode.bind @@ -0,0 +1,16 @@ + + + + + + \ No newline at end of file diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedTextBlock/HeaderedTextBlockPage.xaml b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedTextBlock/HeaderedTextBlockPage.xaml new file mode 100644 index 00000000000..a5795898a0e --- /dev/null +++ b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedTextBlock/HeaderedTextBlockPage.xaml @@ -0,0 +1,9 @@ + + + diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedTextBlock/HeaderedTextBlockPage.xaml.cs b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedTextBlock/HeaderedTextBlockPage.xaml.cs new file mode 100644 index 00000000000..77cdba59f3e --- /dev/null +++ b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedTextBlock/HeaderedTextBlockPage.xaml.cs @@ -0,0 +1,18 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using Microsoft.Toolkit.Uwp.SampleApp.Models; + +using Windows.UI.Xaml.Navigation; + +namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages +{ + public sealed partial class HeaderedTextBlockPage + { + public HeaderedTextBlockPage() + { + InitializeComponent(); + } + } +} \ No newline at end of file diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Light/LightBehavior.png b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Light/LightBehavior.png new file mode 100644 index 0000000000000000000000000000000000000000..b2235f1b9e4577a48af0b24d219f8485b2a71878 GIT binary patch literal 6164 zcmZ9QcQl*r8^@DaF`JayBSuRrwEEhs5hB)W#0)}PlvZh#m{qg(Y|$DaX4EXAX3=4k zB34qfLlIJ=W?R+%^8WjK{&=3}+~?f)ea@|sr>nD zBb@pSO=Xcoc^X?Jv2w9hyZp#udlnKkApBQS0A-^=-~O2Sw*!Ah07a;dI>8@tDWqsS zvO-WcZOMQ#g$?zS%|vSs`r1H8)S{*az6DI&3zEMrXUdSy;e!JA-Sl`>p*MZypSqm` z(Q&_S&|w87QrGrDP{hajHkQH3UkjWS7X^U(k)5Zt34xpJtcw#uDS%&mo3Ue$uTnXA zU(?Nv0D3OC=pP9fKiaE3`HKeo2qf$|BB=nPYi$4q_~=1jzs>C|UXn@j z7X$|N)`OI|zG7_d@a4*UP99o%#{n5Uc(p5R?%?v(UG+?{z!QaIKt zfv17X#EbyAT16NpW-PaFSUY#<1CJfJj2i{OkqEG##vyj+yUH#N$0kAM;2@vg;23WW zVog{L$B0icIIRp;CidTQV=&@62l4WEiJvlCY{}@DY#>yc%)DHG5txI!J6Bn~Y;aA0 zxfWCoCO*J-NnWhtx0wBrBy%?ROlBV#X!Dl0NzPXgI9;o_Xuv;krsl?^6JZU(D5wwLPs$++zphG(nR4~VxmV711D zyz*|dt;tAz@VYYH@Y?kQ7vi%{X=F9?sHzM1J6{DlhULA>4Y-2!j%%-kS5Sn_Aix}& z@{e!+=;IK@jR({RtadgKC{idDFuZ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zY$<@bT7`Iah*Y}aby}#oW0dm?meXB*Xf_mJ)3HJ>^(`7OwH{i0SC}ASxT9;qO2MbJ zms3>qztX`j=6VVFA_$z}rn&)vA%YO&$8cYP+J$ErBCZ27-DZt_f|YmX2Rd2%u~ z&QIPmPa`Z>$AXCwxxfisW$nYQW^-Hoo;!BTCS4}FxRm~rqJ3B{5v4og@eoj%XN(C-A=5OmYL5ftGX@4;7U^7t?6@2 zmR;IqR%>a3;{+ksn7lf&qyb*vb5k~I%J~_Sh4#37{H<3~11=Iu0)#(Vy0=r8ObN>e z6OYX1>plX`#jZl2h_&^bB}q_qj#NO|0F1S|aG$owO;p%$g(3t{i&a*fhm9_d1~${# azb+0$RdwfQyenj4et;>;(x?G>HTHj)(0CpI literal 0 HcmV?d00001 diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Light/LightBehaviorCode.bind b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Light/LightBehaviorCode.bind new file mode 100644 index 00000000000..4019e9a2ce7 --- /dev/null +++ b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Light/LightBehaviorCode.bind @@ -0,0 +1,8 @@ +// XAML UIElement + + +// C# - Light can be applied to any UIElement. In this case it is an image called ToolkitLogo. +using Microsoft.Toolkit.Uwp.UI.Animations; + +var lightAnimationSet = ToolkitLogo.Light(distance: 10, duration: 500, delay: 0, color: Colors.Red); +await lightAnimationSet.StartAsync(); \ No newline at end of file diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Light/LightBehaviorPage.xaml b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Light/LightBehaviorPage.xaml new file mode 100644 index 00000000000..8eba95bedbd --- /dev/null +++ b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Light/LightBehaviorPage.xaml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Light/LightBehaviorPage.xaml.cs b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Light/LightBehaviorPage.xaml.cs new file mode 100644 index 00000000000..fd59ec7d5be --- /dev/null +++ b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Light/LightBehaviorPage.xaml.cs @@ -0,0 +1,52 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Linq; +using Microsoft.Toolkit.Uwp.UI.Animations; +using Microsoft.Toolkit.Uwp.UI.Animations.Behaviors; +using Microsoft.Toolkit.Uwp.UI.Extensions; +using Microsoft.Xaml.Interactivity; +using Windows.UI.Xaml; + +namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages +{ + /// + /// A page that shows how to use the light behavior. + /// + public sealed partial class LightBehaviorPage : IXamlRenderListener + { +#pragma warning disable CS0618 // Type or member is obsolete + private Light _lightBehavior; +#pragma warning restore CS0618 // Type or member is obsolete + + /// + /// Initializes a new instance of the class. + /// + public LightBehaviorPage() + { + this.InitializeComponent(); + + if (!AnimationExtensions.IsLightingSupported) + { + WarningText.Visibility = Visibility.Visible; + } + + SampleController.Current.RegisterNewCommand("Apply", (s, e) => + { + _lightBehavior?.StartAnimation(); + }); + } + + public void OnXamlRendered(FrameworkElement control) + { + if (control.FindChildByName("EffectElement") is FrameworkElement element) + { + var behaviors = Interaction.GetBehaviors(element); +#pragma warning disable CS0618 // Type or member is obsolete + _lightBehavior = behaviors.FirstOrDefault(item => item is Light) as Light; +#pragma warning restore CS0618 // Type or member is obsolete + } + } + } +} \ No newline at end of file diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Light/LightBehaviorXaml.bind b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Light/LightBehaviorXaml.bind new file mode 100644 index 00000000000..2ca51bf1cfc --- /dev/null +++ b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Light/LightBehaviorXaml.bind @@ -0,0 +1,25 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabView/TabView.png b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabView/TabView.png new file mode 100644 index 0000000000000000000000000000000000000000..9aeebd1d673de8670b59cb522700c93f1c75b887 GIT binary patch literal 1392 zcmeAS@N?(olHy`uVBq!ia0y~yU{nCI4{)#n$t4^1Z39v)>5jgR3=A9lx&I`x0{NT; z9+AZi3_@Vc*rT+Q9VjSK;u=vBoS#-wo>-L1P>`6JSE84fTB2a0XQ*fNOZn_apgHe6 zT^vIy;@;jkn3<9;(sHr$a7C&>Me2+jB8``VnSxjjMP@u{{Ps+A*_%VZT#Kdr^5tW8 z?PLG@_VH)g2NUMU?`QbaU-$RJ?e_cje?B@kH25n!957^Jks+S?oXJ@AJU_4Ksap8< z*>{W?tq%CEyYu8#+2m?92lgE&r_PSKn^$z6vX!n@AaI&`f&Rut(%&YBXu(h{8E`O?i>b#Gwa0B+aHTQB0Y2Yh>nZ-My5VNg$EMEQ9q9}FxG6!zhBS5Tj$4m^~aMNz|xVy)78&qol`;+ E0K}H&HUIzs literal 0 HcmV?d00001 diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabView/TabViewPage.xaml b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabView/TabViewPage.xaml new file mode 100644 index 00000000000..32f465f2c64 --- /dev/null +++ b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabView/TabViewPage.xaml @@ -0,0 +1,19 @@ + + + + + + + diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabView/TabViewPage.xaml.cs b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabView/TabViewPage.xaml.cs new file mode 100644 index 00000000000..74d9a3db253 --- /dev/null +++ b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabView/TabViewPage.xaml.cs @@ -0,0 +1,73 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.ObjectModel; +using Microsoft.Toolkit.Uwp.UI.Controls; +using Microsoft.Toolkit.Uwp.UI.Extensions; +using Windows.UI.Popups; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; + +namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages +{ + public sealed partial class TabViewPage : Page, IXamlRenderListener + { + #pragma warning disable CS0618 // Type or member is obsolete + private TabView _tabs; + + private int _counter = 1; + + public TabViewPage() + { + this.InitializeComponent(); + } + + public void OnXamlRendered(FrameworkElement control) + { + _tabs = control.FindChildByName("Tabs") as TabView; + if (_tabs != null) + { + _tabs.TabDraggedOutside += Tabs_TabDraggedOutside; + _tabs.TabClosing += Tabs_TabClosing; + } + + var btn = control.FindDescendantByName("AddTabButtonUpper") as Button; + if (btn != null) + { + btn.Click += AddUpperTabClick; + } + } + + private void AddUpperTabClick(object sender, RoutedEventArgs e) + { + _tabs.Items.Add(new TabViewItem() + { + Header = "Untitled " + _counter, + Icon = new SymbolIcon(Symbol.Document), + Content = "This is new tab #" + _counter++ + "." + }); + } + + private void Tabs_TabClosing(object sender, TabClosingEventArgs e) + { + TabViewNotification.Show("You're closing the '" + e.Tab.Header + "' tab.", 2000); + } + + private void Tabs_TabDraggedOutside(object sender, TabDraggedOutsideEventArgs e) + { + // The sample app let's you drag items from a static TabView with TabViewItem's pre-defined. + // In the case of data bound scenarios e.Item should be your data item, and e.Tab should always be the TabViewItem. + var str = e.Item.ToString(); + + if (e.Tab != null) + { + str = e.Tab.Header.ToString(); + } + + TabViewNotification.Show("Tore Tab '" + str + "' Outside of TabView.", 2000); + } + #pragma warning restore CS0618 // Type or member is obsolete + } +} diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabView/TabViewXaml.bind b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabView/TabViewXaml.bind new file mode 100644 index 00000000000..e81732aa2a3 --- /dev/null +++ b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabView/TabViewXaml.bind @@ -0,0 +1,97 @@ + + + + + + + + + + 40 + 48 + 200 + + + + + + + + + + + The TabView control has multiple uses. + + + It has a lot of versitility out of the box for different scenarios. + + + You can enable drag-and-drop and reorder the tabs too. + + + This tab isn't closable because its IsClosable property is set to False, even when CanCloseTabs is True. + + + + + + + + + + + + + + + + + diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/samples.json b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/samples.json index 7b4d6b3a1c6..f106b270277 100644 --- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/samples.json +++ b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/samples.json @@ -14,6 +14,18 @@ "Icon": "/SamplePages/TextToolbar/TextToolbar.png", "DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/controls/TextToolbar.md" }, + { + "Name": "TabView", + "Type": "TabViewPage", + "Subcategory": "Layout", + "BadgeUpdateVersionRequired": "DEPRECATED", + "DeprecatedWarning": "Please migrate to the TabView control from WinUI, this control will be removed in a future release. https://aka.ms/winui", + "About": "A control for displaying multiple items in the same space and allows a user to easily switch between them.", + "CodeUrl": "https://github.com/windows-toolkit/WindowsCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI.Controls/TabView", + "XamlCodeFile": "TabViewXaml.bind", + "Icon": "/SamplePages/TabView/TabView.png", + "DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/controls/TabView.md" + }, { "Name": "DataGrid", "Type": "DataGridPage", @@ -74,6 +86,18 @@ "Icon": "/SamplePages/ImageEx/ImageEx.png", "DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/controls/ImageEx.md" }, + { + "Name": "HeaderedTextBlock", + "Type": "HeaderedTextBlockPage", + "Subcategory": "Layout", + "About": "The HeaderedTextBlock control is designed to provide a header for read only text. This control is useful for displaying read only forms.", + "CodeUrl": "https://github.com/windows-toolkit/WindowsCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI.Controls/HeaderedTextBlock", + "XamlCodeFile": "HeaderedTextBlockCode.bind", + "Icon": "/SamplePages/HeaderedTextBlock/HeaderedTextBlock.png", + "DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/controls/HeaderedTextBlock.md", + "BadgeUpdateVersionRequired": "DEPRECATED", + "DeprecatedWarning": "The HeaderedTextBlock has been replaced with the HeaderedContentControl and will be removed in a future major release." + }, { "Name": "MasterDetailsView", "Type": "MasterDetailsViewPage", @@ -508,6 +532,19 @@ "BadgeUpdateVersionRequired": "Anniversary Update required", "DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/animations/Saturation.md" }, + { + "Name": "Light", + "Type": "LightBehaviorPage", + "Subcategory": "Behavior", + "About": "The Light effect will be removed in a future major release", + "BadgeUpdateVersionRequired": "DEPRECATED", + "DeprecatedWarning": "The Light effect will be removed in a future major release", + "CodeUrl": "https://github.com/windows-toolkit/WindowsCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI.Animations/Behaviors", + "CodeFile": "LightBehaviorCode.bind", + "XamlCodeFile": "LightBehaviorXaml.bind", + "Icon": "/SamplePages/Light/LightBehavior.png", + "DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/animations/Light.md" + }, { "Name": "FadeHeader", "Type": "FadeHeaderBehaviorPage", diff --git a/Microsoft.Toolkit.Uwp.UI.Animations/Behaviors/Light.cs b/Microsoft.Toolkit.Uwp.UI.Animations/Behaviors/Light.cs new file mode 100644 index 00000000000..8940f3eb630 --- /dev/null +++ b/Microsoft.Toolkit.Uwp.UI.Animations/Behaviors/Light.cs @@ -0,0 +1,69 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using Windows.UI; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Media; + +namespace Microsoft.Toolkit.Uwp.UI.Animations.Behaviors +{ + /// + /// Applies a basic point light to a UIElement. You control the intensity by setting the distance of the light. + /// + /// + /// + [Obsolete("The Light effect will be removed in a future major release. Please use XamlLight instead")] + + public class Light : CompositionBehaviorBase + { + /// + /// The Blur value of the associated object + /// + public static readonly DependencyProperty DistanceProperty = DependencyProperty.Register(nameof(Distance), typeof(double), typeof(Light), new PropertyMetadata(0d, PropertyChangedCallback)); + + /// + /// The Color of the spotlight no the associated object. + /// + public static readonly DependencyProperty ColorProperty = DependencyProperty.Register("Color", typeof(Brush), typeof(Light), new PropertyMetadata(new SolidColorBrush(Colors.White))); + + /// + /// Gets or sets the Blur. + /// + /// + /// The Blur. + /// + public double Distance + { + get { return (double)GetValue(DistanceProperty); } + set { SetValue(DistanceProperty, value); } + } + + /// + /// Gets or sets the color of the spotlight. + /// + public Brush Color + { + get { return (Brush)GetValue(ColorProperty); } + set { SetValue(ColorProperty, value); } + } + + /// + /// Starts the animation. + /// + public override void StartAnimation() + { + if (AnimationExtensions.IsLightingSupported) + { + AssociatedObject?.Light( + duration: Duration, + delay: Delay, + easingType: EasingType, + easingMode: EasingMode, + distance: (float)Distance, + color: ((SolidColorBrush)Color).Color)?.Start(); + } + } + } +} diff --git a/Microsoft.Toolkit.Uwp.UI.Animations/ConnectedAnimations/Connected.cs b/Microsoft.Toolkit.Uwp.UI.Animations/ConnectedAnimations/Connected.cs index 999ea1d40c4..a0e5afa756d 100644 --- a/Microsoft.Toolkit.Uwp.UI.Animations/ConnectedAnimations/Connected.cs +++ b/Microsoft.Toolkit.Uwp.UI.Animations/ConnectedAnimations/Connected.cs @@ -361,6 +361,22 @@ public static void UnregisterListItemForConnectedAnimation(this Page page, ListV } } + /// + /// Sets the object that will be used during next Frame navigation for + /// Connected Animation involving a list control (item must be an element of + /// ListViewBase.ItemsSource collection). + /// Useful if the parameter used during page navigation is different from the + /// data item in the list control. Also useful during back navigation if the + /// item navigating back to is different from the item that was navigated from. + /// + /// The Frame handling the navigation + /// The data item from a list control to be animated during next frame navigation + [Obsolete("Method is replaced by SetListDataItemForNextConnectedAnimation")] + public static void SetListDataItemForNextConnectedAnnimation(this Frame frame, object item) + { + GetConnectedAnimationHelper(frame)?.SetParameterForNextFrameNavigation(item); + } + /// /// Sets the object that will be used during next Frame navigation for /// Connected Animation involving a list control (item must be an element of diff --git a/Microsoft.Toolkit.Uwp.UI.Animations/Extensions/AnimationExtensions.Light.cs b/Microsoft.Toolkit.Uwp.UI.Animations/Extensions/AnimationExtensions.Light.cs index 3bc0da11259..0949dd235dd 100644 --- a/Microsoft.Toolkit.Uwp.UI.Animations/Extensions/AnimationExtensions.Light.cs +++ b/Microsoft.Toolkit.Uwp.UI.Animations/Extensions/AnimationExtensions.Light.cs @@ -3,6 +3,16 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; +using Microsoft.Graphics.Canvas; +using Microsoft.Graphics.Canvas.Effects; +using Microsoft.Toolkit.Uwp.Helpers; +using Windows.UI; +using Windows.UI.Composition; +using Windows.UI.Composition.Effects; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Hosting; +using Windows.UI.Xaml.Media.Animation; namespace Microsoft.Toolkit.Uwp.UI.Animations { @@ -12,12 +22,204 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations public static partial class AnimationExtensions { /// - /// Gets a value indicating whether this instance is lighting supported. Deprecated. Will always return true. + /// Stores all the point lights along with the visuals that they are applied to. + /// This is to stop multiplication of point lights on a single visual. + /// + private static Dictionary pointLights = new Dictionary(); + + /// + /// Gets a value indicating whether this instance is lighting supported. /// /// - /// Deprecated. Will always returns true. + /// true if this instance is lighting supported; otherwise, false. /// - [Obsolete("This method is deprecated and will always return true")] - public static bool IsLightingSupported => true; + public static bool IsLightingSupported + { + get + { + bool lightingSupported = true; + + if (!Windows.Foundation.Metadata.ApiInformation.IsMethodPresent("Windows.UI.Xaml.Hosting.ElementCompositionPreview", "SetElementChildVisual")) + { + lightingSupported = false; + } + + if (!Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.Composition.CompositionSurfaceBrush")) + { + lightingSupported = false; + } + + return lightingSupported; + } + } + + /// + /// Animates a point light and it's distance. + /// + /// The associated object. + /// The value. + /// The duration. + /// The delay. + /// The color of the spotlight. + /// The easing function + /// The easing mode + /// An animation set. + [Obsolete("The Light effect will be removed in a future major release. Please use XamlLight instead")] + public static AnimationSet Light( + this FrameworkElement associatedObject, + double distance = 0d, + double duration = 500d, + double delay = 0d, + Color? color = null, + EasingType easingType = EasingType.Default, + EasingMode easingMode = EasingMode.EaseOut) + { + if (associatedObject == null) + { + return null; + } + + var animationSet = new AnimationSet(associatedObject); + return animationSet.Light(distance, duration, delay, color, easingType, easingMode); + } + + /// + /// Animates a point light and it's distance. + /// + /// The animation set. + /// The distance of the light. + /// The duration in milliseconds. + /// The delay. (ignored if duration == 0) + /// The color of the spotlight. + /// The easing function + /// The easing mode + /// + /// + /// An Animation Set. + /// + [Obsolete("The Light effect will be removed in a future major release. Please use XamlLight instead")] + public static AnimationSet Light( + this AnimationSet animationSet, + double distance = 0d, + double duration = 500d, + double delay = 0d, + Color? color = null, + EasingType easingType = EasingType.Default, + EasingMode easingMode = EasingMode.EaseOut) + { + if (!IsLightingSupported) + { + return null; + } + + if (animationSet == null) + { + return null; + } + + var visual = animationSet.Visual; + var associatedObject = animationSet.Element as FrameworkElement; + + if (associatedObject == null) + { + return animationSet; + } + + var compositor = visual?.Compositor; + if (compositor == null) + { + return null; + } + + var task = new AnimationTask(); + task.AnimationSet = animationSet; + + task.Task = DispatcherHelper.ExecuteOnUIThreadAsync( + () => + { + const string sceneName = "PointLightScene"; + PointLight pointLight; + CompositionDrawingSurface normalMap = null; + + if (!pointLights.ContainsKey(visual)) + { + SurfaceLoader.Initialize(compositor); + normalMap = SurfaceLoader.LoadText(string.Empty, new Windows.Foundation.Size(512, 512), new Graphics.Canvas.Text.CanvasTextFormat(), Colors.Transparent, Colors.Transparent); + } + + if (pointLights.ContainsKey(visual)) + { + pointLight = pointLights[visual]; + } + else + { + pointLight = compositor.CreatePointLight(); + + var normalBrush = compositor.CreateSurfaceBrush(normalMap); + normalBrush.Stretch = CompositionStretch.Fill; + + // check to see if the visual already has a point light applied. + var spriteVisual = ElementCompositionPreview.GetElementChildVisual(associatedObject) as SpriteVisual; + var normalsBrush = spriteVisual?.Brush as CompositionEffectBrush; + + if (normalsBrush == null || normalsBrush.Comment != sceneName) + { + var lightEffect = new CompositeEffect() + { + Mode = CanvasComposite.Add, + Sources = + { + new CompositionEffectSourceParameter("ImageSource"), + new SceneLightingEffect() + { + Name = sceneName, + AmbientAmount = 0, + DiffuseAmount = 0.5f, + SpecularAmount = 0, + NormalMapSource = new CompositionEffectSourceParameter("NormalMap"), + } + } + }; + + var effectFactory = compositor.CreateEffectFactory(lightEffect); + var brush = effectFactory.CreateBrush(); + brush.SetSourceParameter("NormalMap", normalBrush); + + var sprite = compositor.CreateSpriteVisual(); + sprite.Size = visual.Size; + sprite.Brush = brush; + sprite.Comment = sceneName; + + ElementCompositionPreview.SetElementChildVisual(task.AnimationSet.Element, sprite); + + pointLight.CoordinateSpace = visual; + pointLight.Targets.Add(visual); + } + } + + pointLight.Color = color ?? Colors.White; + var delayTime = task.Delay != null ? task.Delay.Value : TimeSpan.FromMilliseconds(delay); + var durationTime = task.Duration != null ? task.Duration.Value : TimeSpan.FromMilliseconds(duration); + + if (durationTime.TotalMilliseconds <= 0) + { + task.AnimationSet.AddEffectDirectPropertyChange(pointLight, (float)distance, nameof(pointLight.Offset)); + } + else + { + var diffuseAnimation = compositor.CreateVector3KeyFrameAnimation(); + diffuseAnimation.InsertKeyFrame(1f, new System.Numerics.Vector3(visual.Size.X / 2, visual.Size.Y / 2, (float)distance), GetCompositionEasingFunction(easingType, compositor, easingMode)); + diffuseAnimation.Duration = durationTime; + diffuseAnimation.DelayTime = delayTime; + + task.AnimationSet.AddCompositionEffectAnimation(pointLight, diffuseAnimation, nameof(pointLight.Offset)); + } + + pointLights[visual] = pointLight; + }, Windows.UI.Core.CoreDispatcherPriority.Normal); + + animationSet.AddAnimationThroughTask(task); + return animationSet; + } } } diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.Design/HeaderedTextBlockMetadata.cs b/Microsoft.Toolkit.Uwp.UI.Controls.Design/HeaderedTextBlockMetadata.cs new file mode 100644 index 00000000000..3cba40e11f1 --- /dev/null +++ b/Microsoft.Toolkit.Uwp.UI.Controls.Design/HeaderedTextBlockMetadata.cs @@ -0,0 +1,49 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using Microsoft.Toolkit.Uwp.UI.Controls.Design.Common; +using Microsoft.Windows.Design; +using Microsoft.Windows.Design.Features; +using Microsoft.Windows.Design.Metadata; +using Microsoft.Windows.Design.Model; +using Microsoft.Windows.Design.PropertyEditing; +using System.ComponentModel; + +namespace Microsoft.Toolkit.Uwp.UI.Controls.Design +{ + internal class HeaderedTextBlockDefaults : DefaultInitializer + { + public override void InitializeDefaults(ModelItem item) + { + item.Properties[nameof(HeaderedTextBlock.Header)].SetValue(string.Empty); + item.Properties[nameof(HeaderedTextBlock.Text)].SetValue(string.Empty); + } + } + internal class HeaderedTextBlockMetadata : AttributeTableBuilder + { + public HeaderedTextBlockMetadata() + : base() + { + AddCallback(typeof(Microsoft.Toolkit.Uwp.UI.Controls.HeaderedTextBlock), + b => + { + b.AddCustomAttributes(new FeatureAttribute(typeof(HeaderedTextBlockDefaults))); + b.AddCustomAttributes(nameof(HeaderedTextBlock.HeaderTemplate), + new CategoryAttribute(Properties.Resources.CategoryAppearance), + new EditorBrowsableAttribute(EditorBrowsableState.Advanced) + ); + b.AddCustomAttributes(nameof(HeaderedTextBlock.TextStyle), + new CategoryAttribute(Properties.Resources.CategoryAppearance), + new EditorBrowsableAttribute(EditorBrowsableState.Advanced) + ); + b.AddCustomAttributes(nameof(HeaderedTextBlock.Header), new CategoryAttribute(Properties.Resources.CategoryCommon)); + b.AddCustomAttributes(nameof(HeaderedTextBlock.Text), new CategoryAttribute(Properties.Resources.CategoryCommon)); + b.AddCustomAttributes(nameof(HeaderedTextBlock.Orientation), new CategoryAttribute(Properties.Resources.CategoryAppearance)); + b.AddCustomAttributes(nameof(HeaderedTextBlock.HideTextIfEmpty), new CategoryAttribute(Properties.Resources.CategoryAppearance)); + b.AddCustomAttributes(new ToolboxCategoryAttribute(ToolboxCategoryPaths.Toolkit, false)); + } + ); + } + } +} diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.Design/Microsoft.Toolkit.Uwp.UI.Controls.Design.csproj b/Microsoft.Toolkit.Uwp.UI.Controls.Design/Microsoft.Toolkit.Uwp.UI.Controls.Design.csproj index b7b241a6403..b611399dd13 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls.Design/Microsoft.Toolkit.Uwp.UI.Controls.Design.csproj +++ b/Microsoft.Toolkit.Uwp.UI.Controls.Design/Microsoft.Toolkit.Uwp.UI.Controls.Design.csproj @@ -85,6 +85,7 @@ + @@ -92,6 +93,7 @@ + @@ -103,6 +105,7 @@ + Code diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.Design/TabViewItemMetadata.cs b/Microsoft.Toolkit.Uwp.UI.Controls.Design/TabViewItemMetadata.cs new file mode 100644 index 00000000000..6ed6bc37bf8 --- /dev/null +++ b/Microsoft.Toolkit.Uwp.UI.Controls.Design/TabViewItemMetadata.cs @@ -0,0 +1,43 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using Microsoft.Toolkit.Uwp.UI.Controls.Design.Common; +using Microsoft.Windows.Design; +using Microsoft.Windows.Design.Features; +using Microsoft.Windows.Design.Metadata; +using Microsoft.Windows.Design.Model; +using Microsoft.Windows.Design.PropertyEditing; +using System.ComponentModel; + +namespace Microsoft.Toolkit.Uwp.UI.Controls.Design +{ + + internal class TabViewItemMetadata : AttributeTableBuilder + { + public TabViewItemMetadata() + : base() + { + AddCallback(typeof(TabViewItem), + b => + { + b.AddCustomAttributes(nameof(TabViewItem.Header), + new CategoryAttribute(Properties.Resources.CategoryCommon) + ); + b.AddCustomAttributes(nameof(TabViewItem.HeaderTemplate), + new CategoryAttribute(Properties.Resources.CategoryCommon), + new EditorBrowsableAttribute(EditorBrowsableState.Advanced) + ); + b.AddCustomAttributes(nameof(TabViewItem.IsClosable), + new CategoryAttribute(Properties.Resources.CategoryCommon) + ); + b.AddCustomAttributes(nameof(TabViewItem.Icon), + new CategoryAttribute(Properties.Resources.CategoryCommon) + ); + + b.AddCustomAttributes(new ToolboxCategoryAttribute(ToolboxCategoryPaths.Toolkit, false)); + } + ); + } + } +} \ No newline at end of file diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.Design/TabViewMetadata.cs b/Microsoft.Toolkit.Uwp.UI.Controls.Design/TabViewMetadata.cs new file mode 100644 index 00000000000..7bfa77541db --- /dev/null +++ b/Microsoft.Toolkit.Uwp.UI.Controls.Design/TabViewMetadata.cs @@ -0,0 +1,54 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using Microsoft.Toolkit.Uwp.UI.Controls.Design.Common; +using Microsoft.Windows.Design; +using Microsoft.Windows.Design.Metadata; +using Microsoft.Windows.Design.PropertyEditing; +using System.ComponentModel; + +namespace Microsoft.Toolkit.Uwp.UI.Controls.Design +{ + internal class TabViewMetadata : AttributeTableBuilder + { + public TabViewMetadata() + : base() + { + AddCallback(typeof(Microsoft.Toolkit.Uwp.UI.Controls.TabView), + b => + { + // Layout + b.AddCustomAttributes(nameof(TabView.TabWidthBehavior), new CategoryAttribute(Properties.Resources.CategoryLayout)); + b.AddCustomAttributes(nameof(TabView.SelectedTabWidth), new CategoryAttribute(Properties.Resources.CategoryLayout)); + b.AddCustomAttributes(nameof(TabView.IsCloseButtonOverlay), new CategoryAttribute(Properties.Resources.CategoryLayout)); + + // Interactions + b.AddCustomAttributes(nameof(TabView.CanCloseTabs), new CategoryAttribute(Properties.Resources.CategoryCommon)); + + // Templates + b.AddCustomAttributes(nameof(TabView.ItemHeaderTemplate), + new CategoryAttribute(Properties.Resources.CategoryCommon), + new EditorBrowsableAttribute(EditorBrowsableState.Advanced) + ); + b.AddCustomAttributes(nameof(TabView.TabActionHeader), new CategoryAttribute(Properties.Resources.CategoryCommon)); + b.AddCustomAttributes(nameof(TabView.TabActionHeaderTemplate), + new CategoryAttribute(Properties.Resources.CategoryCommon), + new EditorBrowsableAttribute(EditorBrowsableState.Advanced) + ); + b.AddCustomAttributes(nameof(TabView.TabEndHeader), new CategoryAttribute(Properties.Resources.CategoryCommon)); + b.AddCustomAttributes(nameof(TabView.TabEndHeaderTemplate), + new CategoryAttribute(Properties.Resources.CategoryCommon), + new EditorBrowsableAttribute(EditorBrowsableState.Advanced) + ); + b.AddCustomAttributes(nameof(TabView.TabStartHeader), new CategoryAttribute(Properties.Resources.CategoryCommon)); + b.AddCustomAttributes(nameof(TabView.TabStartHeaderTemplate), + new CategoryAttribute(Properties.Resources.CategoryCommon), + new EditorBrowsableAttribute(EditorBrowsableState.Advanced) + ); + b.AddCustomAttributes(new ToolboxCategoryAttribute(ToolboxCategoryPaths.Toolkit, false)); + } + ); + } + } +} diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/HeaderedTextBlock/HeaderedTextBlock.Properties.cs b/Microsoft.Toolkit.Uwp.UI.Controls/HeaderedTextBlock/HeaderedTextBlock.Properties.cs new file mode 100644 index 00000000000..7528591fc2b --- /dev/null +++ b/Microsoft.Toolkit.Uwp.UI.Controls/HeaderedTextBlock/HeaderedTextBlock.Properties.cs @@ -0,0 +1,172 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; + +namespace Microsoft.Toolkit.Uwp.UI.Controls +{ + /// + /// Defines the properties for the control. + /// + public partial class HeaderedTextBlock + { + /// + /// Defines the dependency property. + /// + public static readonly DependencyProperty HeaderTemplateProperty = DependencyProperty.Register( + nameof(HeaderTemplate), + typeof(DataTemplate), + typeof(HeaderedTextBlock), + new PropertyMetadata(null)); + + /// + /// Defines the dependency property. + /// + public static readonly DependencyProperty TextStyleProperty = DependencyProperty.Register( + nameof(TextStyle), + typeof(Style), + typeof(HeaderedTextBlock), + new PropertyMetadata(null)); + + /// + /// Defines the dependency property. + /// + public static readonly DependencyProperty HeaderProperty = DependencyProperty.Register( + nameof(Header), + typeof(string), + typeof(HeaderedTextBlock), + new PropertyMetadata(null, (d, e) => { ((HeaderedTextBlock)d).UpdateVisibility(); })); + + /// + /// Defines the dependency property. + /// + public static readonly DependencyProperty TextProperty = DependencyProperty.Register( + nameof(Text), + typeof(string), + typeof(HeaderedTextBlock), + new PropertyMetadata(null, (d, e) => { ((HeaderedTextBlock)d).UpdateVisibility(); })); + + /// + /// Defines the dependency property. + /// + public static readonly DependencyProperty OrientationProperty = DependencyProperty.Register( + nameof(Orientation), + typeof(Orientation), + typeof(HeaderedTextBlock), + new PropertyMetadata(Orientation.Vertical, (d, e) => { ((HeaderedTextBlock)d).UpdateForOrientation((Orientation)e.NewValue); })); + + /// + /// Defines the dependency property. + /// + public static readonly DependencyProperty HideTextIfEmptyProperty = DependencyProperty.Register( + nameof(HideTextIfEmpty), + typeof(bool), + typeof(HeaderedTextBlock), + new PropertyMetadata(false, (d, e) => { ((HeaderedTextBlock)d).UpdateVisibility(); })); + + /// + /// Gets or sets the header style. + /// + public DataTemplate HeaderTemplate + { + get + { + return (DataTemplate)GetValue(HeaderTemplateProperty); + } + + set + { + SetValue(HeaderTemplateProperty, value); + } + } + + /// + /// Gets or sets the text style. + /// + public Style TextStyle + { + get + { + return (Style)GetValue(TextStyleProperty); + } + + set + { + SetValue(TextStyleProperty, value); + } + } + + /// + /// Gets or sets the header. + /// + public string Header + { + get + { + return (string)GetValue(HeaderProperty); + } + + set + { + SetValue(HeaderProperty, value); + } + } + + /// + /// Gets or sets the text. + /// + public string Text + { + get + { + return (string)GetValue(TextProperty); + } + + set + { + SetValue(TextProperty, value); + } + } + + /// + /// Gets the collection of inline text elements within a Windows.UI.Xaml.Controls.TextBlock. + /// + /// + /// A collection that holds all inline text elements from the Windows.UI.Xaml.Controls.TextBlock. The default is an empty collection. + public InlineCollectionWrapper Inlines { get; } = new InlineCollectionWrapper(); + + /// + /// Gets or sets the orientation. + /// + public Orientation Orientation + { + get + { + return (Orientation)GetValue(OrientationProperty); + } + + set + { + SetValue(OrientationProperty, value); + } + } + + /// + /// Gets or sets a value indicating whether the Text TextBlock is hidden if its value is empty + /// + public bool HideTextIfEmpty + { + get + { + return (bool)GetValue(HideTextIfEmptyProperty); + } + + set + { + SetValue(HideTextIfEmptyProperty, value); + } + } + } +} \ No newline at end of file diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/HeaderedTextBlock/HeaderedTextBlock.cs b/Microsoft.Toolkit.Uwp.UI.Controls/HeaderedTextBlock/HeaderedTextBlock.cs new file mode 100644 index 00000000000..b30dfea1d3d --- /dev/null +++ b/Microsoft.Toolkit.Uwp.UI.Controls/HeaderedTextBlock/HeaderedTextBlock.cs @@ -0,0 +1,76 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Markup; + +namespace Microsoft.Toolkit.Uwp.UI.Controls +{ + /// + /// Defines a control for providing a header for read-only text. + /// + [TemplatePart(Name = "HeaderContentPresenter", Type = typeof(ContentPresenter))] + [ContentProperty(Name = nameof(Inlines))] + [Obsolete("The HeaderedTextBlock has been replaced with the more generic HeaderedContentControl.")] + public partial class HeaderedTextBlock : Control + { + private ContentPresenter _headerContentPresenter; + private TextBlock _textContent; + + /// + /// Initializes a new instance of the class. + /// + public HeaderedTextBlock() + { + DefaultStyleKey = typeof(HeaderedTextBlock); + } + + /// + /// Called when applying the control template. + /// + protected override void OnApplyTemplate() + { + base.OnApplyTemplate(); + + _headerContentPresenter = GetTemplateChild("HeaderContentPresenter") as ContentPresenter; + _textContent = GetTemplateChild("TextContent") as TextBlock; + + UpdateVisibility(); + Inlines.AddItemsToTextBlock(_textContent); + UpdateForOrientation(this.Orientation); + } + + private void UpdateVisibility() + { + if (_headerContentPresenter != null) + { + _headerContentPresenter.Visibility = _headerContentPresenter.Content == null + ? Visibility.Collapsed + : Visibility.Visible; + } + + if (_textContent != null) + { + _textContent.Visibility = string.IsNullOrWhiteSpace(_textContent.Text) && HideTextIfEmpty + ? Visibility.Collapsed + : Visibility.Visible; + } + } + + private void UpdateForOrientation(Orientation orientationValue) + { + switch (orientationValue) + { + case Orientation.Vertical: + VisualStateManager.GoToState(this, "Vertical", true); + break; + case Orientation.Horizontal: + VisualStateManager.GoToState(this, "Horizontal", true); + break; + } + } + } +} \ No newline at end of file diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/HeaderedTextBlock/HeaderedTextBlock.xaml b/Microsoft.Toolkit.Uwp.UI.Controls/HeaderedTextBlock/HeaderedTextBlock.xaml new file mode 100644 index 00000000000..6f94a07ba82 --- /dev/null +++ b/Microsoft.Toolkit.Uwp.UI.Controls/HeaderedTextBlock/HeaderedTextBlock.xaml @@ -0,0 +1,60 @@ + + + + + + + \ No newline at end of file diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/Microsoft.Toolkit.Uwp.UI.Controls.csproj b/Microsoft.Toolkit.Uwp.UI.Controls/Microsoft.Toolkit.Uwp.UI.Controls.csproj index 9b240477475..6174415e0f3 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls/Microsoft.Toolkit.Uwp.UI.Controls.csproj +++ b/Microsoft.Toolkit.Uwp.UI.Controls/Microsoft.Toolkit.Uwp.UI.Controls.csproj @@ -17,6 +17,7 @@ - GridSplitter: A the control that redistributes space between columns or rows of a Grid control. - HeaderedContentControl: Provides a header to content. - HeaderedItemsControl: Provides a header to items. + - HeaderedTextBlock: Provide a header for read-only text. - ImageCropper: ImageCropper control allows user to crop image freely. - ImageEx: Images are downloaded asynchronously showing a load indicator and can be stored in a local cache. - InAppNotification: Show local notifications in your application. diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/Microsoft.Toolkit.Uwp.UI.Controls.csproj.DotSettings b/Microsoft.Toolkit.Uwp.UI.Controls/Microsoft.Toolkit.Uwp.UI.Controls.csproj.DotSettings index 8a263d98309..0dd5cea5b9e 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls/Microsoft.Toolkit.Uwp.UI.Controls.csproj.DotSettings +++ b/Microsoft.Toolkit.Uwp.UI.Controls/Microsoft.Toolkit.Uwp.UI.Controls.csproj.DotSettings @@ -5,6 +5,7 @@ True True True + True True True True diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/Strings/en-US/Resources.resw b/Microsoft.Toolkit.Uwp.UI.Controls/Strings/en-US/Resources.resw index d3b003e8b80..66cce5b66ab 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls/Strings/en-US/Resources.resw +++ b/Microsoft.Toolkit.Uwp.UI.Controls/Strings/en-US/Resources.resw @@ -213,6 +213,14 @@ Notification The landmark name for the InAppNotification control. It is said by the narrator when using landmark navigation. + + Close tab + Narrator Resource for TabView Close Button. + + + Close tab + Tooltip for TabView Close Button. + Remove Label for TokenizingTextBox MenuFlyout 'Remove' option. diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabClosingEventArgs.cs b/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabClosingEventArgs.cs new file mode 100644 index 00000000000..893776ff0be --- /dev/null +++ b/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabClosingEventArgs.cs @@ -0,0 +1,36 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.ComponentModel; + +namespace Microsoft.Toolkit.Uwp.UI.Controls +{ + /// + /// Event arguments for event. + /// + public class TabClosingEventArgs : CancelEventArgs + { + /// + /// Initializes a new instance of the class. + /// + /// Item being closed. + /// container being closed. + public TabClosingEventArgs(object item, TabViewItem tab) + { + Item = item; + Tab = tab; + } + + /// + /// Gets the Item being closed. + /// + public object Item { get; private set; } + + /// + /// Gets the Tab being closed. + /// + public TabViewItem Tab { get; private set; } + } +} \ No newline at end of file diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabDraggedOutsideEventArgs.cs b/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabDraggedOutsideEventArgs.cs new file mode 100644 index 00000000000..dcf351aab9b --- /dev/null +++ b/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabDraggedOutsideEventArgs.cs @@ -0,0 +1,35 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; + +namespace Microsoft.Toolkit.Uwp.UI.Controls +{ + /// + /// A class used by the TabDraggedOutside Event + /// + public class TabDraggedOutsideEventArgs : EventArgs + { + /// + /// Initializes a new instance of the class. + /// + /// data context of element dragged + /// container being dragged. + public TabDraggedOutsideEventArgs(object item, TabViewItem tab) + { + Item = item; + Tab = tab; + } + + /// + /// Gets or sets the Item/Data Context of the item being dragged outside of the . + /// + public object Item { get; set; } + + /// + /// Gets the Tab being dragged outside of the . + /// + public TabViewItem Tab { get; private set; } + } +} diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.HeaderLayout.cs b/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.HeaderLayout.cs new file mode 100644 index 00000000000..16885700b35 --- /dev/null +++ b/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.HeaderLayout.cs @@ -0,0 +1,221 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using Windows.UI.Xaml; + +namespace Microsoft.Toolkit.Uwp.UI.Controls +{ + /// + /// TabView methods related to calculating the width of the Headers. + /// + public partial class TabView + { + // Attached property for storing widths of tabs if set by other means during layout. + private static double GetOriginalWidth(TabViewItem obj) + { + return (double)obj.GetValue(OriginalWidthProperty); + } + + private static void SetOriginalWidth(TabViewItem obj, double value) + { + obj.SetValue(OriginalWidthProperty, value); + } + + // Using a DependencyProperty as the backing store for MyProperty. This enables animation, styling, binding, etc... + private static readonly DependencyProperty OriginalWidthProperty = + DependencyProperty.RegisterAttached("OriginalWidth", typeof(double), typeof(TabView), new PropertyMetadata(null)); + + private static void OnLayoutEffectingPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args) + { + var tabview = sender as TabView; + if (tabview != null && tabview._hasLoaded) + { + tabview.TabView_SizeChanged(tabview, null); + } + } + + private void TabView_SizeChanged(object sender, SizeChangedEventArgs e) + { + // We need to do this calculation here in Size Changed as the + // Columns don't have their Actual Size calculated in Measure or Arrange. + if (_hasLoaded && _tabViewContainer != null) + { + // Look for our special columns to calculate size of other 'stuff' + var taken = _tabViewContainer.ColumnDefinitions.Sum(cd => GetIgnoreColumn(cd) ? 0 : cd.ActualWidth); + + // Get the column we want to work on for available space + var tabc = _tabViewContainer.ColumnDefinitions.FirstOrDefault(cd => GetConstrainColumn(cd)); + if (tabc != null) + { + var available = ActualWidth - taken; + var required = 0.0; + var mintabwidth = double.MaxValue; + + if (TabWidthBehavior == TabWidthMode.Actual) + { + if (_tabScroller != null) + { + // If we have a scroll container, get its size. + required = _tabScroller.ExtentWidth; + } + + // Restore original widths + foreach (var item in Items) + { + var tab = ContainerFromItem(item) as TabViewItem; + if (tab == null) + { + continue; // container not generated yet + } + + if (tab.ReadLocalValue(OriginalWidthProperty) != DependencyProperty.UnsetValue) + { + tab.Width = GetOriginalWidth(tab); + } + } + } + else if (available > 0) + { + // Calculate the width for each tab from the provider and determine how much space they take. + foreach (var item in Items) + { + var tab = ContainerFromItem(item) as TabViewItem; + if (tab == null) + { + continue; // container not generated yet + } + + mintabwidth = Math.Min(mintabwidth, tab.MinWidth); + + double width = double.NaN; + + switch (TabWidthBehavior) + { + case TabWidthMode.Equal: + width = ProvideEqualWidth(tab, item, available); + break; + case TabWidthMode.Compact: + width = ProvideCompactWidth(tab, item, available); + break; + } + + if (tab.ReadLocalValue(OriginalWidthProperty) == DependencyProperty.UnsetValue) + { + SetOriginalWidth(tab, tab.Width); + } + + if (width > double.Epsilon) + { + tab.Width = width; + required += Math.Max(Math.Min(width, tab.MaxWidth), tab.MinWidth); + } + else + { + tab.Width = GetOriginalWidth(tab); + required += tab.ActualWidth; + } + } + } + else + { + // Fix negative bounds. + available = 0.0; + + // Still need to determine a 'minimum' width (if available) + // TODO: Consolidate this logic with above better? + foreach (var item in Items) + { + var tab = ContainerFromItem(item) as TabViewItem; + if (tab == null) + { + continue; // container not generated yet + } + + mintabwidth = Math.Min(mintabwidth, tab.MinWidth); + } + } + + if (!(mintabwidth < double.MaxValue)) + { + mintabwidth = 0.0; // No Containers, no visual, 0 size. + } + + if (available > mintabwidth) + { + // Constrain the column based on our required and available space + tabc.MaxWidth = available; + } + + //// TODO: If it's less, should we move the selected tab to only be the one shown by default? + + if (available <= mintabwidth || Math.Abs(available - mintabwidth) < double.Epsilon) + { + tabc.Width = new GridLength(mintabwidth); + } + else if (required >= available) + { + // Fix size as we don't have enough space for all the tabs. + tabc.Width = new GridLength(available); + } + else + { + // We haven't filled up our space, so we want to expand to take as much as needed. + tabc.Width = GridLength.Auto; + } + } + } + } + + private double ProvideEqualWidth(TabViewItem tab, object item, double availableWidth) + { + if (double.IsNaN(SelectedTabWidth)) + { + if (Items.Count <= 1) + { + return availableWidth; + } + + return Math.Max(tab.MinWidth, availableWidth / Items.Count); + } + else if (Items.Count() <= 1) + { + // Default case of a single tab, make it full size. + return Math.Min(SelectedTabWidth, availableWidth); + } + else + { + var width = (availableWidth - SelectedTabWidth) / (Items.Count - 1); + + // Constrain between Min and Selected (Max) + if (width < tab.MinWidth) + { + width = tab.MinWidth; + } + else if (width > SelectedTabWidth) + { + width = SelectedTabWidth; + } + + // If it's selected make it full size, otherwise whatever the size should be. + return tab.IsSelected + ? Math.Min(SelectedTabWidth, availableWidth) + : width; + } + } + + private double ProvideCompactWidth(TabViewItem tab, object item, double availableWidth) + { + // If we're selected and have a value for that, then just return that. + if (tab.IsSelected && !double.IsNaN(SelectedTabWidth)) + { + return SelectedTabWidth; + } + + // Otherwise use min size. + return tab.MinWidth; + } + } +} diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.ItemSources.cs b/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.ItemSources.cs new file mode 100644 index 00000000000..61f61623b6f --- /dev/null +++ b/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.ItemSources.cs @@ -0,0 +1,115 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Reflection; +using Windows.Foundation.Collections; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls.Primitives; + +namespace Microsoft.Toolkit.Uwp.UI.Controls +{ + /// + /// TabView methods related to tracking Items and ItemsSource changes. + /// + public partial class TabView + { + // Temporary tracking of previous collections for removing events. + private MethodInfo _removeItemsSourceMethod; + + /// + protected override void OnItemsChanged(object e) + { + IVectorChangedEventArgs args = (IVectorChangedEventArgs)e; + + base.OnItemsChanged(e); + + if (args.CollectionChange == CollectionChange.ItemRemoved && SelectedIndex == -1) + { + // If we remove the selected item we should select the previous item + int startIndex = (int)args.Index + 1; + if (startIndex > Items.Count) + { + startIndex = 0; + } + + SelectedIndex = FindNextTabIndex(startIndex, -1); + } + + // Update Sizing (in case there are less items now) + TabView_SizeChanged(this, null); + } + + private void ItemContainerGenerator_ItemsChanged(object sender, ItemsChangedEventArgs e) + { + var action = (CollectionChange)e.Action; + if (action == CollectionChange.Reset) + { + // Reset collection to reload later. + _hasLoaded = false; + } + } + + private void SetInitialSelection() + { + if (SelectedItem == null) + { + // If we have an index, but didn't get the selection, make the selection + if (SelectedIndex >= 0 && SelectedIndex < Items.Count) + { + SelectedItem = Items[SelectedIndex]; + } + + // Otherwise, select the first item by default + else if (Items.Count >= 1) + { + SelectedItem = Items[0]; + } + } + } + + // Finds the next visible & enabled tab index. + private int FindNextTabIndex(int startIndex, int direction) + { + int index = startIndex; + if (direction != 0) + { + for (int i = 0; i < Items.Count; i++) + { + index += direction; + + if (index >= Items.Count) + { + index = 0; + } + else if (index < 0) + { + index = Items.Count - 1; + } + + var tabItem = ContainerFromIndex(index) as TabViewItem; + if (tabItem != null && tabItem.IsEnabled && tabItem.Visibility == Visibility.Visible) + { + break; + } + } + } + + return index; + } + + private void ItemsSource_PropertyChanged(DependencyObject sender, DependencyProperty dp) + { + // Use reflection to store a 'Remove' method of any possible collection in ItemsSource + // Cache for efficiency later. + if (ItemsSource != null) + { + _removeItemsSourceMethod = ItemsSource.GetType().GetMethod("Remove"); + } + else + { + _removeItemsSourceMethod = null; + } + } + } +} diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.Properties.cs b/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.Properties.cs new file mode 100644 index 00000000000..5d33b33f1cc --- /dev/null +++ b/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.Properties.cs @@ -0,0 +1,245 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; + +namespace Microsoft.Toolkit.Uwp.UI.Controls +{ + /// + /// TabView properties. + /// + public partial class TabView + { + /// + /// Gets or sets the content to appear to the left or above the tab strip. + /// + public object TabStartHeader + { + get { return (object)GetValue(TabStartHeaderProperty); } + set { SetValue(TabStartHeaderProperty, value); } + } + + /// + /// Identifies the dependency property. + /// + /// The identifier for the dependency property. + public static readonly DependencyProperty TabStartHeaderProperty = + DependencyProperty.Register(nameof(TabStartHeader), typeof(object), typeof(TabView), new PropertyMetadata(null, OnLayoutEffectingPropertyChanged)); + + /// + /// Gets or sets the for the . + /// + public DataTemplate TabStartHeaderTemplate + { + get { return (DataTemplate)GetValue(TabStartHeaderTemplateProperty); } + set { SetValue(TabStartHeaderTemplateProperty, value); } + } + + /// + /// Identifies the dependency property. + /// + /// The identifier for the dependency property. + public static readonly DependencyProperty TabStartHeaderTemplateProperty = + DependencyProperty.Register(nameof(TabStartHeaderTemplate), typeof(DataTemplate), typeof(TabView), new PropertyMetadata(null, OnLayoutEffectingPropertyChanged)); + + /// + /// Gets or sets the content to appear next to the tab strip. + /// + public object TabActionHeader + { + get { return (object)GetValue(TabActionHeaderProperty); } + set { SetValue(TabActionHeaderProperty, value); } + } + + /// + /// Identifies the dependency property. + /// + /// The identifier for the dependency property. + public static readonly DependencyProperty TabActionHeaderProperty = + DependencyProperty.Register(nameof(TabActionHeader), typeof(object), typeof(TabView), new PropertyMetadata(null, OnLayoutEffectingPropertyChanged)); + + /// + /// Gets or sets the for the . + /// + public DataTemplate TabActionHeaderTemplate + { + get { return (DataTemplate)GetValue(TabActionHeaderTemplateProperty); } + set { SetValue(TabActionHeaderTemplateProperty, value); } + } + + /// + /// Identifies the dependency property. + /// + /// The identifier for the dependency property. + public static readonly DependencyProperty TabActionHeaderTemplateProperty = + DependencyProperty.Register(nameof(TabActionHeaderTemplate), typeof(DataTemplate), typeof(TabView), new PropertyMetadata(null, OnLayoutEffectingPropertyChanged)); + + /// + /// Gets or sets the content to appear to the right or below the tab strip. + /// + public object TabEndHeader + { + get { return (object)GetValue(TabEndHeaderProperty); } + set { SetValue(TabEndHeaderProperty, value); } + } + + /// + /// Identifies the dependency property. + /// + /// The identifier for the dependency property. + public static readonly DependencyProperty TabEndHeaderProperty = + DependencyProperty.Register(nameof(TabEndHeader), typeof(object), typeof(TabView), new PropertyMetadata(null, OnLayoutEffectingPropertyChanged)); + + /// + /// Gets or sets the for the . + /// + public DataTemplate TabEndHeaderTemplate + { + get { return (DataTemplate)GetValue(TabEndHeaderTemplateProperty); } + set { SetValue(TabEndHeaderTemplateProperty, value); } + } + + /// + /// Identifies the dependency property. + /// + /// The identifier for the dependency property. + public static readonly DependencyProperty TabEndHeaderTemplateProperty = + DependencyProperty.Register(nameof(TabEndHeaderTemplate), typeof(DataTemplate), typeof(TabView), new PropertyMetadata(null, OnLayoutEffectingPropertyChanged)); + + /// + /// Gets or sets the default for the . + /// + public DataTemplate ItemHeaderTemplate + { + get { return (DataTemplate)GetValue(ItemHeaderTemplateProperty); } + set { SetValue(ItemHeaderTemplateProperty, value); } + } + + /// + /// Identifies the dependency property. + /// + /// The identifier for the dependency property. + public static readonly DependencyProperty ItemHeaderTemplateProperty = + DependencyProperty.Register(nameof(ItemHeaderTemplate), typeof(DataTemplate), typeof(TabView), new PropertyMetadata(null, OnLayoutEffectingPropertyChanged)); + + /// + /// Gets or sets a value indicating whether by default a Tab can be closed or not if no value to is provided. + /// + public bool CanCloseTabs + { + get { return (bool)GetValue(CanCloseTabsProperty); } + set { SetValue(CanCloseTabsProperty, value); } + } + + /// + /// Identifies the dependency property. + /// + /// The identifier for the dependency property. + public static readonly DependencyProperty CanCloseTabsProperty = + DependencyProperty.Register(nameof(CanCloseTabs), typeof(bool), typeof(TabView), new PropertyMetadata(false, OnLayoutEffectingPropertyChanged)); + + /// + /// Gets or sets a value indicating whether a Close Button should be included in layout calculations. + /// + public bool IsCloseButtonOverlay + { + get { return (bool)GetValue(IsCloseButtonOverlayProperty); } + set { SetValue(IsCloseButtonOverlayProperty, value); } + } + + /// + /// Identifies the dependency property. + /// + /// The identifier for the dependency property. + public static readonly DependencyProperty IsCloseButtonOverlayProperty = + DependencyProperty.Register(nameof(IsCloseButtonOverlay), typeof(bool), typeof(TabView), new PropertyMetadata(false, OnLayoutEffectingPropertyChanged)); + + /// + /// Gets or sets a value indicating the size of the selected tab. By default this is set to Auto and the selected tab size doesn't change. + /// + public double SelectedTabWidth + { + get { return (double)GetValue(SelectedTabWidthProperty); } + set { SetValue(SelectedTabWidthProperty, value); } + } + + /// + /// Identifies the dependency property. + /// + /// The identifier for the dependency property. + public static readonly DependencyProperty SelectedTabWidthProperty = + DependencyProperty.Register(nameof(SelectedTabWidth), typeof(double), typeof(TabView), new PropertyMetadata(double.NaN, OnLayoutEffectingPropertyChanged)); + + /// + /// Gets or sets the current which determins how tab headers' width behave. + /// + public TabWidthMode TabWidthBehavior + { + get { return (TabWidthMode)GetValue(TabWidthBehaviorProperty); } + set { SetValue(TabWidthBehaviorProperty, value); } + } + + /// + /// Identifies the dependency property. + /// + /// The identifier for the dependency property. + public static readonly DependencyProperty TabWidthBehaviorProperty = + DependencyProperty.Register(nameof(TabWidthBehavior), typeof(TabWidthMode), typeof(TabView), new PropertyMetadata(TabWidthMode.Actual, OnLayoutEffectingPropertyChanged)); + + /// + /// Gets the attached property value to indicate if this grid column should be ignored when calculating header sizes. + /// + /// Grid Column. + /// Boolean indicating if this column is ignored by TabViewHeader logic. + public static bool GetIgnoreColumn(ColumnDefinition obj) + { + return (bool)obj.GetValue(IgnoreColumnProperty); + } + + /// + /// Sets the attached property value for + /// + /// Grid Column. + /// Boolean value + public static void SetIgnoreColumn(ColumnDefinition obj, bool value) + { + obj.SetValue(IgnoreColumnProperty, value); + } + + /// + /// Identifies the attached property. + /// + /// The identifier for the IgnoreColumn attached property. + public static readonly DependencyProperty IgnoreColumnProperty = + DependencyProperty.RegisterAttached("IgnoreColumn", typeof(bool), typeof(TabView), new PropertyMetadata(false)); + + /// + /// Gets the attached value indicating this column should be restricted for the headers. + /// + /// Grid Column. + /// True if this column should be constrained. + public static bool GetConstrainColumn(ColumnDefinition obj) + { + return (bool)obj.GetValue(ConstrainColumnProperty); + } + + /// + /// Sets the attached property value for the + /// + /// Grid Column. + /// Boolean value. + public static void SetConstrainColumn(ColumnDefinition obj, bool value) + { + obj.SetValue(ConstrainColumnProperty, value); + } + + /// + /// Identifies the attached property. + /// + /// The identifier for the ConstrainColumn attached property. + public static readonly DependencyProperty ConstrainColumnProperty = + DependencyProperty.RegisterAttached("ConstrainColumn", typeof(bool), typeof(TabView), new PropertyMetadata(false)); + } +} diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.cs b/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.cs new file mode 100644 index 00000000000..0e86ab398f5 --- /dev/null +++ b/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.cs @@ -0,0 +1,320 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.ComponentModel; +using System.Linq; +using Microsoft.Toolkit.Uwp.UI.Extensions; +using Windows.ApplicationModel.DataTransfer; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Controls.Primitives; +using Windows.UI.Xaml.Data; + +namespace Microsoft.Toolkit.Uwp.UI.Controls +{ + /// + /// TabView is a control for displaying a set of tabs and their content. + /// + [Obsolete("Please migrate to the TabView control from WinUI, this control will be removed in a future release. https://aka.ms/winui")] + [TemplatePart(Name = TabContentPresenterName, Type = typeof(ContentPresenter))] + [TemplatePart(Name = TabViewContainerName, Type = typeof(Grid))] + [TemplatePart(Name = TabsItemsPresenterName, Type = typeof(ItemsPresenter))] + [TemplatePart(Name = TabsScrollViewerName, Type = typeof(ScrollViewer))] + [TemplatePart(Name = TabsScrollBackButtonName, Type = typeof(ButtonBase))] + [TemplatePart(Name = TabsScrollForwardButtonName, Type = typeof(ButtonBase))] + public partial class TabView : ListViewBase + { + private const int ScrollAmount = 50; // TODO: Should this be based on TabWidthMode + + private const string TabContentPresenterName = "TabContentPresenter"; + private const string TabViewContainerName = "TabViewContainer"; + private const string TabsItemsPresenterName = "TabsItemsPresenter"; + private const string TabsScrollViewerName = "ScrollViewer"; + private const string TabsScrollBackButtonName = "ScrollBackButton"; + private const string TabsScrollForwardButtonName = "ScrollForwardButton"; + + private ContentPresenter _tabContentPresenter; + private Grid _tabViewContainer; + private ItemsPresenter _tabItemsPresenter; + private ScrollViewer _tabScroller; + private ButtonBase _tabScrollBackButton; + private ButtonBase _tabScrollForwardButton; + + private bool _hasLoaded; + private bool _isDragging; + + /// + /// Initializes a new instance of the class. + /// + public TabView() + { + DefaultStyleKey = typeof(TabView); + + // Container Generation Hooks + RegisterPropertyChangedCallback(ItemsSourceProperty, ItemsSource_PropertyChanged); + ItemContainerGenerator.ItemsChanged += ItemContainerGenerator_ItemsChanged; + + // Drag and Layout Hooks + DragItemsStarting += TabView_DragItemsStarting; + DragItemsCompleted += TabView_DragItemsCompleted; + SizeChanged += TabView_SizeChanged; + + // Selection Hook + SelectionChanged += TabView_SelectionChanged; + } + + /// + /// Occurs when a tab is dragged by the user outside of the . Generally, this paradigm is used to create a new-window with the torn-off tab. + /// The creation and handling of the new-window is left to the app's developer. + /// + public event EventHandler TabDraggedOutside; + + /// + /// Occurs when a tab's Close button is clicked. Set to true to prevent automatic Tab Closure. + /// + public event EventHandler TabClosing; + + /// + protected override DependencyObject GetContainerForItemOverride() => new TabViewItem(); + + /// + protected override bool IsItemItsOwnContainerOverride(object item) + { + return item is TabViewItem; + } + + /// + protected override void OnApplyTemplate() + { + base.OnApplyTemplate(); + + if (_tabItemsPresenter != null) + { + _tabItemsPresenter.SizeChanged -= TabView_SizeChanged; + } + + if (_tabScroller != null) + { + _tabScroller.Loaded -= ScrollViewer_Loaded; + } + + _tabContentPresenter = GetTemplateChild(TabContentPresenterName) as ContentPresenter; + _tabViewContainer = GetTemplateChild(TabViewContainerName) as Grid; + _tabItemsPresenter = GetTemplateChild(TabsItemsPresenterName) as ItemsPresenter; + _tabScroller = GetTemplateChild(TabsScrollViewerName) as ScrollViewer; + + if (_tabItemsPresenter != null) + { + _tabItemsPresenter.SizeChanged += TabView_SizeChanged; + } + + if (_tabScroller != null) + { + _tabScroller.Loaded += ScrollViewer_Loaded; + } + } + + private void ScrollViewer_Loaded(object sender, RoutedEventArgs e) + { + _tabScroller.Loaded -= ScrollViewer_Loaded; + + if (_tabScrollBackButton != null) + { + _tabScrollBackButton.Click -= ScrollTabBackButton_Click; + } + + if (_tabScrollForwardButton != null) + { + _tabScrollForwardButton.Click -= ScrollTabForwardButton_Click; + } + + _tabScrollBackButton = _tabScroller.FindDescendantByName(TabsScrollBackButtonName) as ButtonBase; + _tabScrollForwardButton = _tabScroller.FindDescendantByName(TabsScrollForwardButtonName) as ButtonBase; + + if (_tabScrollBackButton != null) + { + _tabScrollBackButton.Click += ScrollTabBackButton_Click; + } + + if (_tabScrollForwardButton != null) + { + _tabScrollForwardButton.Click += ScrollTabForwardButton_Click; + } + } + + private void ScrollTabBackButton_Click(object sender, RoutedEventArgs e) + { + _tabScroller.ChangeView(Math.Max(0, _tabScroller.HorizontalOffset - ScrollAmount), null, null); + } + + private void ScrollTabForwardButton_Click(object sender, RoutedEventArgs e) + { + _tabScroller.ChangeView(Math.Min(_tabScroller.ScrollableWidth, _tabScroller.HorizontalOffset + ScrollAmount), null, null); + } + + private void TabView_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + if (_isDragging) + { + // Skip if we're dragging, we'll reset when we're done. + return; + } + + if (_tabContentPresenter != null) + { + if (SelectedItem == null) + { + _tabContentPresenter.Content = null; + _tabContentPresenter.ContentTemplate = null; + } + else + { + if (ContainerFromItem(SelectedItem) is TabViewItem container) + { + _tabContentPresenter.Content = container.Content; + _tabContentPresenter.ContentTemplate = container.ContentTemplate; + } + } + } + + // If our width can be effected by the selection, need to run algorithm. + if (!double.IsNaN(SelectedTabWidth)) + { + TabView_SizeChanged(sender, null); + } + } + + /// + protected override void PrepareContainerForItemOverride(DependencyObject element, object item) + { + base.PrepareContainerForItemOverride(element, item); + + var tabitem = element as TabViewItem; + + tabitem.Loaded -= TabViewItem_Loaded; + tabitem.Closing -= TabViewItem_Closing; + tabitem.Loaded += TabViewItem_Loaded; + tabitem.Closing += TabViewItem_Closing; + + if (tabitem.Header == null) + { + tabitem.Header = item; + } + + if (tabitem.HeaderTemplate == null) + { + var headertemplatebinding = new Binding() + { + Source = this, + Path = new PropertyPath(nameof(ItemHeaderTemplate)), + Mode = BindingMode.OneWay + }; + tabitem.SetBinding(TabViewItem.HeaderTemplateProperty, headertemplatebinding); + } + + if (tabitem.IsClosable != true && tabitem.ReadLocalValue(TabViewItem.IsClosableProperty) == DependencyProperty.UnsetValue) + { + var iscloseablebinding = new Binding() + { + Source = this, + Path = new PropertyPath(nameof(CanCloseTabs)), + Mode = BindingMode.OneWay, + }; + tabitem.SetBinding(TabViewItem.IsClosableProperty, iscloseablebinding); + } + } + + private void TabViewItem_Loaded(object sender, RoutedEventArgs e) + { + var tabitem = sender as TabViewItem; + + tabitem.Loaded -= TabViewItem_Loaded; + + // Only need to do this once. + if (!_hasLoaded) + { + _hasLoaded = true; + + // Need to set a tab's selection on load, otherwise ListView resets to null. + SetInitialSelection(); + + // Need to make sure ContentPresenter is set to content based on selection. + TabView_SelectionChanged(this, null); + + // Need to make sure we've registered our removal method. + ItemsSource_PropertyChanged(this, null); + + // Make sure we complete layout now. + TabView_SizeChanged(this, null); + } + } + + private void TabViewItem_Closing(object sender, TabClosingEventArgs e) + { + var item = ItemFromContainer(e.Tab); + + var args = new TabClosingEventArgs(item, e.Tab); + TabClosing?.Invoke(this, args); + + if (!args.Cancel) + { + if (ItemsSource != null) + { + _removeItemsSourceMethod?.Invoke(ItemsSource, new object[] { item }); + } + else + { + Items.Remove(item); + } + } + } + + private void TabView_DragItemsStarting(object sender, DragItemsStartingEventArgs e) + { + // Keep track of drag so we don't modify content until done. + _isDragging = true; + } + + private void TabView_DragItemsCompleted(ListViewBase sender, DragItemsCompletedEventArgs args) + { + _isDragging = false; + + // args.DropResult == None when outside of area (e.g. create new window) + if (args.DropResult == DataPackageOperation.None) + { + var item = args.Items.FirstOrDefault(); + var tab = ContainerFromItem(item) as TabViewItem; + + if (tab == null && item is FrameworkElement fe) + { + tab = fe.FindParent(); + } + + if (tab == null) + { + // We still don't have a TabViewItem, most likely is a static TabViewItem in the template being dragged and not selected. + // This is a fallback scenario for static tabs. + // Note: This can be wrong if two TabViewItems share the exact same Content (i.e. a string), this should be unlikely in any practical scenario. + for (int i = 0; i < Items.Count; i++) + { + var tabItem = ContainerFromIndex(i) as TabViewItem; + if (ReferenceEquals(tabItem.Content, item)) + { + tab = tabItem; + break; + } + } + } + + TabDraggedOutside?.Invoke(this, new TabDraggedOutsideEventArgs(item, tab)); + } + else + { + // If dragging the active tab, there's an issue with the CP blanking. + TabView_SelectionChanged(this, null); + } + } + } +} diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.xaml b/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.xaml new file mode 100644 index 00000000000..d3310aadf06 --- /dev/null +++ b/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.xaml @@ -0,0 +1,736 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + 0,0,8,0 + 8,0,-8,0 + 0,1,1,0 + 16 + 48 + 40 + NaN + 32 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabViewItem.Properties.cs b/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabViewItem.Properties.cs new file mode 100644 index 00000000000..3ce0f3e5483 --- /dev/null +++ b/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabViewItem.Properties.cs @@ -0,0 +1,79 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; + +namespace Microsoft.Toolkit.Uwp.UI.Controls +{ + /// + /// Item Container for a . + /// + public partial class TabViewItem + { + /// + /// Gets or sets the header content for the tab. + /// + public object Header + { + get { return (object)GetValue(HeaderProperty); } + set { SetValue(HeaderProperty, value); } + } + + /// + /// Identifies the dependency property. + /// + /// The identifier for the dependency property. + public static readonly DependencyProperty HeaderProperty = + DependencyProperty.Register(nameof(Header), typeof(object), typeof(TabViewItem), new PropertyMetadata(null)); + + /// + /// Gets or sets the icon to appear in the tab header. + /// + public IconElement Icon + { + get { return (IconElement)GetValue(IconProperty); } + set { SetValue(IconProperty, value); } + } + + /// + /// Identifies the dependency property. + /// + /// The identifier for the dependency property. + public static readonly DependencyProperty IconProperty = + DependencyProperty.Register(nameof(Icon), typeof(IconElement), typeof(TabViewItem), new PropertyMetadata(null)); + + /// + /// Gets or sets the template to override for the tab header. + /// + public DataTemplate HeaderTemplate + { + get { return (DataTemplate)GetValue(HeaderTemplateProperty); } + set { SetValue(HeaderTemplateProperty, value); } + } + + /// + /// Identifies the dependency property. + /// + /// The identifier for the dependency property. + public static readonly DependencyProperty HeaderTemplateProperty = + DependencyProperty.Register(nameof(HeaderTemplate), typeof(DataTemplate), typeof(TabViewItem), new PropertyMetadata(null)); + + /// + /// Gets or sets a value indicating whether the tab can be closed by the user with the close button. + /// + public bool IsClosable + { + get { return (bool)GetValue(IsClosableProperty); } + set { SetValue(IsClosableProperty, value); } + } + + /// + /// Identifies the dependency property. + /// + /// The identifier for the dependency property. + public static readonly DependencyProperty IsClosableProperty = + DependencyProperty.Register(nameof(IsClosable), typeof(bool), typeof(TabViewItem), new PropertyMetadata(null)); + } +} diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabViewItem.cs b/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabViewItem.cs new file mode 100644 index 00000000000..69a968fd839 --- /dev/null +++ b/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabViewItem.cs @@ -0,0 +1,116 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using Windows.Devices.Input; +using Windows.System; +using Windows.UI.Core; +using Windows.UI.Input; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Controls.Primitives; +using Windows.UI.Xaml.Input; + +namespace Microsoft.Toolkit.Uwp.UI.Controls +{ + /// + /// Item Container for a . + /// + [TemplatePart(Name = TabCloseButtonName, Type = typeof(ButtonBase))] + public partial class TabViewItem : ListViewItem + { + private const string TabCloseButtonName = "CloseButton"; + + private ButtonBase _tabCloseButton; + + private bool _isMiddleClick; + + /// + /// Initializes a new instance of the class. + /// + public TabViewItem() + { + DefaultStyleKey = typeof(TabViewItem); + } + + /// + /// Fired when the Tab's close button is clicked. + /// + public event EventHandler Closing; + + /// + protected override void OnApplyTemplate() + { + base.OnApplyTemplate(); + + if (_tabCloseButton != null) + { + _tabCloseButton.Click -= TabCloseButton_Click; + } + + _tabCloseButton = GetTemplateChild(TabCloseButtonName) as ButtonBase; + + if (_tabCloseButton != null) + { + _tabCloseButton.Click += TabCloseButton_Click; + } + } + + /// + protected override void OnPointerPressed(PointerRoutedEventArgs e) + { + _isMiddleClick = false; + + if (e.Pointer.PointerDeviceType == PointerDeviceType.Mouse) + { + PointerPoint pointerPoint = e.GetCurrentPoint(this); + + // Record if middle button is pressed + if (pointerPoint.Properties.IsMiddleButtonPressed) + { + _isMiddleClick = true; + } + + // Disable unwanted behaviour inherited by ListViewItem: + // Disable "Ctrl + Left click" to deselect tab + // Or variant like "Ctrl + Shift + Left click" + // Or "Ctrl + Alt + Left click" + if (pointerPoint.Properties.IsLeftButtonPressed) + { + var ctrl = Window.Current.CoreWindow.GetKeyState(VirtualKey.Control); + if (ctrl.HasFlag(CoreVirtualKeyStates.Down)) + { + // return here so the event won't be picked up by the base class + // but keep this event unhandled so it can be picked up further + return; + } + } + } + + base.OnPointerPressed(e); + } + + /// + protected override void OnPointerReleased(PointerRoutedEventArgs e) + { + base.OnPointerReleased(e); + + // Close on Middle-Click + if (_isMiddleClick) + { + TabCloseButton_Click(this, null); + } + + _isMiddleClick = false; + } + + private void TabCloseButton_Click(object sender, RoutedEventArgs e) + { + if (IsClosable) + { + Closing?.Invoke(this, new TabClosingEventArgs(Content, this)); + } + } + } +} diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabWidthMode.cs b/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabWidthMode.cs new file mode 100644 index 00000000000..65b1ce03844 --- /dev/null +++ b/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabWidthMode.cs @@ -0,0 +1,36 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using Windows.UI.Xaml; + +namespace Microsoft.Toolkit.Uwp.UI.Controls +{ + /// + /// Possible modes for how to layout a Header's Width in the . + /// + public enum TabWidthMode + { + /// + /// Each tab header takes up as much space as it needs. This is similar to how WPF and Visual Studio Code behave. + /// Suggest to keep set to false. + /// is ignored. + /// In this scenario, tab width behavior is effectively turned off. This can be useful when using custom styling or a custom panel for layout of as well. + /// + Actual, + + /// + /// Each tab header will use the minimal space set by on the . + /// Suggest to set the to show more content for the selected item. + /// + Compact, + + /// + /// Each tab header will fill to fit the available space. If is set, that will be used as a Maximum Width. + /// This is similar to how Microsoft Edge behaves when used with the . + /// Suggest to set to true. + /// Suggest to set to 200 and the TabViewItemHeaderMinWidth Resource to 90. + /// + Equal, + } +} diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/Themes/Generic.xaml b/Microsoft.Toolkit.Uwp.UI.Controls/Themes/Generic.xaml index 9c17a3717bd..592fbb45626 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls/Themes/Generic.xaml +++ b/Microsoft.Toolkit.Uwp.UI.Controls/Themes/Generic.xaml @@ -9,6 +9,7 @@ + @@ -26,6 +27,7 @@ + diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/TileControl/TileControl.cs b/Microsoft.Toolkit.Uwp.UI.Controls/TileControl/TileControl.cs index cdc4af642c5..6799439d67a 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls/TileControl/TileControl.cs +++ b/Microsoft.Toolkit.Uwp.UI.Controls/TileControl/TileControl.cs @@ -181,6 +181,13 @@ public class TileControl : ContentControl /// public event EventHandler ImageLoaded; + /// + /// Gets a value indicating whether the platform supports Composition. + /// + [Obsolete("This property is now obsolete and will be removed in a future version of the Toolkit.")] + public static bool IsCompositionSupported => !DesignTimeHelpers.IsRunningInLegacyDesignerMode && + ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 3); // SDK >= 14393 + /// /// Initializes a new instance of the class. /// diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/VisualStudioToolsManifest.xml b/Microsoft.Toolkit.Uwp.UI.Controls/VisualStudioToolsManifest.xml index 27fe2b2f0bc..e2bc71350ef 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls/VisualStudioToolsManifest.xml +++ b/Microsoft.Toolkit.Uwp.UI.Controls/VisualStudioToolsManifest.xml @@ -13,6 +13,7 @@ + @@ -32,6 +33,8 @@ + + diff --git a/Microsoft.Toolkit/Extensions/StringExtensions.cs b/Microsoft.Toolkit/Extensions/StringExtensions.cs index a39030a11a4..5e81855f128 100644 --- a/Microsoft.Toolkit/Extensions/StringExtensions.cs +++ b/Microsoft.Toolkit/Extensions/StringExtensions.cs @@ -86,6 +86,14 @@ public static bool IsDecimal(this string str) /// true if the string contains only letters; otherwise, false. public static bool IsCharacterString(this string str) => Regex.IsMatch(str, CharactersRegex); + /// + /// Returns a string representation of an object. + /// + /// The object to convert. + /// String representation of the object. + [Obsolete("Use value?.ToString() instead. This will be removed in the next release of the toolkit.")] + public static string ToSafeString(this object value) => value?.ToString(); + /// /// Returns a string with HTML comments, scripts, styles, and tags removed. /// From 75da45cb656323cdf2a06c4e7d2e27e379f6b7c0 Mon Sep 17 00:00:00 2001 From: Alexandre Zollinger Chohfi Date: Wed, 19 Aug 2020 19:41:50 -0700 Subject: [PATCH 6/8] Removed TabView/TabViewItem, HeaderedTextBlock, and some other smaller methods marked as Obsolete. --- .../Services/LinkedIn/LinkedInDataProvider.cs | 11 - .../Services/LinkedIn/LinkedInService.cs | 9 - .../Services/Twitter/TwitterDataProvider.cs | 11 - .../Services/Twitter/TwitterService.cs | 9 - .../Services/Weibo/WeiboDataProvider.cs | 11 - .../Services/Weibo/WeiboService.cs | 9 - .../Microsoft.Toolkit.Uwp.SampleApp.csproj | 21 - .../HeaderedTextBlock/HeaderedTextBlock.png | Bin 3308 -> 0 bytes .../HeaderedTextBlockCode.bind | 16 - .../HeaderedTextBlockPage.xaml | 9 - .../HeaderedTextBlockPage.xaml.cs | 18 - .../SamplePages/TabView/TabView.png | Bin 1392 -> 0 bytes .../SamplePages/TabView/TabViewPage.xaml | 19 - .../SamplePages/TabView/TabViewPage.xaml.cs | 73 -- .../SamplePages/TabView/TabViewXaml.bind | 97 --- .../SamplePages/samples.json | 24 - .../ConnectedAnimations/Connected.cs | 16 - .../HeaderedTextBlockMetadata.cs | 49 -- ...soft.Toolkit.Uwp.UI.Controls.Design.csproj | 3 - .../TabViewItemMetadata.cs | 43 - .../TabViewMetadata.cs | 54 -- .../HeaderedTextBlock.Properties.cs | 172 ---- .../HeaderedTextBlock/HeaderedTextBlock.cs | 76 -- .../HeaderedTextBlock/HeaderedTextBlock.xaml | 60 -- .../Microsoft.Toolkit.Uwp.UI.Controls.csproj | 1 - ...Toolkit.Uwp.UI.Controls.csproj.DotSettings | 1 - .../Strings/en-US/Resources.resw | 8 - .../TabView/TabClosingEventArgs.cs | 36 - .../TabView/TabDraggedOutsideEventArgs.cs | 35 - .../TabView/TabView.HeaderLayout.cs | 221 ------ .../TabView/TabView.ItemSources.cs | 115 --- .../TabView/TabView.Properties.cs | 245 ------ .../TabView/TabView.cs | 320 -------- .../TabView/TabView.xaml | 736 ------------------ .../TabView/TabViewItem.Properties.cs | 79 -- .../TabView/TabViewItem.cs | 116 --- .../TabView/TabWidthMode.cs | 36 - .../Themes/Generic.xaml | 2 - .../TileControl/TileControl.cs | 7 - .../VisualStudioToolsManifest.xml | 3 - .../Extensions/StringExtensions.cs | 8 - 41 files changed, 2779 deletions(-) delete mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedTextBlock/HeaderedTextBlock.png delete mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedTextBlock/HeaderedTextBlockCode.bind delete mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedTextBlock/HeaderedTextBlockPage.xaml delete mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedTextBlock/HeaderedTextBlockPage.xaml.cs delete mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabView/TabView.png delete mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabView/TabViewPage.xaml delete mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabView/TabViewPage.xaml.cs delete mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabView/TabViewXaml.bind delete mode 100644 Microsoft.Toolkit.Uwp.UI.Controls.Design/HeaderedTextBlockMetadata.cs delete mode 100644 Microsoft.Toolkit.Uwp.UI.Controls.Design/TabViewItemMetadata.cs delete mode 100644 Microsoft.Toolkit.Uwp.UI.Controls.Design/TabViewMetadata.cs delete mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/HeaderedTextBlock/HeaderedTextBlock.Properties.cs delete mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/HeaderedTextBlock/HeaderedTextBlock.cs delete mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/HeaderedTextBlock/HeaderedTextBlock.xaml delete mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabClosingEventArgs.cs delete mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabDraggedOutsideEventArgs.cs delete mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.HeaderLayout.cs delete mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.ItemSources.cs delete mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.Properties.cs delete mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.cs delete mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.xaml delete mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabViewItem.Properties.cs delete mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabViewItem.cs delete mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabWidthMode.cs diff --git a/Microsoft.Toolkit.Services/Services/LinkedIn/LinkedInDataProvider.cs b/Microsoft.Toolkit.Services/Services/LinkedIn/LinkedInDataProvider.cs index f852688bc57..27c7739c333 100644 --- a/Microsoft.Toolkit.Services/Services/LinkedIn/LinkedInDataProvider.cs +++ b/Microsoft.Toolkit.Services/Services/LinkedIn/LinkedInDataProvider.cs @@ -154,17 +154,6 @@ public async Task LoginAsync() return false; } - /// - /// Log user out of LinkedIn. - /// - [Obsolete("Logout is deprecated, please use LogoutAsync instead.", true)] - public void Logout() - { -#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed - LogoutAsync(); -#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed - } - /// /// Log user out of LinkedIn. /// diff --git a/Microsoft.Toolkit.Services/Services/LinkedIn/LinkedInService.cs b/Microsoft.Toolkit.Services/Services/LinkedIn/LinkedInService.cs index 251e5fb711d..7a79b8fc344 100644 --- a/Microsoft.Toolkit.Services/Services/LinkedIn/LinkedInService.cs +++ b/Microsoft.Toolkit.Services/Services/LinkedIn/LinkedInService.cs @@ -92,15 +92,6 @@ public Task ShareActivityAsync(LinkedInShareRequest share return Provider.ShareDataAsync(shareRequest); } - /// - /// Log user out of LinkedIn. - /// - [Obsolete("Logout is deprecated, please use LogoutAsync instead.", true)] - public void Logout() - { - Provider.Logout(); - } - /// /// Log user out of LinkedIn. /// diff --git a/Microsoft.Toolkit.Services/Services/Twitter/TwitterDataProvider.cs b/Microsoft.Toolkit.Services/Services/Twitter/TwitterDataProvider.cs index a6eda59f07e..41db01d748b 100644 --- a/Microsoft.Toolkit.Services/Services/Twitter/TwitterDataProvider.cs +++ b/Microsoft.Toolkit.Services/Services/Twitter/TwitterDataProvider.cs @@ -273,17 +273,6 @@ public async Task LoginAsync() return false; } - /// - /// Log user out of Twitter. - /// - [Obsolete("Logout is deprecated, please use LogoutAsync instead.", true)] - public void Logout() - { -#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed - LogoutAsync(); -#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed - } - /// /// Log user out of Twitter. /// diff --git a/Microsoft.Toolkit.Services/Services/Twitter/TwitterService.cs b/Microsoft.Toolkit.Services/Services/Twitter/TwitterService.cs index 703657cf2fb..b461458ce8d 100644 --- a/Microsoft.Toolkit.Services/Services/Twitter/TwitterService.cs +++ b/Microsoft.Toolkit.Services/Services/Twitter/TwitterService.cs @@ -400,15 +400,6 @@ public Task LoginAsync() return Provider.LoginAsync(); } - /// - /// Log user out of Twitter. - /// - [Obsolete("Logout is deprecated, please use LogoutAsync instead.", true)] - public void Logout() - { - Provider.Logout(); - } - /// /// Log user out of Twitter. /// diff --git a/Microsoft.Toolkit.Services/Services/Weibo/WeiboDataProvider.cs b/Microsoft.Toolkit.Services/Services/Weibo/WeiboDataProvider.cs index 3dd6d59a8ac..6975a33d005 100644 --- a/Microsoft.Toolkit.Services/Services/Weibo/WeiboDataProvider.cs +++ b/Microsoft.Toolkit.Services/Services/Weibo/WeiboDataProvider.cs @@ -163,17 +163,6 @@ public async Task LoginAsync() return false; } - /// - /// Log user out of Weibo. - /// - [Obsolete("Logout is deprecated, please use LogoutAsync instead.", true)] - public void Logout() - { -#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed - LogoutAsync(); -#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed - } - /// /// Log user out of Weibo. /// diff --git a/Microsoft.Toolkit.Services/Services/Weibo/WeiboService.cs b/Microsoft.Toolkit.Services/Services/Weibo/WeiboService.cs index f5f8dd7ec99..ea2f6cea3b1 100644 --- a/Microsoft.Toolkit.Services/Services/Weibo/WeiboService.cs +++ b/Microsoft.Toolkit.Services/Services/Weibo/WeiboService.cs @@ -183,15 +183,6 @@ public Task LoginAsync() return Provider.LoginAsync(); } - /// - /// Log user out of Weibo. - /// - [Obsolete("Logout is deprecated, please use LogoutAsync instead.", true)] - public void Logout() - { - Provider.Logout(); - } - /// /// Log user out of Weibo. /// diff --git a/Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj b/Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj index 51c0fd428b1..5476e2d5c12 100644 --- a/Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj +++ b/Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj @@ -280,7 +280,6 @@ - @@ -317,7 +316,6 @@ - @@ -367,8 +365,6 @@ - - @@ -511,9 +507,6 @@ - - Designer - @@ -655,9 +648,6 @@ - - TabViewPage.xaml - UniformGridPage.xaml @@ -920,9 +910,6 @@ FadeBehaviorPage.xaml - - HeaderedTextBlockPage.xaml - ImageExPage.xaml @@ -1055,10 +1042,6 @@ Designer MSBuild:Compile - - MSBuild:Compile - Designer - MSBuild:Compile Designer @@ -1423,10 +1406,6 @@ MSBuild:Compile Designer - - Designer - MSBuild:Compile - MSBuild:Compile Designer diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedTextBlock/HeaderedTextBlock.png b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedTextBlock/HeaderedTextBlock.png deleted file mode 100644 index 4b495ab237ab617b406082956fa4df6764313695..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3308 zcmeH~**6=C7RE!&Lrtfps8CaTYN&%!Eipt@kydpu#nhIVrIa2af{KI|HIy1^o|V#| z#&Ag0P%+Q5LyRdWGMKM*|AV{MeYg*Iul3t|KYb71!?)MQJ%F0<^N8~R004f|yO4(f z0E_h5-p0jo)(gJ0)}0MDe?!wpTxS)+^&ATT@a3CA3?9AC+@AHtO42TM?bZ_&pUMlc zio3@h=)1=x=nuF=iKt-~BC$pCwht0Cu3TMhXMf{l43ZNQdh@pd#4?YK4<7#{Qs%v& zNJ02z+c(#+inVx`d(WiV)qW1^G5f#xfBlMVN}WBVc+aU?)91JPe1ih@s2RWdDE7b# zlSE;AJNxYW-cbeRgJqx>_4-4jy@15z@Bekg?02C>h|5THccD*?22UmI zbwaK!FtbuOkn44;^MrC+yHxb07glX%DTmXso0g#K@Er)LZ}tm=>AKK_ z_H^FFNs$+~FeR`+fi;hS+{J1mv$>dEhK3*Li%OHsMxWHc&@J9AHrLq0X!JNWUA->Q znfdlMQvc@MHI?3WDt^4UUz4w%B~1e5uL1q8hE_l~;aq%e>^`#VvFhc7%Ghwv7*r@L zhJQ{WpJT}ef>=`}iZr>sIHZ&uz`T;|sI{TiD4t&y#`F9{8n83{k`t!HGi2`iI~ruL zRg!dd;dp7c2%&21x2Nuyt`}+5ww!`E#?htvT^FoVZzQ)jB&~d974ys&)1S5pu?!S` z%`#z)41pmg*|#|6DsKk~Y$M0Zyu+<0vYk;}7A(I4)B1B}d2c^OdU+yBIe)}qoVA8d zJ}MQW$h|C61fT?tbfn~WYdf2YO7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ncf&Cx%!?y)@5;XaCA5%MRl_f6MWx0 z7l1)IM*wVlH{(!}6fYr_A$=o~PM_*Yf%^ zdFvyF%(3`&=|D^Ooa4NCGr>76UjtNm-Bfb_7JS8_*ctlEF0Yk-rDgQ62p2(%?sRC{ z?wf}RSUMGV?Ygr)XP}F);%%sf&82EPtoQ&Qm4V5U3FcE3jOyiW3k?8c;Ov$IDo8Pc z()X6s#qFyNcPk3d@)d06$Ze;=5kjF5w}&b4wQGDT-?*rblDAA!Q5H_rU2r)tzwn1C(#X;J~ZVr({YkD zg6wo?IS;YBKdggVja@ppyo)+9+dMu3G!I>GjqOxfi^o0-hl(_<7hmjWt$Q?_A#1qe z+u01Zc++Enk6|X^pFA8*`JO?f1*}vjbu!#VElniGR!cel7I(2bJu(E|i&BPIR}@mE zG)qOxYmoZ3D2hzX5+=Sfjimr(E`$_}ch!O{%QSI)9>hmYT-8*GGZe^Z3(2r$~0rRsg07MSAnB+zwd#+H=^bD+VhE(_f9!uYP7w2 TO!KSG-WPzWF%(j1=oIlU(~cTl diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedTextBlock/HeaderedTextBlockCode.bind b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedTextBlock/HeaderedTextBlockCode.bind deleted file mode 100644 index a2db4b8dc80..00000000000 --- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedTextBlock/HeaderedTextBlockCode.bind +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedTextBlock/HeaderedTextBlockPage.xaml b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedTextBlock/HeaderedTextBlockPage.xaml deleted file mode 100644 index a5795898a0e..00000000000 --- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedTextBlock/HeaderedTextBlockPage.xaml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedTextBlock/HeaderedTextBlockPage.xaml.cs b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedTextBlock/HeaderedTextBlockPage.xaml.cs deleted file mode 100644 index 77cdba59f3e..00000000000 --- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedTextBlock/HeaderedTextBlockPage.xaml.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Toolkit.Uwp.SampleApp.Models; - -using Windows.UI.Xaml.Navigation; - -namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages -{ - public sealed partial class HeaderedTextBlockPage - { - public HeaderedTextBlockPage() - { - InitializeComponent(); - } - } -} \ No newline at end of file diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabView/TabView.png b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabView/TabView.png deleted file mode 100644 index 9aeebd1d673de8670b59cb522700c93f1c75b887..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1392 zcmeAS@N?(olHy`uVBq!ia0y~yU{nCI4{)#n$t4^1Z39v)>5jgR3=A9lx&I`x0{NT; z9+AZi3_@Vc*rT+Q9VjSK;u=vBoS#-wo>-L1P>`6JSE84fTB2a0XQ*fNOZn_apgHe6 zT^vIy;@;jkn3<9;(sHr$a7C&>Me2+jB8``VnSxjjMP@u{{Ps+A*_%VZT#Kdr^5tW8 z?PLG@_VH)g2NUMU?`QbaU-$RJ?e_cje?B@kH25n!957^Jks+S?oXJ@AJU_4Ksap8< z*>{W?tq%CEyYu8#+2m?92lgE&r_PSKn^$z6vX!n@AaI&`f&Rut(%&YBXu(h{8E`O?i>b#Gwa0B+aHTQB0Y2Yh>nZ-My5VNg$EMEQ9q9}FxG6!zhBS5Tj$4m^~aMNz|xVy)78&qol`;+ E0K}H&HUIzs diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabView/TabViewPage.xaml b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabView/TabViewPage.xaml deleted file mode 100644 index 32f465f2c64..00000000000 --- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabView/TabViewPage.xaml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabView/TabViewPage.xaml.cs b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabView/TabViewPage.xaml.cs deleted file mode 100644 index 74d9a3db253..00000000000 --- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabView/TabViewPage.xaml.cs +++ /dev/null @@ -1,73 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections.ObjectModel; -using Microsoft.Toolkit.Uwp.UI.Controls; -using Microsoft.Toolkit.Uwp.UI.Extensions; -using Windows.UI.Popups; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; - -namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages -{ - public sealed partial class TabViewPage : Page, IXamlRenderListener - { - #pragma warning disable CS0618 // Type or member is obsolete - private TabView _tabs; - - private int _counter = 1; - - public TabViewPage() - { - this.InitializeComponent(); - } - - public void OnXamlRendered(FrameworkElement control) - { - _tabs = control.FindChildByName("Tabs") as TabView; - if (_tabs != null) - { - _tabs.TabDraggedOutside += Tabs_TabDraggedOutside; - _tabs.TabClosing += Tabs_TabClosing; - } - - var btn = control.FindDescendantByName("AddTabButtonUpper") as Button; - if (btn != null) - { - btn.Click += AddUpperTabClick; - } - } - - private void AddUpperTabClick(object sender, RoutedEventArgs e) - { - _tabs.Items.Add(new TabViewItem() - { - Header = "Untitled " + _counter, - Icon = new SymbolIcon(Symbol.Document), - Content = "This is new tab #" + _counter++ + "." - }); - } - - private void Tabs_TabClosing(object sender, TabClosingEventArgs e) - { - TabViewNotification.Show("You're closing the '" + e.Tab.Header + "' tab.", 2000); - } - - private void Tabs_TabDraggedOutside(object sender, TabDraggedOutsideEventArgs e) - { - // The sample app let's you drag items from a static TabView with TabViewItem's pre-defined. - // In the case of data bound scenarios e.Item should be your data item, and e.Tab should always be the TabViewItem. - var str = e.Item.ToString(); - - if (e.Tab != null) - { - str = e.Tab.Header.ToString(); - } - - TabViewNotification.Show("Tore Tab '" + str + "' Outside of TabView.", 2000); - } - #pragma warning restore CS0618 // Type or member is obsolete - } -} diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabView/TabViewXaml.bind b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabView/TabViewXaml.bind deleted file mode 100644 index e81732aa2a3..00000000000 --- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabView/TabViewXaml.bind +++ /dev/null @@ -1,97 +0,0 @@ - - - - - - - - - - 40 - 48 - 200 - - - - - - - - - - - The TabView control has multiple uses. - - - It has a lot of versitility out of the box for different scenarios. - - - You can enable drag-and-drop and reorder the tabs too. - - - This tab isn't closable because its IsClosable property is set to False, even when CanCloseTabs is True. - - - - - - - - - - - - - - - - - diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/samples.json b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/samples.json index f106b270277..2b8f564b7bb 100644 --- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/samples.json +++ b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/samples.json @@ -14,18 +14,6 @@ "Icon": "/SamplePages/TextToolbar/TextToolbar.png", "DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/controls/TextToolbar.md" }, - { - "Name": "TabView", - "Type": "TabViewPage", - "Subcategory": "Layout", - "BadgeUpdateVersionRequired": "DEPRECATED", - "DeprecatedWarning": "Please migrate to the TabView control from WinUI, this control will be removed in a future release. https://aka.ms/winui", - "About": "A control for displaying multiple items in the same space and allows a user to easily switch between them.", - "CodeUrl": "https://github.com/windows-toolkit/WindowsCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI.Controls/TabView", - "XamlCodeFile": "TabViewXaml.bind", - "Icon": "/SamplePages/TabView/TabView.png", - "DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/controls/TabView.md" - }, { "Name": "DataGrid", "Type": "DataGridPage", @@ -86,18 +74,6 @@ "Icon": "/SamplePages/ImageEx/ImageEx.png", "DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/controls/ImageEx.md" }, - { - "Name": "HeaderedTextBlock", - "Type": "HeaderedTextBlockPage", - "Subcategory": "Layout", - "About": "The HeaderedTextBlock control is designed to provide a header for read only text. This control is useful for displaying read only forms.", - "CodeUrl": "https://github.com/windows-toolkit/WindowsCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI.Controls/HeaderedTextBlock", - "XamlCodeFile": "HeaderedTextBlockCode.bind", - "Icon": "/SamplePages/HeaderedTextBlock/HeaderedTextBlock.png", - "DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/controls/HeaderedTextBlock.md", - "BadgeUpdateVersionRequired": "DEPRECATED", - "DeprecatedWarning": "The HeaderedTextBlock has been replaced with the HeaderedContentControl and will be removed in a future major release." - }, { "Name": "MasterDetailsView", "Type": "MasterDetailsViewPage", diff --git a/Microsoft.Toolkit.Uwp.UI.Animations/ConnectedAnimations/Connected.cs b/Microsoft.Toolkit.Uwp.UI.Animations/ConnectedAnimations/Connected.cs index a0e5afa756d..999ea1d40c4 100644 --- a/Microsoft.Toolkit.Uwp.UI.Animations/ConnectedAnimations/Connected.cs +++ b/Microsoft.Toolkit.Uwp.UI.Animations/ConnectedAnimations/Connected.cs @@ -361,22 +361,6 @@ public static void UnregisterListItemForConnectedAnimation(this Page page, ListV } } - /// - /// Sets the object that will be used during next Frame navigation for - /// Connected Animation involving a list control (item must be an element of - /// ListViewBase.ItemsSource collection). - /// Useful if the parameter used during page navigation is different from the - /// data item in the list control. Also useful during back navigation if the - /// item navigating back to is different from the item that was navigated from. - /// - /// The Frame handling the navigation - /// The data item from a list control to be animated during next frame navigation - [Obsolete("Method is replaced by SetListDataItemForNextConnectedAnimation")] - public static void SetListDataItemForNextConnectedAnnimation(this Frame frame, object item) - { - GetConnectedAnimationHelper(frame)?.SetParameterForNextFrameNavigation(item); - } - /// /// Sets the object that will be used during next Frame navigation for /// Connected Animation involving a list control (item must be an element of diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.Design/HeaderedTextBlockMetadata.cs b/Microsoft.Toolkit.Uwp.UI.Controls.Design/HeaderedTextBlockMetadata.cs deleted file mode 100644 index 3cba40e11f1..00000000000 --- a/Microsoft.Toolkit.Uwp.UI.Controls.Design/HeaderedTextBlockMetadata.cs +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Toolkit.Uwp.UI.Controls.Design.Common; -using Microsoft.Windows.Design; -using Microsoft.Windows.Design.Features; -using Microsoft.Windows.Design.Metadata; -using Microsoft.Windows.Design.Model; -using Microsoft.Windows.Design.PropertyEditing; -using System.ComponentModel; - -namespace Microsoft.Toolkit.Uwp.UI.Controls.Design -{ - internal class HeaderedTextBlockDefaults : DefaultInitializer - { - public override void InitializeDefaults(ModelItem item) - { - item.Properties[nameof(HeaderedTextBlock.Header)].SetValue(string.Empty); - item.Properties[nameof(HeaderedTextBlock.Text)].SetValue(string.Empty); - } - } - internal class HeaderedTextBlockMetadata : AttributeTableBuilder - { - public HeaderedTextBlockMetadata() - : base() - { - AddCallback(typeof(Microsoft.Toolkit.Uwp.UI.Controls.HeaderedTextBlock), - b => - { - b.AddCustomAttributes(new FeatureAttribute(typeof(HeaderedTextBlockDefaults))); - b.AddCustomAttributes(nameof(HeaderedTextBlock.HeaderTemplate), - new CategoryAttribute(Properties.Resources.CategoryAppearance), - new EditorBrowsableAttribute(EditorBrowsableState.Advanced) - ); - b.AddCustomAttributes(nameof(HeaderedTextBlock.TextStyle), - new CategoryAttribute(Properties.Resources.CategoryAppearance), - new EditorBrowsableAttribute(EditorBrowsableState.Advanced) - ); - b.AddCustomAttributes(nameof(HeaderedTextBlock.Header), new CategoryAttribute(Properties.Resources.CategoryCommon)); - b.AddCustomAttributes(nameof(HeaderedTextBlock.Text), new CategoryAttribute(Properties.Resources.CategoryCommon)); - b.AddCustomAttributes(nameof(HeaderedTextBlock.Orientation), new CategoryAttribute(Properties.Resources.CategoryAppearance)); - b.AddCustomAttributes(nameof(HeaderedTextBlock.HideTextIfEmpty), new CategoryAttribute(Properties.Resources.CategoryAppearance)); - b.AddCustomAttributes(new ToolboxCategoryAttribute(ToolboxCategoryPaths.Toolkit, false)); - } - ); - } - } -} diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.Design/Microsoft.Toolkit.Uwp.UI.Controls.Design.csproj b/Microsoft.Toolkit.Uwp.UI.Controls.Design/Microsoft.Toolkit.Uwp.UI.Controls.Design.csproj index b611399dd13..b7b241a6403 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls.Design/Microsoft.Toolkit.Uwp.UI.Controls.Design.csproj +++ b/Microsoft.Toolkit.Uwp.UI.Controls.Design/Microsoft.Toolkit.Uwp.UI.Controls.Design.csproj @@ -85,7 +85,6 @@ - @@ -93,7 +92,6 @@ - @@ -105,7 +103,6 @@ - Code diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.Design/TabViewItemMetadata.cs b/Microsoft.Toolkit.Uwp.UI.Controls.Design/TabViewItemMetadata.cs deleted file mode 100644 index 6ed6bc37bf8..00000000000 --- a/Microsoft.Toolkit.Uwp.UI.Controls.Design/TabViewItemMetadata.cs +++ /dev/null @@ -1,43 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Toolkit.Uwp.UI.Controls.Design.Common; -using Microsoft.Windows.Design; -using Microsoft.Windows.Design.Features; -using Microsoft.Windows.Design.Metadata; -using Microsoft.Windows.Design.Model; -using Microsoft.Windows.Design.PropertyEditing; -using System.ComponentModel; - -namespace Microsoft.Toolkit.Uwp.UI.Controls.Design -{ - - internal class TabViewItemMetadata : AttributeTableBuilder - { - public TabViewItemMetadata() - : base() - { - AddCallback(typeof(TabViewItem), - b => - { - b.AddCustomAttributes(nameof(TabViewItem.Header), - new CategoryAttribute(Properties.Resources.CategoryCommon) - ); - b.AddCustomAttributes(nameof(TabViewItem.HeaderTemplate), - new CategoryAttribute(Properties.Resources.CategoryCommon), - new EditorBrowsableAttribute(EditorBrowsableState.Advanced) - ); - b.AddCustomAttributes(nameof(TabViewItem.IsClosable), - new CategoryAttribute(Properties.Resources.CategoryCommon) - ); - b.AddCustomAttributes(nameof(TabViewItem.Icon), - new CategoryAttribute(Properties.Resources.CategoryCommon) - ); - - b.AddCustomAttributes(new ToolboxCategoryAttribute(ToolboxCategoryPaths.Toolkit, false)); - } - ); - } - } -} \ No newline at end of file diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.Design/TabViewMetadata.cs b/Microsoft.Toolkit.Uwp.UI.Controls.Design/TabViewMetadata.cs deleted file mode 100644 index 7bfa77541db..00000000000 --- a/Microsoft.Toolkit.Uwp.UI.Controls.Design/TabViewMetadata.cs +++ /dev/null @@ -1,54 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Toolkit.Uwp.UI.Controls.Design.Common; -using Microsoft.Windows.Design; -using Microsoft.Windows.Design.Metadata; -using Microsoft.Windows.Design.PropertyEditing; -using System.ComponentModel; - -namespace Microsoft.Toolkit.Uwp.UI.Controls.Design -{ - internal class TabViewMetadata : AttributeTableBuilder - { - public TabViewMetadata() - : base() - { - AddCallback(typeof(Microsoft.Toolkit.Uwp.UI.Controls.TabView), - b => - { - // Layout - b.AddCustomAttributes(nameof(TabView.TabWidthBehavior), new CategoryAttribute(Properties.Resources.CategoryLayout)); - b.AddCustomAttributes(nameof(TabView.SelectedTabWidth), new CategoryAttribute(Properties.Resources.CategoryLayout)); - b.AddCustomAttributes(nameof(TabView.IsCloseButtonOverlay), new CategoryAttribute(Properties.Resources.CategoryLayout)); - - // Interactions - b.AddCustomAttributes(nameof(TabView.CanCloseTabs), new CategoryAttribute(Properties.Resources.CategoryCommon)); - - // Templates - b.AddCustomAttributes(nameof(TabView.ItemHeaderTemplate), - new CategoryAttribute(Properties.Resources.CategoryCommon), - new EditorBrowsableAttribute(EditorBrowsableState.Advanced) - ); - b.AddCustomAttributes(nameof(TabView.TabActionHeader), new CategoryAttribute(Properties.Resources.CategoryCommon)); - b.AddCustomAttributes(nameof(TabView.TabActionHeaderTemplate), - new CategoryAttribute(Properties.Resources.CategoryCommon), - new EditorBrowsableAttribute(EditorBrowsableState.Advanced) - ); - b.AddCustomAttributes(nameof(TabView.TabEndHeader), new CategoryAttribute(Properties.Resources.CategoryCommon)); - b.AddCustomAttributes(nameof(TabView.TabEndHeaderTemplate), - new CategoryAttribute(Properties.Resources.CategoryCommon), - new EditorBrowsableAttribute(EditorBrowsableState.Advanced) - ); - b.AddCustomAttributes(nameof(TabView.TabStartHeader), new CategoryAttribute(Properties.Resources.CategoryCommon)); - b.AddCustomAttributes(nameof(TabView.TabStartHeaderTemplate), - new CategoryAttribute(Properties.Resources.CategoryCommon), - new EditorBrowsableAttribute(EditorBrowsableState.Advanced) - ); - b.AddCustomAttributes(new ToolboxCategoryAttribute(ToolboxCategoryPaths.Toolkit, false)); - } - ); - } - } -} diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/HeaderedTextBlock/HeaderedTextBlock.Properties.cs b/Microsoft.Toolkit.Uwp.UI.Controls/HeaderedTextBlock/HeaderedTextBlock.Properties.cs deleted file mode 100644 index 7528591fc2b..00000000000 --- a/Microsoft.Toolkit.Uwp.UI.Controls/HeaderedTextBlock/HeaderedTextBlock.Properties.cs +++ /dev/null @@ -1,172 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; - -namespace Microsoft.Toolkit.Uwp.UI.Controls -{ - /// - /// Defines the properties for the control. - /// - public partial class HeaderedTextBlock - { - /// - /// Defines the dependency property. - /// - public static readonly DependencyProperty HeaderTemplateProperty = DependencyProperty.Register( - nameof(HeaderTemplate), - typeof(DataTemplate), - typeof(HeaderedTextBlock), - new PropertyMetadata(null)); - - /// - /// Defines the dependency property. - /// - public static readonly DependencyProperty TextStyleProperty = DependencyProperty.Register( - nameof(TextStyle), - typeof(Style), - typeof(HeaderedTextBlock), - new PropertyMetadata(null)); - - /// - /// Defines the dependency property. - /// - public static readonly DependencyProperty HeaderProperty = DependencyProperty.Register( - nameof(Header), - typeof(string), - typeof(HeaderedTextBlock), - new PropertyMetadata(null, (d, e) => { ((HeaderedTextBlock)d).UpdateVisibility(); })); - - /// - /// Defines the dependency property. - /// - public static readonly DependencyProperty TextProperty = DependencyProperty.Register( - nameof(Text), - typeof(string), - typeof(HeaderedTextBlock), - new PropertyMetadata(null, (d, e) => { ((HeaderedTextBlock)d).UpdateVisibility(); })); - - /// - /// Defines the dependency property. - /// - public static readonly DependencyProperty OrientationProperty = DependencyProperty.Register( - nameof(Orientation), - typeof(Orientation), - typeof(HeaderedTextBlock), - new PropertyMetadata(Orientation.Vertical, (d, e) => { ((HeaderedTextBlock)d).UpdateForOrientation((Orientation)e.NewValue); })); - - /// - /// Defines the dependency property. - /// - public static readonly DependencyProperty HideTextIfEmptyProperty = DependencyProperty.Register( - nameof(HideTextIfEmpty), - typeof(bool), - typeof(HeaderedTextBlock), - new PropertyMetadata(false, (d, e) => { ((HeaderedTextBlock)d).UpdateVisibility(); })); - - /// - /// Gets or sets the header style. - /// - public DataTemplate HeaderTemplate - { - get - { - return (DataTemplate)GetValue(HeaderTemplateProperty); - } - - set - { - SetValue(HeaderTemplateProperty, value); - } - } - - /// - /// Gets or sets the text style. - /// - public Style TextStyle - { - get - { - return (Style)GetValue(TextStyleProperty); - } - - set - { - SetValue(TextStyleProperty, value); - } - } - - /// - /// Gets or sets the header. - /// - public string Header - { - get - { - return (string)GetValue(HeaderProperty); - } - - set - { - SetValue(HeaderProperty, value); - } - } - - /// - /// Gets or sets the text. - /// - public string Text - { - get - { - return (string)GetValue(TextProperty); - } - - set - { - SetValue(TextProperty, value); - } - } - - /// - /// Gets the collection of inline text elements within a Windows.UI.Xaml.Controls.TextBlock. - /// - /// - /// A collection that holds all inline text elements from the Windows.UI.Xaml.Controls.TextBlock. The default is an empty collection. - public InlineCollectionWrapper Inlines { get; } = new InlineCollectionWrapper(); - - /// - /// Gets or sets the orientation. - /// - public Orientation Orientation - { - get - { - return (Orientation)GetValue(OrientationProperty); - } - - set - { - SetValue(OrientationProperty, value); - } - } - - /// - /// Gets or sets a value indicating whether the Text TextBlock is hidden if its value is empty - /// - public bool HideTextIfEmpty - { - get - { - return (bool)GetValue(HideTextIfEmptyProperty); - } - - set - { - SetValue(HideTextIfEmptyProperty, value); - } - } - } -} \ No newline at end of file diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/HeaderedTextBlock/HeaderedTextBlock.cs b/Microsoft.Toolkit.Uwp.UI.Controls/HeaderedTextBlock/HeaderedTextBlock.cs deleted file mode 100644 index b30dfea1d3d..00000000000 --- a/Microsoft.Toolkit.Uwp.UI.Controls/HeaderedTextBlock/HeaderedTextBlock.cs +++ /dev/null @@ -1,76 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Markup; - -namespace Microsoft.Toolkit.Uwp.UI.Controls -{ - /// - /// Defines a control for providing a header for read-only text. - /// - [TemplatePart(Name = "HeaderContentPresenter", Type = typeof(ContentPresenter))] - [ContentProperty(Name = nameof(Inlines))] - [Obsolete("The HeaderedTextBlock has been replaced with the more generic HeaderedContentControl.")] - public partial class HeaderedTextBlock : Control - { - private ContentPresenter _headerContentPresenter; - private TextBlock _textContent; - - /// - /// Initializes a new instance of the class. - /// - public HeaderedTextBlock() - { - DefaultStyleKey = typeof(HeaderedTextBlock); - } - - /// - /// Called when applying the control template. - /// - protected override void OnApplyTemplate() - { - base.OnApplyTemplate(); - - _headerContentPresenter = GetTemplateChild("HeaderContentPresenter") as ContentPresenter; - _textContent = GetTemplateChild("TextContent") as TextBlock; - - UpdateVisibility(); - Inlines.AddItemsToTextBlock(_textContent); - UpdateForOrientation(this.Orientation); - } - - private void UpdateVisibility() - { - if (_headerContentPresenter != null) - { - _headerContentPresenter.Visibility = _headerContentPresenter.Content == null - ? Visibility.Collapsed - : Visibility.Visible; - } - - if (_textContent != null) - { - _textContent.Visibility = string.IsNullOrWhiteSpace(_textContent.Text) && HideTextIfEmpty - ? Visibility.Collapsed - : Visibility.Visible; - } - } - - private void UpdateForOrientation(Orientation orientationValue) - { - switch (orientationValue) - { - case Orientation.Vertical: - VisualStateManager.GoToState(this, "Vertical", true); - break; - case Orientation.Horizontal: - VisualStateManager.GoToState(this, "Horizontal", true); - break; - } - } - } -} \ No newline at end of file diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/HeaderedTextBlock/HeaderedTextBlock.xaml b/Microsoft.Toolkit.Uwp.UI.Controls/HeaderedTextBlock/HeaderedTextBlock.xaml deleted file mode 100644 index 6f94a07ba82..00000000000 --- a/Microsoft.Toolkit.Uwp.UI.Controls/HeaderedTextBlock/HeaderedTextBlock.xaml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/Microsoft.Toolkit.Uwp.UI.Controls.csproj b/Microsoft.Toolkit.Uwp.UI.Controls/Microsoft.Toolkit.Uwp.UI.Controls.csproj index 6174415e0f3..9b240477475 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls/Microsoft.Toolkit.Uwp.UI.Controls.csproj +++ b/Microsoft.Toolkit.Uwp.UI.Controls/Microsoft.Toolkit.Uwp.UI.Controls.csproj @@ -17,7 +17,6 @@ - GridSplitter: A the control that redistributes space between columns or rows of a Grid control. - HeaderedContentControl: Provides a header to content. - HeaderedItemsControl: Provides a header to items. - - HeaderedTextBlock: Provide a header for read-only text. - ImageCropper: ImageCropper control allows user to crop image freely. - ImageEx: Images are downloaded asynchronously showing a load indicator and can be stored in a local cache. - InAppNotification: Show local notifications in your application. diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/Microsoft.Toolkit.Uwp.UI.Controls.csproj.DotSettings b/Microsoft.Toolkit.Uwp.UI.Controls/Microsoft.Toolkit.Uwp.UI.Controls.csproj.DotSettings index 0dd5cea5b9e..8a263d98309 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls/Microsoft.Toolkit.Uwp.UI.Controls.csproj.DotSettings +++ b/Microsoft.Toolkit.Uwp.UI.Controls/Microsoft.Toolkit.Uwp.UI.Controls.csproj.DotSettings @@ -5,7 +5,6 @@ True True True - True True True True diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/Strings/en-US/Resources.resw b/Microsoft.Toolkit.Uwp.UI.Controls/Strings/en-US/Resources.resw index 66cce5b66ab..d3b003e8b80 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls/Strings/en-US/Resources.resw +++ b/Microsoft.Toolkit.Uwp.UI.Controls/Strings/en-US/Resources.resw @@ -213,14 +213,6 @@ Notification The landmark name for the InAppNotification control. It is said by the narrator when using landmark navigation. - - Close tab - Narrator Resource for TabView Close Button. - - - Close tab - Tooltip for TabView Close Button. - Remove Label for TokenizingTextBox MenuFlyout 'Remove' option. diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabClosingEventArgs.cs b/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabClosingEventArgs.cs deleted file mode 100644 index 893776ff0be..00000000000 --- a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabClosingEventArgs.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.ComponentModel; - -namespace Microsoft.Toolkit.Uwp.UI.Controls -{ - /// - /// Event arguments for event. - /// - public class TabClosingEventArgs : CancelEventArgs - { - /// - /// Initializes a new instance of the class. - /// - /// Item being closed. - /// container being closed. - public TabClosingEventArgs(object item, TabViewItem tab) - { - Item = item; - Tab = tab; - } - - /// - /// Gets the Item being closed. - /// - public object Item { get; private set; } - - /// - /// Gets the Tab being closed. - /// - public TabViewItem Tab { get; private set; } - } -} \ No newline at end of file diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabDraggedOutsideEventArgs.cs b/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabDraggedOutsideEventArgs.cs deleted file mode 100644 index dcf351aab9b..00000000000 --- a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabDraggedOutsideEventArgs.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; - -namespace Microsoft.Toolkit.Uwp.UI.Controls -{ - /// - /// A class used by the TabDraggedOutside Event - /// - public class TabDraggedOutsideEventArgs : EventArgs - { - /// - /// Initializes a new instance of the class. - /// - /// data context of element dragged - /// container being dragged. - public TabDraggedOutsideEventArgs(object item, TabViewItem tab) - { - Item = item; - Tab = tab; - } - - /// - /// Gets or sets the Item/Data Context of the item being dragged outside of the . - /// - public object Item { get; set; } - - /// - /// Gets the Tab being dragged outside of the . - /// - public TabViewItem Tab { get; private set; } - } -} diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.HeaderLayout.cs b/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.HeaderLayout.cs deleted file mode 100644 index 16885700b35..00000000000 --- a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.HeaderLayout.cs +++ /dev/null @@ -1,221 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Linq; -using Windows.UI.Xaml; - -namespace Microsoft.Toolkit.Uwp.UI.Controls -{ - /// - /// TabView methods related to calculating the width of the Headers. - /// - public partial class TabView - { - // Attached property for storing widths of tabs if set by other means during layout. - private static double GetOriginalWidth(TabViewItem obj) - { - return (double)obj.GetValue(OriginalWidthProperty); - } - - private static void SetOriginalWidth(TabViewItem obj, double value) - { - obj.SetValue(OriginalWidthProperty, value); - } - - // Using a DependencyProperty as the backing store for MyProperty. This enables animation, styling, binding, etc... - private static readonly DependencyProperty OriginalWidthProperty = - DependencyProperty.RegisterAttached("OriginalWidth", typeof(double), typeof(TabView), new PropertyMetadata(null)); - - private static void OnLayoutEffectingPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args) - { - var tabview = sender as TabView; - if (tabview != null && tabview._hasLoaded) - { - tabview.TabView_SizeChanged(tabview, null); - } - } - - private void TabView_SizeChanged(object sender, SizeChangedEventArgs e) - { - // We need to do this calculation here in Size Changed as the - // Columns don't have their Actual Size calculated in Measure or Arrange. - if (_hasLoaded && _tabViewContainer != null) - { - // Look for our special columns to calculate size of other 'stuff' - var taken = _tabViewContainer.ColumnDefinitions.Sum(cd => GetIgnoreColumn(cd) ? 0 : cd.ActualWidth); - - // Get the column we want to work on for available space - var tabc = _tabViewContainer.ColumnDefinitions.FirstOrDefault(cd => GetConstrainColumn(cd)); - if (tabc != null) - { - var available = ActualWidth - taken; - var required = 0.0; - var mintabwidth = double.MaxValue; - - if (TabWidthBehavior == TabWidthMode.Actual) - { - if (_tabScroller != null) - { - // If we have a scroll container, get its size. - required = _tabScroller.ExtentWidth; - } - - // Restore original widths - foreach (var item in Items) - { - var tab = ContainerFromItem(item) as TabViewItem; - if (tab == null) - { - continue; // container not generated yet - } - - if (tab.ReadLocalValue(OriginalWidthProperty) != DependencyProperty.UnsetValue) - { - tab.Width = GetOriginalWidth(tab); - } - } - } - else if (available > 0) - { - // Calculate the width for each tab from the provider and determine how much space they take. - foreach (var item in Items) - { - var tab = ContainerFromItem(item) as TabViewItem; - if (tab == null) - { - continue; // container not generated yet - } - - mintabwidth = Math.Min(mintabwidth, tab.MinWidth); - - double width = double.NaN; - - switch (TabWidthBehavior) - { - case TabWidthMode.Equal: - width = ProvideEqualWidth(tab, item, available); - break; - case TabWidthMode.Compact: - width = ProvideCompactWidth(tab, item, available); - break; - } - - if (tab.ReadLocalValue(OriginalWidthProperty) == DependencyProperty.UnsetValue) - { - SetOriginalWidth(tab, tab.Width); - } - - if (width > double.Epsilon) - { - tab.Width = width; - required += Math.Max(Math.Min(width, tab.MaxWidth), tab.MinWidth); - } - else - { - tab.Width = GetOriginalWidth(tab); - required += tab.ActualWidth; - } - } - } - else - { - // Fix negative bounds. - available = 0.0; - - // Still need to determine a 'minimum' width (if available) - // TODO: Consolidate this logic with above better? - foreach (var item in Items) - { - var tab = ContainerFromItem(item) as TabViewItem; - if (tab == null) - { - continue; // container not generated yet - } - - mintabwidth = Math.Min(mintabwidth, tab.MinWidth); - } - } - - if (!(mintabwidth < double.MaxValue)) - { - mintabwidth = 0.0; // No Containers, no visual, 0 size. - } - - if (available > mintabwidth) - { - // Constrain the column based on our required and available space - tabc.MaxWidth = available; - } - - //// TODO: If it's less, should we move the selected tab to only be the one shown by default? - - if (available <= mintabwidth || Math.Abs(available - mintabwidth) < double.Epsilon) - { - tabc.Width = new GridLength(mintabwidth); - } - else if (required >= available) - { - // Fix size as we don't have enough space for all the tabs. - tabc.Width = new GridLength(available); - } - else - { - // We haven't filled up our space, so we want to expand to take as much as needed. - tabc.Width = GridLength.Auto; - } - } - } - } - - private double ProvideEqualWidth(TabViewItem tab, object item, double availableWidth) - { - if (double.IsNaN(SelectedTabWidth)) - { - if (Items.Count <= 1) - { - return availableWidth; - } - - return Math.Max(tab.MinWidth, availableWidth / Items.Count); - } - else if (Items.Count() <= 1) - { - // Default case of a single tab, make it full size. - return Math.Min(SelectedTabWidth, availableWidth); - } - else - { - var width = (availableWidth - SelectedTabWidth) / (Items.Count - 1); - - // Constrain between Min and Selected (Max) - if (width < tab.MinWidth) - { - width = tab.MinWidth; - } - else if (width > SelectedTabWidth) - { - width = SelectedTabWidth; - } - - // If it's selected make it full size, otherwise whatever the size should be. - return tab.IsSelected - ? Math.Min(SelectedTabWidth, availableWidth) - : width; - } - } - - private double ProvideCompactWidth(TabViewItem tab, object item, double availableWidth) - { - // If we're selected and have a value for that, then just return that. - if (tab.IsSelected && !double.IsNaN(SelectedTabWidth)) - { - return SelectedTabWidth; - } - - // Otherwise use min size. - return tab.MinWidth; - } - } -} diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.ItemSources.cs b/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.ItemSources.cs deleted file mode 100644 index 61f61623b6f..00000000000 --- a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.ItemSources.cs +++ /dev/null @@ -1,115 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Reflection; -using Windows.Foundation.Collections; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls.Primitives; - -namespace Microsoft.Toolkit.Uwp.UI.Controls -{ - /// - /// TabView methods related to tracking Items and ItemsSource changes. - /// - public partial class TabView - { - // Temporary tracking of previous collections for removing events. - private MethodInfo _removeItemsSourceMethod; - - /// - protected override void OnItemsChanged(object e) - { - IVectorChangedEventArgs args = (IVectorChangedEventArgs)e; - - base.OnItemsChanged(e); - - if (args.CollectionChange == CollectionChange.ItemRemoved && SelectedIndex == -1) - { - // If we remove the selected item we should select the previous item - int startIndex = (int)args.Index + 1; - if (startIndex > Items.Count) - { - startIndex = 0; - } - - SelectedIndex = FindNextTabIndex(startIndex, -1); - } - - // Update Sizing (in case there are less items now) - TabView_SizeChanged(this, null); - } - - private void ItemContainerGenerator_ItemsChanged(object sender, ItemsChangedEventArgs e) - { - var action = (CollectionChange)e.Action; - if (action == CollectionChange.Reset) - { - // Reset collection to reload later. - _hasLoaded = false; - } - } - - private void SetInitialSelection() - { - if (SelectedItem == null) - { - // If we have an index, but didn't get the selection, make the selection - if (SelectedIndex >= 0 && SelectedIndex < Items.Count) - { - SelectedItem = Items[SelectedIndex]; - } - - // Otherwise, select the first item by default - else if (Items.Count >= 1) - { - SelectedItem = Items[0]; - } - } - } - - // Finds the next visible & enabled tab index. - private int FindNextTabIndex(int startIndex, int direction) - { - int index = startIndex; - if (direction != 0) - { - for (int i = 0; i < Items.Count; i++) - { - index += direction; - - if (index >= Items.Count) - { - index = 0; - } - else if (index < 0) - { - index = Items.Count - 1; - } - - var tabItem = ContainerFromIndex(index) as TabViewItem; - if (tabItem != null && tabItem.IsEnabled && tabItem.Visibility == Visibility.Visible) - { - break; - } - } - } - - return index; - } - - private void ItemsSource_PropertyChanged(DependencyObject sender, DependencyProperty dp) - { - // Use reflection to store a 'Remove' method of any possible collection in ItemsSource - // Cache for efficiency later. - if (ItemsSource != null) - { - _removeItemsSourceMethod = ItemsSource.GetType().GetMethod("Remove"); - } - else - { - _removeItemsSourceMethod = null; - } - } - } -} diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.Properties.cs b/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.Properties.cs deleted file mode 100644 index 5d33b33f1cc..00000000000 --- a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.Properties.cs +++ /dev/null @@ -1,245 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; - -namespace Microsoft.Toolkit.Uwp.UI.Controls -{ - /// - /// TabView properties. - /// - public partial class TabView - { - /// - /// Gets or sets the content to appear to the left or above the tab strip. - /// - public object TabStartHeader - { - get { return (object)GetValue(TabStartHeaderProperty); } - set { SetValue(TabStartHeaderProperty, value); } - } - - /// - /// Identifies the dependency property. - /// - /// The identifier for the dependency property. - public static readonly DependencyProperty TabStartHeaderProperty = - DependencyProperty.Register(nameof(TabStartHeader), typeof(object), typeof(TabView), new PropertyMetadata(null, OnLayoutEffectingPropertyChanged)); - - /// - /// Gets or sets the for the . - /// - public DataTemplate TabStartHeaderTemplate - { - get { return (DataTemplate)GetValue(TabStartHeaderTemplateProperty); } - set { SetValue(TabStartHeaderTemplateProperty, value); } - } - - /// - /// Identifies the dependency property. - /// - /// The identifier for the dependency property. - public static readonly DependencyProperty TabStartHeaderTemplateProperty = - DependencyProperty.Register(nameof(TabStartHeaderTemplate), typeof(DataTemplate), typeof(TabView), new PropertyMetadata(null, OnLayoutEffectingPropertyChanged)); - - /// - /// Gets or sets the content to appear next to the tab strip. - /// - public object TabActionHeader - { - get { return (object)GetValue(TabActionHeaderProperty); } - set { SetValue(TabActionHeaderProperty, value); } - } - - /// - /// Identifies the dependency property. - /// - /// The identifier for the dependency property. - public static readonly DependencyProperty TabActionHeaderProperty = - DependencyProperty.Register(nameof(TabActionHeader), typeof(object), typeof(TabView), new PropertyMetadata(null, OnLayoutEffectingPropertyChanged)); - - /// - /// Gets or sets the for the . - /// - public DataTemplate TabActionHeaderTemplate - { - get { return (DataTemplate)GetValue(TabActionHeaderTemplateProperty); } - set { SetValue(TabActionHeaderTemplateProperty, value); } - } - - /// - /// Identifies the dependency property. - /// - /// The identifier for the dependency property. - public static readonly DependencyProperty TabActionHeaderTemplateProperty = - DependencyProperty.Register(nameof(TabActionHeaderTemplate), typeof(DataTemplate), typeof(TabView), new PropertyMetadata(null, OnLayoutEffectingPropertyChanged)); - - /// - /// Gets or sets the content to appear to the right or below the tab strip. - /// - public object TabEndHeader - { - get { return (object)GetValue(TabEndHeaderProperty); } - set { SetValue(TabEndHeaderProperty, value); } - } - - /// - /// Identifies the dependency property. - /// - /// The identifier for the dependency property. - public static readonly DependencyProperty TabEndHeaderProperty = - DependencyProperty.Register(nameof(TabEndHeader), typeof(object), typeof(TabView), new PropertyMetadata(null, OnLayoutEffectingPropertyChanged)); - - /// - /// Gets or sets the for the . - /// - public DataTemplate TabEndHeaderTemplate - { - get { return (DataTemplate)GetValue(TabEndHeaderTemplateProperty); } - set { SetValue(TabEndHeaderTemplateProperty, value); } - } - - /// - /// Identifies the dependency property. - /// - /// The identifier for the dependency property. - public static readonly DependencyProperty TabEndHeaderTemplateProperty = - DependencyProperty.Register(nameof(TabEndHeaderTemplate), typeof(DataTemplate), typeof(TabView), new PropertyMetadata(null, OnLayoutEffectingPropertyChanged)); - - /// - /// Gets or sets the default for the . - /// - public DataTemplate ItemHeaderTemplate - { - get { return (DataTemplate)GetValue(ItemHeaderTemplateProperty); } - set { SetValue(ItemHeaderTemplateProperty, value); } - } - - /// - /// Identifies the dependency property. - /// - /// The identifier for the dependency property. - public static readonly DependencyProperty ItemHeaderTemplateProperty = - DependencyProperty.Register(nameof(ItemHeaderTemplate), typeof(DataTemplate), typeof(TabView), new PropertyMetadata(null, OnLayoutEffectingPropertyChanged)); - - /// - /// Gets or sets a value indicating whether by default a Tab can be closed or not if no value to is provided. - /// - public bool CanCloseTabs - { - get { return (bool)GetValue(CanCloseTabsProperty); } - set { SetValue(CanCloseTabsProperty, value); } - } - - /// - /// Identifies the dependency property. - /// - /// The identifier for the dependency property. - public static readonly DependencyProperty CanCloseTabsProperty = - DependencyProperty.Register(nameof(CanCloseTabs), typeof(bool), typeof(TabView), new PropertyMetadata(false, OnLayoutEffectingPropertyChanged)); - - /// - /// Gets or sets a value indicating whether a Close Button should be included in layout calculations. - /// - public bool IsCloseButtonOverlay - { - get { return (bool)GetValue(IsCloseButtonOverlayProperty); } - set { SetValue(IsCloseButtonOverlayProperty, value); } - } - - /// - /// Identifies the dependency property. - /// - /// The identifier for the dependency property. - public static readonly DependencyProperty IsCloseButtonOverlayProperty = - DependencyProperty.Register(nameof(IsCloseButtonOverlay), typeof(bool), typeof(TabView), new PropertyMetadata(false, OnLayoutEffectingPropertyChanged)); - - /// - /// Gets or sets a value indicating the size of the selected tab. By default this is set to Auto and the selected tab size doesn't change. - /// - public double SelectedTabWidth - { - get { return (double)GetValue(SelectedTabWidthProperty); } - set { SetValue(SelectedTabWidthProperty, value); } - } - - /// - /// Identifies the dependency property. - /// - /// The identifier for the dependency property. - public static readonly DependencyProperty SelectedTabWidthProperty = - DependencyProperty.Register(nameof(SelectedTabWidth), typeof(double), typeof(TabView), new PropertyMetadata(double.NaN, OnLayoutEffectingPropertyChanged)); - - /// - /// Gets or sets the current which determins how tab headers' width behave. - /// - public TabWidthMode TabWidthBehavior - { - get { return (TabWidthMode)GetValue(TabWidthBehaviorProperty); } - set { SetValue(TabWidthBehaviorProperty, value); } - } - - /// - /// Identifies the dependency property. - /// - /// The identifier for the dependency property. - public static readonly DependencyProperty TabWidthBehaviorProperty = - DependencyProperty.Register(nameof(TabWidthBehavior), typeof(TabWidthMode), typeof(TabView), new PropertyMetadata(TabWidthMode.Actual, OnLayoutEffectingPropertyChanged)); - - /// - /// Gets the attached property value to indicate if this grid column should be ignored when calculating header sizes. - /// - /// Grid Column. - /// Boolean indicating if this column is ignored by TabViewHeader logic. - public static bool GetIgnoreColumn(ColumnDefinition obj) - { - return (bool)obj.GetValue(IgnoreColumnProperty); - } - - /// - /// Sets the attached property value for - /// - /// Grid Column. - /// Boolean value - public static void SetIgnoreColumn(ColumnDefinition obj, bool value) - { - obj.SetValue(IgnoreColumnProperty, value); - } - - /// - /// Identifies the attached property. - /// - /// The identifier for the IgnoreColumn attached property. - public static readonly DependencyProperty IgnoreColumnProperty = - DependencyProperty.RegisterAttached("IgnoreColumn", typeof(bool), typeof(TabView), new PropertyMetadata(false)); - - /// - /// Gets the attached value indicating this column should be restricted for the headers. - /// - /// Grid Column. - /// True if this column should be constrained. - public static bool GetConstrainColumn(ColumnDefinition obj) - { - return (bool)obj.GetValue(ConstrainColumnProperty); - } - - /// - /// Sets the attached property value for the - /// - /// Grid Column. - /// Boolean value. - public static void SetConstrainColumn(ColumnDefinition obj, bool value) - { - obj.SetValue(ConstrainColumnProperty, value); - } - - /// - /// Identifies the attached property. - /// - /// The identifier for the ConstrainColumn attached property. - public static readonly DependencyProperty ConstrainColumnProperty = - DependencyProperty.RegisterAttached("ConstrainColumn", typeof(bool), typeof(TabView), new PropertyMetadata(false)); - } -} diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.cs b/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.cs deleted file mode 100644 index 0e86ab398f5..00000000000 --- a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.cs +++ /dev/null @@ -1,320 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.ComponentModel; -using System.Linq; -using Microsoft.Toolkit.Uwp.UI.Extensions; -using Windows.ApplicationModel.DataTransfer; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Controls.Primitives; -using Windows.UI.Xaml.Data; - -namespace Microsoft.Toolkit.Uwp.UI.Controls -{ - /// - /// TabView is a control for displaying a set of tabs and their content. - /// - [Obsolete("Please migrate to the TabView control from WinUI, this control will be removed in a future release. https://aka.ms/winui")] - [TemplatePart(Name = TabContentPresenterName, Type = typeof(ContentPresenter))] - [TemplatePart(Name = TabViewContainerName, Type = typeof(Grid))] - [TemplatePart(Name = TabsItemsPresenterName, Type = typeof(ItemsPresenter))] - [TemplatePart(Name = TabsScrollViewerName, Type = typeof(ScrollViewer))] - [TemplatePart(Name = TabsScrollBackButtonName, Type = typeof(ButtonBase))] - [TemplatePart(Name = TabsScrollForwardButtonName, Type = typeof(ButtonBase))] - public partial class TabView : ListViewBase - { - private const int ScrollAmount = 50; // TODO: Should this be based on TabWidthMode - - private const string TabContentPresenterName = "TabContentPresenter"; - private const string TabViewContainerName = "TabViewContainer"; - private const string TabsItemsPresenterName = "TabsItemsPresenter"; - private const string TabsScrollViewerName = "ScrollViewer"; - private const string TabsScrollBackButtonName = "ScrollBackButton"; - private const string TabsScrollForwardButtonName = "ScrollForwardButton"; - - private ContentPresenter _tabContentPresenter; - private Grid _tabViewContainer; - private ItemsPresenter _tabItemsPresenter; - private ScrollViewer _tabScroller; - private ButtonBase _tabScrollBackButton; - private ButtonBase _tabScrollForwardButton; - - private bool _hasLoaded; - private bool _isDragging; - - /// - /// Initializes a new instance of the class. - /// - public TabView() - { - DefaultStyleKey = typeof(TabView); - - // Container Generation Hooks - RegisterPropertyChangedCallback(ItemsSourceProperty, ItemsSource_PropertyChanged); - ItemContainerGenerator.ItemsChanged += ItemContainerGenerator_ItemsChanged; - - // Drag and Layout Hooks - DragItemsStarting += TabView_DragItemsStarting; - DragItemsCompleted += TabView_DragItemsCompleted; - SizeChanged += TabView_SizeChanged; - - // Selection Hook - SelectionChanged += TabView_SelectionChanged; - } - - /// - /// Occurs when a tab is dragged by the user outside of the . Generally, this paradigm is used to create a new-window with the torn-off tab. - /// The creation and handling of the new-window is left to the app's developer. - /// - public event EventHandler TabDraggedOutside; - - /// - /// Occurs when a tab's Close button is clicked. Set to true to prevent automatic Tab Closure. - /// - public event EventHandler TabClosing; - - /// - protected override DependencyObject GetContainerForItemOverride() => new TabViewItem(); - - /// - protected override bool IsItemItsOwnContainerOverride(object item) - { - return item is TabViewItem; - } - - /// - protected override void OnApplyTemplate() - { - base.OnApplyTemplate(); - - if (_tabItemsPresenter != null) - { - _tabItemsPresenter.SizeChanged -= TabView_SizeChanged; - } - - if (_tabScroller != null) - { - _tabScroller.Loaded -= ScrollViewer_Loaded; - } - - _tabContentPresenter = GetTemplateChild(TabContentPresenterName) as ContentPresenter; - _tabViewContainer = GetTemplateChild(TabViewContainerName) as Grid; - _tabItemsPresenter = GetTemplateChild(TabsItemsPresenterName) as ItemsPresenter; - _tabScroller = GetTemplateChild(TabsScrollViewerName) as ScrollViewer; - - if (_tabItemsPresenter != null) - { - _tabItemsPresenter.SizeChanged += TabView_SizeChanged; - } - - if (_tabScroller != null) - { - _tabScroller.Loaded += ScrollViewer_Loaded; - } - } - - private void ScrollViewer_Loaded(object sender, RoutedEventArgs e) - { - _tabScroller.Loaded -= ScrollViewer_Loaded; - - if (_tabScrollBackButton != null) - { - _tabScrollBackButton.Click -= ScrollTabBackButton_Click; - } - - if (_tabScrollForwardButton != null) - { - _tabScrollForwardButton.Click -= ScrollTabForwardButton_Click; - } - - _tabScrollBackButton = _tabScroller.FindDescendantByName(TabsScrollBackButtonName) as ButtonBase; - _tabScrollForwardButton = _tabScroller.FindDescendantByName(TabsScrollForwardButtonName) as ButtonBase; - - if (_tabScrollBackButton != null) - { - _tabScrollBackButton.Click += ScrollTabBackButton_Click; - } - - if (_tabScrollForwardButton != null) - { - _tabScrollForwardButton.Click += ScrollTabForwardButton_Click; - } - } - - private void ScrollTabBackButton_Click(object sender, RoutedEventArgs e) - { - _tabScroller.ChangeView(Math.Max(0, _tabScroller.HorizontalOffset - ScrollAmount), null, null); - } - - private void ScrollTabForwardButton_Click(object sender, RoutedEventArgs e) - { - _tabScroller.ChangeView(Math.Min(_tabScroller.ScrollableWidth, _tabScroller.HorizontalOffset + ScrollAmount), null, null); - } - - private void TabView_SelectionChanged(object sender, SelectionChangedEventArgs e) - { - if (_isDragging) - { - // Skip if we're dragging, we'll reset when we're done. - return; - } - - if (_tabContentPresenter != null) - { - if (SelectedItem == null) - { - _tabContentPresenter.Content = null; - _tabContentPresenter.ContentTemplate = null; - } - else - { - if (ContainerFromItem(SelectedItem) is TabViewItem container) - { - _tabContentPresenter.Content = container.Content; - _tabContentPresenter.ContentTemplate = container.ContentTemplate; - } - } - } - - // If our width can be effected by the selection, need to run algorithm. - if (!double.IsNaN(SelectedTabWidth)) - { - TabView_SizeChanged(sender, null); - } - } - - /// - protected override void PrepareContainerForItemOverride(DependencyObject element, object item) - { - base.PrepareContainerForItemOverride(element, item); - - var tabitem = element as TabViewItem; - - tabitem.Loaded -= TabViewItem_Loaded; - tabitem.Closing -= TabViewItem_Closing; - tabitem.Loaded += TabViewItem_Loaded; - tabitem.Closing += TabViewItem_Closing; - - if (tabitem.Header == null) - { - tabitem.Header = item; - } - - if (tabitem.HeaderTemplate == null) - { - var headertemplatebinding = new Binding() - { - Source = this, - Path = new PropertyPath(nameof(ItemHeaderTemplate)), - Mode = BindingMode.OneWay - }; - tabitem.SetBinding(TabViewItem.HeaderTemplateProperty, headertemplatebinding); - } - - if (tabitem.IsClosable != true && tabitem.ReadLocalValue(TabViewItem.IsClosableProperty) == DependencyProperty.UnsetValue) - { - var iscloseablebinding = new Binding() - { - Source = this, - Path = new PropertyPath(nameof(CanCloseTabs)), - Mode = BindingMode.OneWay, - }; - tabitem.SetBinding(TabViewItem.IsClosableProperty, iscloseablebinding); - } - } - - private void TabViewItem_Loaded(object sender, RoutedEventArgs e) - { - var tabitem = sender as TabViewItem; - - tabitem.Loaded -= TabViewItem_Loaded; - - // Only need to do this once. - if (!_hasLoaded) - { - _hasLoaded = true; - - // Need to set a tab's selection on load, otherwise ListView resets to null. - SetInitialSelection(); - - // Need to make sure ContentPresenter is set to content based on selection. - TabView_SelectionChanged(this, null); - - // Need to make sure we've registered our removal method. - ItemsSource_PropertyChanged(this, null); - - // Make sure we complete layout now. - TabView_SizeChanged(this, null); - } - } - - private void TabViewItem_Closing(object sender, TabClosingEventArgs e) - { - var item = ItemFromContainer(e.Tab); - - var args = new TabClosingEventArgs(item, e.Tab); - TabClosing?.Invoke(this, args); - - if (!args.Cancel) - { - if (ItemsSource != null) - { - _removeItemsSourceMethod?.Invoke(ItemsSource, new object[] { item }); - } - else - { - Items.Remove(item); - } - } - } - - private void TabView_DragItemsStarting(object sender, DragItemsStartingEventArgs e) - { - // Keep track of drag so we don't modify content until done. - _isDragging = true; - } - - private void TabView_DragItemsCompleted(ListViewBase sender, DragItemsCompletedEventArgs args) - { - _isDragging = false; - - // args.DropResult == None when outside of area (e.g. create new window) - if (args.DropResult == DataPackageOperation.None) - { - var item = args.Items.FirstOrDefault(); - var tab = ContainerFromItem(item) as TabViewItem; - - if (tab == null && item is FrameworkElement fe) - { - tab = fe.FindParent(); - } - - if (tab == null) - { - // We still don't have a TabViewItem, most likely is a static TabViewItem in the template being dragged and not selected. - // This is a fallback scenario for static tabs. - // Note: This can be wrong if two TabViewItems share the exact same Content (i.e. a string), this should be unlikely in any practical scenario. - for (int i = 0; i < Items.Count; i++) - { - var tabItem = ContainerFromIndex(i) as TabViewItem; - if (ReferenceEquals(tabItem.Content, item)) - { - tab = tabItem; - break; - } - } - } - - TabDraggedOutside?.Invoke(this, new TabDraggedOutsideEventArgs(item, tab)); - } - else - { - // If dragging the active tab, there's an issue with the CP blanking. - TabView_SelectionChanged(this, null); - } - } - } -} diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.xaml b/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.xaml deleted file mode 100644 index d3310aadf06..00000000000 --- a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.xaml +++ /dev/null @@ -1,736 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 - 0,0,8,0 - 8,0,-8,0 - 0,1,1,0 - 16 - 48 - 40 - NaN - 32 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabViewItem.Properties.cs b/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabViewItem.Properties.cs deleted file mode 100644 index 3ce0f3e5483..00000000000 --- a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabViewItem.Properties.cs +++ /dev/null @@ -1,79 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; - -namespace Microsoft.Toolkit.Uwp.UI.Controls -{ - /// - /// Item Container for a . - /// - public partial class TabViewItem - { - /// - /// Gets or sets the header content for the tab. - /// - public object Header - { - get { return (object)GetValue(HeaderProperty); } - set { SetValue(HeaderProperty, value); } - } - - /// - /// Identifies the dependency property. - /// - /// The identifier for the dependency property. - public static readonly DependencyProperty HeaderProperty = - DependencyProperty.Register(nameof(Header), typeof(object), typeof(TabViewItem), new PropertyMetadata(null)); - - /// - /// Gets or sets the icon to appear in the tab header. - /// - public IconElement Icon - { - get { return (IconElement)GetValue(IconProperty); } - set { SetValue(IconProperty, value); } - } - - /// - /// Identifies the dependency property. - /// - /// The identifier for the dependency property. - public static readonly DependencyProperty IconProperty = - DependencyProperty.Register(nameof(Icon), typeof(IconElement), typeof(TabViewItem), new PropertyMetadata(null)); - - /// - /// Gets or sets the template to override for the tab header. - /// - public DataTemplate HeaderTemplate - { - get { return (DataTemplate)GetValue(HeaderTemplateProperty); } - set { SetValue(HeaderTemplateProperty, value); } - } - - /// - /// Identifies the dependency property. - /// - /// The identifier for the dependency property. - public static readonly DependencyProperty HeaderTemplateProperty = - DependencyProperty.Register(nameof(HeaderTemplate), typeof(DataTemplate), typeof(TabViewItem), new PropertyMetadata(null)); - - /// - /// Gets or sets a value indicating whether the tab can be closed by the user with the close button. - /// - public bool IsClosable - { - get { return (bool)GetValue(IsClosableProperty); } - set { SetValue(IsClosableProperty, value); } - } - - /// - /// Identifies the dependency property. - /// - /// The identifier for the dependency property. - public static readonly DependencyProperty IsClosableProperty = - DependencyProperty.Register(nameof(IsClosable), typeof(bool), typeof(TabViewItem), new PropertyMetadata(null)); - } -} diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabViewItem.cs b/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabViewItem.cs deleted file mode 100644 index 69a968fd839..00000000000 --- a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabViewItem.cs +++ /dev/null @@ -1,116 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using Windows.Devices.Input; -using Windows.System; -using Windows.UI.Core; -using Windows.UI.Input; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Controls.Primitives; -using Windows.UI.Xaml.Input; - -namespace Microsoft.Toolkit.Uwp.UI.Controls -{ - /// - /// Item Container for a . - /// - [TemplatePart(Name = TabCloseButtonName, Type = typeof(ButtonBase))] - public partial class TabViewItem : ListViewItem - { - private const string TabCloseButtonName = "CloseButton"; - - private ButtonBase _tabCloseButton; - - private bool _isMiddleClick; - - /// - /// Initializes a new instance of the class. - /// - public TabViewItem() - { - DefaultStyleKey = typeof(TabViewItem); - } - - /// - /// Fired when the Tab's close button is clicked. - /// - public event EventHandler Closing; - - /// - protected override void OnApplyTemplate() - { - base.OnApplyTemplate(); - - if (_tabCloseButton != null) - { - _tabCloseButton.Click -= TabCloseButton_Click; - } - - _tabCloseButton = GetTemplateChild(TabCloseButtonName) as ButtonBase; - - if (_tabCloseButton != null) - { - _tabCloseButton.Click += TabCloseButton_Click; - } - } - - /// - protected override void OnPointerPressed(PointerRoutedEventArgs e) - { - _isMiddleClick = false; - - if (e.Pointer.PointerDeviceType == PointerDeviceType.Mouse) - { - PointerPoint pointerPoint = e.GetCurrentPoint(this); - - // Record if middle button is pressed - if (pointerPoint.Properties.IsMiddleButtonPressed) - { - _isMiddleClick = true; - } - - // Disable unwanted behaviour inherited by ListViewItem: - // Disable "Ctrl + Left click" to deselect tab - // Or variant like "Ctrl + Shift + Left click" - // Or "Ctrl + Alt + Left click" - if (pointerPoint.Properties.IsLeftButtonPressed) - { - var ctrl = Window.Current.CoreWindow.GetKeyState(VirtualKey.Control); - if (ctrl.HasFlag(CoreVirtualKeyStates.Down)) - { - // return here so the event won't be picked up by the base class - // but keep this event unhandled so it can be picked up further - return; - } - } - } - - base.OnPointerPressed(e); - } - - /// - protected override void OnPointerReleased(PointerRoutedEventArgs e) - { - base.OnPointerReleased(e); - - // Close on Middle-Click - if (_isMiddleClick) - { - TabCloseButton_Click(this, null); - } - - _isMiddleClick = false; - } - - private void TabCloseButton_Click(object sender, RoutedEventArgs e) - { - if (IsClosable) - { - Closing?.Invoke(this, new TabClosingEventArgs(Content, this)); - } - } - } -} diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabWidthMode.cs b/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabWidthMode.cs deleted file mode 100644 index 65b1ce03844..00000000000 --- a/Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabWidthMode.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Windows.UI.Xaml; - -namespace Microsoft.Toolkit.Uwp.UI.Controls -{ - /// - /// Possible modes for how to layout a Header's Width in the . - /// - public enum TabWidthMode - { - /// - /// Each tab header takes up as much space as it needs. This is similar to how WPF and Visual Studio Code behave. - /// Suggest to keep set to false. - /// is ignored. - /// In this scenario, tab width behavior is effectively turned off. This can be useful when using custom styling or a custom panel for layout of as well. - /// - Actual, - - /// - /// Each tab header will use the minimal space set by on the . - /// Suggest to set the to show more content for the selected item. - /// - Compact, - - /// - /// Each tab header will fill to fit the available space. If is set, that will be used as a Maximum Width. - /// This is similar to how Microsoft Edge behaves when used with the . - /// Suggest to set to true. - /// Suggest to set to 200 and the TabViewItemHeaderMinWidth Resource to 90. - /// - Equal, - } -} diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/Themes/Generic.xaml b/Microsoft.Toolkit.Uwp.UI.Controls/Themes/Generic.xaml index 592fbb45626..9c17a3717bd 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls/Themes/Generic.xaml +++ b/Microsoft.Toolkit.Uwp.UI.Controls/Themes/Generic.xaml @@ -9,7 +9,6 @@ - @@ -27,7 +26,6 @@ - diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/TileControl/TileControl.cs b/Microsoft.Toolkit.Uwp.UI.Controls/TileControl/TileControl.cs index 6799439d67a..cdc4af642c5 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls/TileControl/TileControl.cs +++ b/Microsoft.Toolkit.Uwp.UI.Controls/TileControl/TileControl.cs @@ -181,13 +181,6 @@ public class TileControl : ContentControl /// public event EventHandler ImageLoaded; - /// - /// Gets a value indicating whether the platform supports Composition. - /// - [Obsolete("This property is now obsolete and will be removed in a future version of the Toolkit.")] - public static bool IsCompositionSupported => !DesignTimeHelpers.IsRunningInLegacyDesignerMode && - ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 3); // SDK >= 14393 - /// /// Initializes a new instance of the class. /// diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/VisualStudioToolsManifest.xml b/Microsoft.Toolkit.Uwp.UI.Controls/VisualStudioToolsManifest.xml index e2bc71350ef..27fe2b2f0bc 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls/VisualStudioToolsManifest.xml +++ b/Microsoft.Toolkit.Uwp.UI.Controls/VisualStudioToolsManifest.xml @@ -13,7 +13,6 @@ - @@ -33,8 +32,6 @@ - - diff --git a/Microsoft.Toolkit/Extensions/StringExtensions.cs b/Microsoft.Toolkit/Extensions/StringExtensions.cs index 5e81855f128..a39030a11a4 100644 --- a/Microsoft.Toolkit/Extensions/StringExtensions.cs +++ b/Microsoft.Toolkit/Extensions/StringExtensions.cs @@ -86,14 +86,6 @@ public static bool IsDecimal(this string str) /// true if the string contains only letters; otherwise, false. public static bool IsCharacterString(this string str) => Regex.IsMatch(str, CharactersRegex); - /// - /// Returns a string representation of an object. - /// - /// The object to convert. - /// String representation of the object. - [Obsolete("Use value?.ToString() instead. This will be removed in the next release of the toolkit.")] - public static string ToSafeString(this object value) => value?.ToString(); - /// /// Returns a string with HTML comments, scripts, styles, and tags removed. /// From 24c2da528f9f4823cdd7897d6e501cd2608263b8 Mon Sep 17 00:00:00 2001 From: Alexandre Zollinger Chohfi Date: Thu, 20 Aug 2020 14:08:18 -0700 Subject: [PATCH 7/8] Removed RSS parsers. --- .../Microsoft.Toolkit.Parsers.csproj | 4 +- Microsoft.Toolkit.Parsers/Rss/AtomParser.cs | 136 ------ .../Rss/BaseRssParser.cs | 59 --- .../Rss/Enums/RssType.cs | 27 - Microsoft.Toolkit.Parsers/Rss/Rss2Parser.cs | 214 -------- Microsoft.Toolkit.Parsers/Rss/RssHelper.cs | 460 ------------------ Microsoft.Toolkit.Parsers/Rss/RssParser.cs | 43 -- Microsoft.Toolkit.Parsers/Rss/RssSchema.cs | 65 --- .../Microsoft.Toolkit.Uwp.SampleApp.csproj | 7 - .../SamplePages/RssParser/RssParserPage.xaml | 46 -- .../RssParser/RssParserPage.xaml.cs | 70 --- .../SamplePages/samples.json | 8 - readme.md | 2 +- 13 files changed, 2 insertions(+), 1139 deletions(-) delete mode 100644 Microsoft.Toolkit.Parsers/Rss/AtomParser.cs delete mode 100644 Microsoft.Toolkit.Parsers/Rss/BaseRssParser.cs delete mode 100644 Microsoft.Toolkit.Parsers/Rss/Enums/RssType.cs delete mode 100644 Microsoft.Toolkit.Parsers/Rss/Rss2Parser.cs delete mode 100644 Microsoft.Toolkit.Parsers/Rss/RssHelper.cs delete mode 100644 Microsoft.Toolkit.Parsers/Rss/RssParser.cs delete mode 100644 Microsoft.Toolkit.Parsers/Rss/RssSchema.cs delete mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/RssParser/RssParserPage.xaml delete mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/RssParser/RssParserPage.xaml.cs diff --git a/Microsoft.Toolkit.Parsers/Microsoft.Toolkit.Parsers.csproj b/Microsoft.Toolkit.Parsers/Microsoft.Toolkit.Parsers.csproj index 49d99bd104f..a141b75c84b 100644 --- a/Microsoft.Toolkit.Parsers/Microsoft.Toolkit.Parsers.csproj +++ b/Microsoft.Toolkit.Parsers/Microsoft.Toolkit.Parsers.csproj @@ -8,10 +8,8 @@ Markdown: Allows you to parse a Markdown String into a Markdown Document, and then Render it with a Markdown Renderer. - RSS: Allows you to parse an RSS content String into an RSS Schema. - - UWP Toolkit Windows Parsers Parsing Markdown RSS + UWP Toolkit Windows Parsers Parsing Markdown diff --git a/Microsoft.Toolkit.Parsers/Rss/AtomParser.cs b/Microsoft.Toolkit.Parsers/Rss/AtomParser.cs deleted file mode 100644 index 65c2a56a6b7..00000000000 --- a/Microsoft.Toolkit.Parsers/Rss/AtomParser.cs +++ /dev/null @@ -1,136 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Xml.Linq; -using Microsoft.Toolkit.Extensions; - -namespace Microsoft.Toolkit.Parsers.Rss -{ - /// - /// Parser for Atom endpoints. - /// - internal class AtomParser : BaseRssParser - { - /// - /// Atom reader implementation to parse Atom content. - /// - /// XDocument to parse. - /// Strong typed response. - public override IEnumerable LoadFeed(XDocument doc) - { - Collection feed = new Collection(); - - if (doc.Root == null) - { - return feed; - } - - var items = doc.Root.Elements(doc.Root.GetDefaultNamespace() + "entry").Select(item => GetRssSchema(item)).ToList(); - - feed = new Collection(items); - - return feed; - } - - /// - /// Retrieves strong type for passed item. - /// - /// XElement to parse. - /// Strong typed object. - private static RssSchema GetRssSchema(XElement item) - { - RssSchema rssItem = new RssSchema - { - Author = GetItemAuthor(item), - Title = item.GetSafeElementString("title").Trim().DecodeHtml(), - ImageUrl = GetItemImage(item), - PublishDate = item.GetSafeElementDate("published"), - FeedUrl = item.GetLink("alternate"), - }; - - var content = GetItemContent(item); - - // Removes scripts from html - if (!string.IsNullOrEmpty(content)) - { - rssItem.Summary = ProcessHtmlSummary(content); - rssItem.Content = ProcessHtmlContent(content); - } - - string id = item.GetSafeElementString("guid").Trim(); - if (string.IsNullOrEmpty(id)) - { - id = item.GetSafeElementString("id").Trim(); - if (string.IsNullOrEmpty(id)) - { - id = rssItem.FeedUrl; - } - } - - rssItem.InternalID = id; - return rssItem; - } - - /// - /// Retrieves item author from XElement. - /// - /// XElement item. - /// String of Item Author. - private static string GetItemAuthor(XElement item) - { - var content = string.Empty; - - if (item != null && item.Element(item.GetDefaultNamespace() + "author") != null) - { - content = item.Element(item.GetDefaultNamespace() + "author").GetSafeElementString("name"); - } - - if (string.IsNullOrEmpty(content)) - { - content = item.GetSafeElementString("author"); - } - - return content; - } - - /// - /// Returns item image from XElement item. - /// - /// XElement item. - /// String pointing to item image. - private static string GetItemImage(XElement item) - { - if (!string.IsNullOrEmpty(item.GetSafeElementString("image"))) - { - return item.GetSafeElementString("image"); - } - - return item.GetImage(); - } - - /// - /// Returns item content from XElement item. - /// - /// XElement item. - /// String of item content. - private static string GetItemContent(XElement item) - { - var content = item.GetSafeElementString("description"); - if (string.IsNullOrEmpty(content)) - { - content = item.GetSafeElementString("content"); - } - - if (string.IsNullOrEmpty(content)) - { - content = item.GetSafeElementString("summary"); - } - - return content; - } - } -} \ No newline at end of file diff --git a/Microsoft.Toolkit.Parsers/Rss/BaseRssParser.cs b/Microsoft.Toolkit.Parsers/Rss/BaseRssParser.cs deleted file mode 100644 index d268cf5d10c..00000000000 --- a/Microsoft.Toolkit.Parsers/Rss/BaseRssParser.cs +++ /dev/null @@ -1,59 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using System.Xml.Linq; -using Microsoft.Toolkit.Extensions; - -namespace Microsoft.Toolkit.Parsers.Rss -{ - /// - /// Base class for Rss Parser(s). - /// - internal abstract class BaseRssParser - { - /// - /// Retrieve feed type from XDocument. - /// - /// XDocument doc. - /// Return feed type. - public static RssType GetFeedType(XDocument doc) - { - if (doc.Root == null) - { - return RssType.Unknown; - } - - XNamespace defaultNamespace = doc.Root.GetDefaultNamespace(); - return defaultNamespace.NamespaceName.EndsWith("Atom") ? RssType.Atom : RssType.Rss; - } - - /// - /// Abstract method to be override by specific implementations of the reader. - /// - /// XDocument doc. - /// Returns list of strongly typed results. - public abstract IEnumerable LoadFeed(XDocument doc); - - /// - /// Fix up the HTML content. - /// - /// Content to be fixed up. - /// Fixed up content. - protected internal static string ProcessHtmlContent(string htmlContent) - { - return htmlContent.FixHtml().SanitizeString(); - } - - /// - /// Create a summary of the HTML content. - /// - /// Content to be processed. - /// Summary of the content. - protected internal static string ProcessHtmlSummary(string htmlContent) - { - return htmlContent.DecodeHtml().Trim().Truncate(500).SanitizeString(); - } - } -} \ No newline at end of file diff --git a/Microsoft.Toolkit.Parsers/Rss/Enums/RssType.cs b/Microsoft.Toolkit.Parsers/Rss/Enums/RssType.cs deleted file mode 100644 index 99ae9570887..00000000000 --- a/Microsoft.Toolkit.Parsers/Rss/Enums/RssType.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Toolkit.Parsers.Rss -{ - /// - /// Type of Rss. - /// - internal enum RssType - { - /// - /// Atom - /// - Atom, - - /// - /// RSS - /// - Rss, - - /// - /// Unknown - /// - Unknown - } -} \ No newline at end of file diff --git a/Microsoft.Toolkit.Parsers/Rss/Rss2Parser.cs b/Microsoft.Toolkit.Parsers/Rss/Rss2Parser.cs deleted file mode 100644 index e693f0994ac..00000000000 --- a/Microsoft.Toolkit.Parsers/Rss/Rss2Parser.cs +++ /dev/null @@ -1,214 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Xml.Linq; -using Microsoft.Toolkit.Extensions; - -namespace Microsoft.Toolkit.Parsers.Rss -{ - /// - /// Rss reader implementation to parse Rss content. - /// - internal class Rss2Parser : BaseRssParser - { - /// - /// RDF Namespace Uri. - /// - private static readonly XNamespace NsRdfNamespaceUri = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; - - /// - /// RDF Elements Namespace Uri. - /// - private static readonly XNamespace NsRdfElementsNamespaceUri = "http://purl.org/dc/elements/1.1/"; - - /// - /// RDF Content Namespace Uri. - /// - private static readonly XNamespace NsRdfContentNamespaceUri = "http://purl.org/rss/1.0/modules/content/"; - - /// - /// This override load and parses the document and return a list of RssSchema values. - /// - /// XDocument to be loaded. - /// Strongly typed list of feeds. - public override IEnumerable LoadFeed(XDocument doc) - { - bool isRDF = false; - var feed = new Collection(); - XNamespace defaultNamespace = string.Empty; - - if (doc.Root != null) - { - isRDF = doc.Root.Name == (NsRdfNamespaceUri + "RDF"); - defaultNamespace = doc.Root.GetDefaultNamespace(); - } - - foreach (var item in doc.Descendants(defaultNamespace + "item")) - { - var rssItem = isRDF ? ParseRDFItem(item) : ParseRssItem(item); - feed.Add(rssItem); - } - - return feed; - } - - /// - /// Parses XElement item into strong typed object. - /// - /// XElement item to parse. - /// Strong typed object. - private static RssSchema ParseItem(XElement item) - { - var rssItem = new RssSchema(); - rssItem.Title = item.GetSafeElementString("title").Trim().DecodeHtml(); - rssItem.FeedUrl = item.GetSafeElementString("link"); - - rssItem.Author = GetItemAuthor(item); - - string content = item.GetSafeElementString("encoded", NsRdfContentNamespaceUri); - if (string.IsNullOrEmpty(content)) - { - content = item.GetSafeElementString("description"); - if (string.IsNullOrEmpty(content)) - { - content = item.GetSafeElementString("content"); - } - } - - var summary = item.GetSafeElementString("description"); - if (string.IsNullOrEmpty(summary)) - { - summary = item.GetSafeElementString("encoded", NsRdfContentNamespaceUri); - } - - // Removes scripts from html - if (!string.IsNullOrEmpty(summary)) - { - rssItem.Summary = ProcessHtmlSummary(summary); - } - - if (!string.IsNullOrEmpty(content)) - { - rssItem.Content = ProcessHtmlContent(content); - } - - string id = item.GetSafeElementString("guid").Trim(); - if (string.IsNullOrEmpty(id)) - { - id = item.GetSafeElementString("id").Trim(); - if (string.IsNullOrEmpty(id)) - { - id = rssItem.FeedUrl; - } - } - - rssItem.InternalID = id; - - return rssItem; - } - - /// - /// Parses RSS version 1.0 objects. - /// - /// XElement item. - /// Strong typed object. - private static RssSchema ParseRDFItem(XElement item) - { - XNamespace ns = "http://search.yahoo.com/mrss/"; - var rssItem = ParseItem(item); - - rssItem.PublishDate = item.GetSafeElementDate("date", NsRdfElementsNamespaceUri); - - string image = item.GetSafeElementString("image"); - if (string.IsNullOrEmpty(image) && item.Elements(ns + "thumbnail").LastOrDefault() != null) - { - var element = item.Elements(ns + "thumbnail").Last(); - image = element.Attribute("url").Value; - } - - if (string.IsNullOrEmpty(image) && item.ToString().Contains("thumbnail")) - { - image = item.GetSafeElementString("thumbnail"); - } - - if (string.IsNullOrEmpty(image)) - { - image = item.GetImage(); - } - - rssItem.ImageUrl = image; - - return rssItem; - } - - /// - /// Parses RSS version 2.0 objects. - /// - /// XElement item. - /// Strong typed object. - private static RssSchema ParseRssItem(XElement item) - { - XNamespace ns = "http://search.yahoo.com/mrss/"; - var rssItem = ParseItem(item); - - rssItem.PublishDate = item.GetSafeElementDate("pubDate"); - - string image = item.GetSafeElementString("image"); - if (string.IsNullOrEmpty(image)) - { - image = item.GetImageFromEnclosure(); - } - - if (string.IsNullOrEmpty(image) && item.Elements(ns + "content").LastOrDefault() != null) - { - var element = item.Elements(ns + "content").Last(); - if (element.Attribute("type") != null && element.Attribute("type").Value.Contains("image/")) - { - image = element.Attribute("url").Value; - } - } - - if (string.IsNullOrEmpty(image) && item.Elements(ns + "thumbnail").LastOrDefault() != null) - { - var element = item.Elements(ns + "thumbnail").Last(); - image = element.Attribute("url").Value; - } - - if (string.IsNullOrEmpty(image) && item.ToString().Contains("thumbnail")) - { - image = item.GetSafeElementString("thumbnail"); - } - - if (string.IsNullOrEmpty(image)) - { - image = item.GetImage(); - } - - rssItem.Categories = item.GetSafeElementsString("category"); - - rssItem.ImageUrl = image; - - return rssItem; - } - - /// - /// Retrieve item author from item. - /// - /// XElement item. - /// String of item author. - private static string GetItemAuthor(XElement item) - { - var content = item.GetSafeElementString("creator", NsRdfElementsNamespaceUri).Trim(); - if (string.IsNullOrEmpty(content)) - { - content = item.GetSafeElementString("author"); - } - - return content; - } - } -} \ No newline at end of file diff --git a/Microsoft.Toolkit.Parsers/Rss/RssHelper.cs b/Microsoft.Toolkit.Parsers/Rss/RssHelper.cs deleted file mode 100644 index 5b4b19d5af3..00000000000 --- a/Microsoft.Toolkit.Parsers/Rss/RssHelper.cs +++ /dev/null @@ -1,460 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Globalization; -using System.Linq; -using System.Text.RegularExpressions; -using System.Xml.Linq; - -namespace Microsoft.Toolkit.Parsers.Rss -{ - /// - /// Class with utilities for Rss related works. - /// - internal static class RssHelper - { - /// - /// String for regular expression for image pattern. - /// - private const string ImagePattern = @""; - - /// - /// String for regular expression for hyperlink pattern. - /// - private const string HyperlinkPattern = @"]*?\s+)?href=""([^ ""]*)"""; - - /// - /// String for regular expression for height pattern. - /// - private const string HeightPattern = @"height=(?:(['""])(?(?:(?!\1).)*)\1|(?\S+))"; - - /// - /// String for regular expression for width pattern. - /// - private const string WidthPattern = @"width=(?:(['""])(?(?:(?!\1).)*)\1|(?\S+))"; - - /// - /// Regular expression for image pattern. - /// - private static readonly Regex RegexImages = new Regex(ImagePattern, RegexOptions.IgnoreCase); - - /// - /// Regular expression for hyperlink pattern. - /// - private static readonly Regex RegexLinks = new Regex(HyperlinkPattern, RegexOptions.IgnoreCase); - - /// - /// Regular expression for height pattern. - /// - private static readonly Regex RegexHeight = new Regex(HeightPattern, RegexOptions.IgnoreCase | RegexOptions.Singleline); - - /// - /// Regular expression for width pattern. - /// - private static readonly Regex RegexWidth = new Regex(WidthPattern, RegexOptions.IgnoreCase | RegexOptions.Singleline); - - /// - /// Removes \t characters in the string and trim additional space and carriage returns. - /// - /// Text string. - /// Sanitized string. - public static string SanitizeString(this string text) - { - if (string.IsNullOrEmpty(text)) - { - return string.Empty; - } - - var textArray = text.Split(new[] { "\t" }, StringSplitOptions.RemoveEmptyEntries); - string sanitizedText = string.Empty; - foreach (var item in textArray.ToList()) - { - sanitizedText += item.Trim(); - } - - sanitizedText = string.Join(" ", Regex.Split(sanitizedText, @"(?:\r\n|\n|\r)")); - - return sanitizedText; - } - - /// - /// Get item date from and element name. - /// - /// XElement item. - /// Name of element. - /// Item date. - public static DateTime GetSafeElementDate(this XElement item, string elementName) - { - return GetSafeElementDate(item, elementName, item.GetDefaultNamespace()); - } - - /// - /// Get item date from , element name and . - /// - /// XElement item. - /// Name of element. - /// XNamespace namespace. - /// Item date. - public static DateTime GetSafeElementDate(this XElement item, string elementName, XNamespace xNamespace) - { - DateTime date; - XElement element = item.Element(xNamespace + elementName); - if (element == null) - { - return DateTime.Now; - } - - if (TryParseDateTime(element.Value, out date)) - { - return date; - } - - return DateTime.Now; - } - - /// - /// Get item string value for and element name. - /// - /// XElement item. - /// Name of element. - /// Safe string. - public static string GetSafeElementString(this XElement item, string elementName) - { - if (item == null) - { - return string.Empty; - } - - return GetSafeElementString(item, elementName, item.GetDefaultNamespace()); - } - - /// - /// Get item string values for and element name. - /// - /// XElement item. - /// Name of the element. - /// Safe list of string values. - public static IEnumerable GetSafeElementsString(this XElement item, string elementName) - { - return GetSafeElementsString(item, elementName, item.GetDefaultNamespace()); - } - - /// - /// Get item string values for , element name and namespace. - /// - /// XElement item. - /// Name of element. - /// XNamespace namespace. - /// Safe list of string values. - public static IEnumerable GetSafeElementsString(this XElement item, string elementName, XNamespace xNamespace) - { - if (item != null) - { - IEnumerable values = item.Elements(xNamespace + elementName); - return values.Where(f => !string.IsNullOrEmpty(f.Value)) - .Select(f => f.Value); - } - - return Enumerable.Empty(); - } - - /// - /// Get item string value for , element name and namespace. - /// - /// XElement item. - /// Name of element. - /// XNamespace namespace. - /// Safe string. - public static string GetSafeElementString(this XElement item, string elementName, XNamespace xNamespace) - { - if (item == null) - { - return string.Empty; - } - - XElement value = item.Element(xNamespace + elementName); - if (value != null) - { - return value.Value; - } - - return string.Empty; - } - - /// - /// Get feed url to see full original information. - /// - /// XElement item. - /// rel attribute value. - /// String link. - public static string GetLink(this XElement item, string rel) - { - IEnumerable links = item.Elements(item.GetDefaultNamespace() + "link"); - var xElements = links as XElement[] ?? links.ToArray(); - IEnumerable link = from l in xElements - let xAttribute = l.Attribute("rel") - where xAttribute != null && xAttribute.Value == rel - let attribute = l.Attribute("href") - where attribute != null - select attribute.Value; - var enumerable = link as string[] ?? link.ToArray(); - if (!enumerable.Any() && xElements.Any()) - { - return xElements.FirstOrDefault().Attributes().First().Value; - } - - return enumerable.FirstOrDefault(); - } - - /// - /// Get feed image. - /// - /// XElement item. - /// Feed data image. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "The general catch is intended to avoid breaking the Data Provider by a Html decode exception")] - public static string GetImage(this XElement item) - { - string feedDataImage = null; - try - { - feedDataImage = GetImagesInHTMLString(item.Value).FirstOrDefault(); - if (!string.IsNullOrEmpty(feedDataImage) && feedDataImage.EndsWith("'")) - { - feedDataImage = feedDataImage.Remove(feedDataImage.Length - 1); - } - } - catch (Exception ex) - { - Debug.WriteLine(ex); - } - - return feedDataImage; - } - - /// - /// Get the item image from the enclosure element http://www.w3schools.com/rss/rss_tag_enclosure.asp - /// - /// XElement item. - /// Feed data image. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "The general catch is intended to avoid breaking the Data Provider by a Html decode exception")] - public static string GetImageFromEnclosure(this XElement item) - { - string feedDataImage = null; - try - { - XElement element = item.Element(item.GetDefaultNamespace() + "enclosure"); - if (element == null) - { - return string.Empty; - } - - var typeAttribute = element.Attribute("type"); - if (!string.IsNullOrEmpty(typeAttribute?.Value) && typeAttribute.Value.StartsWith("image")) - { - var urlAttribute = element.Attribute("url"); - feedDataImage = (!string.IsNullOrEmpty(urlAttribute?.Value)) ? - urlAttribute.Value : string.Empty; - } - } - catch (Exception ex) - { - Debug.WriteLine(ex); - } - - return feedDataImage; - } - - /// - /// Tries to parse the original string to a datetime format. - /// - /// Input string. - /// Parsed datetime. - /// True if success - public static bool TryParseDateTime(string s, out DateTime result) - { - if (DateTime.TryParse(s, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.AllowWhiteSpaces, out result)) - { - return true; - } - - int tzIndex = s.LastIndexOf(" "); - if (tzIndex >= 0) - { - string tz = s.Substring(tzIndex, s.Length - tzIndex); - string offset = TimeZoneToOffset(tz); - if (offset != null) - { - string offsetDate = string.Format("{0} {1}", s.Substring(0, tzIndex), offset); - return TryParseDateTime(offsetDate, out result); - } - } - - result = default(DateTime); - return false; - } - - /// - /// Calculate and return timezone. - /// - /// Input string. - /// Parsed timezone. - public static string TimeZoneToOffset(string tz) - { - if (tz == null) - { - return null; - } - - tz = tz.ToUpper().Trim(); - - if (TimeZones.ContainsKey(tz)) - { - return TimeZones[tz].First(); - } - - return null; - } - - /// - /// Retrieve images from HTML string. - /// - /// String of HTML. - /// List of images. - private static IEnumerable GetImagesInHTMLString(string htmlString) - { - var images = new List(); - foreach (Match match in RegexImages.Matches(htmlString)) - { - bool include = true; - string tag = match.Value; - - // Ignores images with low size - var matchHeight = RegexHeight.Match(tag); - if (matchHeight.Success) - { - var heightValue = matchHeight.Groups["height"].Value; - if (int.TryParse(heightValue, out var heightIntValue) && heightIntValue < 10) - { - include = false; - } - } - - var matchWidth = RegexWidth.Match(tag); - if (matchWidth.Success) - { - var widthValue = matchWidth.Groups["width"].Value; - if (int.TryParse(widthValue, out var widthIntValue) && widthIntValue < 10) - { - include = false; - } - } - - if (include) - { - images.Add(match.Groups[1].Value); - } - } - - foreach (Match match in RegexLinks.Matches(htmlString)) - { - var value = match.Groups[1].Value; - if (value.Contains(".jpg") || value.Contains(".png")) - { - images.Add(value); - } - } - - return images; - } - - /// - /// Dictionary of timezones. - /// - private static readonly Dictionary TimeZones = new Dictionary - { - { "ACDT", new[] { "-1030", "Australian Central Daylight" } }, - { "ACST", new[] { "-0930", "Australian Central Standard" } }, - { "ADT", new[] { "+0300", "(US) Atlantic Daylight" } }, - { "AEDT", new[] { "-1100", "Australian East Daylight" } }, - { "AEST", new[] { "-1000", "Australian East Standard" } }, - { "AHDT", new[] { "+0900", string.Empty } }, - { "AHST", new[] { "+1000", string.Empty } }, - { "AST", new[] { "+0400", "(US) Atlantic Standard" } }, - { "AT", new[] { "+0200", "Azores" } }, - { "AWDT", new[] { "-0900", "Australian West Daylight" } }, - { "AWST", new[] { "-0800", "Australian West Standard" } }, - { "BAT", new[] { "-0300", "Baghdad" } }, - { "BDST", new[] { "-0200", "British Double Summer" } }, - { "BET", new[] { "+1100", "Bering Standard" } }, - { "BST", new[] { "+0300", "Brazil Standard" } }, - { "BT", new[] { "-0300", "Baghdad" } }, - { "BZT2", new[] { "+0300", "Brazil Zone 2" } }, - { "CADT", new[] { "-1030", "Central Australian Daylight" } }, - { "CAST", new[] { "-0930", "Central Australian Standard" } }, - { "CAT", new[] { "+1000", "Central Alaska" } }, - { "CCT", new[] { "-0800", "China Coast" } }, - { "CDT", new[] { "+0500", "(US) Central Daylight" } }, - { "CED", new[] { "-0200", "Central European Daylight" } }, - { "CET", new[] { "-0100", "Central European" } }, - { "CST", new[] { "+0600", "(US) Central Standard" } }, - { "EAST", new[] { "-1000", "Eastern Australian Standard" } }, - { "EDT", new[] { "+0400", "(US) Eastern Daylight" } }, - { "EED", new[] { "-0300", "Eastern European Daylight" } }, - { "EET", new[] { "-0200", "Eastern Europe" } }, - { "EEST", new[] { "-0300", "Eastern Europe Summer" } }, - { "EST", new[] { "+0500", "(US) Eastern Standard" } }, - { "FST", new[] { "-0200", "French Summer" } }, - { "FWT", new[] { "-0100", "French Winter" } }, - { "GMT", new[] { "+0000", "Greenwich Mean" } }, - { "GST", new[] { "-1000", "Guam Standard" } }, - { "HDT", new[] { "+0900", "Hawaii Daylight" } }, - { "HST", new[] { "+1000", "Hawaii Standard" } }, - { "IDLE", new[] { "-1200", "International Date Line East" } }, - { "IDLW", new[] { "+1200", "International Date Line West" } }, - { "IST", new[] { "-0530", "Indian Standard" } }, - { "IT", new[] { "-0330", "Iran" } }, - { "JST", new[] { "-0900", "Japan Standard" } }, - { "JT", new[] { "-0700", "Java" } }, - { "MDT", new[] { "+0600", "(US) Mountain Daylight" } }, - { "MED", new[] { "-0200", "Middle European Daylight" } }, - { "MET", new[] { "-0100", "Middle European" } }, - { "MEST", new[] { "-0200", "Middle European Summer" } }, - { "MEWT", new[] { "-0100", "Middle European Winter" } }, - { "MST", new[] { "+0700", "(US) Mountain Standard" } }, - { "MT", new[] { "-0800", "Moluccas" } }, - { "NDT", new[] { "+0230", "Newfoundland Daylight" } }, - { "NFT", new[] { "+0330", "Newfoundland" } }, - { "NT", new[] { "+1100", "Nome" } }, - { "NST", new[] { "-0630", "North Sumatra" } }, - { "NZ", new[] { "-1100", "New Zealand " } }, - { "NZST", new[] { "-1200", "New Zealand Standard" } }, - { "NZDT", new[] { "-1300", "New Zealand Daylight" } }, - { "NZT", new[] { "-1200", "New Zealand" } }, - { "PDT", new[] { "+0700", "(US) Pacific Daylight" } }, - { "PST", new[] { "+0800", "(US) Pacific Standard" } }, - { "ROK", new[] { "-0900", "Republic of Korea" } }, - { "SAD", new[] { "-1000", "South Australia Daylight" } }, - { "SAST", new[] { "-0900", "South Australia Standard" } }, - { "SAT", new[] { "-0900", "South Australia Standard" } }, - { "SDT", new[] { "-1000", "South Australia Daylight" } }, - { "SST", new[] { "-0200", "Swedish Summer" } }, - { "SWT", new[] { "-0100", "Swedish Winter" } }, - { "USZ3", new[] { "-0400", "Volga Time (Russia)" } }, - { "USZ4", new[] { "-0500", "Ural Time (Russia)" } }, - { "USZ5", new[] { "-0600", "West-Siberian Time (Russia) " } }, - { "USZ6", new[] { "-0700", "Yenisei Time (Russia)" } }, - { "UT", new[] { "+0000", "Universal Coordinated" } }, - { "UTC", new[] { "+0000", "Universal Coordinated" } }, - { "UZ10", new[] { "-1100", "Okhotsk Time (Russia)" } }, - { "WAT", new[] { "+0100", "West Africa" } }, - { "WET", new[] { "+0000", "West European" } }, - { "WST", new[] { "-0800", "West Australian Standard" } }, - { "YDT", new[] { "+0800", "Yukon Daylight" } }, - { "YST", new[] { "+0900", "Yukon Standard" } } - }; - } -} \ No newline at end of file diff --git a/Microsoft.Toolkit.Parsers/Rss/RssParser.cs b/Microsoft.Toolkit.Parsers/Rss/RssParser.cs deleted file mode 100644 index e3f1952523c..00000000000 --- a/Microsoft.Toolkit.Parsers/Rss/RssParser.cs +++ /dev/null @@ -1,43 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using System.Xml.Linq; - -namespace Microsoft.Toolkit.Parsers.Rss -{ - /// - /// The RSS Parser allows you to parse an RSS content String into RSS Schema. - /// - public class RssParser : IParser - { - /// - /// Parse an RSS content string into RSS Schema. - /// - /// Input string. - /// Strong type. - public IEnumerable Parse(string data) - { - if (string.IsNullOrEmpty(data)) - { - return null; - } - - var doc = XDocument.Parse(data); - var type = BaseRssParser.GetFeedType(doc); - - BaseRssParser rssParser; - if (type == RssType.Rss) - { - rssParser = new Rss2Parser(); - } - else - { - rssParser = new AtomParser(); - } - - return rssParser.LoadFeed(doc); - } - } -} \ No newline at end of file diff --git a/Microsoft.Toolkit.Parsers/Rss/RssSchema.cs b/Microsoft.Toolkit.Parsers/Rss/RssSchema.cs deleted file mode 100644 index 3ea8b7453ee..00000000000 --- a/Microsoft.Toolkit.Parsers/Rss/RssSchema.cs +++ /dev/null @@ -1,65 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections.Generic; - -namespace Microsoft.Toolkit.Parsers.Rss -{ - /// - /// Implementation of the RssSchema class. - /// - public class RssSchema : SchemaBase - { - /// - /// Gets or sets title. - /// - public string Title { get; set; } - - /// - /// Gets or sets summary. - /// - public string Summary { get; set; } - - /// - /// Gets or sets content. - /// - public string Content { get; set; } - - /// - /// Gets or sets image Url. - /// - public string ImageUrl { get; set; } - - /// - /// Gets or sets extra Image Url. - /// - public string ExtraImageUrl { get; set; } - - /// - /// Gets or sets media Url. - /// - public string MediaUrl { get; set; } - - /// - /// Gets or sets feed Url. - /// - public string FeedUrl { get; set; } - - /// - /// Gets or sets author. - /// - public string Author { get; set; } - - /// - /// Gets or sets publish Date. - /// - public DateTime PublishDate { get; set; } - - /// - /// Gets or sets item's categories. - /// - public IEnumerable Categories { get; set; } - } -} \ No newline at end of file diff --git a/Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj b/Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj index 5476e2d5c12..5d4e14a81fb 100644 --- a/Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj +++ b/Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj @@ -762,9 +762,6 @@ RemoteDevicePickerControlPage.xaml - - RssParserPage.xaml - RadialGradientBrushPage.xaml @@ -1226,10 +1223,6 @@ Designer MSBuild:Compile - - Designer - MSBuild:Compile - Designer MSBuild:Compile diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/RssParser/RssParserPage.xaml b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/RssParser/RssParserPage.xaml deleted file mode 100644 index e844fc9773d..00000000000 --- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/RssParser/RssParserPage.xaml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - -