From: Lukasz Stanislawski Date: Tue, 20 Oct 2020 12:46:08 +0000 (+0200) Subject: Review fixes X-Git-Tag: accepted/tizen/unified/20210915.100113~156 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fdd1facca2e12b8e978792032aed0a10ecd8687d;p=profile%2Fiot%2Fapps%2Fdotnet%2Ffitness.git Review fixes --- diff --git a/Fitness/Config.cs b/Fitness/Config.cs index 26cc8ef..a7fc539 100644 --- a/Fitness/Config.cs +++ b/Fitness/Config.cs @@ -13,11 +13,6 @@ namespace Fitness /// /// Unit Size for current screen /// - public const UnitSize PixelsPerUnit = UnitSize.MediumUnit; - - /// - /// Number of units per pixel - /// - public const float UnitsPerPixel = 1.0f / (int)PixelsPerUnit; + public const UnitSize PixelsPerUnit = UnitSize.Medium; } } diff --git a/Fitness/UnitSize.cs b/Fitness/UnitSize.cs index 4236315..b1938fd 100644 --- a/Fitness/UnitSize.cs +++ b/Fitness/UnitSize.cs @@ -9,26 +9,26 @@ namespace Fitness /// /// Number of pixels per unit for very large size displays with very small dpi. /// - ExtraSmallUnit = 1, + ExtraSmall = 1, /// /// Number of pixels per unit for large size displays with small dpi. /// - SmallUnit = 2, + Small = 2, /// /// Number of pixels per unit for average size displays with average dpi. /// - MediumUnit = 4, + Medium = 4, /// /// Number of pixels per unit for small size displays with high dpi. /// - LargeUnit = 6, + Large = 6, /// /// Number of pixels per unit for very small size displays with very high dpi. /// - ExtraLargUnit = 8, + ExtraLarge = 8, } } diff --git a/Fitness/Views/SizeInUnitsMarkup.cs b/Fitness/Views/SizeInUnitsMarkup.cs new file mode 100644 index 0000000..e1a2f80 --- /dev/null +++ b/Fitness/Views/SizeInUnitsMarkup.cs @@ -0,0 +1,26 @@ +using System; +using Tizen.NUI; +using Tizen.NUI.BaseComponents; +using Tizen.NUI.Binding; +using Tizen.NUI.Xaml; + +namespace Fitness.Views +{ + public class SizeInUnitsMarkup : IMarkupExtension + { + /// + /// Width in units + /// + public int Width { get; set; } + + /// + /// Height in units + /// + public int Height { get; set; } + + public object ProvideValue(IServiceProvider provider) + { + return new Size2D(UnitsUtils.UnitsToPixels(Width), UnitsUtils.UnitsToPixels(Height)); + } + } +} diff --git a/Fitness/Views/UnitsUtils.cs b/Fitness/Views/UnitsUtils.cs index 5dd8065..83e0e4a 100644 --- a/Fitness/Views/UnitsUtils.cs +++ b/Fitness/Views/UnitsUtils.cs @@ -6,6 +6,11 @@ namespace Fitness.Views public static class UnitsUtils { /// + /// Number of units per pixel + /// + private const float UnitsPerPixel = 1.0f / (int)Config.PixelsPerUnit; + + /// /// Converts units into pixels using current UnitSize settings /// public static int UnitsToPixels(int units) @@ -18,7 +23,7 @@ namespace Fitness.Views /// public static int PixelsToUnits(int pixels) { - return (int)(pixels * Config.UnitsPerPixel); + return (int)(pixels * UnitsPerPixel); } /// diff --git a/Fitness/Views/XamlExtensions.cs b/Fitness/Views/XamlExtensions.cs deleted file mode 100644 index df05243..0000000 --- a/Fitness/Views/XamlExtensions.cs +++ /dev/null @@ -1,24 +0,0 @@ -using Tizen.NUI; -using Tizen.NUI.BaseComponents; -using Tizen.NUI.Binding; - -namespace Fitness.Views -{ - public static class XamlExtensions - { - /// - /// SizeInUnits Xaml property extension. - /// Use this property to define Size of view int Units system. - /// - public static readonly BindableProperty SizeInUnitsProperty = - BindableProperty.CreateAttached("SizeInUnits", typeof(Size2D), typeof(XamlExtensions), default(Size2D), propertyChanged: OnSizeInUnitsChanged); - - public static void OnSizeInUnitsChanged(BindableObject view, object oldValue, object newValue) - { - if (view is View nuiView) - { - nuiView.Size = UnitsUtils.UnitsToPixels(newValue as Size2D); - } - } - } -} diff --git a/Fitness/res/layout/1280x720/MainView.xaml b/Fitness/res/layout/1280x720/MainView.xaml index 737b7ed..6a8fc5f 100644 --- a/Fitness/res/layout/1280x720/MainView.xaml +++ b/Fitness/res/layout/1280x720/MainView.xaml @@ -11,5 +11,5 @@ - +