From: Krzysztof Wieclaw/IoT & UI Sample (PLT) /SRPOL/Engineer/Samsung Electronics Date: Fri, 24 Sep 2021 14:48:38 +0000 (+0200) Subject: Add DpUtils X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Fdp;p=profile%2Fiot%2Fapps%2Fnative%2Foobe.git Add DpUtils Change-Id: I2f659e7cb6c4aaea488ea327d3ceefd03d795962 Signed-off-by: Krzysztof Wieclaw/IoT & UI Sample (PLT) /SRPOL/Engineer/Samsung Electronics --- diff --git a/Oobe/Oobe.Common/Controls/CarouselPicker.cs b/Oobe/Oobe.Common/Controls/CarouselPicker.cs index 054a27f..f292c89 100644 --- a/Oobe/Oobe.Common/Controls/CarouselPicker.cs +++ b/Oobe/Oobe.Common/Controls/CarouselPicker.cs @@ -1,301 +1,301 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using System; -using System.Collections.Generic; -using Oobe.Common.Utils; -using Tizen.NUI; -using Tizen.NUI.BaseComponents; -using Tizen.NUI.Binding; -using Tizen.NUI.Components; - -namespace Oobe.Common.Controls -{ - public class CarouselPicker : Control - { - private Oobe.Common.Controls.ScrollableBase scrollableBase; - private View itemsListView; - private View upperLine; - private View lowerLine; - - private Vector3 textCenterColorHSV = new Vector3(); - private Vector3 textOuterColorHSV = new Vector3(); - - private float textCenterOpacity; - private float textOuterOpacity; - private int selectedItemIndex = 0; - - private List items = new List(); - - public CarouselPicker() - : base() - { - } - - public CarouselPicker(CarouselPickerStyle style) - : base(style) - { - // TODO fix a bug with style not properly applied by base class - ApplyStyle(style); - } - - public event EventHandler SelectedItemChanged; - - public new CarouselPickerStyle Style => ViewStyle as CarouselPickerStyle; - - public int SelectedItemIndex - { - get - { - return selectedItemIndex; - } - - set - { - // always scroll - scrollableBase.ScrollToIndex(value); - if (selectedItemIndex != value) - { - SelectedItemChanged?.Invoke(this, null); - selectedItemIndex = value; - } - } - } - - public void AddItem(CarouselPickerItemData item) - { - var view = CreateItemView(item); - itemsListView.Add(view); - items.Add(item); - } - - public void RemoveItem(CarouselPickerItemData item) - { - var index = items.IndexOf(item); - items.Remove(item); - itemsListView.Children.RemoveAt(index); - } - - public override void ApplyStyle(ViewStyle viewStyle) - { - base.ApplyStyle(viewStyle); - - CarouselPickerStyle style = viewStyle as CarouselPickerStyle; - - if (style != null) - { - Layout = new LinearLayout - { - LinearOrientation = LinearLayout.Orientation.Vertical, - LinearAlignment = LinearLayout.Alignment.Center, - }; - ClippingMode = ClippingModeType.ClipToBoundingBox; - - // Animatable properties - textCenterColorHSV = Style.CenterText?.TextColor?.All?.ToHSV() ?? new Vector3(); - textCenterOpacity = Style.CenterText?.Opacity?.All ?? 1.0f; - - textOuterColorHSV = Style.OuterText?.TextColor?.All?.ToHSV() ?? new Vector3(); - textOuterOpacity = Style.OuterText?.Opacity?.All ?? 1.0f; - - if (itemsListView != null) - { - scrollableBase?.Remove(itemsListView); - itemsListView.Dispose(); - } - - itemsListView = new View - { - Layout = new LinearLayout - { - LinearOrientation = LinearLayout.Orientation.Vertical, - }, - WidthSpecification = LayoutParamPolicies.MatchParent, - HeightSpecification = LayoutParamPolicies.WrapContent, - }; - - if (scrollableBase != null) - { - Remove(scrollableBase); - scrollableBase.Dispose(); - } - - scrollableBase = new Oobe.Common.Controls.ScrollableBase - { - ClippingMode = ClippingModeType.Disabled, - WidthResizePolicy = ResizePolicyType.FillToParent, - SnapToPage = true, - ScrollingDirection = ScrollableBase.Direction.Vertical, - ScrollEnabled = true, - SizeHeight = CalculateScrollerSize(), - FlickDistanceMultiplierRange = new Vector2(4.6f, 5.8f), - EventsView = this, - }; - - scrollableBase.ScrollEvent += (sender, args) => - { - UpdateItems(); - }; - scrollableBase.ScrollAnimationEndEvent += (sender, args) => - { - if (selectedItemIndex != scrollableBase.CurrentPage) - { - selectedItemIndex = scrollableBase.CurrentPage; - SelectedItemChanged?.Invoke(this, null); - } - }; - - if (upperLine != null) - { - Remove(upperLine); - upperLine.Dispose(); - } - - upperLine = new View() - { - BackgroundColor = Style.LinesColor, - Size2D = new Size2D(0, 1), - WidthResizePolicy = ResizePolicyType.FillToParent, - Position2D = new Position2D(0, 93), - Opacity = 0.95f, - }; - - if (lowerLine != null) - { - Remove(lowerLine); - lowerLine.Dispose(); - } - - lowerLine = new View() - { - BackgroundColor = Style.LinesColor, - Size2D = new Size2D(0, 1), - WidthResizePolicy = ResizePolicyType.FillToParent, - Position2D = new Position2D(0, 156), - Opacity = 0.95f, - }; - - scrollableBase.Add(itemsListView); - - Add(upperLine); - Add(scrollableBase); - Add(lowerLine); - } - } - - protected override void OnUpdate() - { - base.OnUpdate(); - UpdateItems(); - } - - protected override void Dispose(Tizen.NUI.DisposeTypes type) - { - if (disposed) - { - return; - } - - if (type == DisposeTypes.Explicit) - { - // Dispose all containing widgets - scrollableBase.Dispose(); - upperLine.Dispose(); - lowerLine.Dispose(); - } - - base.Dispose(type); - } - - private float CalculateScrollerSize() - { - float size = 0.0f; - - size += Style.CenterText?.Size2D?.Height ?? 0.0f; - size += (float)Style.CenterText?.Margin?.Top; - size += (float)Style.CenterText?.Margin?.Bottom; - - return size; - } - - private View CreateItemView(CarouselPickerItemData item) - { - var view = new TextLabel(); - - // TODO for some reason TextLabel(Style.CenterText) - // or view.ApplyStyle(Style.CenterText) do not work here so set - // everything manually - // var view = new TextLabel(Style.CenterText); - // view.ApplyStyle(Style.CenterText); - float? pixelSize = null; +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Collections.Generic; +using Oobe.Common.Utils; +using Tizen.NUI; +using Tizen.NUI.BaseComponents; +using Tizen.NUI.Binding; +using Tizen.NUI.Components; + +namespace Oobe.Common.Controls +{ + public class CarouselPicker : Control + { + private Oobe.Common.Controls.ScrollableBase scrollableBase; + private View itemsListView; + private View upperLine; + private View lowerLine; + + private Vector3 textCenterColorHSV = new Vector3(); + private Vector3 textOuterColorHSV = new Vector3(); + + private float textCenterOpacity; + private float textOuterOpacity; + private int selectedItemIndex = 0; + + private List items = new List(); + + public CarouselPicker() + : base() + { + } + + public CarouselPicker(CarouselPickerStyle style) + : base(style) + { + // TODO fix a bug with style not properly applied by base class + ApplyStyle(style); + } + + public event EventHandler SelectedItemChanged; + + public new CarouselPickerStyle Style => ViewStyle as CarouselPickerStyle; + + public int SelectedItemIndex + { + get + { + return selectedItemIndex; + } + + set + { + // always scroll + scrollableBase.ScrollToIndex(value); + if (selectedItemIndex != value) + { + SelectedItemChanged?.Invoke(this, null); + selectedItemIndex = value; + } + } + } + + public void AddItem(CarouselPickerItemData item) + { + var view = CreateItemView(item); + itemsListView.Add(view); + items.Add(item); + } + + public void RemoveItem(CarouselPickerItemData item) + { + var index = items.IndexOf(item); + items.Remove(item); + itemsListView.Children.RemoveAt(index); + } + + public override void ApplyStyle(ViewStyle viewStyle) + { + base.ApplyStyle(viewStyle); + + CarouselPickerStyle style = viewStyle as CarouselPickerStyle; + + if (style != null) + { + Layout = new LinearLayout + { + LinearOrientation = LinearLayout.Orientation.Vertical, + LinearAlignment = LinearLayout.Alignment.Center, + }; + ClippingMode = ClippingModeType.ClipToBoundingBox; + + // Animatable properties + textCenterColorHSV = Style.CenterText?.TextColor?.All?.ToHSV() ?? new Vector3(); + textCenterOpacity = Style.CenterText?.Opacity?.All ?? 1.0f; + + textOuterColorHSV = Style.OuterText?.TextColor?.All?.ToHSV() ?? new Vector3(); + textOuterOpacity = Style.OuterText?.Opacity?.All ?? 1.0f; + + if (itemsListView != null) + { + scrollableBase?.Remove(itemsListView); + itemsListView.Dispose(); + } + + itemsListView = new View + { + Layout = new LinearLayout + { + LinearOrientation = LinearLayout.Orientation.Vertical, + }, + WidthSpecification = LayoutParamPolicies.MatchParent, + HeightSpecification = LayoutParamPolicies.WrapContent, + }; + + if (scrollableBase != null) + { + Remove(scrollableBase); + scrollableBase.Dispose(); + } + + scrollableBase = new Oobe.Common.Controls.ScrollableBase + { + ClippingMode = ClippingModeType.Disabled, + WidthResizePolicy = ResizePolicyType.FillToParent, + SnapToPage = true, + ScrollingDirection = ScrollableBase.Direction.Vertical, + ScrollEnabled = true, + SizeHeight = CalculateScrollerSize(), + FlickDistanceMultiplierRange = new Vector2(4.6f, 5.8f), + EventsView = this, + }; + + scrollableBase.ScrollEvent += (sender, args) => + { + UpdateItems(); + }; + scrollableBase.ScrollAnimationEndEvent += (sender, args) => + { + if (selectedItemIndex != scrollableBase.CurrentPage) + { + selectedItemIndex = scrollableBase.CurrentPage; + SelectedItemChanged?.Invoke(this, null); + } + }; + + if (upperLine != null) + { + Remove(upperLine); + upperLine.Dispose(); + } + + upperLine = new View() + { + BackgroundColor = Style.LinesColor, + Size2D = DpUtils.ToPixels(new Size2D(0, 1)), + WidthResizePolicy = ResizePolicyType.FillToParent, + Position2D = DpUtils.ToPixels(new Position2D(0, 93)), + Opacity = 0.95f, + }; + + if (lowerLine != null) + { + Remove(lowerLine); + lowerLine.Dispose(); + } + + lowerLine = new View() + { + BackgroundColor = Style.LinesColor, + Size2D = DpUtils.ToPixels(new Size2D(0, 1)), + WidthResizePolicy = ResizePolicyType.FillToParent, + Position2D = DpUtils.ToPixels(new Position2D(0, 93)), + Opacity = 0.95f, + }; + + scrollableBase.Add(itemsListView); + + Add(upperLine); + Add(scrollableBase); + Add(lowerLine); + } + } + + protected override void OnUpdate() + { + base.OnUpdate(); + UpdateItems(); + } + + protected override void Dispose(Tizen.NUI.DisposeTypes type) + { + if (disposed) + { + return; + } + + if (type == DisposeTypes.Explicit) + { + // Dispose all containing widgets + scrollableBase.Dispose(); + upperLine.Dispose(); + lowerLine.Dispose(); + } + + base.Dispose(type); + } + + private float CalculateScrollerSize() + { + float size = 0.0f; + + size += Style.CenterText?.Size2D?.Height ?? 0.0f; + size += (float)Style.CenterText?.Margin?.Top; + size += (float)Style.CenterText?.Margin?.Bottom; + + return size; + } + + private View CreateItemView(CarouselPickerItemData item) + { + var view = new TextLabel(); + + // TODO for some reason TextLabel(Style.CenterText) + // or view.ApplyStyle(Style.CenterText) do not work here so set + // everything manually + // var view = new TextLabel(Style.CenterText); + // view.ApplyStyle(Style.CenterText); + float? pixelSize = null; Style.CenterText?.PixelSize.GetValue(ControlState.Normal, out pixelSize); - view.Text = item.Text; - view.TranslatableText = item.TranslatableText; - view.Size2D = Style.CenterText?.Size2D ?? new Size2D(); + view.Text = item.Text; + view.TranslatableText = item.TranslatableText; + view.Size2D = Style.CenterText?.Size2D ?? new Size2D(); view.PixelSize = pixelSize ?? 10.0f; - view.Margin = Style.CenterText?.Margin ?? new Extents(); - view.HorizontalAlignment = Style.CenterText?.HorizontalAlignment ?? HorizontalAlignment.Center; - view.VerticalAlignment = Style.CenterText?.VerticalAlignment ?? VerticalAlignment.Center; - view.Opacity = Style.CenterText?.Opacity?.All ?? 1.0f; - - // TODO other properties? - return view; - } - - private void CreateMainList() - { - } - - private Vector3 ScaleVector(Vector3 from, Vector3 to, float percent) - { - percent = Math.Clamp(percent, 0.0f, 1.0f); - - float a = from[0] + ((to[0] - from[0]) * percent); - float b = from[1] + ((to[1] - from[1]) * percent); - float c = from[2] + ((to[2] - from[2]) * percent); - - return new Vector3(a, b, c); - } - - private float ScaleScalar(float from, float to, float percent) - { - percent = Math.Clamp(percent, 0.0f, 1.0f); - return from + ((to - from) * percent); - } - - private void UpdateItems() - { - float mid = itemsListView.PositionY - (int)(scrollableBase.Size2D.Height / 2.0f); - int threshold = 80; // after this value the color will become outer - - foreach (View view in itemsListView.Children) - { - TextLabel itemView = view as TextLabel; - if (itemView == null) - { - continue; - } - - float viewMid = view.PositionY + (view.Size2D.Height / 2.0f); - float percent = Math.Abs(viewMid + mid) / threshold; - - itemView.Opacity = ScaleScalar(textCenterOpacity, textOuterOpacity, percent); - itemView.TextColor = ColorUtils.ColorFromHSV(ScaleVector(textCenterColorHSV, textOuterColorHSV, percent)); - } - } - } -} + view.Margin = Style.CenterText?.Margin ?? new Extents(); + view.HorizontalAlignment = Style.CenterText?.HorizontalAlignment ?? HorizontalAlignment.Center; + view.VerticalAlignment = Style.CenterText?.VerticalAlignment ?? VerticalAlignment.Center; + view.Opacity = Style.CenterText?.Opacity?.All ?? 1.0f; + + // TODO other properties? + return view; + } + + private void CreateMainList() + { + } + + private Vector3 ScaleVector(Vector3 from, Vector3 to, float percent) + { + percent = Math.Clamp(percent, 0.0f, 1.0f); + + float a = from[0] + ((to[0] - from[0]) * percent); + float b = from[1] + ((to[1] - from[1]) * percent); + float c = from[2] + ((to[2] - from[2]) * percent); + + return new Vector3(a, b, c); + } + + private float ScaleScalar(float from, float to, float percent) + { + percent = Math.Clamp(percent, 0.0f, 1.0f); + return from + ((to - from) * percent); + } + + private void UpdateItems() + { + float mid = itemsListView.PositionY - (int)(scrollableBase.Size2D.Height / 2.0f); + int threshold = 80; // after this value the color will become outer + + foreach (View view in itemsListView.Children) + { + TextLabel itemView = view as TextLabel; + if (itemView == null) + { + continue; + } + + float viewMid = view.PositionY + (view.Size2D.Height / 2.0f); + float percent = Math.Abs(viewMid + mid) / threshold; + + itemView.Opacity = ScaleScalar(textCenterOpacity, textOuterOpacity, percent); + itemView.TextColor = ColorUtils.ColorFromHSV(ScaleVector(textCenterColorHSV, textOuterColorHSV, percent)); + } + } + } +} diff --git a/Oobe/Oobe.Common/Oobe.Common.csproj b/Oobe/Oobe.Common/Oobe.Common.csproj index e059149..c7ea57c 100644 --- a/Oobe/Oobe.Common/Oobe.Common.csproj +++ b/Oobe/Oobe.Common/Oobe.Common.csproj @@ -8,7 +8,7 @@ - + Runtime diff --git a/Oobe/Oobe.Common/Pages/BasePage.cs b/Oobe/Oobe.Common/Pages/BasePage.cs index 332339e..126d130 100644 --- a/Oobe/Oobe.Common/Pages/BasePage.cs +++ b/Oobe/Oobe.Common/Pages/BasePage.cs @@ -15,6 +15,7 @@ */ using Oobe.Common.Styles; +using Oobe.Common.Utils; using Tizen.NUI; using Tizen.NUI.BaseComponents; using Tizen.NUI.Components; @@ -47,12 +48,12 @@ namespace Oobe.Common.Pages PositionUsesPivotPoint = true, PivotPoint = new Position(0.5f, 0.0f), ParentOrigin = new Position(0.5f, 0.167f), - Size2D = new Size2D(0, 48), + Size2D = DpUtils.ToPixels(new Size2D(0, 48)), WidthResizePolicy = ResizePolicyType.FillToParent, TextColor = new Color(0, 20.0f / 255.0f, 71.0f / 255.0f, 1.0f), HorizontalAlignment = HorizontalAlignment.Center, Ellipsis = false, - PixelSize = 40.0f, + PixelSize = DpUtils.ToPixels(40.0f), FontFamily = "BreezeSans", FontStyle = new PropertyMap().AddLightFontStyle(), }; diff --git a/Oobe/Oobe.Common/Styles/ButtonStyles.cs b/Oobe/Oobe.Common/Styles/ButtonStyles.cs index 62fedbe..f5e1cd6 100644 --- a/Oobe/Oobe.Common/Styles/ButtonStyles.cs +++ b/Oobe/Oobe.Common/Styles/ButtonStyles.cs @@ -14,6 +14,7 @@ * limitations under the License. */ +using Oobe.Common.Utils; using Tizen.NUI; using Tizen.NUI.BaseComponents; using Tizen.NUI.Components; @@ -46,8 +47,8 @@ namespace Oobe.Common.Styles { PixelSize = new Selector { - Normal = 22.0f, - Pressed = 24.0f, + Normal = DpUtils.ToPixels(22.0f), + Pressed = DpUtils.ToPixels(24.0f), }, EnableMarkup = true, TranslatableText = "PREVIOUS", @@ -58,7 +59,7 @@ namespace Oobe.Common.Styles }, FontFamily = GetNavigationFont(), }, - Size2D = new Size2D(240, 72), + Size2D = DpUtils.ToPixels(new Size2D(240, 72)), }; private static ButtonStyle GetSkipButtonStyle() @@ -80,14 +81,14 @@ namespace Oobe.Common.Styles { PixelSize = new Selector { - Normal = 22.0f, - Pressed = 24.0f, + Normal = DpUtils.ToPixels(22.0f), + Pressed = DpUtils.ToPixels(24.0f), }, TextColor = Color.White, TranslatableText = "CONTINUE", FontFamily = GetNavigationFont(), }, - Size2D = new Size2D(240, 72), + Size2D = DpUtils.ToPixels(new Size2D(240, 72)), }; private static Selector GetNavigationFont() diff --git a/Oobe/Oobe.Common/Styles/CarouselPickerStyles.cs b/Oobe/Oobe.Common/Styles/CarouselPickerStyles.cs index b615222..7e0dcd1 100644 --- a/Oobe/Oobe.Common/Styles/CarouselPickerStyles.cs +++ b/Oobe/Oobe.Common/Styles/CarouselPickerStyles.cs @@ -15,6 +15,7 @@ */ using Oobe.Common.Controls; +using Oobe.Common.Utils; using Tizen.NUI; using Tizen.NUI.BaseComponents; using Tizen.NUI.Components; @@ -27,18 +28,18 @@ namespace Oobe.Common.Styles { CenterText = new TextLabelStyle { - Size2D = new Size2D(312, 26), - PixelSize = 20.0f, - Margin = new Extents(24, 24, 16, 16), + Size2D = DpUtils.ToPixels(new Size2D(312, 26)), + PixelSize = DpUtils.ToPixels(20.0f), + Margin = DpUtils.ToPixels(new Extents(24, 24, 16, 16)), HorizontalAlignment = HorizontalAlignment.Center, TextColor = new Color(0, 20.0f / 255.0f, 71.0f / 255.0f, 1.0f), Opacity = 1.0f, }, OuterText = new TextLabelStyle { - Size2D = new Size2D(312, 26), - PixelSize = 20.0f, - Margin = new Extents(24, 24, 16, 16), + Size2D = DpUtils.ToPixels(new Size2D(312, 26)), + PixelSize = DpUtils.ToPixels(20.0f), + Margin = DpUtils.ToPixels(new Extents(24, 24, 16, 16)), HorizontalAlignment = HorizontalAlignment.Center, TextColor = new Color(195.0f / 255.0f, 202.0f / 255.0f, 210.0f / 255.0f, 1.0f), Opacity = 0.4f, diff --git a/Oobe/Oobe.Common/Utils/DpUtils.cs b/Oobe/Oobe.Common/Utils/DpUtils.cs new file mode 100644 index 0000000..25691df --- /dev/null +++ b/Oobe/Oobe.Common/Utils/DpUtils.cs @@ -0,0 +1,70 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tizen.NUI; + +namespace Oobe.Common.Utils +{ + public static class DpUtils + { + private const float DefaultFactor = 2.75f; + public static int ToPixels(int dp) + { + return (int)Math.Round(DpTypeConverter.Instance.ConvertToPixel(dp / DefaultFactor), MidpointRounding.AwayFromZero); + } + public static ushort ToPixels(ushort dp) + { + return (ushort)Math.Round(DpTypeConverter.Instance.ConvertToPixel(dp / DefaultFactor), MidpointRounding.AwayFromZero); + } + + public static float ToPixels(float dp) + { + return (float)DpTypeConverter.Instance.ConvertToPixel(dp / DefaultFactor); + } + + public static Size2D ToPixels(Size2D dp) + { + return new Size2D(ToPixels(dp.Width), ToPixels(dp.Height)); + } + + public static Position2D ToPixels(Position2D dp) + { + return new Position2D(ToPixels(dp.X), ToPixels(dp.Y)); + } + + public static Extents ToPixels(Extents dp) + { + return new Extents(ToPixels(dp.Start), ToPixels(dp.End), ToPixels(dp.Top), ToPixels(dp.Bottom)); + } + + public static int FromPixels(int px) + { + return (int)Math.Round(DpTypeConverter.Instance.ConvertFromPixel(px) * DefaultFactor, MidpointRounding.ToZero); + } + + public static ushort FromPixels(ushort px) + { + return (ushort)Math.Round(DpTypeConverter.Instance.ConvertFromPixel(px) * DefaultFactor, MidpointRounding.ToZero); + } + + public static float FromPixels(float px) + { + return (float)DpTypeConverter.Instance.ConvertFromPixel(px) * DefaultFactor; + } + + public static Size2D FromPixels(Size2D px) + { + return new Size2D(FromPixels(px.Width), FromPixels(px.Height)); + } + public static Position2D FromPixels(Position2D px) + { + return new Position2D(FromPixels(px.X), FromPixels(px.Y)); + } + public static Extents FromPixels(Extents px) + { + return new Extents(FromPixels(px.Start), FromPixels(px.End), FromPixels(px.Top), FromPixels(px.Bottom)); + } + } +} diff --git a/Oobe/Oobe.Language/LanguageStep.cs b/Oobe/Oobe.Language/LanguageStep.cs index f3a7480..6f21973 100644 --- a/Oobe/Oobe.Language/LanguageStep.cs +++ b/Oobe/Oobe.Language/LanguageStep.cs @@ -51,7 +51,7 @@ namespace Oobe.Language container.Title.TranslatableText = "CHOOSE_LANGUAGE"; var carousel = new CarouselPicker(CarouselPickerStyles.Default); - carousel.Size2D = new Size2D(360, 249); + carousel.Size2D = DpUtils.ToPixels(new Size2D(360, 249)); foreach (LanguageInfo info in manager.Languages) { diff --git a/Oobe/Oobe.Language/Oobe.Language.csproj b/Oobe/Oobe.Language/Oobe.Language.csproj index 4f488fe..1db3a9d 100644 --- a/Oobe/Oobe.Language/Oobe.Language.csproj +++ b/Oobe/Oobe.Language/Oobe.Language.csproj @@ -8,7 +8,7 @@ - + Runtime diff --git a/Oobe/Oobe.Region/Oobe.Region.csproj b/Oobe/Oobe.Region/Oobe.Region.csproj index 3030234..3ddff2b 100644 --- a/Oobe/Oobe.Region/Oobe.Region.csproj +++ b/Oobe/Oobe.Region/Oobe.Region.csproj @@ -8,7 +8,7 @@ - + Runtime diff --git a/Oobe/Oobe.Terms/Oobe.Terms.csproj b/Oobe/Oobe.Terms/Oobe.Terms.csproj index 11f6d02..d32c3e5 100644 --- a/Oobe/Oobe.Terms/Oobe.Terms.csproj +++ b/Oobe/Oobe.Terms/Oobe.Terms.csproj @@ -8,7 +8,7 @@ - + Runtime diff --git a/Oobe/Oobe.Terms/TermsStep.cs b/Oobe/Oobe.Terms/TermsStep.cs index 061453e..59b887e 100644 --- a/Oobe/Oobe.Terms/TermsStep.cs +++ b/Oobe/Oobe.Terms/TermsStep.cs @@ -1,19 +1,19 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + using Oobe.Common.Interfaces; using Oobe.Common.Pages; using Oobe.Terms.Model; @@ -33,7 +33,7 @@ namespace Oobe.Terms public override BasePage CreateView(IProcessNavigation nav) { - return new TermsView(nav, provider); + return new TermsView(nav, provider); } } } diff --git a/Oobe/Oobe.Terms/Views/TermsView.cs b/Oobe/Oobe.Terms/Views/TermsView.cs index 82def94..2817c24 100644 --- a/Oobe/Oobe.Terms/Views/TermsView.cs +++ b/Oobe/Oobe.Terms/Views/TermsView.cs @@ -52,7 +52,7 @@ namespace Oobe.Terms.Views Layout = new LinearLayout { LinearOrientation = LinearLayout.Orientation.Vertical, - CellPadding = new Size2D(0, 12), + CellPadding = DpUtils.ToPixels(new Size2D(0, 12)), }, }; @@ -75,7 +75,7 @@ namespace Oobe.Terms.Views var scrollerContent = new View { - Padding = new Extents(64, 64, 0, 0), + Padding = DpUtils.ToPixels(new Extents(64, 64, 0, 0)), WidthResizePolicy = ResizePolicyType.FillToParent, HeightResizePolicy = ResizePolicyType.FitToChildren, Layout = new LinearLayout(), @@ -85,7 +85,7 @@ namespace Oobe.Terms.Views // performance on ScrollableBase termsContent = new TextLabel(); termsContent.TextColor = new Color(0, 12.0f / 255.0f, 43.0f / 255.0f, 1.0f); - termsContent.PixelSize = 18.0f; + termsContent.PixelSize = DpUtils.ToPixels(18.0f); termsContent.FontFamily = "BreezeSans"; termsContent.Text = terms.LoadTerms(); termsContent.LineWrapMode = LineWrapMode.Character; @@ -121,8 +121,8 @@ namespace Oobe.Terms.Views guide.TranslatableText = "YOU_MUST_SCROLL_DOWN_AND_READ_THE_WHOLE_TEXT_ABOVE"; agreeSwitch = new Switch(SwitchStyles.IHaveReadAndAgreeSwitchStyle); - agreeSwitch.Size2D = new Size2D(24, 24); - agreeSwitch.Margin = new Extents(0, 0, 0, 2); + agreeSwitch.Size2D = DpUtils.ToPixels(new Size2D(24, 24)); + agreeSwitch.Margin = DpUtils.ToPixels(new Extents(0, 0, 0, 2)); agreeSwitch.IsSelected = false; agreeSwitch.IsEnabled = false; agreeSwitch.Clicked += (obj, args) => @@ -136,12 +136,12 @@ namespace Oobe.Terms.Views var footnote = new View { - Padding = new Extents(64, 64, 0, 0), + Padding = DpUtils.ToPixels(new Extents(64, 64, 0, 0)), Layout = new LinearLayout { LinearOrientation = LinearLayout.Orientation.Horizontal, LinearAlignment = LinearLayout.Alignment.Bottom, - CellPadding = new Size2D(16, 0), + CellPadding = DpUtils.ToPixels(new Size2D(16, 0)), }, }; @@ -290,7 +290,7 @@ namespace Oobe.Terms.Views private Size2D CalculateTermsViewSize() { - var referenceTermsSize = new Size2D(1072, 316); + var referenceTermsSize = DpUtils.ToPixels(new Size2D(1072, 316)); return Config.ScaledSize(referenceTermsSize); } } diff --git a/Oobe/Oobe.Welcome/Oobe.Welcome.csproj b/Oobe/Oobe.Welcome/Oobe.Welcome.csproj index fe4fd2c..4b5f882 100644 --- a/Oobe/Oobe.Welcome/Oobe.Welcome.csproj +++ b/Oobe/Oobe.Welcome/Oobe.Welcome.csproj @@ -8,7 +8,7 @@ - + Runtime diff --git a/Oobe/Oobe.Wifi/Controls/ListView.cs b/Oobe/Oobe.Wifi/Controls/ListView.cs index 8897796..1ecd81c 100644 --- a/Oobe/Oobe.Wifi/Controls/ListView.cs +++ b/Oobe/Oobe.Wifi/Controls/ListView.cs @@ -21,6 +21,7 @@ using System.Collections.ObjectModel; using System.Linq; using System.Threading.Tasks; using Oobe.Common.Styles; +using Oobe.Common.Utils; using Tizen.NUI; using Tizen.NUI.BaseComponents; using Tizen.NUI.Components; @@ -72,7 +73,7 @@ namespace Oobe.Wifi.Controls { scrollableBase = new ScrollableBase() { - Size = new Size(width, height), + Size = DpUtils.ToPixels(new Size(width, height)), ScrollingDirection = ScrollableBase.Direction.Vertical, Scrollbar = new Scrollbar(ScrollbarStyles.Default), HideScrollbar = false, diff --git a/Oobe/Oobe.Wifi/Controls/Wifi/AddNewNetworkPupup.cs b/Oobe/Oobe.Wifi/Controls/Wifi/AddNewNetworkPupup.cs index 995b5be..af0a218 100644 --- a/Oobe/Oobe.Wifi/Controls/Wifi/AddNewNetworkPupup.cs +++ b/Oobe/Oobe.Wifi/Controls/Wifi/AddNewNetworkPupup.cs @@ -49,9 +49,9 @@ namespace Oobe.Wifi.Controls.Wifi private string backgroundImagePath = System.IO.Path.Combine(NUIApplication.Current.DirectoryInfo.Resource, "08_popup_body.png"); private string arrowImagePath = System.IO.Path.Combine(NUIApplication.Current.DirectoryInfo.Resource, "12_back_active.png"); - private int labelFontSize = 14; - private int textFontSize = 22; - private int passwordFontSize = 22; + private int labelFontSize = DpUtils.ToPixels(14); + private int textFontSize = DpUtils.ToPixels(22); + private int passwordFontSize = DpUtils.ToPixels(22); public AddNewNetworkPupup() { @@ -77,18 +77,18 @@ namespace Oobe.Wifi.Controls.Wifi private static Color SmallTextColor => new Color(0.0f, 0xC / 255.0f, 0x2B / 255.0f, 1.0f); - private static Size LabelSize => new Size(600, 19); + private static Size LabelSize => DpUtils.ToPixels(new Size(600, 19)); - private static Size TextControlSize => new Size(680, 27); + private static Size TextControlSize => DpUtils.ToPixels(new Size(680, 27)); - private static Size PasswordControlSize => new Size(583, 27); + private static Size PasswordControlSize => DpUtils.ToPixels(new Size(583, 27)); private TextLabel CreateTextLabel(string translatableText, Position2D position = null) { position ??= new Position2D(); return new TextLabel { - Position = position, + Position = DpUtils.ToPixels(position), Size = LabelSize, PixelSize = labelFontSize, TranslatableText = translatableText, @@ -105,7 +105,7 @@ namespace Oobe.Wifi.Controls.Wifi position ??= new Position2D(); var textField = new TextField { - Position = position, + Position = DpUtils.ToPixels(position), Size = TextControlSize, PixelSize = textFontSize, FontFamily = "BreezeSans", @@ -124,8 +124,8 @@ namespace Oobe.Wifi.Controls.Wifi size ??= new Size2D(728, 1); return new View() { - Position = position, - Size = size, + Position = DpUtils.ToPixels(position), + Size = DpUtils.ToPixels(size), BackgroundColor = new Color(0xC3 / 255.0f, 0xCA / 255.0f, 0xD2 / 255.0f, 1.0f), }; } @@ -135,7 +135,7 @@ namespace Oobe.Wifi.Controls.Wifi position ??= new Position2D(); var passwordEntry = new PasswordEntry { - Position = position, + Position = DpUtils.ToPixels(position), Size = PasswordControlSize, PixelSize = passwordFontSize, FontFamily = "BreezeSans", @@ -154,8 +154,8 @@ namespace Oobe.Wifi.Controls.Wifi position ??= new Position2D(); var button = new Button(ButtonStyles.Reveal) { - Size = new Size(32, 32), - Position = position, + Size = DpUtils.ToPixels(new Size(32, 32)), + Position = DpUtils.ToPixels(position), IsSelectable = true, }; button.Clicked += (s, e) => @@ -170,9 +170,9 @@ namespace Oobe.Wifi.Controls.Wifi this.BackgroundImage = backgroundImagePath; titleLabel = new TextLabel { - Position = new Position2D(104, 24), - Size = new Size(600, 34), - PixelSize = 26, + Position = DpUtils.ToPixels(new Position2D(104, 24)), + Size = DpUtils.ToPixels(new Size(600, 34)), + PixelSize = DpUtils.ToPixels(26), TranslatableText = "WIFI_ADD_NETWORK", FontFamily = "BreezeSans", FontStyle = new PropertyMap().AddLightFontStyle(), @@ -193,14 +193,14 @@ namespace Oobe.Wifi.Controls.Wifi cancelButton = new Button(ButtonStyles.Cancel) { - Size = new Size(240, 72), + Size = DpUtils.ToPixels(new Size(240, 72)), }; cancelButton.Clicked += (s, e) => OnDismiss?.Invoke(); this.Add(cancelButton); addButton = new Button(ButtonStyles.OK) { - Size = new Size(240, 72), + Size = DpUtils.ToPixels(new Size(240, 72)), TranslatableText = "WIFI_ADD", }; addButton.Clicked += async (s, e) => @@ -295,7 +295,7 @@ namespace Oobe.Wifi.Controls.Wifi failureLabel = new TextLabel { Size = new Size2D(), - PixelSize = 12, + PixelSize = DpUtils.ToPixels(12), FontFamily = "BreezeSans", FontStyle = new PropertyMap().AddRegularFontStyle(), TextColor = new Color(0xAA / 255.0f, 0x18 / 255.0f, 0x18 / 255.0f, 1.0f), @@ -310,14 +310,14 @@ namespace Oobe.Wifi.Controls.Wifi { var view = new View() { - Size = new Size(728, 72), - Position2D = new Position2D(40, 148), + Size = DpUtils.ToPixels(new Size(728, 72)), + Position2D = DpUtils.ToPixels(new Position2D(40, 148)), Layout = new AbsoluteLayout(), }; selectedSecurityTypeLabel = new TextLabel() { - Size = new Size(200, 28), - Position = new Position2D(0, 23), + Size = DpUtils.ToPixels(new Size(200, 28)), + Position = DpUtils.ToPixels(new Position2D(0, 23)), PixelSize = 22, TranslatableText = currentSecurityType.GetUIName(), FontStyle = new PropertyMap().AddRegularFontStyle(), @@ -330,7 +330,7 @@ namespace Oobe.Wifi.Controls.Wifi view.Add(new View() { BackgroundImage = arrowImagePath, - Position = new Position(696, 31), + Position = DpUtils.ToPixels(new Position(696, 31)), }); securityTypeDetector = new TapGestureDetector(); securityTypeDetector.Attach(view); @@ -355,8 +355,8 @@ namespace Oobe.Wifi.Controls.Wifi Size = new Size(808, 343); Position = new Position2D(236, 118); - addButton.Position = new Position2D(488, ((int)Size.Height) - 96); - cancelButton.Position = new Position2D(80, ((int)Size.Height) - 96); + addButton.Position = DpUtils.ToPixels(new Position2D(488, ((int)Size.Height) - 96)); + cancelButton.Position = DpUtils.ToPixels(new Position2D(80, ((int)Size.Height) - 96)); if (!(usernameLabel is null)) { @@ -405,11 +405,11 @@ namespace Oobe.Wifi.Controls.Wifi private void ResetViewToPasswordOnly() { - Size = new Size2D(808, 412); - Position = new Position2D(236, 59); + Size = DpUtils.ToPixels(new Size2D(808, 412)); + Position = DpUtils.ToPixels(new Position2D(236, 59)); - addButton.Position = new Position2D(488, ((int)Size.Height) - 96); - cancelButton.Position = new Position2D(80, ((int)Size.Height) - 96); + addButton.Position = DpUtils.ToPixels(new Position2D(488, ((int)Size.Height) - 96)); + cancelButton.Position = DpUtils.ToPixels(new Position2D(80, ((int)Size.Height) - 96)); if (!(usernameLabel is null)) { @@ -450,20 +450,20 @@ namespace Oobe.Wifi.Controls.Wifi this.Add(revealButton); } - passwordEntry.Position = new Position2D(40, 232); - passwordUnderline.Position = new Position2D(40, 258); - revealButton.Position = new Position2D(728, 232); + passwordEntry.Position = DpUtils.ToPixels(new Position2D(40, 232)); + passwordUnderline.Position = DpUtils.ToPixels(new Position2D(40, 258)); + revealButton.Position = DpUtils.ToPixels(new Position2D(728, 232)); currentViewMode = NewNetworkViewMode.PasswordOnly; } private void ResetViewToUserPassword() { - Size = new Size2D(808, 440); - Position = new Position2D(236, 0); + Size = DpUtils.ToPixels(new Size2D(808, 440)); + Position = DpUtils.ToPixels(new Position2D(236, 0)); - addButton.Position = new Position2D(488, ((int)Size.Height) - 96); - cancelButton.Position = new Position2D(80, ((int)Size.Height) - 96); + addButton.Position = DpUtils.ToPixels(new Position2D(488, ((int)Size.Height) - 96)); + cancelButton.Position = DpUtils.ToPixels(new Position2D(80, ((int)Size.Height) - 96)); if (usernameLabel is null) { @@ -501,12 +501,12 @@ namespace Oobe.Wifi.Controls.Wifi this.Add(revealButton); } - usernameLabel.Position2D = new Position2D(104, 208); - usernameTextField.Position2D = new Position2D(121, 225); - usernameUnderline.Position2D = new Position2D(104, 251); - passwordEntry.Position2D = new Position2D(40, 232); - passwordUnderline.Position2D = new Position2D(40, 258); - revealButton.Position = new Position2D(728, 232); + usernameLabel.Position2D = DpUtils.ToPixels(new Position2D(104, 208)); + usernameTextField.Position2D = DpUtils.ToPixels(new Position2D(121, 225)); + usernameUnderline.Position2D = DpUtils.ToPixels(new Position2D(104, 251)); + passwordEntry.Position2D = DpUtils.ToPixels(new Position2D(40, 232)); + passwordUnderline.Position2D = DpUtils.ToPixels(new Position2D(40, 258)); + revealButton.Position = DpUtils.ToPixels(new Position2D(728, 232)); currentViewMode = NewNetworkViewMode.UserPassword; } @@ -537,7 +537,7 @@ namespace Oobe.Wifi.Controls.Wifi { failureLabel.Show(); failureLabel.TranslatableText = "WIFI_SSID_FAILURE"; - failureLabel.Position2D = ssidTextField.Position2D + new Position2D(0, (int)ssidTextField.Size.Height); + failureLabel.Position2D = DpUtils.ToPixels(ssidTextField.Position2D + new Position2D(0, (int)ssidTextField.Size.Height)); } private void ShowFailurePasswordLabel() @@ -546,12 +546,12 @@ namespace Oobe.Wifi.Controls.Wifi if (currentViewMode == NewNetworkViewMode.NoPassword) { failureLabel.TranslatableText = "WIFI_SSID_FAILURE"; - failureLabel.Position2D = ssidTextField.Position2D + new Position2D(0, (int)ssidTextField.Size.Height); + failureLabel.Position2D = DpUtils.ToPixels(ssidTextField.Position2D + new Position2D(0, (int)ssidTextField.Size.Height)); } else { failureLabel.TranslatableText = "WIFI_SECUIRTY_KEY_FAILURE"; - failureLabel.Position2D = passwordEntry.Position2D + new Position2D(0, (int)passwordEntry.Size.Height); + failureLabel.Position2D = DpUtils.ToPixels(passwordEntry.Position2D + new Position2D(0, (int)passwordEntry.Size.Height)); } } diff --git a/Oobe/Oobe.Wifi/Controls/Wifi/ApView.cs b/Oobe/Oobe.Wifi/Controls/Wifi/ApView.cs index f87a6c8..39c9641 100644 --- a/Oobe/Oobe.Wifi/Controls/Wifi/ApView.cs +++ b/Oobe/Oobe.Wifi/Controls/Wifi/ApView.cs @@ -16,6 +16,7 @@ using System; using Oobe.Common.Styles; +using Oobe.Common.Utils; using Tizen.Network.WiFi; using Tizen.NUI; using Tizen.NUI.BaseComponents; @@ -32,7 +33,7 @@ namespace Oobe.Wifi.Controls.Wifi public ApView() { - Size = new Size(WifiView.ListItemWidth, WifiView.ListItemHeight); + Size = DpUtils.ToPixels(new Size(WifiView.ListItemWidth, WifiView.ListItemHeight)); Layout = new AbsoluteLayout(); } @@ -44,15 +45,15 @@ namespace Oobe.Wifi.Controls.Wifi { range = new View() { - Position = new Position(39, 21), + Position = DpUtils.ToPixels(new Position(39, 21)), BackgroundImage = GetRangeImage(wifiAp), }; this.Add(range); this.Add(new TextLabel(wifiAp.NetworkInformation.Essid) { - Position = new Position(78, 17), - PixelSize = 20f, + Position = DpUtils.ToPixels(new Position(78, 17)), + PixelSize = DpUtils.ToPixels(20f), TextColor = new Color(0, 0x0C / 255f, 0x2B / 255f, 1.0f), FontFamily = "BreezeSans", FontStyle = new PropertyMap().AddLightFontStyle(), @@ -61,8 +62,8 @@ namespace Oobe.Wifi.Controls.Wifi detail = new TextLabel(GetDetailInfo(wifiAp)) { WidthSpecification = LayoutParamPolicies.WrapContent, - Position = new Position(79, 45), - PixelSize = 14f, + Position = DpUtils.ToPixels(new Position(79, 45)), + PixelSize = DpUtils.ToPixels(14f), TextColor = new Color(0, 0x0C / 255f, 0x2B / 255f, 1.0f), FontFamily = "BreezeSans", FontStyle = new PropertyMap().AddRegularFontStyle(), diff --git a/Oobe/Oobe.Wifi/Controls/Wifi/ButtonStyles.cs b/Oobe/Oobe.Wifi/Controls/Wifi/ButtonStyles.cs index c0d966f..f7891cb 100644 --- a/Oobe/Oobe.Wifi/Controls/Wifi/ButtonStyles.cs +++ b/Oobe/Oobe.Wifi/Controls/Wifi/ButtonStyles.cs @@ -14,6 +14,7 @@ * limitations under the License. */ +using Oobe.Common.Utils; using System; using System.Collections.Generic; using System.Linq; @@ -51,8 +52,8 @@ namespace Oobe.Wifi.Controls.Wifi { PixelSize = new Selector { - Normal = 22.0f, - Pressed = 24.0f, + Normal = DpUtils.ToPixels(22.0f), + Pressed = DpUtils.ToPixels(24.0f), }, EnableMarkup = true, TranslatableText = "WIFI_CANCEL", @@ -63,7 +64,7 @@ namespace Oobe.Wifi.Controls.Wifi }, FontFamily = GetNavigationFont(), }, - Size2D = new Size2D(240, 72), + Size2D = DpUtils.ToPixels(new Size2D(240, 72)), }; private static ButtonStyle GetScanButtonStyle() => new ButtonStyle @@ -74,7 +75,7 @@ namespace Oobe.Wifi.Controls.Wifi Pressed = NUIApplication.Current.DirectoryInfo.Resource + "12_icon_scan_pressed.png", Disabled = NUIApplication.Current.DirectoryInfo.Resource + "12_icon_scan_disabled.png", }, - Size2D = new Size2D(72, 32), + Size2D = DpUtils.ToPixels(new Size2D(72, 32)), }; private static ButtonStyle GetTurnOnOffButtonStyle() => new ButtonStyle @@ -86,7 +87,7 @@ namespace Oobe.Wifi.Controls.Wifi Selected = NUIApplication.Current.DirectoryInfo.Resource + "12_icon_wifion.png", DisabledSelected = NUIApplication.Current.DirectoryInfo.Resource + "12_icon_wifion_disabled.png", }, - Size2D = new Size2D(72, 32), + Size2D = DpUtils.ToPixels(new Size2D(72, 32)), }; private static ButtonStyle GetAddNetworkButtonStyle() => new ButtonStyle @@ -96,7 +97,7 @@ namespace Oobe.Wifi.Controls.Wifi Normal = NUIApplication.Current.DirectoryInfo.Resource + "12_icon_addnetwork.png", Pressed = NUIApplication.Current.DirectoryInfo.Resource + "12_icon_addnetwork_pressed.png", }, - Size2D = new Size2D(42, 42), + Size2D = DpUtils.ToPixels(new Size2D(42, 42)), }; private static ButtonStyle GetRevealButtonStyle() => new ButtonStyle @@ -120,14 +121,14 @@ namespace Oobe.Wifi.Controls.Wifi { PixelSize = new Selector { - Normal = 22.0f, - Pressed = 24.0f, + Normal = DpUtils.ToPixels(22.0f), + Pressed = DpUtils.ToPixels(24.0f), }, TextColor = Color.White, TranslatableText = "WIFI_OK", FontFamily = GetNavigationFont(), }, - Size2D = new Size2D(240, 72), + Size2D = DpUtils.ToPixels(new Size2D(240, 72)), }; private static Selector GetNavigationFont() diff --git a/Oobe/Oobe.Wifi/Controls/Wifi/ChangeSecurityTypePopup.cs b/Oobe/Oobe.Wifi/Controls/Wifi/ChangeSecurityTypePopup.cs index 3be9075..6e45394 100644 --- a/Oobe/Oobe.Wifi/Controls/Wifi/ChangeSecurityTypePopup.cs +++ b/Oobe/Oobe.Wifi/Controls/Wifi/ChangeSecurityTypePopup.cs @@ -21,6 +21,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Oobe.Common.Styles; +using Oobe.Common.Utils; using Tizen.Network.WiFi; using Tizen.NUI; using Tizen.NUI.BaseComponents; @@ -39,8 +40,8 @@ namespace Oobe.Wifi.Controls.Wifi { this.originalWifUISecurityType = wifUISecurityType; this.WifiUISecurityType = wifUISecurityType; - this.Size = new Size(808, 440); - this.Position = new Position(236, 140); + this.Size = DpUtils.ToPixels(new Size(808, 440)); + this.Position = DpUtils.ToPixels(new Position(236, 140)); this.BackgroundImage = System.IO.Path.Combine(NUIApplication.Current.DirectoryInfo.Resource, "08_popup_body.png"); InitializeStaticElements(); @@ -55,8 +56,8 @@ namespace Oobe.Wifi.Controls.Wifi { var titleLabel = new TextLabel() { - Position = new Position2D(80, 24), - Size = new Size(648, 34), + Position = DpUtils.ToPixels(new Position2D(80, 24)), + Size = DpUtils.ToPixels(new Size(648, 34)), PixelSize = 26, TranslatableText = "WIFI_CHOOSE_SECURITY_TYPE", FontFamily = "BreezeSans", @@ -69,8 +70,8 @@ namespace Oobe.Wifi.Controls.Wifi var cancelButton = new Button(ButtonStyles.Cancel) { - Position = new Position(80, 344), - Size = new Size(240, 72), + Position = DpUtils.ToPixels(new Position(80, 344)), + Size = DpUtils.ToPixels(new Size(240, 72)), }; cancelButton.Clicked += (s, e) => { @@ -81,8 +82,8 @@ namespace Oobe.Wifi.Controls.Wifi var addButton = new Button(ButtonStyles.OK) { - Position = new Position(488, 344), - Size = new Size(240, 72), + Position = DpUtils.ToPixels(new Position(488, 344)), + Size = DpUtils.ToPixels(new Size(240, 72)), TranslatableText = "WIFI_OK", }; diff --git a/Oobe/Oobe.Wifi/Controls/Wifi/SecurityTypeView.cs b/Oobe/Oobe.Wifi/Controls/Wifi/SecurityTypeView.cs index 4d76587..f1e58df 100644 --- a/Oobe/Oobe.Wifi/Controls/Wifi/SecurityTypeView.cs +++ b/Oobe/Oobe.Wifi/Controls/Wifi/SecurityTypeView.cs @@ -16,6 +16,7 @@ using System; using Oobe.Common.Styles; +using Oobe.Common.Utils; using Tizen.Network.WiFi; using Tizen.NUI; using Tizen.NUI.BaseComponents; @@ -29,7 +30,7 @@ namespace Oobe.Wifi.Controls.Wifi public SecurityTypeView(WifiUISecurityType wifiUISecurityType) { - Size = new Size(768, 64); + Size = DpUtils.ToPixels(new Size(768, 64)); Layout = new AbsoluteLayout(); this.WifiUISecurityType = wifiUISecurityType; @@ -45,8 +46,8 @@ namespace Oobe.Wifi.Controls.Wifi Button = new RadioButton { IsSelected = false, - Position = new Position(40, 20), - Size = new Size(24, 24), + Position = DpUtils.ToPixels(new Position(40, 20)), + Size = DpUtils.ToPixels(new Size(24, 24)), CellHorizontalAlignment = HorizontalAlignmentType.Center, CellVerticalAlignment = VerticalAlignmentType.Center, }; @@ -54,9 +55,9 @@ namespace Oobe.Wifi.Controls.Wifi descriptionTextLabel = new TextLabel { - Position = new Position(92, 19), - Size = new Size(648, 26), - PixelSize = 20, + Position = DpUtils.ToPixels(new Position(92, 19)), + Size = DpUtils.ToPixels(new Size(648, 26)), + PixelSize = DpUtils.ToPixels(20), TranslatableText = WifiUISecurityType.GetUIName(), FontFamily = "BreezeSans", FontStyle = new PropertyMap().AddLightFontStyle(), diff --git a/Oobe/Oobe.Wifi/Controls/Wifi/WifiPasswordPopup.cs b/Oobe/Oobe.Wifi/Controls/Wifi/WifiPasswordPopup.cs index 36423a7..99c43a6 100644 --- a/Oobe/Oobe.Wifi/Controls/Wifi/WifiPasswordPopup.cs +++ b/Oobe/Oobe.Wifi/Controls/Wifi/WifiPasswordPopup.cs @@ -17,6 +17,7 @@ using System; using System.Threading.Tasks; using Oobe.Common.Styles; +using Oobe.Common.Utils; using Oobe.Wifi.Controls.Wifi; using Tizen.Network.WiFi; using Tizen.NUI; @@ -41,25 +42,25 @@ namespace Oobe.Wifi.Controls.Wifi public WifiPasswordPopup(Tizen.Network.WiFi.WiFiAP wifiAp) { BackgroundImage = backgroundImagePath; - Size = new Size(808, 271); - Position = new Position(new Position2D(236, 116)); + Size = DpUtils.ToPixels(new Size(808, 271)); + Position2D = DpUtils.ToPixels(new Position2D(236, 116)); this.wifiAp = wifiAp; this.Add(new View() // underline { - Size = new Size(672, 1), - Position = new Position(40, 116), + Size = DpUtils.ToPixels(new Size(672, 1)), + Position2D = DpUtils.ToPixels(new Position2D(40, 116)), BackgroundColor = new Color(0xC3 / 255.0f, 0xCA / 255.0f, 0xD2 / 255.0f, 1.0f), }); var titleLabel = new TextLabel { - Size = new Size(728, 33), - Position = new Position(40, 24), + Size = DpUtils.ToPixels(new Size(728, 33)), + Position2D = DpUtils.ToPixels(new Position2D(40, 24)), // no translatableText because of dynamic content Text = string.Format(Translations.WIFI_ENTER_PASSWORD_TO_JOIN, wifiAp.NetworkInformation.Essid), - PixelSize = 26, + PixelSize = DpUtils.ToPixels(26), TextColor = new Color(0, 0x14 / 255.0f, 0x47 / 255.0f, 1.0f), FontFamily = "BreezeSans", FontStyle = new PropertyMap().AddRegularFontStyle(), @@ -70,10 +71,10 @@ namespace Oobe.Wifi.Controls.Wifi passwordEntry = new PasswordEntry() { - Size = new Size(624, 27), - Position = new Position(40, 90), + Size = DpUtils.ToPixels(new Size(624, 27)), + Position = DpUtils.ToPixels(new Position(40, 90)), MaxLength = MaxPasswordLength, - PixelSize = 22, + PixelSize = DpUtils.ToPixels(22), TextColor = new Color(0, 0x0C / 255.0f, 0x2B / 255.0f, 1.0f), FontFamily = "BreezeSans", FontStyle = new PropertyMap().AddRegularFontStyle(), @@ -86,10 +87,10 @@ namespace Oobe.Wifi.Controls.Wifi connectionFailure = new TextLabel { - Size = new Size(624, 22), - Position = new Position(40, 117), + Size = DpUtils.ToPixels(new Size(624, 22)), + Position = DpUtils.ToPixels(new Position(40, 117)), TranslatableText = "WIFI_INVALID_PASSWORD", - PixelSize = 18, + PixelSize = DpUtils.ToPixels(18), TextColor = new Color(0xAA / 255.0f, 0x18 / 255.0f, 0x18 / 255.0f, 1.0f), FontFamily = "BreezeSans", FontStyle = new PropertyMap().AddRegularFontStyle(), @@ -101,8 +102,8 @@ namespace Oobe.Wifi.Controls.Wifi revealButton = new Button(ButtonStyles.Reveal) { - Size = new Size(48, 48), - Position = new Position(720, 79), + Size = DpUtils.ToPixels(new Size(48, 48)), + Position = DpUtils.ToPixels(new Position(720, 79)), IsSelectable = true, }; revealButton.Clicked += (s, e) => TogglePasswordVisibility(); @@ -110,8 +111,8 @@ namespace Oobe.Wifi.Controls.Wifi cancelButton = new Button(ButtonStyles.Cancel) { - Size = new Size(240, 72), - Position = new Position(80, 175), + Size = DpUtils.ToPixels(new Size(240, 72)), + Position = DpUtils.ToPixels(new Position(80, 175)), }; cancelButton.Clicked += (s, e) => { @@ -121,8 +122,8 @@ namespace Oobe.Wifi.Controls.Wifi okButton = new Button(ButtonStyles.OK) { - Size = new Size(240, 72), - Position = new Position(488, 175), + Size = DpUtils.ToPixels(new Size(240, 72)), + Position = DpUtils.ToPixels(new Position(488, 175)), IsEnabled = false, }; okButton.Clicked += async (s, e) => diff --git a/Oobe/Oobe.Wifi/Controls/Wifi/WifiView.cs b/Oobe/Oobe.Wifi/Controls/Wifi/WifiView.cs index 9478816..ec1a058 100644 --- a/Oobe/Oobe.Wifi/Controls/Wifi/WifiView.cs +++ b/Oobe/Oobe.Wifi/Controls/Wifi/WifiView.cs @@ -16,6 +16,7 @@ using System; using Oobe.Common.Styles; +using Oobe.Common.Utils; using Tizen.NUI; using Tizen.NUI.BaseComponents; using Tizen.NUI.Components; @@ -42,7 +43,7 @@ namespace Oobe.Wifi.Controls.Wifi LinearOrientation = LinearLayout.Orientation.Vertical, }, BackgroundImage = System.IO.Path.Combine(NUIApplication.Current.DirectoryInfo.Resource, "Rectangle_918.png"), - Size = new Size(480, 416), + Size = DpUtils.ToPixels(new Size(480, 416)), }; view.Add(CreateHeader(480, 91)); @@ -78,8 +79,8 @@ namespace Oobe.Wifi.Controls.Wifi var progress = new View() { - Size = new Size(22, 23), - Margin = new Extents(0, 0, 1, 0), + Size = DpUtils.ToPixels(new Size(22, 23)), + Margin = DpUtils.ToPixels(new Extents(0, 0, 1, 0)), BackgroundImage = System.IO.Path.Combine(NUIApplication.Current.DirectoryInfo.Resource, "12_icon_scanning.png"), }; view.Add(progress); @@ -106,12 +107,12 @@ namespace Oobe.Wifi.Controls.Wifi view.Add(new TextLabel() { - Size = new Size(190, 25), + Size = DpUtils.ToPixels(new Size(190, 25)), TranslatableText = "WIFI_SCANNING", - Margin = new Extents(17, 0, 0, 0), + Margin = DpUtils.ToPixels(new Extents(17, 0, 0, 0)), VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Begin, - PixelSize = 20f, + PixelSize = DpUtils.ToPixels(20f), TextColor = new Color(0, 0x0C / 255f, 0x2B / 255f, 1.0f), FontFamily = "BreezeSans", FontStyle = new PropertyMap().AddRegularFontStyle(), @@ -123,9 +124,9 @@ namespace Oobe.Wifi.Controls.Wifi { return new View() { - Size2D = new Size(400, 1), + Size2D = DpUtils.ToPixels(new Size(400, 1)), BackgroundColor = new Color(0xC3 / 255f, 0xCA / 255f, 0xD2 / 255f, 1.0f), - Margin = new Extents(40, 0, 0, 0), + Margin = DpUtils.ToPixels(new Extents(40, 0, 0, 0)), }; } @@ -133,14 +134,14 @@ namespace Oobe.Wifi.Controls.Wifi { var manualWifi = new View() { - Size = new Size(ListItemWidth, ListItemHeight), + Size = DpUtils.ToPixels(new Size(ListItemWidth, ListItemHeight)), Layout = new AbsoluteLayout(), }; var addNewButton = new Button(ButtonStyles.AddNetwork) { - Position = new Position(29, 20), - Size = new Size(42, 42), + Position = DpUtils.ToPixels(new Position(29, 20)), + Size = DpUtils.ToPixels(new Size(42, 42)), }; addNewButton.Clicked += (s, e) => ShowAddNetworkPopup(); @@ -149,8 +150,8 @@ namespace Oobe.Wifi.Controls.Wifi manualWifi.Add(new TextLabel() { TranslatableText = "WIFI_ADD_NEW_NETWORK", - Position = new Position(87, 29), - PixelSize = 20f, + Position = DpUtils.ToPixels(new Position(87, 29)), + PixelSize = DpUtils.ToPixels(20f), TextColor = new Color(0, 0x0C / 255f, 0x2B / 255f, 1.0f), FontFamily = "BreezeSans", FontStyle = new PropertyMap().AddRegularFontStyle(), @@ -189,7 +190,7 @@ namespace Oobe.Wifi.Controls.Wifi { var header = new View() { - Size = new Size(width, height), + Size = DpUtils.ToPixels(new Size(width, height)), Layout = new AbsoluteLayout(), }; @@ -197,8 +198,8 @@ namespace Oobe.Wifi.Controls.Wifi var scan = new Button(ButtonStyles.Scan) { - Size = new Size(72, 32), - Position = new Position(276, 39), + Size = DpUtils.ToPixels(new Size(72, 32)), + Position = DpUtils.ToPixels(new Position(276, 39)), }; scan.Clicked += async (s, e) => { @@ -220,8 +221,8 @@ namespace Oobe.Wifi.Controls.Wifi { var button = new Button(ButtonStyles.TurnOnOff) { - Size = new Size(72, 32), - Position = new Position(369, 39), + Size = DpUtils.ToPixels(new Size(72, 32)), + Position = DpUtils.ToPixels(new Position(369, 39)), }; button.IsSelectable = true; button.IsSelected = State.IsTurnedOn; @@ -251,8 +252,8 @@ namespace Oobe.Wifi.Controls.Wifi var prompt = new TextLabel() { - Position = new Position(40, 21), - PixelSize = 20, + Position = DpUtils.ToPixels(new Position(40, 21)), + PixelSize = DpUtils.ToPixels(20), TextColor = new Color(0, 0x14 / 255f, 0x47 / 255f, 1.0f), FontFamily = "BreezeSans", FontStyle = new PropertyMap().AddRegularFontStyle(), @@ -291,12 +292,12 @@ namespace Oobe.Wifi.Controls.Wifi { var view = new View() { - Position = new Position(40, 43), + Position = DpUtils.ToPixels(new Position(40, 43)), }; var wifi = new TextLabel("Wi-Fi") { - PixelSize = 20f, + PixelSize = DpUtils.ToPixels(20f), TextColor = new Color(0, 0x0C / 255f, 0x2B / 255f, 1.0f), FontFamily = "BreezeSans", FontStyle = new PropertyMap().AddRegularFontStyle(), diff --git a/Oobe/Oobe.Wifi/Oobe.Wifi.csproj b/Oobe/Oobe.Wifi/Oobe.Wifi.csproj index e24155c..646c5b4 100644 --- a/Oobe/Oobe.Wifi/Oobe.Wifi.csproj +++ b/Oobe/Oobe.Wifi/Oobe.Wifi.csproj @@ -9,7 +9,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Oobe/Oobe/Oobe.csproj b/Oobe/Oobe/Oobe.csproj index 09e09f5..724519b 100644 --- a/Oobe/Oobe/Oobe.csproj +++ b/Oobe/Oobe/Oobe.csproj @@ -24,7 +24,7 @@ - + Runtime diff --git a/Oobe/Oobe/OobeApp.cs b/Oobe/Oobe/OobeApp.cs index dc31eb3..cca0be7 100644 --- a/Oobe/Oobe/OobeApp.cs +++ b/Oobe/Oobe/OobeApp.cs @@ -18,6 +18,7 @@ using System; using System.Globalization; using Oobe.Common.Resources; using Oobe.Common.Services; +using Oobe.Common.Utils; using Oobe.Managers; using Tizen.NUI; using Tizen.NUI.Components; @@ -38,6 +39,7 @@ namespace Oobe { Tizen.Log.Debug("oobe", "OnCreate"); base.OnCreate(); + Tizen.Log.Debug("oobe", $"Dp->Px: {1.0f} -> {DpUtils.ToPixels(1.0f)}, Px->Dp: {1.0f} -> {DpUtils.FromPixels(1.0f)}"); Window.Instance.Hide(); }