2 * Copyright(c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 using Tizen.NUI.BaseComponents;
20 using Tizen.NUI.Components;
22 namespace NUITizenGallery
24 public partial class ImageTest5Page : ContentPage
27 private float imgWidth = 0;
28 private float imgHeight = 0;
29 private String mode = "FillToParent";
30 private int choice = 0;
32 private void updateLabel()
34 imgHeight = imageView.Size2D.Height;
35 imgWidth = imageView.Size2D.Width;
37 if (choice == 0) mode = "FillToParent";
38 else if (choice == 1) mode = "SizeRelativeToParent";
39 else if (choice == 2) mode = "FitToChildren";
41 desc1.Text = "Mode : " + mode + "/ Width : " + (imgWidth > 0 ? imgWidth.ToString() : "-") + ", Height: " + (imgHeight > 0 ? imgHeight.ToString() : "-");
44 public ImageTest5Page()
46 InitializeComponent();
49 image1Btn.Clicked += (o, e) =>
51 imageView.Size2D = new Size2D(imageView.Size2D.Width + 100, imageView.Size2D.Height + 100);
54 image2Btn.Clicked += (o, e) =>
56 imageView.Size2D = new Size2D(imageView.Size2D.Width - 100, imageView.Size2D.Height - 100);
59 image3Btn.Clicked += (o, e) =>
61 imageView.Size2D = new Size2D(imageView.Size2D.Width, imageView.Size2D.Height + 100);
64 image4Btn.Clicked += (o, e) =>
66 imageView.Size2D = new Size2D(imageView.Size2D.Width, imageView.Size2D.Height - 100);
69 image5Btn.Clicked += (o, e) =>
73 imageView.HeightResizePolicy = Tizen.NUI.ResizePolicyType.FillToParent;
74 imageView.WidthResizePolicy = Tizen.NUI.ResizePolicyType.FillToParent;
79 imageView.HeightResizePolicy = Tizen.NUI.ResizePolicyType.SizeRelativeToParent;
80 imageView.WidthResizePolicy = Tizen.NUI.ResizePolicyType.SizeRelativeToParent;
85 imageView.HeightResizePolicy = Tizen.NUI.ResizePolicyType.FitToChildren;
86 imageView.WidthResizePolicy = Tizen.NUI.ResizePolicyType.FitToChildren;
92 protected override void Dispose(DisposeTypes type)
99 if (type == DisposeTypes.Explicit)
101 RemoveAllChildren(true);
107 private void RemoveAllChildren(bool dispose = false)
109 RecursiveRemoveChildren(this, dispose);
112 private void RecursiveRemoveChildren(View parent, bool dispose)
119 int maxChild = (int)parent.ChildCount;
120 for (int i = maxChild - 1; i >= 0; --i)
122 View child = parent.GetChildAt((uint)i);
128 RecursiveRemoveChildren(child, dispose);
129 parent.Remove(child);