public virtual bool OverlayBorderShow(uint time = 3000) { if (BorderWindow != null && BorderWindow.IsMaximized()) { if (overlayTimer == null) { overlayTimer = new Timer(time); overlayTimer.Tick += (s, e) => { BorderWindow.GetBorderWindowBottomLayer().LowerToBottom(); borderView?.Hide(); overlayTimer?.Stop(); overlayTimer?.Dispose(); overlayTimer = null; return(false); }; overlayTimer.Start(); BorderWindow.GetBorderWindowBottomLayer().RaiseToTop(); borderView?.Show(); } else { overlayTimer.Start(); } return(true); } return(false); }
public override bool CreateTopBorderView(View topView) { if (topView == null) { return(false); } topView.Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Horizontal, LinearAlignment = LinearLayout.Alignment.CenterVertical, CellPadding = new Size2D(20, 20), }; title = new TextLabel() { Text = "CustomBorder", }; var button = new Button() { Text = "AlwaysOnTop", }; button.Clicked += (s, e) => { BorderWindow.EnableFloatingMode(true); }; topView.Add(title); topView.Add(button); return(true); }
// If two finger long press is done, create a windowView. // then, Register a gesture on the windowView to do a resize or move. private bool OnTick(object o, Timer.TickEventArgs e) { windowView = new View() { WidthResizePolicy = ResizePolicyType.FillToParent, HeightResizePolicy = ResizePolicyType.FillToParent, BackgroundColor = new Color(1, 1, 1, 0.5f), }; windowView.TouchEvent += (s, e) => { return(true); }; BorderWindow.Add(windowView); winTapGestureDetector = new TapGestureDetector(); winTapGestureDetector.Attach(windowView); winTapGestureDetector.SetMaximumTapsRequired(3); winTapGestureDetector.Detected += OnWinTapGestureDetected; winPanGestureDetector = new PanGestureDetector(); winPanGestureDetector.Attach(windowView); winPanGestureDetector.Detected += OnWinPanGestureDetected; BorderWindow.InterceptTouchEvent -= OnWinInterceptedTouch; isWinGestures = true; return(false); }
// Window moves through pan gestures. private void OnWinPanGestureDetected(object source, PanGestureDetector.DetectedEventArgs e) { if (currentGesture <= CurrentGesture.PanGesture /*&& panGesture.NumberOfTouches == 1*/) { PanGesture panGesture = e.PanGesture; if (panGesture.State == Gesture.StateType.Started) { currentGesture = CurrentGesture.PanGesture; if (BorderWindow.IsMaximized() == true) { BorderWindow.Maximize(false); } else { BorderWindow.RequestMoveToServer(); } } else if (panGesture.State == Gesture.StateType.Finished || panGesture.State == Gesture.StateType.Cancelled) { currentGesture = CurrentGesture.None; ClearWindowGesture(); } } }
/// Determines the behavior of pinch gesture. private void OnPinchGestureDetected(object source, PinchGestureDetector.DetectedEventArgs e) { if (e == null) { return; } if (e.PinchGesture.State == Gesture.StateType.Started) { preScale = e.PinchGesture.Scale; } else if (e.PinchGesture.State == Gesture.StateType.Finished || e.PinchGesture.State == Gesture.StateType.Cancelled) { if (preScale > e.PinchGesture.Scale) { if (BorderWindow.IsMaximized()) { BorderWindow.Maximize(false); } else { BorderWindow.Minimize(true); } } else { BorderWindow.Maximize(true); } } }
private void UpdateIcons() { if (BorderWindow != null && rootView != null) { if (BorderWindow.IsMaximized() == true) { if (maximalizeIcon != null) { maximalizeIcon.ResourceUrl = DarkPreviousIcon; } if (minimalizeIcon != null) { minimalizeIcon.ResourceUrl = DarkMinimalizeIcon; } if (closeIcon != null) { closeIcon.ResourceUrl = DarkCloseIcon; } if (leftCornerIcon != null) { leftCornerIcon.ResourceUrl = DarkLeftCornerIcon; } if (rightCornerIcon != null) { rightCornerIcon.ResourceUrl = DarkRightCornerIcon; } rootView.CornerRadius = new Vector4(0, 0, 0, 0); rootView.CornerRadiusPolicy = VisualTransformPolicyType.Relative; BorderWindow.SetTransparency(false); } else { if (maximalizeIcon != null) { maximalizeIcon.ResourceUrl = MaximalizeIcon; } if (minimalizeIcon != null) { minimalizeIcon.ResourceUrl = MinimalizeIcon; } if (closeIcon != null) { closeIcon.ResourceUrl = CloseIcon; } if (leftCornerIcon != null) { leftCornerIcon.ResourceUrl = LeftCornerIcon; } if (rightCornerIcon != null) { rightCornerIcon.ResourceUrl = RightCornerIcon; } rootView.CornerRadius = new Vector4(0.03f, 0.03f, 0.03f, 0.03f); rootView.CornerRadiusPolicy = VisualTransformPolicyType.Relative; BorderWindow.SetTransparency(true); } } }
public virtual bool OverlayBorderHide() { if (BorderWindow != null && BorderWindow.IsMaximized()) { borderView?.Hide(); return(true); } return(false); }
public virtual void OnResized(int width, int height) { if (overlayTimer != null) { overlayTimer.Stop(); overlayTimer.Dispose(); overlayTimer = null; BorderWindow?.GetBorderWindowBottomLayer().LowerToBottom(); borderView?.Show(); } UpdateIcons(); }
private void ClearWindowGesture() { if (isWinGestures) { winPanGestureDetector.Dispose(); winTapGestureDetector.Dispose(); isWinGestures = false; BorderWindow.Remove(windowView); BorderWindow.InterceptTouchEvent += OnWinInterceptedTouch; } }
/// Determines the behavior of borders. private void OnPanGestureDetected(object source, PanGestureDetector.DetectedEventArgs e) { if (e == null) { return; } PanGesture panGesture = e.PanGesture; if (panGesture.State == Gesture.StateType.Started && panGesture.Position != null) { direction = BorderWindow.GetDirection(panGesture.Position.X, panGesture.Position.Y); if (direction == Window.BorderDirection.Move) { if (BorderWindow.IsMaximized() == true) { BorderWindow.Maximize(false); } else { BorderWindow.RequestMoveToServer(); } } else if (direction != Window.BorderDirection.None) { OnRequestResize(); BorderWindow.RequestResizeToServer((Window.ResizeDirection)direction); } } else if (panGesture.State == Gesture.StateType.Continuing) { if (direction == Window.BorderDirection.BottomLeft || direction == Window.BorderDirection.BottomRight || direction == Window.BorderDirection.TopLeft || direction == Window.BorderDirection.TopRight) { BorderWindow.WindowSize += new Size2D((int)panGesture.ScreenDisplacement.X, (int)panGesture.ScreenDisplacement.Y); } else if (direction == Window.BorderDirection.Left || direction == Window.BorderDirection.Right) { BorderWindow.WindowSize += new Size2D((int)panGesture.ScreenDisplacement.X, 0); } else if (direction == Window.BorderDirection.Bottom || direction == Window.BorderDirection.Top) { BorderWindow.WindowSize += new Size2D(0, (int)panGesture.ScreenDisplacement.Y); } else if (direction == Window.BorderDirection.Move) { BorderWindow.WindowPosition += new Position2D((int)panGesture.ScreenDisplacement.X, (int)panGesture.ScreenDisplacement.Y); } } else if (panGesture.State == Gesture.StateType.Finished || panGesture.State == Gesture.StateType.Cancelled) { direction = Window.BorderDirection.None; ClearWindowGesture(); } }
public virtual bool OnMinimizeIconTouched(object sender, View.TouchEventArgs e) { if (e == null) { return(false); } if (e.Touch.GetState(0) == PointStateType.Up) { ClearWindowGesture(); BorderWindow.Minimize(true); } return(true); }
public override bool OnMinimizeIconTouched(object sender, View.TouchEventArgs e) { if (e.Touch.GetState(0) == PointStateType.Up) { if (BorderWindow.IsMaximized() == true) { BorderWindow.Maximize(false); } preWinPositonSize = BorderWindow.WindowPositionSize; BorderWindow.WindowPositionSize = new Rectangle(preWinPositonSize.X, preWinPositonSize.Y, 500, 0); } return(true); }
public virtual bool OnCloseIconTouched(object sender, View.TouchEventArgs e) { if (e == null) { return(false); } if (e.Touch.GetState(0) == PointStateType.Up) { BorderWindow.Destroy(); BorderWindow = null; } return(true); }
public virtual bool OnRightBottomCornerIconTouched(object sender, View.TouchEventArgs e) { if (e != null && e.Touch.GetState(0) == PointStateType.Down) { ClearWindowGesture(); if (ResizePolicy != Window.BorderResizePolicyType.Fixed) { OnRequestResize(); BorderWindow.RequestResizeToServer(Window.ResizeDirection.BottomRight); } } return(true); }
protected void MaximizeBorderWindow() { ClearWindowGesture(); if (BorderWindow.IsMaximized()) { BorderWindow.Maximize(false); OnMaximize(false); } else { BorderWindow.Maximize(true); OnMaximize(true); } }
public virtual bool OnRightCornerIconTouched(object sender, View.TouchEventArgs e) { if (e == null) { return(false); } if (e.Touch.GetState(0) == PointStateType.Down) { ClearWindowGesture(); OnRequestResize(); BorderWindow.RequestResizeToServer(Window.ResizeDirection.BottomRight); } return(true); }
void InitBorders() { _left = new BorderWindow(this) { Side = BorderSide.Left }; _top = new BorderWindow(this) { Side = BorderSide.Top }; _right = new BorderWindow(this) { Side = BorderSide.Right }; _bottom = new BorderWindow(this) { Side = BorderSide.Bottom }; SetRegion(hWndContent, 0, 0, true); var hSrc = HwndSource.FromHwnd(hWndContent); hSrc.AddHook(WndProc); //Calculate the effective DPI used by WPF; _wpfDPI = 96.0 * hSrc.CompositionTarget.TransformToDevice.M11; //Get the Current DPI of the monitor of the window. _monitorDPI = Shcore.GetDpiForWindow(hSrc.Handle); //Calculate the scale factor used to modify window size, graphics and text _dpiScaleFactor = _monitorDPI / _wpfDPI; ContentWindow.Width *= _dpiScaleFactor; ContentWindow.Height *= _dpiScaleFactor; RescaleForDpi(); // SWP_DRAWFRAME makes window bg really transparent (visible during resize) and not black User32.SetWindowPos(hWndContent, IntPtr.Zero, 0, 0, 0, 0, SetWindowPosOptions.SWP_NOOWNERZORDER | SetWindowPosOptions.SWP_DRAWFRAME | SetWindowPosOptions.SWP_NOACTIVATE | SetWindowPosOptions.SWP_NOZORDER | SetWindowPosOptions.SWP_NOMOVE | SetWindowPosOptions.SWP_NOSIZE); }
public virtual void OnCreated(View borderView) { if (borderView == null) { return; } this.borderView = borderView; // Register to resize and move through pan gestures. borderPanGestureDetector = new PanGestureDetector(); borderPanGestureDetector.Attach(borderView); borderPanGestureDetector.Detected += OnPanGestureDetected; // Register touch event for effect when border is touched. borderView.LeaveRequired = true; borderView.TouchEvent += (s, e) => { if (e.Touch.GetState(0) == PointStateType.Started) { if (BorderWindow.IsMaximized() == false) { BorderWindow.Raise(); } backgroundColor = new Color(borderView.BackgroundColor); borderView.BackgroundColor = DefaultClickedBackgroundColor; } else if (e.Touch.GetState(0) == PointStateType.Finished || e.Touch.GetState(0) == PointStateType.Leave || e.Touch.GetState(0) == PointStateType.Interrupted) { borderView.BackgroundColor = backgroundColor; } return(true); }; borderPinchGestureDetector = new PinchGestureDetector(); borderPinchGestureDetector.Attach(borderView); borderPinchGestureDetector.Detected += OnPinchGestureDetected; AddInterceptGesture(); UpdateIcons(); }
private void UpdateIcons() { if (BorderWindow != null && borderView != null) { if (BorderWindow.IsMaximized() == true) { if (maximalizeIcon != null) { maximalizeIcon.ResourceUrl = RestoreIcon; } } else { if (maximalizeIcon != null) { maximalizeIcon.ResourceUrl = MaximalizeIcon; } } } }
void InitBorders() { _left = new BorderWindow(this) { Side = BorderSide.Left }; _top = new BorderWindow(this) { Side = BorderSide.Top }; _right = new BorderWindow(this) { Side = BorderSide.Right }; _bottom = new BorderWindow(this) { Side = BorderSide.Bottom }; var wpl = default(WINDOWPLACEMENT); wpl.length = (uint)Marshal.SizeOf(typeof(WINDOWPLACEMENT)); if (User32.GetWindowPlacement(hWndContent, ref wpl)) { UpdateClipRegion(hWndContent, wpl, ClipRegionChangeType.FromPropertyChange); } var hSrc = HwndSource.FromHwnd(hWndContent); hSrc.AddHook(WndProc); // SWP_DRAWFRAME makes window bg really transparent (visible during resize) and not black User32.SetWindowPos(hWndContent, IntPtr.Zero, 0, 0, 0, 0, SetWindowPosOptions.SWP_NOOWNERZORDER | SetWindowPosOptions.SWP_DRAWFRAME | SetWindowPosOptions.SWP_NOACTIVATE | SetWindowPosOptions.SWP_NOZORDER | SetWindowPosOptions.SWP_NOMOVE | SetWindowPosOptions.SWP_NOSIZE); }
public void HiddingTest() { // arrange BorderWindow Test = new BorderWindow(); Grid[] WallsFloor = new Grid[70]; Grid Wall1 = new Grid(); Wall1.Opacity = 100; WallsFloor[50] = Wall1; int i = 50; double wall = 100; // act Test.Hidding(i); // assert double wall2 = WallsFloor[50].Opacity; Assert.AreEqual(wall2, wall, "nie schowano"); }
// Behavior when the window is tapped. private void OnWinTapGestureDetected(object source, TapGestureDetector.DetectedEventArgs e) { if (currentGesture <= CurrentGesture.TapGesture) { currentGesture = CurrentGesture.TapGesture; if (e.TapGesture.NumberOfTaps == 2) { if (BorderWindow.IsMaximized() == false) { BorderWindow.Maximize(true); } else { BorderWindow.Maximize(false); } } else { ClearWindowGesture(); } } }
/// Determines the behavior of borders. private void OnPanGestureDetected(object source, PanGestureDetector.DetectedEventArgs e) { if (e == null) { return; } PanGesture panGesture = e.PanGesture; if (panGesture.State == Gesture.StateType.Started && panGesture.Position != null) { direction = BorderWindow.GetDirection(panGesture.Position.X, panGesture.Position.Y); if (direction == Window.BorderDirection.Move) { if (BorderWindow.IsMaximized() == true) { BorderWindow.Maximize(false); OnMaximize(false); } else { BorderWindow.RequestMoveToServer(); } } else if (direction != Window.BorderDirection.None && ResizePolicy != Window.BorderResizePolicyType.Fixed) { OnRequestResize(); BorderWindow.RequestResizeToServer((Window.ResizeDirection)direction); } } else if (panGesture.State == Gesture.StateType.Finished || panGesture.State == Gesture.StateType.Cancelled) { direction = Window.BorderDirection.None; ClearWindowGesture(); } }
protected void MinimizeBorderWindow() { ClearWindowGesture(); BorderWindow.Minimize(true); OnMinimize(true); }
protected void CloseBorderWindow() { BorderWindow.BorderDestroy(); }
public BorderBrushConverter(BorderWindow border) { _border = border; }