4 using Tizen.NUI.BaseComponents;
5 using Tizen.NUI.Components;
6 using System.Collections.Generic;
9 namespace Tizen.NUI.Samples
11 public class BorderWindowTest : IExample
14 private Window subWindowOne = null;
15 private Window subWindowTwo = null;
16 private static readonly string imagePath = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "/images/Dali/CubeTransitionEffect/";
19 class CustomBorder : DefaultBorder
21 private int width = 500;
22 private bool hide = false;
23 private View rootView;
24 private View borderView;
25 private TextLabel title;
27 public CustomBorder() : base()
32 public override void CreateBorderView(View rootView)
34 this.rootView = rootView;
35 rootView.CornerRadius = new Vector4(0.03f, 0.03f, 0.03f, 0.03f);
36 rootView.CornerRadiusPolicy = VisualTransformPolicyType.Relative;
38 borderView = new View()
40 Layout = new LinearLayout()
42 LinearAlignment = LinearLayout.Alignment.End,
43 LinearOrientation = LinearLayout.Orientation.Horizontal,
45 WidthSpecification = LayoutParamPolicies.MatchParent,
46 HeightSpecification = LayoutParamPolicies.MatchParent,
48 title = new TextLabel()
50 Text = "CustomBorder",
51 Size = new Size(300, 50),
52 Position = new Position(60, 0),
53 PositionUsesPivotPoint = true,
54 PivotPoint = PivotPoint.BottomLeft,
55 ParentOrigin = ParentOrigin.BottomLeft,
58 var minimalizeIcon = new Button()
61 PositionUsesPivotPoint = true,
62 PivotPoint = PivotPoint.BottomLeft,
63 ParentOrigin = ParentOrigin.BottomLeft,
64 Size = new Size(50, 50),
67 var maximalizeIcon = new Button()
70 PositionUsesPivotPoint = true,
71 PivotPoint = PivotPoint.BottomLeft,
72 ParentOrigin = ParentOrigin.BottomLeft,
73 Size = new Size(50, 50),
76 var closeIcon = new Button()
79 PositionUsesPivotPoint = true,
80 PivotPoint = PivotPoint.BottomLeft,
81 ParentOrigin = ParentOrigin.BottomLeft,
82 Size = new Size(50, 50),
86 var leftPadding = new View()
88 PositionUsesPivotPoint = true,
89 PivotPoint = PivotPoint.BottomLeft,
90 ParentOrigin = ParentOrigin.BottomLeft,
91 Size = new Size(50, 50),
94 var rightPadding = new View()
96 PositionUsesPivotPoint = true,
97 PivotPoint = PivotPoint.BottomLeft,
98 ParentOrigin = ParentOrigin.BottomLeft,
99 Size = new Size(50, 50),
102 rootView.Add(leftPadding);
104 borderView.Add(minimalizeIcon);
105 borderView.Add(maximalizeIcon);
106 borderView.Add(closeIcon);
107 borderView.Add(rightPadding);
108 rootView.Add(borderView);
110 minimalizeIcon.TouchEvent += OnMinimizeIconTouched;
111 maximalizeIcon.TouchEvent += OnMaximizeIconTouched;
112 closeIcon.TouchEvent += OnCloseIconTouched;
113 leftPadding.TouchEvent += OnLeftCornerIconTouched;
114 rightPadding.TouchEvent += OnRightCornerIconTouched;
117 public override void OnCreated(View rootView)
119 base.OnCreated(rootView);
122 public override bool OnCloseIconTouched(object sender, View.TouchEventArgs e)
124 base.OnCloseIconTouched(sender, e);
128 public override bool OnMinimizeIconTouched(object sender, View.TouchEventArgs e)
130 base.OnMinimizeIconTouched(sender, e);
134 public override void OnResized(int width, int height)
136 if (rootView != null)
138 if (this.width > width && hide == false)
143 else if (this.width < width && hide == true)
148 base.OnResized(width, height);
154 void CreateSubWindowOne()
156 if (subWindowOne == null)
158 subWindowOne = new Window("subwin1", null, new Rectangle(20, 20, 800, 800), false);
160 var root = new ImageView()
162 WidthResizePolicy = ResizePolicyType.FillToParent,
163 HeightResizePolicy = ResizePolicyType.FillToParent,
164 ResourceUrl = imagePath + "gallery-large-9.jpg",
165 CornerRadius = new Vector4(0.03f, 0.03f, 0.03f, 0.03f),
166 CornerRadiusPolicy = VisualTransformPolicyType.Relative,
168 subWindowOne.Add(root);
170 TextLabel text = new TextLabel("Hello Tizen NUI World");
171 text.HorizontalAlignment = HorizontalAlignment.Center;
172 text.VerticalAlignment = VerticalAlignment.Center;
173 text.TextColor = Color.CornflowerBlue;
174 text.HeightResizePolicy = ResizePolicyType.FillToParent;
175 text.WidthResizePolicy = ResizePolicyType.FillToParent;
178 Animation animation = new Animation(2000);
179 animation.AnimateTo(text, "Orientation", new Rotation(new Radian(new Degree(180.0f)), PositionAxis.X), 0, 500);
180 animation.AnimateTo(text, "Orientation", new Rotation(new Radian(new Degree(0.0f)), PositionAxis.X), 500, 1000);
181 animation.Looping = true;
186 subWindowOne.Minimize(false);
190 void CreateSubWindowTwo()
192 if (subWindowTwo == null)
194 IBorderInterface customBorder = new CustomBorder();
195 subWindowTwo = new Window("subwin1", customBorder, new Rectangle(60, 20, 800, 800), false);
197 subWindowTwo.BackgroundColor = Color.Red;
199 var root = new View(){
200 Layout = new LinearLayout()
202 LinearAlignment = LinearLayout.Alignment.CenterHorizontal,
204 WidthResizePolicy = ResizePolicyType.FillToParent,
205 HeightResizePolicy = ResizePolicyType.FillToParent,
206 BackgroundColor = Color.Yellow,
209 var image = new ImageView()
211 Size = new Size(300, 300),
212 ResourceUrl = imagePath + "gallery-large-5.jpg",
213 CornerRadius = new Vector4(0.03f, 0.03f, 0, 0),
214 CornerRadiusPolicy = VisualTransformPolicyType.Relative,
217 subWindowTwo.Add(root);
221 subWindowTwo.Minimize(false);
229 win = NUIApplication.GetDefaultWindow();
230 var root = new ImageView()
232 WidthResizePolicy = ResizePolicyType.FillToParent,
233 HeightResizePolicy = ResizePolicyType.FillToParent,
234 ResourceUrl = imagePath + "gallery-large-14.jpg",
235 Layout = new LinearLayout()
237 LinearAlignment = LinearLayout.Alignment.CenterHorizontal,
238 LinearOrientation = LinearLayout.Orientation.Horizontal,
239 CellPadding = new Size(10, 10),
246 var imageViewA = new ImageView()
248 PositionUsesPivotPoint = true,
249 PivotPoint = PivotPoint.BottomLeft,
250 ParentOrigin = ParentOrigin.BottomLeft,
251 Size = new Size(150, 150),
252 ResourceUrl = imagePath + "gallery-large-9.jpg",
254 CornerRadiusPolicy = VisualTransformPolicyType.Relative,
256 root.Add(imageViewA);
257 imageViewA.TouchEvent += (s, e) =>
259 if (e.Touch.GetState(0) == PointStateType.Up)
261 CreateSubWindowOne();
266 var imageViewB = new ImageView()
268 PositionUsesPivotPoint = true,
269 PivotPoint = PivotPoint.BottomLeft,
270 ParentOrigin = ParentOrigin.BottomLeft,
271 Size = new Size(150, 150),
272 ResourceUrl = imagePath + "gallery-large-5.jpg",
274 CornerRadiusPolicy = VisualTransformPolicyType.Relative,
276 root.Add(imageViewB);
277 imageViewB.TouchEvent += (s, e) =>
279 if (e.Touch.GetState(0) == PointStateType.Up)
281 CreateSubWindowTwo();
287 public void Activate()
292 public void Deactivate()