コード例 #1
0
ファイル: WindowBase.cs プロジェクト: amwx/Avalonia
 public WindowBase(IWindowBaseImpl impl, IAvaloniaDependencyResolver?dependencyResolver) : base(impl, dependencyResolver)
 {
     Screens              = new Screens(PlatformImpl?.Screen);
     impl.Activated       = HandleActivated;
     impl.Deactivated     = HandleDeactivated;
     impl.PositionChanged = HandlePositionChanged;
 }
コード例 #2
0
        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;
                }
            }
        }
コード例 #3
0
 /// <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);
 }
コード例 #4
0
 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));
 }
コード例 #5
0
ファイル: WindowBase.cs プロジェクト: soerendd/Avalonia
        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;
        }
コード例 #6
0
ファイル: Window.cs プロジェクト: xuezs/Avalonia
        /// <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;
            }
        }
コード例 #7
0
        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);
                }
            }
        }