public WindowBase(IWindowBaseImpl impl, IAvaloniaDependencyResolver?dependencyResolver) : base(impl, dependencyResolver) { Screens = new Screens(PlatformImpl?.Screen); impl.Activated = HandleActivated; impl.Deactivated = HandleDeactivated; impl.PositionChanged = HandlePositionChanged; }
private void SetWindowStartupLocation(IWindowBaseImpl owner = null) { var scaling = owner?.Scaling ?? PlatformImpl?.Scaling ?? 1; // TODO: We really need non-client size here. var rect = new PixelRect( PixelPoint.Origin, PixelSize.FromSize(ClientSize, scaling)); if (WindowStartupLocation == WindowStartupLocation.CenterScreen) { var screen = Screens.ScreenFromPoint(owner?.Position ?? Position); if (screen != null) { Position = screen.WorkingArea.CenterRect(rect).Position; } } else if (WindowStartupLocation == WindowStartupLocation.CenterOwner) { if (owner != null) { // TODO: We really need non-client size here. var ownerRect = new PixelRect( owner.Position, PixelSize.FromSize(owner.ClientSize, scaling)); Position = ownerRect.CenterRect(rect).Position; } } }
/// <summary> /// Initializes a new instance of the <see cref="Window"/> class. /// </summary> /// <param name="impl">The window implementation.</param> public Window(IWindowImpl impl) : base(impl) { impl.Closing = HandleClosing; _maxPlatformClientSize = PlatformImpl?.MaxClientSize ?? default(Size); Screens = new Screens(PlatformImpl?.Screen); }
public WindowBase(IWindowBaseImpl impl, IAvaloniaDependencyResolver dependencyResolver) : base(impl, dependencyResolver) { Screens = new Screens(PlatformImpl?.Screen); impl.Activated = HandleActivated; impl.Deactivated = HandleDeactivated; impl.PositionChanged = HandlePositionChanged; this.GetObservable(ClientSizeProperty).Skip(1).Subscribe(x => PlatformImpl?.Resize(x)); }
public WindowBase(IWindowBaseImpl impl, IAvaloniaDependencyResolver dependencyResolver) : base(ValidatingWindowBaseImpl.Wrap(impl), dependencyResolver) { Screens = new Screens(PlatformImpl?.Screen); var wrapped = PlatformImpl !; wrapped.Activated = HandleActivated; wrapped.Deactivated = HandleDeactivated; wrapped.PositionChanged = HandlePositionChanged; }
/// <summary> /// Initializes a new instance of the <see cref="Window"/> class. /// </summary> /// <param name="impl">The window implementation.</param> public Window(IWindowImpl impl) : base(impl) { impl.Closing = HandleClosing; _maxPlatformClientSize = PlatformImpl?.MaxClientSize ?? default(Size); Screens = new Screens(PlatformImpl?.Screen); if (PlatformImpl != null) { PlatformImpl.WindowStateChanged = s => WindowState = s; } }
void SetWindowStartupLocation() { if (WindowStartupLocation == WindowStartupLocation.CenterScreen) { var screen = Screens.ScreenFromPoint(Bounds.Position); if (screen != null) { Position = screen.WorkingArea.CenterRect(new Rect(ClientSize)).Position; } } else if (WindowStartupLocation == WindowStartupLocation.CenterOwner) { if (Owner != null) { var positionAsSize = Owner.ClientSize / 2 - ClientSize / 2; Position = Owner.Position + new Point(positionAsSize.Width, positionAsSize.Height); } } }