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 static readonly string ResourcePath = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
22 private static readonly string MinimalizeIcon = ResourcePath + "/images/minimalize.png";
23 private static readonly string MaximalizeIcon = ResourcePath + "/images/maximalize.png";
24 private static readonly string RestoreIcon = ResourcePath + "/images/smallwindow.png";
25 private static readonly string CloseIcon = ResourcePath + "/images/close.png";
26 private static readonly string LeftCornerIcon = ResourcePath + "/images/leftCorner.png";
27 private static readonly string RightCornerIcon = ResourcePath + "/images/rightCorner.png";
29 private int width = 500;
30 private bool hide = false;
31 private View borderView;
32 private TextLabel title;
34 private ImageView minimalizeIcon;
35 private ImageView maximalizeIcon;
36 private ImageView closeIcon;
37 private ImageView leftCornerIcon;
38 private ImageView rightCornerIcon;
40 private Rectangle preWinPositonSize;
42 public CustomBorder() : base()
46 BorderLineThickness = 0;
49 public override bool CreateTopBorderView(View topView)
55 topView.Layout = new LinearLayout()
57 LinearOrientation = LinearLayout.Orientation.Horizontal,
58 LinearAlignment = LinearLayout.Alignment.CenterVertical,
59 CellPadding = new Size2D(20, 20),
61 title = new TextLabel()
63 Text = "CustomBorder",
66 var button = new Button()
70 button.Clicked += (s, e) =>
72 BorderWindow.EnableFloatingMode(true);
79 public override bool CreateBottomBorderView(View bottomView)
81 if (bottomView == null)
85 bottomView.Layout = new RelativeLayout();
87 minimalizeIcon = new ImageView()
89 ResourceUrl = MinimalizeIcon,
92 maximalizeIcon = new ImageView()
94 ResourceUrl = MaximalizeIcon,
97 closeIcon = new ImageView()
99 ResourceUrl = CloseIcon,
102 leftCornerIcon = new ImageView()
104 ResourceUrl = LeftCornerIcon,
107 rightCornerIcon = new ImageView()
109 ResourceUrl = RightCornerIcon,
112 RelativeLayout.SetRightTarget(minimalizeIcon, maximalizeIcon);
113 RelativeLayout.SetRightRelativeOffset(minimalizeIcon, 0.0f);
114 RelativeLayout.SetHorizontalAlignment(minimalizeIcon, RelativeLayout.Alignment.End);
115 RelativeLayout.SetRightTarget(maximalizeIcon, closeIcon);
116 RelativeLayout.SetRightRelativeOffset(maximalizeIcon, 0.0f);
117 RelativeLayout.SetHorizontalAlignment(maximalizeIcon, RelativeLayout.Alignment.End);
118 RelativeLayout.SetRightTarget(closeIcon, rightCornerIcon);
119 RelativeLayout.SetRightRelativeOffset(closeIcon, 0.0f);
120 RelativeLayout.SetHorizontalAlignment(closeIcon, RelativeLayout.Alignment.End);
121 RelativeLayout.SetRightRelativeOffset(rightCornerIcon, 1.0f);
122 RelativeLayout.SetHorizontalAlignment(rightCornerIcon, RelativeLayout.Alignment.End);
123 bottomView.Add(leftCornerIcon);
124 bottomView.Add(minimalizeIcon);
125 bottomView.Add(maximalizeIcon);
126 bottomView.Add(closeIcon);
127 bottomView.Add(rightCornerIcon);
130 minimalizeIcon.TouchEvent += OnMinimizeIconTouched;
131 maximalizeIcon.TouchEvent += OnMaximizeIconTouched;
132 closeIcon.TouchEvent += OnCloseIconTouched;
133 leftCornerIcon.TouchEvent += OnLeftBottomCornerIconTouched;
134 rightCornerIcon.TouchEvent += OnRightBottomCornerIconTouched;
138 public override void CreateBorderView(View borderView)
140 this.borderView = borderView;
141 borderView.CornerRadius = new Vector4(0.03f, 0.03f, 0.03f, 0.03f);
142 borderView.CornerRadiusPolicy = VisualTransformPolicyType.Relative;
143 borderView.BackgroundColor = new Color(1, 1, 1, 0.3f);
146 public override void OnCreated(View borderView)
148 base.OnCreated(borderView);
152 public override bool OnCloseIconTouched(object sender, View.TouchEventArgs e)
154 base.OnCloseIconTouched(sender, e);
158 public override bool OnMinimizeIconTouched(object sender, View.TouchEventArgs e)
160 if (e.Touch.GetState(0) == PointStateType.Up)
162 if (BorderWindow.IsMaximized() == true)
164 BorderWindow.Maximize(false);
166 preWinPositonSize = BorderWindow.WindowPositionSize;
167 BorderWindow.WindowPositionSize = new Rectangle(preWinPositonSize.X, preWinPositonSize.Y, 500, 0);
172 public override void OnRequestResize()
174 if (borderView != null)
176 borderView.BackgroundColor = new Color(0, 1, 0, 0.3f); // 보더의 배경을 변경할 수 있습니다.
180 public override void OnResized(int width, int height)
182 if (borderView != null)
184 if (this.width > width && hide == false)
189 else if (this.width < width && hide == true)
194 borderView.BackgroundColor = new Color(1, 1, 1, 0.3f); // 리사이즈가 끝나면 보더의 색깔은 원래대로 돌려놓습니다.
195 base.OnResized(width, height);
200 private void UpdateIcons()
202 if (BorderWindow != null && borderView != null)
204 if (BorderWindow.IsMaximized() == true)
206 if (maximalizeIcon != null)
208 maximalizeIcon.ResourceUrl = RestoreIcon;
213 if (maximalizeIcon != null)
215 maximalizeIcon.ResourceUrl = MaximalizeIcon;
223 void CreateSubWindowOne()
225 if (subWindowOne == null)
227 subWindowOne = new Window("subwin1", null, new Rectangle(20, 20, 800, 800), false);
229 var root = new ImageView()
231 WidthResizePolicy = ResizePolicyType.FillToParent,
232 HeightResizePolicy = ResizePolicyType.FillToParent,
233 ResourceUrl = imagePath + "gallery-large-9.jpg",
234 CornerRadius = new Vector4(0.03f, 0.03f, 0.03f, 0.03f),
235 CornerRadiusPolicy = VisualTransformPolicyType.Relative,
237 subWindowOne.Add(root);
239 TextLabel text = new TextLabel("Hello Tizen NUI World");
240 text.HorizontalAlignment = HorizontalAlignment.Center;
241 text.VerticalAlignment = VerticalAlignment.Center;
242 text.TextColor = Color.CornflowerBlue;
243 text.HeightResizePolicy = ResizePolicyType.FillToParent;
244 text.WidthResizePolicy = ResizePolicyType.FillToParent;
247 Animation animation = new Animation(2000);
248 animation.AnimateTo(text, "Orientation", new Rotation(new Radian(new Degree(180.0f)), PositionAxis.X), 0, 500);
249 animation.AnimateTo(text, "Orientation", new Rotation(new Radian(new Degree(0.0f)), PositionAxis.X), 500, 1000);
250 animation.Looping = true;
255 subWindowOne.Minimize(false);
259 void CreateSubWindowTwo()
261 if (subWindowTwo == null)
263 IBorderInterface customBorder = new CustomBorder();
264 subWindowTwo = new Window("subwin1", customBorder, new Rectangle(60, 20, 800, 800), false);
265 subWindowTwo.EnableFloatingMode(true);
267 var root = new View(){
268 Layout = new LinearLayout()
270 LinearAlignment = LinearLayout.Alignment.CenterHorizontal,
272 WidthResizePolicy = ResizePolicyType.FillToParent,
273 HeightResizePolicy = ResizePolicyType.FillToParent,
274 BackgroundColor = Color.Brown,
277 var image = new ImageView()
279 Size = new Size(300, 300),
280 ResourceUrl = imagePath + "gallery-large-5.jpg",
281 CornerRadius = new Vector4(0.03f, 0.03f, 0, 0),
282 CornerRadiusPolicy = VisualTransformPolicyType.Relative,
285 subWindowTwo.Add(root);
289 subWindowTwo.Minimize(false);
297 win = NUIApplication.GetDefaultWindow();
299 var root = new ImageView()
301 WidthResizePolicy = ResizePolicyType.FillToParent,
302 HeightResizePolicy = ResizePolicyType.FillToParent,
303 ResourceUrl = imagePath + "gallery-large-14.jpg",
304 Layout = new LinearLayout()
306 LinearAlignment = LinearLayout.Alignment.CenterHorizontal,
307 LinearOrientation = LinearLayout.Orientation.Horizontal,
308 CellPadding = new Size(10, 10),
314 var appFunctionList = new View()
316 PositionUsesPivotPoint = true,
317 PivotPoint = PivotPoint.BottomLeft,
318 ParentOrigin = ParentOrigin.BottomLeft,
319 BackgroundColor = new Color(0, 1, 1, 0.5f),
320 Size = new Size(500, 200),
322 CornerRadiusPolicy = VisualTransformPolicyType.Relative,
323 Layout = new LinearLayout()
325 LinearAlignment = LinearLayout.Alignment.CenterHorizontal,
326 LinearOrientation = LinearLayout.Orientation.Horizontal,
327 CellPadding = new Size(10, 10),
328 Padding = new Extents(10, 10, 10 , 10),
331 root.Add(appFunctionList);
333 var defaultBorder = new View()
335 Size = new Size(150, 180),
336 Layout = new LinearLayout()
338 LinearAlignment = LinearLayout.Alignment.Center,
339 LinearOrientation = LinearLayout.Orientation.Vertical,
343 var imageViewA = new ImageView()
345 Size = new Size(150, 150),
346 ResourceUrl = imagePath + "gallery-large-9.jpg",
348 CornerRadiusPolicy = VisualTransformPolicyType.Relative,
351 var textViewA = new TextLabel()
356 defaultBorder.Add(imageViewA);
357 defaultBorder.Add(textViewA);
358 appFunctionList.Add(defaultBorder);
359 defaultBorder.TouchEvent += (s, e) =>
361 if (e.Touch.GetState(0) == PointStateType.Up)
363 CreateSubWindowOne();
368 var customBorder = new View()
370 Size = new Size(150, 180),
371 Layout = new LinearLayout()
373 LinearAlignment = LinearLayout.Alignment.Center,
374 LinearOrientation = LinearLayout.Orientation.Vertical,
378 var imageViewB = new ImageView()
380 Size = new Size(150, 150),
381 ResourceUrl = imagePath + "gallery-large-5.jpg",
383 CornerRadiusPolicy = VisualTransformPolicyType.Relative,
385 var textViewB = new TextLabel()
390 customBorder.Add(imageViewB);
391 customBorder.Add(textViewB);
392 appFunctionList.Add(customBorder);
393 customBorder.TouchEvent += (s, e) =>
395 if (e.Touch.GetState(0) == PointStateType.Up)
397 CreateSubWindowTwo();
403 public void Activate()
408 public void Deactivate()