-/*
- * 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<CarouselPickerItemData> items = new List<CarouselPickerItemData>();
-
- 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;
+/*\r
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using Oobe.Common.Utils;\r
+using Tizen.NUI;\r
+using Tizen.NUI.BaseComponents;\r
+using Tizen.NUI.Binding;\r
+using Tizen.NUI.Components;\r
+\r
+namespace Oobe.Common.Controls\r
+{\r
+ public class CarouselPicker : Control\r
+ {\r
+ private Oobe.Common.Controls.ScrollableBase scrollableBase;\r
+ private View itemsListView;\r
+ private View upperLine;\r
+ private View lowerLine;\r
+\r
+ private Vector3 textCenterColorHSV = new Vector3();\r
+ private Vector3 textOuterColorHSV = new Vector3();\r
+\r
+ private float textCenterOpacity;\r
+ private float textOuterOpacity;\r
+ private int selectedItemIndex = 0;\r
+\r
+ private List<CarouselPickerItemData> items = new List<CarouselPickerItemData>();\r
+\r
+ public CarouselPicker()\r
+ : base()\r
+ {\r
+ }\r
+\r
+ public CarouselPicker(CarouselPickerStyle style)\r
+ : base(style)\r
+ {\r
+ // TODO fix a bug with style not properly applied by base class\r
+ ApplyStyle(style);\r
+ }\r
+\r
+ public event EventHandler SelectedItemChanged;\r
+\r
+ public new CarouselPickerStyle Style => ViewStyle as CarouselPickerStyle;\r
+\r
+ public int SelectedItemIndex\r
+ {\r
+ get\r
+ {\r
+ return selectedItemIndex;\r
+ }\r
+\r
+ set\r
+ {\r
+ // always scroll\r
+ scrollableBase.ScrollToIndex(value);\r
+ if (selectedItemIndex != value)\r
+ {\r
+ SelectedItemChanged?.Invoke(this, null);\r
+ selectedItemIndex = value;\r
+ }\r
+ }\r
+ }\r
+\r
+ public void AddItem(CarouselPickerItemData item)\r
+ {\r
+ var view = CreateItemView(item);\r
+ itemsListView.Add(view);\r
+ items.Add(item);\r
+ }\r
+\r
+ public void RemoveItem(CarouselPickerItemData item)\r
+ {\r
+ var index = items.IndexOf(item);\r
+ items.Remove(item);\r
+ itemsListView.Children.RemoveAt(index);\r
+ }\r
+\r
+ public override void ApplyStyle(ViewStyle viewStyle)\r
+ {\r
+ base.ApplyStyle(viewStyle);\r
+\r
+ CarouselPickerStyle style = viewStyle as CarouselPickerStyle;\r
+\r
+ if (style != null)\r
+ {\r
+ Layout = new LinearLayout\r
+ {\r
+ LinearOrientation = LinearLayout.Orientation.Vertical,\r
+ LinearAlignment = LinearLayout.Alignment.Center,\r
+ };\r
+ ClippingMode = ClippingModeType.ClipToBoundingBox;\r
+\r
+ // Animatable properties\r
+ textCenterColorHSV = Style.CenterText?.TextColor?.All?.ToHSV() ?? new Vector3();\r
+ textCenterOpacity = Style.CenterText?.Opacity?.All ?? 1.0f;\r
+\r
+ textOuterColorHSV = Style.OuterText?.TextColor?.All?.ToHSV() ?? new Vector3();\r
+ textOuterOpacity = Style.OuterText?.Opacity?.All ?? 1.0f;\r
+\r
+ if (itemsListView != null)\r
+ {\r
+ scrollableBase?.Remove(itemsListView);\r
+ itemsListView.Dispose();\r
+ }\r
+\r
+ itemsListView = new View\r
+ {\r
+ Layout = new LinearLayout\r
+ {\r
+ LinearOrientation = LinearLayout.Orientation.Vertical,\r
+ },\r
+ WidthSpecification = LayoutParamPolicies.MatchParent,\r
+ HeightSpecification = LayoutParamPolicies.WrapContent,\r
+ };\r
+\r
+ if (scrollableBase != null)\r
+ {\r
+ Remove(scrollableBase);\r
+ scrollableBase.Dispose();\r
+ }\r
+\r
+ scrollableBase = new Oobe.Common.Controls.ScrollableBase\r
+ {\r
+ ClippingMode = ClippingModeType.Disabled,\r
+ WidthResizePolicy = ResizePolicyType.FillToParent,\r
+ SnapToPage = true,\r
+ ScrollingDirection = ScrollableBase.Direction.Vertical,\r
+ ScrollEnabled = true,\r
+ SizeHeight = CalculateScrollerSize(),\r
+ FlickDistanceMultiplierRange = new Vector2(4.6f, 5.8f),\r
+ EventsView = this,\r
+ };\r
+\r
+ scrollableBase.ScrollEvent += (sender, args) =>\r
+ {\r
+ UpdateItems();\r
+ };\r
+ scrollableBase.ScrollAnimationEndEvent += (sender, args) =>\r
+ {\r
+ if (selectedItemIndex != scrollableBase.CurrentPage)\r
+ {\r
+ selectedItemIndex = scrollableBase.CurrentPage;\r
+ SelectedItemChanged?.Invoke(this, null);\r
+ }\r
+ };\r
+\r
+ if (upperLine != null)\r
+ {\r
+ Remove(upperLine);\r
+ upperLine.Dispose();\r
+ }\r
+\r
+ upperLine = new View()\r
+ {\r
+ BackgroundColor = Style.LinesColor,\r
+ Size2D = DpUtils.ToPixels(new Size2D(0, 1)),\r
+ WidthResizePolicy = ResizePolicyType.FillToParent,\r
+ Position2D = DpUtils.ToPixels(new Position2D(0, 93)),\r
+ Opacity = 0.95f,\r
+ };\r
+\r
+ if (lowerLine != null)\r
+ {\r
+ Remove(lowerLine);\r
+ lowerLine.Dispose();\r
+ }\r
+\r
+ lowerLine = new View()\r
+ {\r
+ BackgroundColor = Style.LinesColor,\r
+ Size2D = DpUtils.ToPixels(new Size2D(0, 1)),\r
+ WidthResizePolicy = ResizePolicyType.FillToParent,\r
+ Position2D = DpUtils.ToPixels(new Position2D(0, 93)),\r
+ Opacity = 0.95f,\r
+ };\r
+\r
+ scrollableBase.Add(itemsListView);\r
+\r
+ Add(upperLine);\r
+ Add(scrollableBase);\r
+ Add(lowerLine);\r
+ }\r
+ }\r
+\r
+ protected override void OnUpdate()\r
+ {\r
+ base.OnUpdate();\r
+ UpdateItems();\r
+ }\r
+\r
+ protected override void Dispose(Tizen.NUI.DisposeTypes type)\r
+ {\r
+ if (disposed)\r
+ {\r
+ return;\r
+ }\r
+\r
+ if (type == DisposeTypes.Explicit)\r
+ {\r
+ // Dispose all containing widgets\r
+ scrollableBase.Dispose();\r
+ upperLine.Dispose();\r
+ lowerLine.Dispose();\r
+ }\r
+\r
+ base.Dispose(type);\r
+ }\r
+\r
+ private float CalculateScrollerSize()\r
+ {\r
+ float size = 0.0f;\r
+\r
+ size += Style.CenterText?.Size2D?.Height ?? 0.0f;\r
+ size += (float)Style.CenterText?.Margin?.Top;\r
+ size += (float)Style.CenterText?.Margin?.Bottom;\r
+\r
+ return size;\r
+ }\r
+\r
+ private View CreateItemView(CarouselPickerItemData item)\r
+ {\r
+ var view = new TextLabel();\r
+\r
+ // TODO for some reason TextLabel(Style.CenterText)\r
+ // or view.ApplyStyle(Style.CenterText) do not work here so set\r
+ // everything manually\r
+ // var view = new TextLabel(Style.CenterText);\r
+ // view.ApplyStyle(Style.CenterText);\r
+ float? pixelSize = null;\r
Style.CenterText?.PixelSize.GetValue(ControlState.Normal, out pixelSize);\r
\r
- view.Text = item.Text;
- view.TranslatableText = item.TranslatableText;
- view.Size2D = Style.CenterText?.Size2D ?? new Size2D();
+ view.Text = item.Text;\r
+ view.TranslatableText = item.TranslatableText;\r
+ view.Size2D = Style.CenterText?.Size2D ?? new Size2D();\r
view.PixelSize = pixelSize ?? 10.0f;\r
- 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();\r
+ view.HorizontalAlignment = Style.CenterText?.HorizontalAlignment ?? HorizontalAlignment.Center;\r
+ view.VerticalAlignment = Style.CenterText?.VerticalAlignment ?? VerticalAlignment.Center;\r
+ view.Opacity = Style.CenterText?.Opacity?.All ?? 1.0f;\r
+\r
+ // TODO other properties?\r
+ return view;\r
+ }\r
+\r
+ private void CreateMainList()\r
+ {\r
+ }\r
+\r
+ private Vector3 ScaleVector(Vector3 from, Vector3 to, float percent)\r
+ {\r
+ percent = Math.Clamp(percent, 0.0f, 1.0f);\r
+\r
+ float a = from[0] + ((to[0] - from[0]) * percent);\r
+ float b = from[1] + ((to[1] - from[1]) * percent);\r
+ float c = from[2] + ((to[2] - from[2]) * percent);\r
+\r
+ return new Vector3(a, b, c);\r
+ }\r
+\r
+ private float ScaleScalar(float from, float to, float percent)\r
+ {\r
+ percent = Math.Clamp(percent, 0.0f, 1.0f);\r
+ return from + ((to - from) * percent);\r
+ }\r
+\r
+ private void UpdateItems()\r
+ {\r
+ float mid = itemsListView.PositionY - (int)(scrollableBase.Size2D.Height / 2.0f);\r
+ int threshold = 80; // after this value the color will become outer\r
+\r
+ foreach (View view in itemsListView.Children)\r
+ {\r
+ TextLabel itemView = view as TextLabel;\r
+ if (itemView == null)\r
+ {\r
+ continue;\r
+ }\r
+\r
+ float viewMid = view.PositionY + (view.Size2D.Height / 2.0f);\r
+ float percent = Math.Abs(viewMid + mid) / threshold;\r
+\r
+ itemView.Opacity = ScaleScalar(textCenterOpacity, textOuterOpacity, percent);\r
+ itemView.TextColor = ColorUtils.ColorFromHSV(ScaleVector(textCenterColorHSV, textOuterColorHSV, percent));\r
+ }\r
+ }\r
+ }\r
+}\r
</PropertyGroup>
<ItemGroup>
- <PackageReference Include="Tizen.NET" Version="9.0.0.16249">
+ <PackageReference Include="Tizen.NET" Version="9.0.0.16715">
<ExcludeAssets>Runtime</ExcludeAssets>
</PackageReference>
<PackageReference Include="Tizen.NET.Sdk" Version="1.1.6" />
*/
using Oobe.Common.Styles;
+using Oobe.Common.Utils;
using Tizen.NUI;
using Tizen.NUI.BaseComponents;
using Tizen.NUI.Components;
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(),
};
* limitations under the License.
*/
+using Oobe.Common.Utils;
using Tizen.NUI;
using Tizen.NUI.BaseComponents;
using Tizen.NUI.Components;
{
PixelSize = new Selector<float?>
{
- Normal = 22.0f,
- Pressed = 24.0f,
+ Normal = DpUtils.ToPixels(22.0f),
+ Pressed = DpUtils.ToPixels(24.0f),
},
EnableMarkup = true,
TranslatableText = "PREVIOUS",
},
FontFamily = GetNavigationFont(),
},
- Size2D = new Size2D(240, 72),
+ Size2D = DpUtils.ToPixels(new Size2D(240, 72)),
};
private static ButtonStyle GetSkipButtonStyle()
{
PixelSize = new Selector<float?>
{
- 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<string> GetNavigationFont()
*/
using Oobe.Common.Controls;
+using Oobe.Common.Utils;
using Tizen.NUI;
using Tizen.NUI.BaseComponents;
using Tizen.NUI.Components;
{
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,
--- /dev/null
+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));
+ }
+ }
+}
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)
{
</PropertyGroup>
<ItemGroup>
- <PackageReference Include="Tizen.NET" Version="9.0.0.16249">
+ <PackageReference Include="Tizen.NET" Version="9.0.0.16715">
<ExcludeAssets>Runtime</ExcludeAssets>
</PackageReference>
<PackageReference Include="Tizen.NET.Sdk" Version="1.1.6" />
</PropertyGroup>
<ItemGroup>
- <PackageReference Include="Tizen.NET" Version="9.0.0.16249">
+ <PackageReference Include="Tizen.NET" Version="9.0.0.16715">
<ExcludeAssets>Runtime</ExcludeAssets>
</PackageReference>
<PackageReference Include="Tizen.NET.Sdk" Version="1.1.6" />
</PropertyGroup>
<ItemGroup>
- <PackageReference Include="Tizen.NET" Version="9.0.0.16249">
+ <PackageReference Include="Tizen.NET" Version="9.0.0.16715">
<ExcludeAssets>Runtime</ExcludeAssets>
</PackageReference>
<PackageReference Include="Tizen.NET.Sdk" Version="1.1.6" />
-/*
- * 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.
- */
-
+/*\r
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
using Oobe.Common.Interfaces;\r
using Oobe.Common.Pages;\r
using Oobe.Terms.Model;\r
\r
public override BasePage CreateView(IProcessNavigation nav)\r
{\r
- return new TermsView(nav, provider);
+ return new TermsView(nav, provider);\r
}\r
}\r
}\r
Layout = new LinearLayout
{
LinearOrientation = LinearLayout.Orientation.Vertical,
- CellPadding = new Size2D(0, 12),
+ CellPadding = DpUtils.ToPixels(new Size2D(0, 12)),
},
};
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(),
// 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;
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) =>
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)),
},
};
private Size2D CalculateTermsViewSize()
{
- var referenceTermsSize = new Size2D(1072, 316);
+ var referenceTermsSize = DpUtils.ToPixels(new Size2D(1072, 316));
return Config.ScaledSize(referenceTermsSize);
}
}
</PropertyGroup>
<ItemGroup>
- <PackageReference Include="Tizen.NET" Version="9.0.0.16249">
+ <PackageReference Include="Tizen.NET" Version="9.0.0.16715">
<ExcludeAssets>Runtime</ExcludeAssets>
</PackageReference>
<PackageReference Include="Tizen.NET.Sdk" Version="1.1.6" />
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;
{
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,
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()
{
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,
position ??= new Position2D();
var textField = new TextField
{
- Position = position,
+ Position = DpUtils.ToPixels(position),
Size = TextControlSize,
PixelSize = textFontSize,
FontFamily = "BreezeSans",
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),
};
}
position ??= new Position2D();
var passwordEntry = new PasswordEntry
{
- Position = position,
+ Position = DpUtils.ToPixels(position),
Size = PasswordControlSize,
PixelSize = passwordFontSize,
FontFamily = "BreezeSans",
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) =>
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(),
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) =>
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),
{\r
var view = new View()\r
{\r
- Size = new Size(728, 72),\r
- Position2D = new Position2D(40, 148),\r
+ Size = DpUtils.ToPixels(new Size(728, 72)),\r
+ Position2D = DpUtils.ToPixels(new Position2D(40, 148)),\r
Layout = new AbsoluteLayout(),\r
};\r
selectedSecurityTypeLabel = new TextLabel()\r
{\r
- Size = new Size(200, 28),\r
- Position = new Position2D(0, 23),
+ Size = DpUtils.ToPixels(new Size(200, 28)),\r
+ Position = DpUtils.ToPixels(new Position2D(0, 23)),
PixelSize = 22,\r
TranslatableText = currentSecurityType.GetUIName(),\r
FontStyle = new PropertyMap().AddRegularFontStyle(),\r
view.Add(new View()\r
{\r
BackgroundImage = arrowImagePath,\r
- Position = new Position(696, 31),\r
+ Position = DpUtils.ToPixels(new Position(696, 31)),\r
});\r
securityTypeDetector = new TapGestureDetector();\r
securityTypeDetector.Attach(view);\r
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))
{
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))
{
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)
{
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;
}
{
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()
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));
}
}
using System;
using Oobe.Common.Styles;
+using Oobe.Common.Utils;
using Tizen.Network.WiFi;
using Tizen.NUI;
using Tizen.NUI.BaseComponents;
public ApView()
{
- Size = new Size(WifiView.ListItemWidth, WifiView.ListItemHeight);
+ Size = DpUtils.ToPixels(new Size(WifiView.ListItemWidth, WifiView.ListItemHeight));
Layout = new AbsoluteLayout();
}
{
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(),
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(),
* limitations under the License.
*/
+using Oobe.Common.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
{
PixelSize = new Selector<float?>
{
- Normal = 22.0f,
- Pressed = 24.0f,
+ Normal = DpUtils.ToPixels(22.0f),
+ Pressed = DpUtils.ToPixels(24.0f),
},
EnableMarkup = true,
TranslatableText = "WIFI_CANCEL",
},
FontFamily = GetNavigationFont(),
},
- Size2D = new Size2D(240, 72),
+ Size2D = DpUtils.ToPixels(new Size2D(240, 72)),
};
private static ButtonStyle GetScanButtonStyle() => new ButtonStyle
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
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
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
{
PixelSize = new Selector<float?>
{
- 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<string> GetNavigationFont()
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;
{
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();
{
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",
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) =>
{
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",
};
using System;
using Oobe.Common.Styles;
+using Oobe.Common.Utils;
using Tizen.Network.WiFi;
using Tizen.NUI;
using Tizen.NUI.BaseComponents;
public SecurityTypeView(WifiUISecurityType wifiUISecurityType)
{
- Size = new Size(768, 64);
+ Size = DpUtils.ToPixels(new Size(768, 64));
Layout = new AbsoluteLayout();
this.WifiUISecurityType = wifiUISecurityType;
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,
};
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(),
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;
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(),
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(),
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(),
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();
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) =>
{
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) =>
using System;
using Oobe.Common.Styles;
+using Oobe.Common.Utils;
using Tizen.NUI;
using Tizen.NUI.BaseComponents;
using Tizen.NUI.Components;
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));
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);
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(),
{
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)),
};
}
{
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();
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(),
{
var header = new View()
{
- Size = new Size(width, height),
+ Size = DpUtils.ToPixels(new Size(width, height)),
Layout = new AbsoluteLayout(),
};
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) =>
{
{
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;
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(),
{
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(),
</PropertyGroup>
<ItemGroup>
- <PackageReference Include="Tizen.NET" Version="9.0.0.16249" />
+ <PackageReference Include="Tizen.NET" Version="9.0.0.16715" />
<PackageReference Include="Tizen.NET.Sdk" Version="1.1.6" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</ItemGroup>
<ItemGroup>
- <PackageReference Include="Tizen.NET" Version="9.0.0.16249">
+ <PackageReference Include="Tizen.NET" Version="9.0.0.16715">
<ExcludeAssets>Runtime</ExcludeAssets>
</PackageReference>
<PackageReference Include="Tizen.NET.Sdk" Version="1.1.6" />
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;
{
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();
}