/// <summary> /// Enable the border window with IBorderInterface. /// This adds a border area to the Window. /// The border's UI is configured using IBorderInterface. /// Users can reisze and move by touching the border area. /// </summary> /// <param name="borderInterface">The IBorderInterface.</param> /// <returns>Whether the border window is enabled</returns> internal bool EnableBorder(IBorderInterface borderInterface = null) { if (isBorderWindow == true) { Tizen.Log.Error("NUI", $"Already EnableBorderWindow\n"); return(false); } if (borderInterface == null) { borderInterface = new DefaultBorder(); } this.borderInterface = borderInterface; GetDefaultLayer().Name = "OriginalRootLayer"; Resized += OnBorderWindowResized; isBorderWindow = true; // The current window is as below // ***** // ***** // Increase the window size as much as the border area. // +++++++ // +*****+ // +*****+ // +=====+ // +=====+ // '+' is BorderLineThickness // '=' is BorderHeight WindowSize += new Size2D((int)borderInterface.BorderLineThickness * 2, (int)(borderInterface.BorderHeight + borderInterface.BorderLineThickness)); if (CreateBorder() == false) { WindowSize -= new Size2D((int)borderInterface.BorderLineThickness * 2, (int)(borderInterface.BorderHeight + borderInterface.BorderLineThickness)); Resized -= OnBorderWindowResized; isBorderWindow = false; this.borderInterface = null; return(false); } SetTransparency(true); BackgroundColor = Color.Transparent; borderInterface.BorderWindow = this; EnableFloatingMode(true); borderInterface.OnCreated(rootView); return(true); }
/// <summary> /// Enable the border window with IBorderInterface. /// This adds a border area to the Window. /// The border's UI is configured using IBorderInterface. /// Users can reisze and move by touching the border area. /// </summary> /// <param name="borderInterface">The IBorderInterface.</param> /// <param name="borderCloseDelegate">The BorderCloseDelegate. When close, this delegate is called.</param> /// <returns>Whether the border window is enabled</returns> internal bool EnableBorder(IBorderInterface borderInterface, BorderCloseDelegate borderCloseDelegate = null) { if (isBorderWindow == true) { Tizen.Log.Error("NUI", $"Already EnableBorderWindow\n"); return(false); } try { Information.TryGetValue <int>("http://tizen.org/feature/screen.width", out screenWidth); Information.TryGetValue <int>("http://tizen.org/feature/screen.height", out screenHeight); } catch (DllNotFoundException e) { Tizen.Log.Fatal("NUI", $"{e}\n"); } if (borderInterface == null) { borderInterface = new DefaultBorder(); } this.borderInterface = borderInterface; this.borderCloseDelegate = borderCloseDelegate; GetDefaultLayer().Name = "OriginalRootLayer"; SetTransparency(true); BackgroundColor = Color.Transparent; borderInterface.BorderWindow = this; if (CreateBorder() == true) { using var realWindowSize = new Size2D(WindowSize.Width, WindowSize.Height); isBorderWindow = true; Resized += OnBorderWindowResized; borderInterface.OnCreated(borderView); // Increase the window size as much as the border area. borderHeight = 0; if (isTop) { borderHeight += topView.SizeHeight; } if (isBottom) { borderHeight += bottomView.SizeHeight; } // When running the app for the first time, if it runs in full size, do Maximize(true). if (screenWidth != 0 && screenHeight != 0 && realWindowSize.Width >= screenWidth && realWindowSize.Height >= screenHeight && IsMaximized() == false) { Maximize(true); borderInterface.OnMaximize(true); ResizedEventArgs e = new ResizedEventArgs(); e.WindowSize = WindowSize; OnBorderWindowResized(this, e); } else { WindowSize += new Size2D((int)borderInterface.BorderLineThickness * 2, (int)(borderHeight + borderInterface.BorderLineThickness * 2)); } // If it is BorderResizePolicyType.KeepRatio type, it will be resized according to the ratio. if (borderInterface.ResizePolicy == BorderResizePolicyType.KeepRatio) { AddAuxiliaryHint("wm.policy.win.resize_aspect_ratio", "1"); } // Add a view to the border layer. GetBorderWindowBottomLayer().Add(rootView); InterceptTouchEvent += (s, e) => { if (e.Touch.GetState(0) == PointStateType.Down && IsMaximized() == false) { Raise(); } return(false); }; return(true); } else { this.borderInterface.Dispose(); return(false); } }
public NUIApplication(string styleSheet, Size2D windowSize, Position2D windowPosition, IBorderInterface borderInterface, WindowMode windowMode = WindowMode.Opaque) : base(new NUICoreBackend(styleSheet, windowMode, windowSize, windowPosition)) { borderEnabled = true; this.borderInterface = borderInterface; }