--- /dev/null
+using System;
+using Tizen.NUI;
+
+namespace Fitness.Views
+{
+ /// <summary>
+ /// Utils for converting dp pixels.
+ /// </summary>
+ public static class DpUtils
+ {
+ private const float DpPixelDivider = 2.75f;
+
+ /// <summary>
+ /// Converts dp pixels into pixels.
+ /// </summary>
+ /// <param name="pixels">The number of dp pixels.</param>
+ /// <returns>The number of pixels.</returns>
+ public static int DpToPixels(int pixels)
+ {
+ return (int)Math.Round(DpTypeConverter.Instance.ConvertToPixel(pixels / DpPixelDivider), MidpointRounding.AwayFromZero);
+ }
+
+ /// <summary>
+ /// Converts dp pixels into pixels.
+ /// </summary>
+ /// <param name="pixels">The number of dp pixels.</param>
+ /// <returns>The number of pixels.</returns>
+ public static ushort DpToPixels(ushort pixels)
+ {
+ return (ushort)Math.Round(DpTypeConverter.Instance.ConvertToPixel(pixels / DpPixelDivider), MidpointRounding.AwayFromZero);
+ }
+
+ /// <summary>
+ /// Converts dp pixels into pixels.
+ /// </summary>
+ /// <param name="pixels">The number of dp pixels.</param>
+ /// <returns>The number of pixels.</returns>
+ public static float DpToPixels(float pixels)
+ {
+ return DpTypeConverter.Instance.ConvertToPixel(pixels / DpPixelDivider);
+ }
+
+ /// <summary>
+ /// Converts dp pixels into pixels.
+ /// </summary>
+ /// <param name="size">The size to be converted to pixels.</param>
+ /// <returns>The number of pixels.</returns>
+ public static Size2D DpToPixels(Size2D size)
+ {
+ return new Size2D(DpToPixels(size.Width), DpToPixels(size.Height));
+ }
+
+ /// <summary>
+ /// Converts dp pixels into pixels.
+ /// </summary>
+ /// <param name="extents">The extents collection to be converted to pixels.</param>
+ /// <returns>The number of pixels.</returns>
+ public static Extents DpToPixels(Extents extents)
+ {
+ return new Extents(DpToPixels(extents.Start), DpToPixels(extents.End), DpToPixels(extents.Top), DpToPixels(extents.Bottom));
+ }
+ }
+}
--- /dev/null
+using System;
+using Tizen.NUI;
+using Tizen.NUI.Xaml;
+
+namespace Fitness.Views
+{
+ /// <summary>
+ /// Converts number of dp pixels to exact number of pixels in the target.
+ /// </summary>
+ public class ExtentsInDpExtension : IMarkupExtension
+ {
+ /// <summary>
+ /// Gets or sets the start offset in dp type.
+ /// </summary>
+ public ushort Start { get; set; }
+
+ /// <summary>
+ /// Gets or sets the end offset in dp type.
+ /// </summary>
+ public ushort End { get; set; }
+
+ /// <summary>
+ /// Gets or sets the top offset in dp type.
+ /// </summary>
+ public ushort Top { get; set; }
+
+ /// <summary>
+ /// Gets or sets the bottom offset in dp type.
+ /// </summary>
+ public ushort Bottom { get; set; }
+
+ /// <inheritdoc/>
+ public object ProvideValue(IServiceProvider serviceProvider)
+ {
+ return new Extents(DpUtils.DpToPixels(Start), DpUtils.DpToPixels(End), DpUtils.DpToPixels(Top), DpUtils.DpToPixels(Bottom));
+ }
+ }
+}
--- /dev/null
+using System;
+using Tizen.NUI;
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Binding;
+using Tizen.NUI.Xaml;
+
+namespace Fitness.Views
+{
+ /// <summary>
+ /// Converts TextLabels's PixelSize to exact number of pixels in the target.
+ /// </summary>
+ public class PixelSizeInDpExtension : IMarkupExtension
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="PixelSizeInDpExtension"/> class.
+ /// Creates markups with given size (in number of dp pixels).
+ /// </summary>
+ /// <param name="dpSize">The number of dp pixels.</param>
+ public PixelSizeInDpExtension(float dpSize = 0)
+ {
+ DpSize = dpSize;
+ }
+
+ /// <summary>
+ /// Gets or sets the size of font in dp pixels.
+ /// </summary>
+ public float DpSize { get; set; }
+
+ /// <inheritdoc/>
+ public object ProvideValue(IServiceProvider serviceProvider)
+ {
+ return DpUtils.DpToPixels(DpSize);
+ }
+ }
+}
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tizen.NUI;
+using Tizen.NUI.Components;
+using Tizen.NUI.Xaml;
+
+namespace Fitness.Views
+{
+ /// <summary>
+ /// PositionInDpExtension.
+ /// </summary>
+ public class PositionInDpExtension : IMarkupExtension
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="PositionInDpExtension"/> class.
+ /// </summary>
+ /// <param name="x">x.</param>
+ /// <param name="y">y.</param>
+ public PositionInDpExtension(int x = 0, int y = 0)
+ {
+ X = x;
+ Y = y;
+ }
+
+ /// <summary>
+ /// Gets or sets x as number of dp pixels.
+ /// </summary>
+ public int X { get; set; }
+
+ /// <summary>
+ /// Gets or sets y as number of dp pixels.
+ /// </summary>
+ public int Y { get; set; }
+
+ /// <inheritdoc/>
+ public object ProvideValue(IServiceProvider serviceProvider)
+ {
+ return new Position(DpUtils.DpToPixels(X), DpUtils.DpToPixels(Y));
+ }
+ }
+}
--- /dev/null
+using System;
+using Tizen.NUI;
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Binding;
+using Tizen.NUI.Xaml;
+
+namespace Fitness.Views
+{
+ /// <summary>
+ /// Creates markups with given width and height (in number of dp pixels).
+ /// </summary>
+ public class SizeInDpExtension : IMarkupExtension
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="SizeInDpExtension"/> class.
+ /// </summary>
+ /// <param name="width">The size width.</param>
+ /// <param name="height">The size height.</param>
+ public SizeInDpExtension(int width = 0, int height = 0)
+ {
+ Width = width;
+ Height = height;
+ }
+
+ /// <summary>
+ /// Gets or sets the width.
+ /// </summary>
+ public int Width { get; set; }
+
+ /// <summary>
+ /// Gets or sets the height.
+ /// </summary>
+ public int Height { get; set; }
+
+ /// <inheritdoc/>
+ public object ProvideValue(IServiceProvider serviceProvider)
+ {
+ return new Size2D(DpUtils.DpToPixels(Width), DpUtils.DpToPixels(Height));
+ }
+ }
+}