From 9c134267817503ad1f88947d35ecef15300061e9 Mon Sep 17 00:00:00 2001 From: rmbgame Date: Sun, 6 Jun 2021 01:48:44 +0800 Subject: [PATCH] fix more screen --- .../UI/Views/Windows/TaskBarWindow.axaml.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/TaskBarWindow.axaml.cs b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/TaskBarWindow.axaml.cs index 7fa2ee6ee11..e3592c13447 100644 --- a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/TaskBarWindow.axaml.cs +++ b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/TaskBarWindow.axaml.cs @@ -49,17 +49,21 @@ private void Window_Opened(object? sender, EventArgs e) //{ // this.Position = new PixelPoint(vm.SizePosition.X, vm.SizePosition.Y - (int)this.Height); //} - var workingAreaWidth = this.Screens.Primary.WorkingArea.Width; + vm.WhenAnyValue(x => x.SizePosition.X, x => x.SizePosition.Y) .Subscribe(x => { + var screen = this.Screens.ScreenFromPoint(new PixelPoint(x.Item1, x.Item2)); + var workingAreaWidth = screen.WorkingArea.Width; + if ((x.Item1 + (int)this.Width + 30) > workingAreaWidth) { - this.Position = new PixelPoint(x.Item1 - (int)this.Width, x.Item2 - (int)(this.Height * this.Screens.Primary.PixelDensity)); + this.Position = new PixelPoint(x.Item1 - (int)(this.Width * screen.PixelDensity), x.Item2 - (int)(this.Height * screen.PixelDensity)); } else { - this.Position = new PixelPoint(x.Item1, x.Item2 - (int)(this.Height * this.Screens.Primary.PixelDensity)); + this.Position = new PixelPoint(x.Item1, x.Item2 - (int)(this.Height * screen.PixelDensity)); + } }); }