Skip to content

Commit

Permalink
fix more screen
Browse files Browse the repository at this point in the history
  • Loading branch information
rmbadmin committed Jun 5, 2021
1 parent 67ec02a commit 9c13426
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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));

}
});
}
Expand Down

0 comments on commit 9c13426

Please sign in to comment.