void AddChildrenInScrollableBase() { tlog.Debug(tag, "AddChildrenInScrollableBase test"); grid = new View() { Layout = new GridLayout() { GridOrientation = GridLayout.Orientation.Vertical, Columns = 3, Rows = 3, }, WidthSpecification = 390, HeightSpecification = 590, BackgroundColor = new Color(global::System.Drawing.Color.FromName("SlateBlue")), Padding = new Extents(5, 5, 5, 5), Name = "grid-1", }; scroll.Add(grid); for (int i = 0; i < 9; i++) { var t = new TextLabel() { Size = new Size(100, 180), Text = $"con-{i}", BackgroundColor = new Color(0.5f, (100 + 10 * i) / 255.0f, 0.5f, 1), Margin = new Extents(2, 2, 2, 2), Name = $"sub-tl-{i}", }; grid.Add(t); } t3 = new TextLabel() { WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = 200, Text = "TextLable-3", BackgroundColor = Color.Magenta, Margin = new Extents(10, 10, 10, 10), Name = "tl-3", }; scroll.Add(t3); t4 = new TextLabel() { WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = 200, Text = "TextLable-4", BackgroundColor = new Color(global::System.Drawing.Color.FromName("HotPink")), Margin = new Extents(10, 10, 10, 10), Name = "tl-4", }; scroll.Add(t4); }
void Initialize() { ScrollableBase scrollableBase = new ScrollableBase(); scrollableBase.Size = new Size(720, 1280); scrollableBase.ScrollingDirection = ScrollableBase.Direction.Vertical; Window.Instance.GetDefaultLayer().Add(scrollableBase); scrollableBase.ScrollDragStarted += ScrollDragStarted; scrollableBase.ScrollDragEnded += ScrollDragEnded; View[] items; items = new View[10]; for (int i = 0; i < items.Length; i++) { items[i] = new View { Position = new Position(0, i * 200), Size = new Size(720, 200), }; if (i % 2 == 0) { items[i].BackgroundColor = Color.Magenta; } else { items[i].BackgroundColor = Color.Cyan; } scrollableBase.Add(items[i]); } }
protected override void OnCreate() { base.OnCreate(); var window = NUIApplication.GetDefaultWindow(); var screenLength = Math.Min(window.Size.Width, window.Size.Height); var view = new ImageView() { Size = new Size(360, 1440), ResourceUrl = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "/image.jpg", Focusable = true, }; scrollableBase = new ScrollableBase() { Size = new Size(360, 360), HideScrollbar = false, Scrollbar = new Scrollbar() { TrackColor = Color.Blue, ThumbColor = new Color(1.0f, 0.0f, 0.0f, 0.5f), TrackPadding = new Extents(24, 24, 40, 40) } }; scrollableBase.Add(view); window.Add(scrollableBase); }
void OnAddButtonClicked(object sender, EventArgs args) { var image = new ImageView() { Size = new Size(360, 360), ResourceUrl = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "/image.jpg" }; items.Add(image); scrollable.Add(image); }
void CreateItems(View parent, int width, int height, string resource = null, string text = null) { var horizBox = new ScrollableBase() { WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = height + 30, ScrollingDirection = ScrollableBase.Direction.Horizontal, HideScrollbar = false, Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, CellPadding = new Size2D(10, 0), }, }; var enabledItem = CreateItem(width, height, null, text); horizBox.Add(enabledItem); var disabledItem = CreateItem(width, height, null, text); disabledItem.IsEnabled = false; horizBox.Add(disabledItem); var selectedItem = CreateItem(width, height, null, text); selectedItem.IsSelectable = true; selectedItem.IsSelected = true; horizBox.Add(selectedItem); var imageItem = CreateItem(width, height, resource, text); horizBox.Add(imageItem); parent.Add(horizBox); }
public PerformanceTest3Page() { InitializeComponent(); //Application Linear Layout LinearLayout layout = new LinearLayout(); layout.LinearOrientation = LinearLayout.Orientation.Vertical; layout.LinearAlignment = LinearLayout.Alignment.Center; layout.Padding = new Extents(5, 5, 5, 5); layout.CellPadding = new Size2D(5, 5); this.Layout = layout; LinearLayout hLayout = new LinearLayout(); hLayout.LinearOrientation = LinearLayout.Orientation.Horizontal; hLayout.LinearAlignment = LinearLayout.Alignment.Center; hLayout.Padding = new Extents(5, 5, 5, 5); hLayout.CellPadding = new Size2D(5, 5); ButtonBox.Layout = hLayout; ScrollBegin.Clicked += OnScrollBeginClicked; ScrollMiddle.Clicked += OnScrollMiddleClicked; ScrollEnd.Clicked += OnScrollEndClicked; //Create List for Labels LabelsListView = new ScrollableBase(); LabelsListView.BackgroundColor = Color.White; LabelsListView.Size2D = new Size2D(700, 1200); //Set linead layout for scrollable widget LinearLayout scrollLayout = new LinearLayout(); scrollLayout.LinearOrientation = LinearLayout.Orientation.Vertical; scrollLayout.LinearAlignment = LinearLayout.Alignment.Center; scrollLayout.CellPadding = new Size2D(5, 5); LabelsListView.Layout = scrollLayout; LabelsListView.ScrollDuration = ScrollTime; this.Add(LabelsListView); var items = new ListItemTitleView[TestItems]; for (int i = 0; i < TestItems; i++) { items[i] = new ListItemTitleView("item: " + i.ToString()); LabelsListView.Add(items[i]); } }
public void CreatePage() { scrollable = new ScrollableBase() { Size = new Size(360, 360), SnapToPage = true, ScrollingDirection = ScrollableBase.Direction.Horizontal, ParentOrigin = ParentOrigin.Center, PivotPoint = PivotPoint.Center, PositionUsesPivotPoint = true, }; View view = new View() { WidthSpecification = LayoutParamPolicies.WrapContent, HeightSpecification = 360, Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Horizontal, SetPositionByLayout = false, }, BackgroundColor = new Color(0.15f, 0.15f, 0.15f, 1.0f), }; scrollable.Add(view); List <string> appList = WidgetApplicationInfo.LoadAllParameters(); for (int i = 0; i < appStr.Count; i++) { ImageView viewer = new ImageView() { Name = appList[i], //ParentOrigin = ParentOrigin.Center, //PivotPoint = PivotPoint.Center, //PositionUsesPivotPoint = true, Size = new Size(360, 360), CornerRadius = 180.0f, Scale = new Vector3(0.6f, 0.6f, 0.6f), BackgroundImage = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "widget_capture/" + appStr[i], }; viewer.TouchEvent += Viewer_TouchEvent; view.Add(viewer); } }
void AddItem(View view, string desc) { view.ParentOrigin = ParentOrigin.CenterLeft; view.PivotPoint = PivotPoint.CenterLeft; view.PositionUsesPivotPoint = true; var item = new View() { Size = new Size(440, 140), BackgroundColor = Color.White, Padding = new Extents(20, 20, 0, 0), CornerRadius = 6, Layout = new LinearLayout() { CellPadding = new Size2D(30, 0) }, }; item.Add(view); var textArea = new View() { BackgroundColor = new Color(0, 0, 0, 0.8f), Size = new Size(250, 120), ParentOrigin = ParentOrigin.CenterLeft, PivotPoint = PivotPoint.CenterLeft, PositionUsesPivotPoint = true, CornerRadius = 4, }; item.Add(textArea); textArea.Add(new TextLabel() { ParentOrigin = ParentOrigin.CenterLeft, PivotPoint = PivotPoint.CenterLeft, PositionUsesPivotPoint = true, MultiLine = true, PointSize = 10, TextColor = Color.White, Text = desc, Padding = new Extents(10, 10, 0, 0), }); contents.Add(item); }
void test() { window = NUIApplication.GetDefaultWindow(); window.KeyEvent += OnKeyEvent; t1 = new TextLabel() { Size = new Size(400, 100), Position = new Position(10, 10), Text = "TextLable-1", BackgroundColor = Color.Yellow, Name = "tl-1", }; window.Add(t1); t2 = new TextLabel() { Size = new Size(400, 150), Position = new Position(10, 120), Text = "TextLable-2", BackgroundColor = Color.Green, Name = "tl-2", }; window.Add(t2); scroll = new ScrollableBase() { Size = new Size(400, 500), Position = new Position(10, 280), BackgroundColor = Color.Red, ScrollingDirection = ScrollableBase.Direction.Vertical, Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Vertical, }, Padding = new Extents(20, 20, 20, 20), Name = "scr-1", }; window.Add(scroll); grid = new View() { Layout = new GridLayout() { GridOrientation = GridLayout.Orientation.Vertical, Columns = 3, Rows = 3, }, WidthSpecification = 390, HeightSpecification = 590, BackgroundColor = new Color(global::System.Drawing.Color.FromName("SlateBlue")), Padding = new Extents(5, 5, 5, 5), Name = "grid-1", }; scroll.Add(grid); for (int i = 0; i < 9; i++) { var t = new TextLabel() { Size = new Size(100, 180), Text = $"con-{i}", BackgroundColor = new Color(0.5f, (100 + 10 * i) / 255.0f, 0.5f, 1), Margin = new Extents(2, 2, 2, 2), Name = $"sub-tl-{i}", }; grid.Add(t); } t3 = new TextLabel() { WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = 200, Text = "TextLable-3", BackgroundColor = Color.Magenta, Margin = new Extents(10, 10, 10, 10), Name = "tl-3", }; scroll.Add(t3); t4 = new TextLabel() { WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = 200, Text = "TextLable-4", BackgroundColor = new Color(global::System.Drawing.Color.FromName("HotPink")), Margin = new Extents(10, 10, 10, 10), Name = "tl-4", }; scroll.Add(t4); }
public View CreatePagination() { View view = new View() { Size = new Size(360, 360), PositionUsesPivotPoint = true, ParentOrigin = ParentOrigin.Center, PivotPoint = PivotPoint.Center, }; pagination = new CircularPagination() { Size = new Size(360, 360), Position = new Position(0, 100), // Set Pagination properties, such as Indicator size, count, and images. IndicatorSize = new Size(10, 10), IndicatorImageURL = new Selector <string>() { Normal = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "normal_dot.png", Selected = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "focus_dot.png", }, //IndicatorSpacing = 8, IndicatorCount = PAGE_COUNT, SelectedIndex = 0, // Positioning it to the top center ParentOrigin = ParentOrigin.TopCenter, PivotPoint = PivotPoint.TopCenter, PositionUsesPivotPoint = true }; // To move on to the next page using Swipe gesture, add ScrollableBase and its View container. scrollable = new ScrollableBase() { Size = new Size(120, 120), Position = new Position(0, 10), ScrollingDirection = ScrollableBase.Direction.Horizontal, SnapToPage = true, ParentOrigin = ParentOrigin.Center, PivotPoint = PivotPoint.Center, PositionUsesPivotPoint = true }; View container = new View() { WidthSpecification = LayoutParamPolicies.WrapContent, HeightSpecification = 120, Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Horizontal, SetPositionByLayout = false, }, //BackgroundColor = Color.Black, }; scrollable.Add(container); Tizen.Log.Error("MYLOG", "add scroll"); for (int i = 0; i < PAGE_COUNT; i++) { View page = new View() { Size = new Size(120, 120), CornerRadius = 60.0f, BackgroundColor = (i % 2 == 0)?Color.Yellow:Color.Red, }; container.Add(page); } view.Add(scrollable); view.Add(pagination); // Screen Touch Event scrollable.ScrollAnimationEnded += Scrollable_ScrollAnimationEnded; return(view); }
public void Activate() { Random rnd = new Random(); Window window = NUIApplication.GetDefaultWindow(); root = new View() { BackgroundColor = Color.White, WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = LayoutParamPolicies.MatchParent, Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Vertical, HorizontalAlignment = HorizontalAlignment.Center, CellPadding = new Size(10, 10), }, }; window.Add(root); FocusManager.Instance.EnableDefaultAlgorithm(true); var top = new Button() { Focusable = true, FocusableInTouch = true, Text = "Top" }; root.Add(top); var verticalScrollView = new ScrollableBase() { ScrollingDirection = ScrollableBase.Direction.Vertical, WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = LayoutParamPolicies.MatchParent, BackgroundColor = Color.Gray, Layout = new LinearLayout { LinearOrientation = LinearLayout.Orientation.Vertical, HorizontalAlignment = HorizontalAlignment.Center, CellPadding = new Size2D(10, 10), } }; root.Add(verticalScrollView); for (int i = 0; i < SCROLLMAX; i++) { var colorItem = new View() { WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = LayoutParamPolicies.WrapContent, BackgroundColor = new Color((float)rnd.Next(256) / 256f, (float)rnd.Next(256) / 256f, (float)rnd.Next(256) / 256f, 1), Focusable = true, FocusableInTouch = true, Layout = new LinearLayout { LinearOrientation = LinearLayout.Orientation.Horizontal, VerticalAlignment = VerticalAlignment.Center, CellPadding = new Size2D(10, 10), } }; var label = new TextLabel() { Text = $"[{i}]", PointSize = 20, }; colorItem.Add(label); verticalScrollView.Add(colorItem); } var middle = new Button() { Focusable = true, FocusableInTouch = true, Text = "Middle" }; root.Add(middle); var horizontalLayout = new View() { BackgroundColor = Color.White, WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = LayoutParamPolicies.MatchParent, Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Horizontal, VerticalAlignment = VerticalAlignment.Center, CellPadding = new Size(10, 10), }, }; root.Add(horizontalLayout); var leftIcon = new RadioButton() { WidthSpecification = 50, HeightSpecification = 50, Focusable = true, FocusableInTouch = true, }; horizontalLayout.Add(leftIcon); var horizontalScrollView = new ScrollableBase() { ScrollingDirection = ScrollableBase.Direction.Horizontal, WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = LayoutParamPolicies.MatchParent, BackgroundColor = Color.Gray, Layout = new LinearLayout { LinearOrientation = LinearLayout.Orientation.Horizontal, VerticalAlignment = VerticalAlignment.Center, CellPadding = new Size2D(10, 10), } }; horizontalLayout.Add(horizontalScrollView); for (int i = 0; i < SCROLLMAX; i++) { var colorItem = new View() { WidthSpecification = LayoutParamPolicies.WrapContent, HeightSpecification = LayoutParamPolicies.MatchParent, BackgroundColor = new Color((float)rnd.Next(256) / 256f, (float)rnd.Next(256) / 256f, (float)rnd.Next(256) / 256f, 1), Focusable = true, FocusableInTouch = true, Layout = new LinearLayout { LinearOrientation = LinearLayout.Orientation.Vertical, HorizontalAlignment = HorizontalAlignment.Center, CellPadding = new Size2D(10, 10), } }; var label = new TextLabel() { Text = $"[{i}]", PointSize = 20, }; colorItem.Add(label); horizontalScrollView.Add(colorItem); } var rightIcon = new RadioButton() { WidthSpecification = 50, HeightSpecification = 50, Focusable = true, FocusableInTouch = true, }; horizontalLayout.Add(rightIcon); var bottom = new Button() { Focusable = true, FocusableInTouch = true, Text = "Bottom" }; root.Add(bottom); }
View CreateListPage(IEnumerable <TestCaseBase> tests) { var layout = new View { HeightResizePolicy = ResizePolicyType.FillToParent, WidthResizePolicy = ResizePolicyType.FillToParent, Layout = new LinearLayout { LinearOrientation = LinearLayout.Orientation.Vertical, } }; EventHandler <ClickedEventArgs> clicked = (object sender, ClickedEventArgs args) => { var testCase = ((sender as View).BindingContext as TestCaseBase); RunTC(testCase); }; var collectionview = new ScrollableBase { Layout = new LinearLayout { LinearOrientation = LinearLayout.Orientation.Vertical } }; foreach (var item in tests) { var itemView = new DefaultLinearItem(); itemView.Focusable = true; itemView.BindingContext = item; itemView.Clicked += clicked; var label = new TextLabel { VerticalAlignment = VerticalAlignment.Center, WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = LayoutParamPolicies.MatchParent, }; label.PixelSize = 30; label.SetBinding(TextLabel.TextProperty, new Binding("TestName")); itemView.Add(label); collectionview.Add(itemView); } // NUI bug - on target NUI CollectionView was crashed /* * var collectionview = new CollectionView * { * SelectionMode = ItemSelectionMode.None, * WidthResizePolicy = ResizePolicyType.FillToParent, * HeightResizePolicy = ResizePolicyType.FillToParent, * ItemsLayouter = new LinearLayouter(), * ScrollingDirection = ScrollableBase.Direction.Vertical, * ItemsSource = tests, * ItemTemplate = new DataTemplate(() => * { * //var itemView = new RecyclerViewItem * //{ * // Layout = new LinearLayout * // { * // LinearOrientation = LinearLayout.Orientation.Vertical, * // LinearAlignment = LinearLayout.Alignment.Center * // }, * // WidthResizePolicy = ResizePolicyType.FillToParent, * // SizeHeight = 100, * //}; * //var border = new BorderVisual * //{ * // Opacity = 0.8f, * // CornerRadius = 0, * // BorderSize = 1, * // Color = Color.Black, * // AntiAliasing = true, * //}; * //itemView.AddVisual("border", border); * * var itemView = new DefaultLinearItem(); * * itemView.Clicked += clicked; * * var label = new TextLabel * { * VerticalAlignment = VerticalAlignment.Center, * WidthSpecification = LayoutParamPolicies.MatchParent, * HeightSpecification = LayoutParamPolicies.MatchParent, * }; * * label.PixelSize = 30; * label.SetBinding(TextLabel.TextProperty, new Binding("TestName")); * itemView.Add(label); * return itemView; * //var itemView = new DefaultLinearItem * //{ * // WidthResizePolicy = ResizePolicyType.FillToParent, * //}; * * //itemView.Clicked += clicked; * //itemView.Label.PixelSize = 30; * //itemView.Label.SetBinding(TextLabel.TextProperty, new Binding("TestName")); * //return itemView; * }) * }; */ layout.Add(collectionview); return(layout); }
public void Activate() { window = NUIApplication.GetDefaultWindow(); rootView = new ScrollableBase() { ScrollingDirection = ScrollableBase.Direction.Vertical, HideScrollbar = false, WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = LayoutParamPolicies.MatchParent, BackgroundColor = Color.White, }; window.Add(rootView); var mainView = new View() { Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Vertical, CellPadding = new Size2D(0, 20), }, WidthSpecification = LayoutParamPolicies.MatchParent, BackgroundColor = Color.White, }; rootView.Add(mainView); var absoluteViewTitle = new TextLabel() { Text = "AbsoluteLayout", WidthSpecification = LayoutParamPolicies.MatchParent, }; mainView.Add(absoluteViewTitle); var absoluteView = new View() { Layout = new AbsoluteLayout(), WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = 150, BackgroundColor = Color.White, }; mainView.Add(absoluteView); var absoluteTopText = new TextField() { WidthSpecification = LayoutParamPolicies.MatchParent, BackgroundColor = Color.Red, }; absoluteTopText.TextChanged += (object sender, TextField.TextChangedEventArgs args) => { global::System.Console.WriteLine($"AbsoluteLayout Top Text has been changed to \"{args.TextField.Text}\"."); }; absoluteView.Add(absoluteTopText); var absoluteCenterText = new TextField() { Text = "Center", BackgroundColor = Color.Blue, ParentOrigin = new Position(0.5f, 0.5f, 0.5f), PivotPoint = new Position(0.5f, 0.5f, 0.5f), PositionUsesPivotPoint = true, }; absoluteCenterText.TextChanged += (object sender, TextField.TextChangedEventArgs args) => { global::System.Console.WriteLine($"AbsoluteLayout Center Text has been changed to \"{args.TextField.Text}\"."); }; absoluteView.Add(absoluteCenterText); var absoluteBottomText = new TextField() { Text = "Bottom", BackgroundColor = Color.Green, ParentOrigin = new Position(0.5f, 1.0f, 0.5f), PivotPoint = new Position(0.5f, 1.0f, 0.5f), PositionUsesPivotPoint = true, }; absoluteBottomText.TextChanged += (object sender, TextField.TextChangedEventArgs args) => { global::System.Console.WriteLine($"AbsoluteLayout Bottom Text has been changed to \"{args.TextField.Text}\"."); }; absoluteView.Add(absoluteBottomText); var linearViewTitle = new TextLabel() { Text = "LinearLayout", WidthSpecification = LayoutParamPolicies.MatchParent, }; mainView.Add(linearViewTitle); var linearView = new View() { Layout = new LinearLayout() { CellPadding = new Size2D(10, 0), }, WidthSpecification = LayoutParamPolicies.MatchParent, BackgroundColor = Color.White, }; mainView.Add(linearView); var linearLeft = new View() { Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Vertical, CellPadding = new Size2D(0, 10), }, WidthSpecification = LayoutParamPolicies.MatchParent, BackgroundColor = Color.White, }; linearView.Add(linearLeft); var linearLeftText1 = new TextField() { WidthSpecification = LayoutParamPolicies.MatchParent, BackgroundColor = Color.Red, }; linearLeftText1.TextChanged += (object sender, TextField.TextChangedEventArgs args) => { global::System.Console.WriteLine($"LinearLayout Left default size Text has been changed to \"{args.TextField.Text}\"."); }; linearLeft.Add(linearLeftText1); var linearLeftText2 = new TextField() { PixelSize = 16, WidthSpecification = LayoutParamPolicies.MatchParent, BackgroundColor = Color.Red, }; linearLeftText2.TextChanged += (object sender, TextField.TextChangedEventArgs args) => { global::System.Console.WriteLine($"LinearLayout Left PixelSize 16 Text has been changed to \"{args.TextField.Text}\"."); }; linearLeft.Add(linearLeftText2); var linearLeftText3 = new TextField() { PixelSize = 64, WidthSpecification = LayoutParamPolicies.MatchParent, BackgroundColor = Color.Red, }; linearLeftText3.TextChanged += (object sender, TextField.TextChangedEventArgs args) => { global::System.Console.WriteLine($"LinearLayout Left PixelSize 64 Text has been changed to \"{args.TextField.Text}\"."); }; linearLeft.Add(linearLeftText3); var linearLeftText4 = new TextField() { BackgroundColor = Color.Red, }; linearLeftText4.TextChanged += (object sender, TextField.TextChangedEventArgs args) => { global::System.Console.WriteLine($"LinearLayout Left Text with WrapContent WidthSpecification has been changed to \"{args.TextField.Text}\"."); }; linearLeft.Add(linearLeftText4); var linearRight = new View() { Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Vertical, CellPadding = new Size2D(0, 10), }, WidthSpecification = LayoutParamPolicies.MatchParent, BackgroundColor = Color.White, }; linearView.Add(linearRight); var linearRightText1 = new TextField() { Text = "Default", WidthSpecification = LayoutParamPolicies.MatchParent, BackgroundColor = Color.Red, }; linearRightText1.TextChanged += (object sender, TextField.TextChangedEventArgs args) => { global::System.Console.WriteLine($"LinearLayout Right default size Text has been changed to \"{args.TextField.Text}\"."); }; linearRight.Add(linearRightText1); var linearRightText2 = new TextField() { Text = "16", PixelSize = 16, WidthSpecification = LayoutParamPolicies.MatchParent, BackgroundColor = Color.Red, }; linearRightText2.TextChanged += (object sender, TextField.TextChangedEventArgs args) => { global::System.Console.WriteLine($"LinearLayout Right PixelSize 16 Text has been changed to \"{args.TextField.Text}\"."); }; linearRight.Add(linearRightText2); var linearRightText3 = new TextField() { Text = "64", PixelSize = 64, WidthSpecification = LayoutParamPolicies.MatchParent, BackgroundColor = Color.Red, }; linearRightText3.TextChanged += (object sender, TextField.TextChangedEventArgs args) => { global::System.Console.WriteLine($"LinearLayout Right PixelSize 64 Text has been changed to \"{args.TextField.Text}\"."); }; linearRight.Add(linearRightText3); var linearRightText4 = new TextField() { Text = "WrapContent", BackgroundColor = Color.Red, }; linearRightText4.TextChanged += (object sender, TextField.TextChangedEventArgs args) => { global::System.Console.WriteLine($"LinearLayout Right Text with WrapContent WidthSpecification has been changed to \"{args.TextField.Text}\"."); }; linearRight.Add(linearRightText4); var gridViewTitle = new TextLabel() { Text = "GridLayout", WidthSpecification = LayoutParamPolicies.MatchParent, }; mainView.Add(gridViewTitle); var gridView = new View() { Layout = new GridLayout() { Rows = 5, Columns = 2, RowSpacing = 10, ColumnSpacing = 10, }, WidthSpecification = LayoutParamPolicies.MatchParent, BackgroundColor = Color.White, }; mainView.Add(gridView); var gridCol1Text1 = new TextField() { BackgroundColor = Color.Green, }; gridCol1Text1.TextChanged += (object sender, TextField.TextChangedEventArgs args) => { global::System.Console.WriteLine($"GridLayout Column 1 default size Text has been changed to \"{args.TextField.Text}\"."); }; GridLayout.SetRow(gridCol1Text1, 0); GridLayout.SetColumn(gridCol1Text1, 0); GridLayout.SetHorizontalStretch(gridCol1Text1, GridLayout.StretchFlags.ExpandAndFill); GridLayout.SetVerticalStretch(gridCol1Text1, GridLayout.StretchFlags.ExpandAndFill); gridView.Add(gridCol1Text1); var gridCol1Text2 = new TextField() { PixelSize = 16, BackgroundColor = Color.Green, }; gridCol1Text2.TextChanged += (object sender, TextField.TextChangedEventArgs args) => { global::System.Console.WriteLine($"GridLayout Column 1 PixelSize 16 Text has been changed to \"{args.TextField.Text}\"."); }; GridLayout.SetRow(gridCol1Text2, 1); GridLayout.SetColumn(gridCol1Text2, 0); GridLayout.SetHorizontalStretch(gridCol1Text2, GridLayout.StretchFlags.ExpandAndFill); GridLayout.SetVerticalStretch(gridCol1Text2, GridLayout.StretchFlags.ExpandAndFill); gridView.Add(gridCol1Text2); var gridCol1Text3 = new TextField() { PixelSize = 64, BackgroundColor = Color.Green, }; gridCol1Text3.TextChanged += (object sender, TextField.TextChangedEventArgs args) => { global::System.Console.WriteLine($"GridLayout Column 1 PixelSize 64 Text has been changed to \"{args.TextField.Text}\"."); }; GridLayout.SetRow(gridCol1Text3, 2); GridLayout.SetColumn(gridCol1Text3, 0); GridLayout.SetHorizontalStretch(gridCol1Text3, GridLayout.StretchFlags.ExpandAndFill); GridLayout.SetVerticalStretch(gridCol1Text3, GridLayout.StretchFlags.ExpandAndFill); gridView.Add(gridCol1Text3); var gridCol1Text4 = new TextField() { BackgroundColor = Color.Green, }; gridCol1Text4.TextChanged += (object sender, TextField.TextChangedEventArgs args) => { global::System.Console.WriteLine($"GridLayout Column 1 Text with Fill has been changed to \"{args.TextField.Text}\"."); }; GridLayout.SetRow(gridCol1Text4, 3); GridLayout.SetColumn(gridCol1Text4, 0); GridLayout.SetHorizontalStretch(gridCol1Text4, GridLayout.StretchFlags.Fill); GridLayout.SetVerticalStretch(gridCol1Text4, GridLayout.StretchFlags.Fill); gridView.Add(gridCol1Text4); var gridCol1Text5 = new TextField() { BackgroundColor = Color.Green, }; gridCol1Text5.TextChanged += (object sender, TextField.TextChangedEventArgs args) => { global::System.Console.WriteLine($"GridLayout Column 1 Text with Expand has been changed to \"{args.TextField.Text}\"."); }; GridLayout.SetRow(gridCol1Text5, 4); GridLayout.SetColumn(gridCol1Text5, 0); GridLayout.SetHorizontalStretch(gridCol1Text5, GridLayout.StretchFlags.Expand); GridLayout.SetVerticalStretch(gridCol1Text5, GridLayout.StretchFlags.Expand); gridView.Add(gridCol1Text5); var gridCol2Text1 = new TextField() { Text = "Default", BackgroundColor = Color.Green, }; gridCol2Text1.TextChanged += (object sender, TextField.TextChangedEventArgs args) => { global::System.Console.WriteLine($"GridLayout Column 2 default size Text has been changed to \"{args.TextField.Text}\"."); }; GridLayout.SetRow(gridCol2Text1, 0); GridLayout.SetColumn(gridCol2Text1, 1); GridLayout.SetHorizontalStretch(gridCol2Text1, GridLayout.StretchFlags.ExpandAndFill); GridLayout.SetVerticalStretch(gridCol2Text1, GridLayout.StretchFlags.ExpandAndFill); gridView.Add(gridCol2Text1); var gridCol2Text2 = new TextField() { Text = "16", PixelSize = 16, BackgroundColor = Color.Green, }; gridCol2Text2.TextChanged += (object sender, TextField.TextChangedEventArgs args) => { global::System.Console.WriteLine($"GridLayout Column 2 PixelSize 16 Text has been changed to \"{args.TextField.Text}\"."); }; GridLayout.SetRow(gridCol2Text2, 1); GridLayout.SetColumn(gridCol2Text2, 1); GridLayout.SetHorizontalStretch(gridCol2Text2, GridLayout.StretchFlags.ExpandAndFill); GridLayout.SetVerticalStretch(gridCol2Text2, GridLayout.StretchFlags.ExpandAndFill); gridView.Add(gridCol2Text2); var gridCol2Text3 = new TextField() { Text = "64", PixelSize = 64, BackgroundColor = Color.Green, }; gridCol2Text3.TextChanged += (object sender, TextField.TextChangedEventArgs args) => { global::System.Console.WriteLine($"GridLayout Column 2 PixelSize 64 Text has been changed to \"{args.TextField.Text}\"."); }; GridLayout.SetRow(gridCol2Text3, 2); GridLayout.SetColumn(gridCol2Text3, 1); GridLayout.SetHorizontalStretch(gridCol2Text3, GridLayout.StretchFlags.ExpandAndFill); GridLayout.SetVerticalStretch(gridCol2Text3, GridLayout.StretchFlags.ExpandAndFill); gridView.Add(gridCol2Text3); var gridCol2Text4 = new TextField() { Text = "Fill", BackgroundColor = Color.Green, }; gridCol2Text4.TextChanged += (object sender, TextField.TextChangedEventArgs args) => { global::System.Console.WriteLine($"GridLayout Column 2 Text with Fill has been changed to \"{args.TextField.Text}\"."); }; GridLayout.SetRow(gridCol2Text4, 3); GridLayout.SetColumn(gridCol2Text4, 1); GridLayout.SetHorizontalStretch(gridCol2Text4, GridLayout.StretchFlags.Fill); GridLayout.SetVerticalStretch(gridCol2Text4, GridLayout.StretchFlags.ExpandAndFill); gridView.Add(gridCol2Text4); var gridCol2Text5 = new TextField() { Text = "Expand", BackgroundColor = Color.Green, }; gridCol2Text5.TextChanged += (object sender, TextField.TextChangedEventArgs args) => { global::System.Console.WriteLine($"GridLayout Column 2 Text with Expand has been changed to \"{args.TextField.Text}\"."); }; GridLayout.SetRow(gridCol2Text5, 4); GridLayout.SetColumn(gridCol2Text5, 1); GridLayout.SetHorizontalStretch(gridCol2Text5, GridLayout.StretchFlags.Expand); GridLayout.SetVerticalStretch(gridCol2Text5, GridLayout.StretchFlags.ExpandAndFill); gridView.Add(gridCol2Text5); var relativeViewTitle = new TextLabel() { Text = "RelativeLayout", WidthSpecification = LayoutParamPolicies.MatchParent, }; mainView.Add(relativeViewTitle); var relativeView = new View() { Layout = new RelativeLayout(), WidthSpecification = LayoutParamPolicies.MatchParent, BackgroundColor = Color.White, }; mainView.Add(relativeView); var relTopText = new TextField() { Text = "Top with Fill", HorizontalAlignment = HorizontalAlignment.Center, BackgroundColor = Color.Red, }; relTopText.TextChanged += (object sender, TextField.TextChangedEventArgs args) => { global::System.Console.WriteLine($"RelativeLayout Top Text has been changed to \"{args.TextField.Text}\"."); }; RelativeLayout.SetTopRelativeOffset(relTopText, 0.0f); RelativeLayout.SetBottomRelativeOffset(relTopText, 0.0f); RelativeLayout.SetLeftRelativeOffset(relTopText, 0.0f); RelativeLayout.SetRightRelativeOffset(relTopText, 1.0f); RelativeLayout.SetFillHorizontal(relTopText, true); relativeView.Add(relTopText); var relLeftText = new TextField() { Text = "Left", BackgroundColor = Color.Green, }; relLeftText.TextChanged += (object sender, TextField.TextChangedEventArgs args) => { global::System.Console.WriteLine($"RelativeLayout Left Text has been changed to \"{args.TextField.Text}\"."); }; RelativeLayout.SetTopTarget(relLeftText, relTopText); RelativeLayout.SetTopRelativeOffset(relLeftText, 1.0f); RelativeLayout.SetBottomTarget(relLeftText, relTopText); RelativeLayout.SetBottomRelativeOffset(relLeftText, 1.0f); RelativeLayout.SetLeftRelativeOffset(relLeftText, 0.0f); RelativeLayout.SetRightRelativeOffset(relLeftText, 0.0f); relativeView.Add(relLeftText); var relRightText = new TextField() { Text = "Right", BackgroundColor = Color.Blue, }; relRightText.TextChanged += (object sender, TextField.TextChangedEventArgs args) => { global::System.Console.WriteLine($"RelativeLayout Right Text has been changed to \"{args.TextField.Text}\"."); }; RelativeLayout.SetTopTarget(relRightText, relTopText); RelativeLayout.SetTopRelativeOffset(relRightText, 1.0f); RelativeLayout.SetBottomTarget(relRightText, relTopText); RelativeLayout.SetBottomRelativeOffset(relRightText, 1.0f); RelativeLayout.SetLeftRelativeOffset(relRightText, 1.0f); RelativeLayout.SetRightRelativeOffset(relRightText, 1.0f); RelativeLayout.SetHorizontalAlignment(relRightText, RelativeLayout.Alignment.End); relativeView.Add(relRightText); var relBottomText = new TextField() { Text = "Bottom", BackgroundColor = Color.Yellow, }; relBottomText.TextChanged += (object sender, TextField.TextChangedEventArgs args) => { global::System.Console.WriteLine($"RelativeLayout Bottom Text has been changed to \"{args.TextField.Text}\"."); }; RelativeLayout.SetTopRelativeOffset(relBottomText, 1.0f); RelativeLayout.SetBottomRelativeOffset(relBottomText, 1.0f); RelativeLayout.SetLeftTarget(relBottomText, relLeftText); RelativeLayout.SetLeftRelativeOffset(relBottomText, 1.0f); RelativeLayout.SetRightTarget(relBottomText, relRightText); RelativeLayout.SetRightRelativeOffset(relBottomText, 0.0f); RelativeLayout.SetHorizontalAlignment(relBottomText, RelativeLayout.Alignment.Center); RelativeLayout.SetVerticalAlignment(relBottomText, RelativeLayout.Alignment.End); relativeView.Add(relBottomText); var relCenterText = new TextField() { BackgroundColor = Color.Purple, }; relCenterText.TextChanged += (object sender, TextField.TextChangedEventArgs args) => { global::System.Console.WriteLine($"RelativeLayout Center Text has been changed to \"{args.TextField.Text}\"."); }; RelativeLayout.SetTopTarget(relCenterText, relTopText); RelativeLayout.SetTopRelativeOffset(relCenterText, 1.0f); RelativeLayout.SetBottomTarget(relCenterText, relBottomText); RelativeLayout.SetBottomRelativeOffset(relCenterText, 0.0f); RelativeLayout.SetLeftTarget(relCenterText, relLeftText); RelativeLayout.SetLeftRelativeOffset(relCenterText, 1.0f); RelativeLayout.SetRightTarget(relCenterText, relRightText); RelativeLayout.SetRightRelativeOffset(relCenterText, 0.0f); RelativeLayout.SetFillHorizontal(relCenterText, true); relativeView.Add(relCenterText); var flexRowViewTitle = new TextLabel() { Text = "FlexLayout with Row Direction", WidthSpecification = LayoutParamPolicies.MatchParent, }; mainView.Add(flexRowViewTitle); var flexRowView = new View() { Layout = new FlexLayout() { Direction = FlexLayout.FlexDirection.Row, WrapType = FlexLayout.FlexWrapType.Wrap, Alignment = FlexLayout.AlignmentType.Center, ItemsAlignment = FlexLayout.AlignmentType.Center, Justification = FlexLayout.FlexJustification.SpaceEvenly, }, WidthSpecification = LayoutParamPolicies.MatchParent, BackgroundColor = Color.White, }; mainView.Add(flexRowView); var flexRowText1 = new TextField() { Text = "TextField", BackgroundColor = Color.Red, }; flexRowText1.TextChanged += (object sender, TextField.TextChangedEventArgs args) => { global::System.Console.WriteLine($"FlexLayout with Row First Text has been changed to \"{args.TextField.Text}\"."); }; flexRowView.Add(flexRowText1); var flexRowText2 = new TextField() { Text = "TextField", BackgroundColor = Color.Green, }; flexRowText2.TextChanged += (object sender, TextField.TextChangedEventArgs args) => { global::System.Console.WriteLine($"FlexLayout with Row Second Text has been changed to \"{args.TextField.Text}\"."); }; flexRowView.Add(flexRowText2); var flexRowText3 = new TextField() { Text = "TextField", BackgroundColor = Color.Blue, }; flexRowText3.TextChanged += (object sender, TextField.TextChangedEventArgs args) => { global::System.Console.WriteLine($"FlexLayout with Row Third Text has been changed to \"{args.TextField.Text}\"."); }; flexRowView.Add(flexRowText3); var flexRowText4 = new TextField() { Text = "TextField", BackgroundColor = Color.Yellow, }; flexRowText4.TextChanged += (object sender, TextField.TextChangedEventArgs args) => { global::System.Console.WriteLine($"FlexLayout with Row Fourth Text has been changed to \"{args.TextField.Text}\"."); }; flexRowView.Add(flexRowText4); var flexColViewTitle = new TextField() { Text = "FlexLayout with Column Direction", WidthSpecification = LayoutParamPolicies.MatchParent, }; mainView.Add(flexColViewTitle); var flexColView = new View() { Layout = new FlexLayout() { Direction = FlexLayout.FlexDirection.Column, WrapType = FlexLayout.FlexWrapType.Wrap, Alignment = FlexLayout.AlignmentType.Center, ItemsAlignment = FlexLayout.AlignmentType.Center, Justification = FlexLayout.FlexJustification.SpaceEvenly, }, WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = 150, BackgroundColor = Color.White, }; mainView.Add(flexColView); var flexColText1 = new TextField() { Text = "TextField", BackgroundColor = Color.Red, }; flexColText1.TextChanged += (object sender, TextField.TextChangedEventArgs args) => { global::System.Console.WriteLine($"FlexLayout with Column First Text has been changed to \"{args.TextField.Text}\"."); }; flexColView.Add(flexColText1); var flexColText2 = new TextField() { Text = "TextField", BackgroundColor = Color.Green, }; flexColText2.TextChanged += (object sender, TextField.TextChangedEventArgs args) => { global::System.Console.WriteLine($"FlexLayout with Column Second Text has been changed to \"{args.TextField.Text}\"."); }; flexColView.Add(flexColText2); var flexColText3 = new TextField() { Text = "TextField", BackgroundColor = Color.Blue, }; flexColText3.TextChanged += (object sender, TextField.TextChangedEventArgs args) => { global::System.Console.WriteLine($"FlexLayout with Column Third Text has been changed to \"{args.TextField.Text}\"."); }; flexColView.Add(flexColText3); var flexColText4 = new TextField() { Text = "TextField", BackgroundColor = Color.Yellow, }; flexColText4.TextChanged += (object sender, TextField.TextChangedEventArgs args) => { global::System.Console.WriteLine($"FlexLayout with Column Fourth Text has been changed to \"{args.TextField.Text}\"."); }; flexColView.Add(flexColText4); }
public ItemDetailPage(ItemData data) : base(data) { ScrollableBase infoScroll = new ScrollableBase() { ScrollingDirection = ScrollableBase.Direction.Vertical, Size = new Size(Size), Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Vertical, }, }; Add(infoScroll); View information = new View() { WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = LayoutParamPolicies.WrapContent, Margin = new Extents(0, 0, (ushort)NUIApplication.GetDefaultWindow().Size.Width, 0), Padding = new Extents(PADDING, PADDING, 0, 0), Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Vertical, } }; infoScroll.Add(information); TextLabel itemName = new TextLabel() { Text = data.Name, WidthSpecification = LayoutParamPolicies.MatchParent, PixelSize = 24.0f, Margin = new Extents(0, 0, PADDING, 0), MultiLine = true, }; information.Add(itemName); TextLabel origin = new TextLabel() { Text = "원산지 : " + data.Origin, WidthSpecification = LayoutParamPolicies.MatchParent, PixelSize = 16.0f, Margin = new Extents(0, 0, PADDING, 0), TextColor = new Color("#777777"), }; information.Add(origin); TextLabel price = new TextLabel() { Text = data.Price, WidthSpecification = LayoutParamPolicies.MatchParent, PixelSize = 24.0f, Margin = new Extents(0, 0, PADDING, 0), }; information.Add(price); View line = new View() { WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = 1, Margin = new Extents(0, 0, PADDING, PADDING), BackgroundColor = new Color("#f0f0f0") }; information.Add(line); TextLabel detailHeader = new TextLabel() { Text = "상품에 대한 자세한 정보", WidthSpecification = LayoutParamPolicies.MatchParent, PixelSize = 24.0f, Margin = new Extents(0, 0, 0, PADDING), }; information.Add(detailHeader); View fakeDetails = new View() { WidthSpecification = 480, HeightSpecification = 4000, BackgroundColor = Color.White, }; information.Add(fakeDetails); View header = new View() { Size = new Size(NUIApplication.GetDefaultWindow().Size.Width, 80), BackgroundColor = new Color(1.0f, 1.0f, 1.0f, 0.9f), Layout = new AbsoluteLayout() { SetPositionByLayout = false, } }; Add(header); ImageView itemImage = new ImageView() { ResourceUrl = "./res/images/" + data.ImageUrl, Size = new Size(NUIApplication.GetDefaultWindow().Size.Width, NUIApplication.GetDefaultWindow().Size.Width), DesiredWidth = NUIApplication.GetDefaultWindow().Size.Width, DesiredHeight = NUIApplication.GetDefaultWindow().Size.Width, PositionUsesPivotPoint = true, PivotPoint = Tizen.NUI.PivotPoint.TopCenter, ParentOrigin = Tizen.NUI.ParentOrigin.TopCenter, Layout = new AbsoluteLayout() { SetPositionByLayout = false, } }; header.Add(itemImage); ImageView backButton = new ImageView() { Size = new Size(BACK_BUTTON_IMAGE_SIZE, BACK_BUTTON_IMAGE_SIZE), Color = Color.Black, Position = new Position(PADDING, 0), PositionUsesPivotPoint = true, PivotPoint = Tizen.NUI.PivotPoint.CenterLeft, ParentOrigin = Tizen.NUI.ParentOrigin.CenterLeft, ResourceUrl = "./res/images/back.png", }; header.Add(backButton); backButton.TouchEvent += (object source, TouchEventArgs args) => { if (args.Touch.GetState(0) == PointStateType.Finished || args.Touch.GetState(0) == PointStateType.Up) { PageController.Instance.GoBack(); return(true); } else { return(false); } }; TextLabel headerItemName = new TextLabel() { Text = data.Name, Size = new Size(NUIApplication.GetDefaultWindow().Size.Width - (PADDING * 2 + backButton.Size.Width) - (PADDING * 2 + ITEM_IMAGE_SMALL_SIZE), header.Size.Height), PixelSize = 18.0f, VerticalAlignment = VerticalAlignment.Center, Position = new Position(PADDING * 2 + backButton.Size.Width, 0), Opacity = 0.0f, }; header.Add(headerItemName); iconSlideAnimation = new Animation(200); iconSlideAnimation.DefaultAlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseOut); infoScroll.Scrolling += (object source, ScrollEventArgs args) => { float scrollPosition = Math.Abs(args.Position.Y); if (scrollPosition <= NUIApplication.GetDefaultWindow().Size.Width - header.Size.Height) { float process = scrollPosition / (NUIApplication.GetDefaultWindow().Size.Width - header.Size.Height); float targetRadius = ITEM_IMAGE_SMALL_SIZE / 2.0f * process; targetRadius = targetRadius < 1f ? 1f : targetRadius; float targetSize = -(NUIApplication.GetDefaultWindow().Size.Width - ITEM_IMAGE_SMALL_SIZE) * process + NUIApplication.GetDefaultWindow().Size.Width; float targetPosition = PADDING * process; itemImage.CornerRadius = targetRadius; itemImage.Size = new Size(targetSize, targetSize); itemImage.PositionY = targetPosition; headerItemName.Opacity = 0.0f; headerItemName.EnableAutoScroll = false; if (itemImage.CurrentPosition.X == (NUIApplication.GetDefaultWindow().Size.Width / 2.0f - (PADDING + ITEM_IMAGE_SMALL_SIZE / 2.0f))) { header.BackgroundColor = new Color(1.0f, 1.0f, 1.0f, 0.9f); iconSlideAnimation.Reset(); iconSlideAnimation.AnimateTo(itemImage, "positionX", 0.0f); iconSlideAnimation.Play(); } } else if (scrollPosition <= NUIApplication.GetDefaultWindow().Size.Width + header.Size.Height) { float process = (scrollPosition - NUIApplication.GetDefaultWindow().Size.Width + header.Size.Height) / (header.Size.Height * 2.0f); float targetPosition = (NUIApplication.GetDefaultWindow().Size.Width / 2.0f - (PADDING + ITEM_IMAGE_SMALL_SIZE / 2.0f)) * process; float targetButtonColor = -process + 1.0f; float targetHeaderBackgroundColor = process > 0.8f ? 0.8f : process; itemImage.CornerRadius = ITEM_IMAGE_SMALL_SIZE / 2.0f; itemImage.Size = new Size(ITEM_IMAGE_SMALL_SIZE, ITEM_IMAGE_SMALL_SIZE); itemImage.PositionY = PADDING; headerItemName.Opacity = process; headerItemName.EnableAutoScroll = true; if (itemImage.CurrentPosition.X == 0.0f) { header.BackgroundColor = new Color("#ffd040"); iconSlideAnimation.Reset(); iconSlideAnimation.AnimateTo(itemImage, "positionX", (NUIApplication.GetDefaultWindow().Size.Width / 2.0f - (PADDING + ITEM_IMAGE_SMALL_SIZE / 2.0f))); iconSlideAnimation.Play(); } } else { itemImage.CornerRadius = ITEM_IMAGE_SMALL_SIZE / 2.0f; itemImage.Size = new Size(ITEM_IMAGE_SMALL_SIZE, ITEM_IMAGE_SMALL_SIZE); headerItemName.Opacity = 1.0f; } }; BackKeyPressed += (object source, EventArgs args) => { PageController.Instance.GoBack(); }; }
public void Activate() { window = NUIApplication.GetDefaultWindow(); rootView = new ScrollableBase() { ScrollingDirection = ScrollableBase.Direction.Vertical, HideScrollbar = false, WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = LayoutParamPolicies.MatchParent, BackgroundColor = Color.White, }; window.Add(rootView); var mainView = new View() { Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Vertical, CellPadding = new Size2D(0, 20), }, WidthSpecification = LayoutParamPolicies.MatchParent, BackgroundColor = Color.Black, }; rootView.Add(mainView); var flexRowViewTitle = new TextLabel() { Text = "Row with MatchParent", WidthSpecification = LayoutParamPolicies.MatchParent, BackgroundColor = Color.White, }; mainView.Add(flexRowViewTitle); var flexRowView = new View() { Layout = new FlexLayout() { Direction = FlexLayout.FlexDirection.Row, }, WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = 400, Margin = new Extents(20, 20, 20, 20), Padding = new Extents(20, 20, 20, 20), BackgroundColor = Color.White, }; mainView.Add(flexRowView); var rowChild = new View() { Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Horizontal, }, WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = LayoutParamPolicies.MatchParent, BackgroundColor = Color.Black, }; flexRowView.Add(rowChild); var rowGrandChild = new View() { WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = LayoutParamPolicies.MatchParent, BackgroundColor = Color.Red, }; rowChild.Add(rowGrandChild); var rowGrandChild2 = new View() { WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = LayoutParamPolicies.MatchParent, BackgroundColor = Color.Green, }; rowChild.Add(rowGrandChild2); var rowChild2 = new View() { Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Horizontal, }, WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = LayoutParamPolicies.MatchParent, BackgroundColor = Color.Black, }; flexRowView.Add(rowChild2); var rowGrandChild3 = new View() { WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = LayoutParamPolicies.MatchParent, BackgroundColor = Color.Blue, }; rowChild2.Add(rowGrandChild3); var rowGrandChild4 = new View() { WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = LayoutParamPolicies.MatchParent, BackgroundColor = Color.Yellow, }; rowChild2.Add(rowGrandChild4); var flexColViewTitle = new TextLabel() { Text = "Column with MatchParent", WidthSpecification = LayoutParamPolicies.MatchParent, BackgroundColor = Color.White, }; mainView.Add(flexColViewTitle); var flexColView = new View() { Layout = new FlexLayout() { Direction = FlexLayout.FlexDirection.Column, }, WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = 400, Margin = new Extents(20, 20, 20, 20), Padding = new Extents(20, 20, 20, 20), BackgroundColor = Color.White, }; mainView.Add(flexColView); var colChild = new View() { Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Vertical, }, WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = LayoutParamPolicies.MatchParent, BackgroundColor = Color.Black, }; flexColView.Add(colChild); var colGrandChild = new View() { WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = LayoutParamPolicies.MatchParent, BackgroundColor = Color.Red, }; colChild.Add(colGrandChild); var colGrandChild2 = new View() { WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = LayoutParamPolicies.MatchParent, BackgroundColor = Color.Green, }; colChild.Add(colGrandChild2); var colChild2 = new View() { Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Vertical, }, WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = LayoutParamPolicies.MatchParent, BackgroundColor = Color.Black, }; flexColView.Add(colChild2); var colGrandChild3 = new View() { WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = LayoutParamPolicies.MatchParent, BackgroundColor = Color.Blue, }; colChild2.Add(colGrandChild3); var colGrandChild4 = new View() { WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = LayoutParamPolicies.MatchParent, BackgroundColor = Color.Yellow, }; colChild2.Add(colGrandChild4); }
public MainPage() : base() { ScrollableBase infoScroll = new ScrollableBase() { ScrollingDirection = ScrollableBase.Direction.Vertical, Size = new Size(Size), Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Vertical, }, }; Add(infoScroll); infoScroll.ContentContainer.Padding = new Extents(0, 0, 80, 0); List <object> dummyData = ItemData.CreateDummyItemData(50); Random r = new Random(); foreach (ItemData data in dummyData) { View item = new View() { Size = new Size(Size.Width, 260), Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Vertical, }, Padding = new Extents(15, 15, 0, 0), Margin = new Extents(0, 0, 15, 0), }; infoScroll.Add(item); View mainInformation = new View() { WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = 200, Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Horizontal, } }; item.Add(mainInformation); ImageView itemImage = new ImageView() { Size = new Size(200, 200), ResourceUrl = "./res/images/" + data.ImageUrl, DesiredWidth = 200, DesiredHeight = 200, BackgroundColor = new Color("#f0f0f0"), }; mainInformation.Add(itemImage); View detailInformation = new View() { WidthSpecification = 250, HeightSpecification = 200, Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Vertical, } }; mainInformation.Add(detailInformation); View details = new View() { WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = 160, Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Vertical, } }; detailInformation.Add(details); TextLabel itemName = new TextLabel() { Text = data.Name, WidthSpecification = LayoutParamPolicies.MatchParent, MultiLine = true, PixelSize = 16, Margin = new Extents(15, 15, 15, 15) }; details.Add(itemName); TextLabel itemPrice = new TextLabel() { Text = data.Price, WidthSpecification = LayoutParamPolicies.MatchParent, PixelSize = 24, Margin = new Extents(15, 15, 0, 0) }; details.Add(itemPrice); detailInformation.Add(new View() { WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = 1, BackgroundColor = new Color("#f0f0f0"), }); View icons = new View() { WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = 40, Layout = new FlexLayout() { Direction = FlexLayout.FlexDirection.Row, ItemsAlignment = FlexLayout.AlignmentType.Center, Justification = FlexLayout.FlexJustification.FlexEnd, }, }; detailInformation.Add(icons); ImageView heart = new ImageView() { Size = new Size(40, 32), ResourceUrl = "./res/images/" + (r.Next(0, 10) % 2 == 0 ? "heart.png" : "heart_selected.png"), FittingMode = FittingModeType.ScaleToFill, Margin = new Extents(0, 10, 0, 0) }; icons.Add(heart); ImageView cart = new ImageView() { Size = new Size(40, 40), ResourceUrl = "./res/images/cart.svg", FittingMode = FittingModeType.ScaleToFill }; icons.Add(cart); detailInformation.Add(new View() { WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = 1, BackgroundColor = new Color("#f0f0f0"), }); View additionalInformation = new View() { WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = 60, Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Horizontal, CellPadding = new Size2D(15, 15), LinearAlignment = LinearLayout.Alignment.CenterVertical, }, }; item.Add(additionalInformation); TextLabel point = new TextLabel() { Text = "☆ " + ((float)r.Next(30, 50) / 10.0f) + "점", PixelSize = 16.0f, }; additionalInformation.Add(point); TextLabel views = new TextLabel() { Text = (r.Next(300, 4000)) + "건", PixelSize = 16.0f, }; additionalInformation.Add(views); if (r.Next(0, 10) % 2 == 0) { TextLabel quick = new TextLabel() { Text = "퀵배송", PixelSize = 16.0f, TextColor = new Color("#6c7080"), }; additionalInformation.Add(quick); } if (r.Next(0, 10) % 2 == 0) { TextLabel discount = new TextLabel() { Text = r.Next(0, 20) + "% 카드할인", PixelSize = 16.0f, TextColor = new Color("#6c7080"), }; additionalInformation.Add(discount); } mainInformation.TouchEvent += (object source, TouchEventArgs args) => { bool result = false; if (args.Touch.GetState(0) == PointStateType.Finished) { PageController.Instance.Go("ItemDetail", data); result = true; } return(result); }; View header = new View() { Size = new Size(NUIApplication.GetDefaultWindow().Size.Width, 80), BackgroundColor = new Color("#ffd040"), Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Horizontal, LinearAlignment = LinearLayout.Alignment.CenterVertical, CellPadding = new Tizen.NUI.Vector2(15, 0), }, Padding = new Extents(15, 15, 0, 0), }; Add(header); TextLabel logo = new TextLabel() { Text = "Y-MART", PixelSize = 24, }; header.Add(logo); } BackKeyPressed += (object source, EventArgs args) => { NUIApplication.Current.Exit(); }; }
public ScrollableBaseDirectionExample(string dir) : base() { Log.Info(this.GetType().Name, $"{this.GetType().Name} is contructed\n"); WidthSpecification = LayoutParamPolicies.MatchParent; HeightSpecification = LayoutParamPolicies.MatchParent; bool isHorizontal = (dir == "Horizontal"); // Navigator bar title is added here. AppBar = new AppBar() { Title = "ScrollableBase " + dir + " Style", }; // Example root content view. // you can decorate, add children on this view. var scrollView = new ScrollableBase() { WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = LayoutParamPolicies.MatchParent, HideScrollbar = false, }; // FIXME: should work focus on ScrollableBase. // scrollView.EnableFocus(); if (isHorizontal) { scrollView.ScrollingDirection = ScrollableBase.Direction.Horizontal; scrollView.Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Horizontal, VerticalAlignment = VerticalAlignment.Center, CellPadding = new Size2D(10, 10), }; } else { scrollView.ScrollingDirection = ScrollableBase.Direction.Vertical; scrollView.Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Vertical, HorizontalAlignment = HorizontalAlignment.Center, CellPadding = new Size2D(10, 10), }; } Random rnd = new Random(); for (int i = 0; i < SCROLLMAX; i++) { var colorView = new View(); colorView.WidthSpecification = (isHorizontal? 200 : LayoutParamPolicies.MatchParent); colorView.HeightSpecification = (isHorizontal? LayoutParamPolicies.MatchParent : 200); colorView.BackgroundColor = new Color((float)rnd.Next(256) / 256f, (float)rnd.Next(256) / 256f, (float)rnd.Next(256) / 256f, 1); colorView.EnableFocus(); scrollView.Add(colorView); } Content = scrollView; }
protected override void OnCreate() { base.OnCreate(); Window window = NUIApplication.GetDefaultWindow(); window.BackgroundColor = Color.Black; // Create Pagination component pagination = new Pagination() { Size = new Size(118, 10), Position = new Position(0, 24), // Set Pagination properties, such as Indicator size, count, and images. IndicatorSize = new Size(10, 10), IndicatorSpacing = 8, IndicatorCount = PAGE_COUNT, SelectedIndex = 0, // Positioning it to the top center ParentOrigin = ParentOrigin.TopCenter, PivotPoint = PivotPoint.TopCenter, PositionUsesPivotPoint = true }; // To move on to the next page using Swipe gesture, add ScrollableBase and its View container. scrollable = new ScrollableBase() { Size = new Size(360, 360), ScrollingDirection = ScrollableBase.Direction.Horizontal, SnapToPage = true, ParentOrigin = ParentOrigin.Center, PivotPoint = PivotPoint.Center, PositionUsesPivotPoint = true }; View container = new View() { WidthSpecification = LayoutParamPolicies.WrapContent, HeightSpecification = 360, Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Horizontal, }, BackgroundColor = Color.Black, }; scrollable.Add(container); for (int i = 0; i < PAGE_COUNT; i++) { View page = new View() { Size = new Size(360, 360), CornerRadius = 150.0f, BackgroundColor = Color.Black, }; container.Add(page); } window.Add(scrollable); window.Add(pagination); // Bezel event window.WheelEvent += Pagination_WheelEvent; // Screen Touch Event scrollable.ScrollAnimationEnded += Scroll_AnimationEnded; }
/// Modify this method for adding other examples. public DefaultTitleItemExample() : base() { Log.Info(this.GetType().Name, $"{this.GetType().Name} is contructed\n"); WidthSpecification = LayoutParamPolicies.MatchParent; HeightSpecification = LayoutParamPolicies.MatchParent; // Navigator bar title is added here. AppBar = new AppBar() { Title = "DefaultTitleItemExample Style", }; // Example root content view. // you can decorate, add children on this view. var rootContent = new ScrollableBase() { WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = LayoutParamPolicies.MatchParent, ScrollingDirection = ScrollableBase.Direction.Vertical, HideScrollbar = false, Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Vertical, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, CellPadding = new Size2D(10, 20), }, }; var item = new DefaultTitleItem() { WidthSpecification = LayoutParamPolicies.MatchParent, Text = "Title Item", }; rootContent.Add(item); var path = Tizen.Applications.Application.Current.DirectoryInfo.Resource; var arrowStyle = new ButtonStyle() { IsSelectable = true, Size = new Size(40, 40), ItemHorizontalAlignment = HorizontalAlignment.Center, ItemVerticalAlignment = VerticalAlignment.Center, Icon = new ImageViewStyle() { ResourceUrl = new Selector <string>() { Normal = path + "/icon/icon_arrow_down.svg", Pressed = path + "/icon/icon_arrow_up.svg", Selected = path + "/icon/icon_arrow_up.svg", } } }; var itemWithArrow = new DefaultTitleItem() { WidthSpecification = LayoutParamPolicies.MatchParent, Text = "Title Item With Arrow", EnableControlStatePropagation = true, Icon = new Button(arrowStyle) { EnableControlStatePropagation = true, }, IsSelectable = true, }; rootContent.Add(itemWithArrow); Content = rootContent; }
private void initialize() { popupStyle = Style as PopupStyle; if (popupStyle == null) { throw new Exception("Popup style is null."); } BackgroundColor = Color.Black; Size = new Size(POPUP_WIDTH, POPUP_HEIGHT); PositionUsesPivotPoint = true; ParentOrigin = NUI.ParentOrigin.Center; PivotPoint = NUI.PivotPoint.Center; Layout = new AbsoluteLayout(); layer = new Layer() { Name = "PopupLayer", }; layer.Add(this); buttonList = new Dictionary <string, Button>(); buttonContainer = new View() { WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = LayoutParamPolicies.MatchParent, }; Add(buttonContainer); titleContentContainer = new View() { WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = LayoutParamPolicies.MatchParent, }; Add(titleContentContainer); //will be fixed later. //titleContentContainer.Layout = new LinearLayout() //{ // LinearOrientation = LinearLayout.Orientation.Vertical, // LinearAlignment = LinearLayout.Alignment.Top, //}; title = new TextLabel() { Name = "Title", Size = new Size(TITLE_WIDTH, TITLE_HEIGHT), PointSize = TEXT_POINT_SIZE, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, TextColor = Color.Cyan, //will be removed later. PositionUsesPivotPoint = true, ParentOrigin = Tizen.NUI.ParentOrigin.TopCenter, PivotPoint = Tizen.NUI.PivotPoint.TopCenter, Position = new Position(0, TITLE_POSITION_Y), }; titleContentContainer.Add(title); LinearLayout scrollLayout = new LinearLayout(); scrollLayout.LinearOrientation = LinearLayout.Orientation.Vertical; ContentContainer = new View() { Layout = scrollLayout, //will be removed later. PositionUsesPivotPoint = true, ParentOrigin = Tizen.NUI.ParentOrigin.TopCenter, PivotPoint = Tizen.NUI.PivotPoint.TopCenter, }; scroll = new ScrollableBase() { Name = "Scroll", PositionUsesPivotPoint = true, ScrollingDirection = ScrollableBase.Direction.Vertical, ScrollEnabled = true, WidthResizePolicy = ResizePolicyType.FillToParent, HeightResizePolicy = ResizePolicyType.FillToParent, //will be removed later. ParentOrigin = Tizen.NUI.ParentOrigin.TopCenter, PivotPoint = Tizen.NUI.PivotPoint.TopCenter, Position = new Position(0, CONTENT_POSITION_Y), }; titleContentContainer.Add(scroll); scroll.Add(ContentContainer); scrollList = new Dictionary <string, View>(); TouchEvent += Popup_TouchEvent; title.PropertyChanged += Title_PropertyChanged; }
public void Activate() { window = NUIApplication.GetDefaultWindow(); rootView = new ScrollableBase() { WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = LayoutParamPolicies.MatchParent, Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Vertical }, Padding = new Extents(20, 20, 0, 0) }; /* GraphicsTypeManager test. */ var managerTitleText = new TextLabel(); managerTitleText.Text = "GraphicsTypeManager"; managerTitleText.PointSize = 40; managerTitleText.TextColor = Color.Blue; managerTitleText.Padding = new Extents(0, 0, 0, 10); rootView.Add(managerTitleText); var baseDpiText = new TextLabel(); baseDpiText.Text = $"Baseline Dpi : {GraphicsTypeManager.Instance.BaselineDpi}"; rootView.Add(baseDpiText); var densityText = new TextLabel(); densityText.Text = $"Density : {GraphicsTypeManager.Instance.Density}"; rootView.Add(densityText); var dpiText = new TextLabel(); dpiText.Text = $"Dpi : {GraphicsTypeManager.Instance.Dpi}"; rootView.Add(dpiText); var scalingFactorText = new TextLabel(); scalingFactorText.Text = $"ScalingFactor : {GraphicsTypeManager.Instance.ScalingFactor}"; rootView.Add(scalingFactorText); var scaledDpiText = new TextLabel(); scaledDpiText.Text = $"Scaled Dpi : {GraphicsTypeManager.Instance.ScaledDpi}"; rootView.Add(scaledDpiText); /* GraphicsTypeConverter test. */ var converterTitleText = new TextLabel(); converterTitleText.Text = "GraphicsTypeConverter"; converterTitleText.PointSize = 40; converterTitleText.TextColor = Color.Red; converterTitleText.Padding = new Extents(0, 0, 10, 10); rootView.Add(converterTitleText); var dpConvertText = new TextLabel(); var dp = 100.0f; dpConvertText.Text = $"dp : {dp}, pixel : {DpTypeConverter.Instance.ConvertToPixel(dp)}"; rootView.Add(dpConvertText); var pxConvertText = new TextLabel(); var px = 100.0f; pxConvertText.Text = $"pixel : {px}, dp : {DpTypeConverter.Instance.ConvertFromPixel(px)}"; rootView.Add(pxConvertText); var spConvertText = new TextLabel(); var sp = 100.0f; spConvertText.Text = $"sp : {sp}, pixel : {SpTypeConverter.Instance.ConvertToPixel(sp)}"; rootView.Add(spConvertText); pxConvertText = new TextLabel(); px = 100.0f; pxConvertText.Text = $"pixel : {px}, sp : {PointTypeConverter.Instance.ConvertFromPixel(px)}"; rootView.Add(pxConvertText); var ptConvertText = new TextLabel(); var pt = 100.0f; ptConvertText.Text = $"point : {pt}, pixel : {PointTypeConverter.Instance.ConvertToPixel(pt)}"; rootView.Add(pxConvertText); pxConvertText = new TextLabel(); px = 100.0f; pxConvertText.Text = $"pixel : {px}, point : {PointTypeConverter.Instance.ConvertFromPixel(px)}"; rootView.Add(pxConvertText); /* GraphicsTypeExtension test. */ var extTitleText = new TextLabel(); extTitleText.Text = "GraphicsTypeExtensions"; extTitleText.PointSize = 40; extTitleText.TextColor = Color.Green; extTitleText.Padding = new Extents(0, 0, 10, 10); rootView.Add(extTitleText); var spToPxFloatText = new TextLabel(); spToPxFloatText.Text = $"sp : {100.01f}, pixel : {100.01f.SpToPx()}"; rootView.Add(spToPxFloatText); var pixelToSpFloatText = new TextLabel(); pixelToSpFloatText.Text = $"pixel : {60.01f}, sp : {60.01f.PxToSp()}"; rootView.Add(pixelToSpFloatText); var spToPxIntText = new TextLabel(); spToPxIntText.Text = $"sp : {100}, pixel : {100.SpToPx()}"; rootView.Add(spToPxIntText); var pixelToSpIntText = new TextLabel(); pixelToSpIntText.Text = $"pixel : {60}, sp : {60.PxToSp()}"; rootView.Add(pixelToSpIntText); var spToPxSizeText = new TextLabel(); var spSize = new Size(100.0f, 100.0f); var pixelSize = spSize.SpToPx(); spToPxSizeText.Text = $"sp : ({spSize.Width}, {spSize.Height}), pixel : ({pixelSize.Width}, {pixelSize.Height})"; rootView.Add(spToPxSizeText); var pixelToSpSizeText = new TextLabel(); pixelSize = new Size(100.0f, 100.0f); spSize = pixelSize.PxToSp(); pixelToSpSizeText.Text = $"pixel : ({pixelSize.Width}, {pixelSize.Height}), sp : ({spSize.Width}, {spSize.Height})"; rootView.Add(pixelToSpSizeText); var spToPxPosText = new TextLabel(); var spPos = new Position(100.0f, 100.0f); var pixelPos = spPos.SpToPx(); spToPxPosText.Text = $"sp : ({spPos.X}, {spPos.Y}), pixel : ({pixelPos.X}, {pixelPos.Y})"; rootView.Add(spToPxPosText); var pixelToSpPosText = new TextLabel(); pixelPos = new Position(100.0f, 100.0f); spPos = pixelPos.PxToSp(); pixelToSpPosText.Text = $"pixel : ({pixelPos.X}, {pixelPos.Y}), sp : ({spPos.X}, {spPos.Y})"; rootView.Add(pixelToSpPosText); var spToPxRectText = new TextLabel(); var spRect = new Rectangle(100, 100, 100, 100); var pixelRect = spRect.SpToPx(); spToPxRectText.Text = $"sp : ({spRect.X}, {spRect.Y}, {spRect.Width}, {spRect.Height}), pixel : ({pixelRect.X}, {pixelRect.Y}, {pixelRect.Width}, {pixelRect.Height})"; rootView.Add(spToPxRectText); var pixelToSpRectText = new TextLabel(); pixelRect = new Rectangle(100, 100, 100, 100); spRect = pixelRect.PxToSp(); pixelToSpRectText.Text = $"pixel : ({pixelRect.X}, {pixelRect.Y}, {pixelRect.Width}, {pixelRect.Height}), sp : ({spRect.X}, {spRect.Y}, {spRect.Width}, {spRect.Height})"; rootView.Add(pixelToSpRectText); var spToPxExtentText = new TextLabel(); var spExtent = new Extents(10, 10, 10, 10); var pixelExtent = spExtent.SpToPx(); spToPxExtentText.Text = $"sp : ({spExtent.Start}, {spExtent.End}, {spExtent.Top}, {spExtent.Bottom}), pixel : ({pixelExtent.Start}, {pixelExtent.End}, {pixelExtent.Top}, {pixelExtent.Bottom})"; rootView.Add(spToPxExtentText); var pixelToDpExtentText = new TextLabel(); pixelExtent = new Extents(10, 10, 10, 10); spExtent = pixelExtent.PxToSp(); pixelToDpExtentText.Text = $"pixel : ({pixelExtent.Start}, {pixelExtent.End}, {pixelExtent.Top}, {pixelExtent.Bottom}), sp : ({spExtent.Start}, {spExtent.End}, {spExtent.Top}, {spExtent.Bottom})"; rootView.Add(pixelToDpExtentText); var pixelToPointText = new TextLabel(); var fontPxSize = 30.0f; pixelToPointText.PointSize = fontPxSize.PxToPt(); pixelToPointText.Text = $"pixel : {fontPxSize}, point: {fontPxSize.PxToPt()}"; rootView.Add(pixelToPointText); var dpToPointText = new TextLabel(); var dpPxSize = 80.0f; dpToPointText.PointSize = dpPxSize.DpToPt(); dpToPointText.Text = $"pixel : {dpPxSize}, point: {dpPxSize.DpToPt()}"; rootView.Add(dpToPointText); window.Add(rootView); }