private void WindowStoppedMoving(UIFrame MovedFrame) { // Put it back in this view RemoveSubview(MovedFrame); UIFrame LastWindowAbove = null; foreach (UIFrame Window in ContentView.SubviewsOfType <UIFrame>()) { // Check if dropped above another window int TopOfWindow = ContentView.ClientBounds.Top + Window.Bounds.Y + Window.Bounds.Height / 2; if (MovedFrame.Bounds.Y < TopOfWindow) { LastWindowAbove = Window; break; } } // Add it to the content view again if (LastWindowAbove != null) { ContentView.AddSubviewBefore(MovedFrame, LastWindowAbove); } else { ContentView.AddSubview(MovedFrame); } }
public void AddWindow(UIFrame Window) { Window.FrameStartedToMove += WindowStartedToMove; Window.FrameMoved += WindowMoved; Window.FrameStoppedMoving += WindowStoppedMoving; ContentView.AddSubview(Window); }
private void WindowStartedToMove(UIFrame MovedFrame) { // Remove it from content view and add it as a subview to this view ContentView.RemoveSubview(MovedFrame); ContentView.NeedsLayout = false; AddSubview(MovedFrame); NeedsLayout = false; // Offset it's position so it's still under the cursor MovedFrame.Bounds.X += ContentView.Bounds.Left; MovedFrame.Bounds.Y += ContentView.Bounds.Top; }
private void WindowStoppedMoving(UIFrame MovedFrame) { // Put it back in this view RemoveSubview(MovedFrame); UIFrame LastWindowAbove = null; foreach (UIFrame Window in ContentView.SubviewsOfType<UIFrame>()) { // Check if dropped above another window int TopOfWindow = ContentView.ClientBounds.Top + Window.Bounds.Y + Window.Bounds.Height / 2; if (MovedFrame.Bounds.Y < TopOfWindow) { LastWindowAbove = Window; break; } } // Add it to the content view again if (LastWindowAbove != null) ContentView.AddSubviewBefore(MovedFrame, LastWindowAbove); else ContentView.AddSubview(MovedFrame); }
private void WindowMoved(UIFrame MovedFrame) { // Offset it's position so it's still under the cursor MovedFrame.Bounds.Y += ContentView.Bounds.Top; }