diff --git a/MAUI.FreakyControls/MAUI.FreakyControls.sln b/MAUI.FreakyControls/MAUI.FreakyControls.sln index 596d4c38..9f42cec4 100644 --- a/MAUI.FreakyControls/MAUI.FreakyControls.sln +++ b/MAUI.FreakyControls/MAUI.FreakyControls.sln @@ -1,7 +1,6 @@ - Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 25.0.1703.2 +# Visual Studio Version 17 +VisualStudioVersion = 17.13.35723.152 d17.13 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Samples", "Samples\Samples.csproj", "{FA323AEE-85A9-4D5D-9726-03C7D1FD71A2}" EndProject @@ -15,16 +14,13 @@ Global GlobalSection(ProjectConfigurationPlatforms) = postSolution {FA323AEE-85A9-4D5D-9726-03C7D1FD71A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FA323AEE-85A9-4D5D-9726-03C7D1FD71A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA323AEE-85A9-4D5D-9726-03C7D1FD71A2}.Debug|Any CPU.Deploy.0 = Debug|Any CPU {FA323AEE-85A9-4D5D-9726-03C7D1FD71A2}.Release|Any CPU.ActiveCfg = Release|Any CPU {FA323AEE-85A9-4D5D-9726-03C7D1FD71A2}.Release|Any CPU.Build.0 = Release|Any CPU {864B4829-7286-4921-A185-DA67FE0D1155}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {864B4829-7286-4921-A185-DA67FE0D1155}.Debug|Any CPU.Build.0 = Debug|Any CPU {864B4829-7286-4921-A185-DA67FE0D1155}.Release|Any CPU.ActiveCfg = Release|Any CPU {864B4829-7286-4921-A185-DA67FE0D1155}.Release|Any CPU.Build.0 = Release|Any CPU - {C80669FA-43B5-4B68-9819-30BFD1915031}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C80669FA-43B5-4B68-9819-30BFD1915031}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C80669FA-43B5-4B68-9819-30BFD1915031}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C80669FA-43B5-4B68-9819-30BFD1915031}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -32,4 +28,4 @@ Global GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {3A49EF6E-4CF5-41B1-8F23-FCD2AC812C50} EndGlobalSection -EndGlobal \ No newline at end of file +EndGlobal diff --git a/MAUI.FreakyControls/MAUI.FreakyControls/Converters/InverseBoolConverter.cs b/MAUI.FreakyControls/MAUI.FreakyControls/Converters/InverseBoolConverter.cs index 704895af..da779069 100644 --- a/MAUI.FreakyControls/MAUI.FreakyControls/Converters/InverseBoolConverter.cs +++ b/MAUI.FreakyControls/MAUI.FreakyControls/Converters/InverseBoolConverter.cs @@ -6,7 +6,7 @@ public class InverseBoolConverter : BaseOneWayValueConverter { public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - if (!(value is bool boolValue)) + if (value is not bool boolValue) { throw new ArgumentException("Value must be a boolean", nameof(value)); } diff --git a/MAUI.FreakyControls/MAUI.FreakyControls/Extensions/CollectionExtensions.cs b/MAUI.FreakyControls/MAUI.FreakyControls/Extensions/CollectionExtensions.cs index b8adef4f..fdb39b6c 100644 --- a/MAUI.FreakyControls/MAUI.FreakyControls/Extensions/CollectionExtensions.cs +++ b/MAUI.FreakyControls/MAUI.FreakyControls/Extensions/CollectionExtensions.cs @@ -6,7 +6,7 @@ public static class CollectionExtensions { public static ObservableCollection ToObservable(this IEnumerable col) { - return new ObservableCollection(col); + return [.. col]; } public static IEnumerable<(T item, int index)> WithIndex(this IEnumerable self) => self?.Select((item, index) => (item, index)) ?? new List<(T, int)>(); diff --git a/MAUI.FreakyControls/MAUI.FreakyControls/Extensions/StreamExtensions.cs b/MAUI.FreakyControls/MAUI.FreakyControls/Extensions/StreamExtensions.cs index f6a81aff..61c4cd99 100644 --- a/MAUI.FreakyControls/MAUI.FreakyControls/Extensions/StreamExtensions.cs +++ b/MAUI.FreakyControls/MAUI.FreakyControls/Extensions/StreamExtensions.cs @@ -4,7 +4,7 @@ public static class StreamExtensions { public static MemoryStream GetMemoryStream(this Stream stream) { - MemoryStream memoryStream = new MemoryStream(); + MemoryStream memoryStream = new(); stream.CopyTo(memoryStream); memoryStream.Position = 0; return memoryStream; diff --git a/MAUI.FreakyControls/MAUI.FreakyControls/Helpers/DownloadHelper.cs b/MAUI.FreakyControls/MAUI.FreakyControls/Helpers/DownloadHelper.cs index 88e13ce9..4779476d 100644 --- a/MAUI.FreakyControls/MAUI.FreakyControls/Helpers/DownloadHelper.cs +++ b/MAUI.FreakyControls/MAUI.FreakyControls/Helpers/DownloadHelper.cs @@ -20,7 +20,7 @@ private static async Task DownloadStreamAsync(Uri uri, CancellationToken // Do not remove this await otherwise the client will dispose before // the stream even starts - return await StreamWrapper.GetStreamAsync(uri, cancellationToken, client).ConfigureAwait(false); + return await StreamWrapper.GetStreamAsync(uri, client, cancellationToken).ConfigureAwait(false); } catch (Exception ex) { diff --git a/MAUI.FreakyControls/MAUI.FreakyControls/Helpers/SizeOrScale.cs b/MAUI.FreakyControls/MAUI.FreakyControls/Helpers/SizeOrScale.cs index 5d834dd3..035b27c1 100644 --- a/MAUI.FreakyControls/MAUI.FreakyControls/Helpers/SizeOrScale.cs +++ b/MAUI.FreakyControls/MAUI.FreakyControls/Helpers/SizeOrScale.cs @@ -60,9 +60,9 @@ public SizeOrScale(float x, float y, SizeOrScaleType type, bool keepAspectRatio) public bool KeepAspectRatio { get; set; } - public bool IsValid => X > 0 && Y > 0; + public readonly bool IsValid => X > 0 && Y > 0; - public Size GetScale(float width, float height) + public readonly Size GetScale(float width, float height) { if (Type == SizeOrScaleType.Scale) { @@ -74,7 +74,7 @@ public Size GetScale(float width, float height) } } - public Size GetSize(float width, float height) + public readonly Size GetSize(float width, float height) { if (Type == SizeOrScaleType.Scale) { diff --git a/MAUI.FreakyControls/MAUI.FreakyControls/Platforms/Android/FreakySignatureCanvasViewHandler.android.cs b/MAUI.FreakyControls/MAUI.FreakyControls/Platforms/Android/FreakySignatureCanvasViewHandler.android.cs index f7786d85..b662b34e 100644 --- a/MAUI.FreakyControls/MAUI.FreakyControls/Platforms/Android/FreakySignatureCanvasViewHandler.android.cs +++ b/MAUI.FreakyControls/MAUI.FreakyControls/Platforms/Android/FreakySignatureCanvasViewHandler.android.cs @@ -10,7 +10,7 @@ protected override Platforms.Android.SignaturePadCanvasView private void OnImageStreamRequested(object sender, ImageStreamRequestedEventArgs e) { - var ctrl = this.PlatformView; + var ctrl = PlatformView; if (ctrl is not null) { var format = e.ImageFormat; diff --git a/MAUI.FreakyControls/MAUI.FreakyControls/Wrappers/StreamWrapper.cs b/MAUI.FreakyControls/MAUI.FreakyControls/Wrappers/StreamWrapper.cs index 376bb061..2751c2a4 100644 --- a/MAUI.FreakyControls/MAUI.FreakyControls/Wrappers/StreamWrapper.cs +++ b/MAUI.FreakyControls/MAUI.FreakyControls/Wrappers/StreamWrapper.cs @@ -1,4 +1,5 @@ using System.Diagnostics; +using System.Threading; namespace Maui.FreakyControls.Wrappers { @@ -83,7 +84,7 @@ protected override void Dispose(bool disposing) base.Dispose(disposing); } - public static async Task GetStreamAsync(Uri uri, CancellationToken cancellationToken, HttpClient client) + public static async Task GetStreamAsync(Uri uri, HttpClient client, CancellationToken cancellationToken) { var response = await client.GetAsync(uri, cancellationToken).ConfigureAwait(false); if (!response.IsSuccessStatusCode) @@ -96,7 +97,7 @@ public static async Task GetStreamAsync(Uri uri, CancellationToken cance // the HttpResponseMessage needs to be disposed of after the calling code is done with the stream // otherwise the stream may get disposed before the caller can use it - return new StreamWrapper(await response.Content.ReadAsStreamAsync().ConfigureAwait(false), response); + return new StreamWrapper(await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false), response); } } } \ No newline at end of file diff --git a/MAUI.FreakyControls/Samples/AppShell.xaml.cs b/MAUI.FreakyControls/Samples/AppShell.xaml.cs index b1fc5e0b..0a45e9b0 100644 --- a/MAUI.FreakyControls/Samples/AppShell.xaml.cs +++ b/MAUI.FreakyControls/Samples/AppShell.xaml.cs @@ -2,35 +2,35 @@ namespace Samples; public partial class AppShell : Shell { - internal const string buttons = "Buttons"; - internal const string checkboxes = "Checkboxes"; - internal const string imageViews = "ImageViews"; - internal const string inputViews = "InputViews"; - internal const string pickers = "Pickers"; - internal const string radioButtons = "RadioButtons"; - internal const string signaturePreview = "ImageDisplay"; - internal const string signatureView = "SignatureView"; - internal const string textInputLayout = "TextInputLayouts"; - internal const string jumpList = "JumpList"; - internal const string pinView = "PinView"; - internal const string switches = "Switch"; - internal const string zoomImage = "ZoomImage"; + internal const string Buttons = "Buttons"; + internal const string Checkboxes = "Checkboxes"; + internal const string ImageViews = "ImageViews"; + internal const string InputViews = "InputViews"; + internal const string Pickers = "Pickers"; + internal const string RadioButtons = "RadioButtons"; + internal const string SignaturePreview = "ImageDisplay"; + internal const string SignatureView = "SignatureView"; + internal const string TextInputLayout = "TextInputLayouts"; + internal const string JumpList = "JumpList"; + internal const string PinView = "PinView"; + internal const string Switches = "Switch"; + internal const string ZoomImage = "ZoomImage"; public AppShell() { InitializeComponent(); - Routing.RegisterRoute(inputViews, typeof(InputViews.InputViews)); - Routing.RegisterRoute(pickers, typeof(Pickers.PickersView)); - Routing.RegisterRoute(textInputLayout, typeof(TextInputLayout.TextInputLayoutView)); - Routing.RegisterRoute(imageViews, typeof(ImageViews.ImagesPage)); - Routing.RegisterRoute(signatureView, typeof(SignatureView.SignatureView)); - Routing.RegisterRoute(signaturePreview, typeof(SignatureView.ImageDisplay)); - Routing.RegisterRoute(checkboxes, typeof(Checkboxes.CheckboxesView)); - Routing.RegisterRoute(radioButtons, typeof(RadioButtons.RadioButtonsView)); - Routing.RegisterRoute(buttons, typeof(ButtonsView.ButtonsView)); - Routing.RegisterRoute(jumpList, typeof(JumpList.JumpListView)); - Routing.RegisterRoute(pinView, typeof(PinView.PinView)); - Routing.RegisterRoute(switches, typeof(Switch.SwitchsView)); - Routing.RegisterRoute(zoomImage, typeof(ZoomImage.ZoomImageView)); + Routing.RegisterRoute(InputViews, typeof(InputViews.InputViews)); + Routing.RegisterRoute(Pickers, typeof(Pickers.PickersView)); + Routing.RegisterRoute(TextInputLayout, typeof(TextInputLayout.TextInputLayoutView)); + Routing.RegisterRoute(ImageViews, typeof(ImageViews.ImagesPage)); + Routing.RegisterRoute(SignatureView, typeof(SignatureView.SignatureView)); + Routing.RegisterRoute(SignaturePreview, typeof(SignatureView.ImageDisplay)); + Routing.RegisterRoute(Checkboxes, typeof(Checkboxes.CheckboxesView)); + Routing.RegisterRoute(RadioButtons, typeof(RadioButtons.RadioButtonsView)); + Routing.RegisterRoute(Buttons, typeof(ButtonsView.ButtonsView)); + Routing.RegisterRoute(JumpList, typeof(JumpList.JumpListView)); + Routing.RegisterRoute(PinView, typeof(PinView.PinView)); + Routing.RegisterRoute(Switches, typeof(Switch.SwitchsView)); + Routing.RegisterRoute(ZoomImage, typeof(ZoomImage.ZoomImageView)); } } \ No newline at end of file diff --git a/MAUI.FreakyControls/Samples/Checkboxes/CheckboxesView.xaml b/MAUI.FreakyControls/Samples/Checkboxes/CheckboxesView.xaml index bbe26983..9059cdab 100644 --- a/MAUI.FreakyControls/Samples/Checkboxes/CheckboxesView.xaml +++ b/MAUI.FreakyControls/Samples/Checkboxes/CheckboxesView.xaml @@ -5,7 +5,10 @@ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:constants="clr-namespace:Samples" xmlns:freakyControls="clr-namespace:Maui.FreakyControls;assembly=Maui.FreakyControls" + xmlns:vm="clr-namespace:Samples.Checkboxes" + x:DataType="vm:CheckboxesViewModel" Title="CheckboxesView"> +