protected Window(IWindowBaseImpl window) { this.window = window; adapter = new ControlAdapter(this); window.Input = OnInput; window.Paint = OnPaint; window.Resized = OnResize; window.Closed = () => Closed?.Invoke(this, EventArgs.Empty); window.Deactivated = () => Deactivated?.Invoke(this, EventArgs.Empty); window.Resize(new Size(DefaultSize.Width, DefaultSize.Height)); }
internal Window(IWindowBaseImpl window) { this.window = window; adapter = new ControlAdapter(this); window.Input = OnInput; window.Paint = OnPaint; window.Resized = OnResize; window.Closed = () => Closed?.Invoke(this, EventArgs.Empty); window.Deactivated = () => { // If we're clicking off the form, deactivate any active menus Application.ActiveMenu?.Deactivate(); Deactivated?.Invoke(this, EventArgs.Empty); }; window.Resize(new Size(DefaultSize.Width, DefaultSize.Height)); }
private void MoveWindow(Point position) { var diff = position - _prevPoint; var edge = _edge.Value; var rc = new Rect(_window.Position, _window.ClientSize); if (edge == WindowEdge.East || edge == WindowEdge.NorthEast || edge == WindowEdge.SouthEast) { rc = rc.WithWidth(rc.Width + diff.X); _prevPoint = _prevPoint.WithX(position.X); } if (edge == WindowEdge.West || edge == WindowEdge.NorthWest || edge == WindowEdge.SouthWest) { rc = rc.WithX(rc.X + diff.X).WithWidth(rc.Width - diff.X); } if (edge == WindowEdge.South || edge == WindowEdge.SouthWest || edge == WindowEdge.SouthEast) { rc = rc.WithHeight(rc.Height + diff.Y); _prevPoint = _prevPoint.WithY(position.Y); } if (edge == WindowEdge.North || edge == WindowEdge.NorthWest || edge == WindowEdge.NorthEast) { rc = rc.WithY(rc.Y + diff.Y).WithHeight(rc.Height - diff.Y); } if (_resize != null) { _resize(rc); } else { if (_window.Position != rc.Position) { _window.Position = rc.Position; } if (_window.ClientSize != rc.Size) { _window.Resize(rc.Size); } } }