Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DockHelper.cs: Possible bugs #3

Open
paulushub opened this issue Apr 10, 2020 · 1 comment
Open

DockHelper.cs: Possible bugs #3

paulushub opened this issue Apr 10, 2020 · 1 comment

Comments

@paulushub
Copy link

When you dock a pane and try to resize it, it crashes most of the times due a negative width or height:

public static void ComputeSpliterLocation(Popup spliter, Point location, Size size)
{
    if (location.X < 0)
    {
        spliter.HorizontalOffset = 0;
        spliter.Width = size.Width + location.X;
    }
    if (location.Y < 0)
    {
        spliter.VerticalOffset = 0;
        spliter.Height = size.Height + location.Y;
    }
    if (location.X + size.Width > SystemParameters.PrimaryScreenWidth)
        spliter.Width = SystemParameters.PrimaryScreenWidth - location.X;
    if (location.Y + size.Height > SystemParameters.PrimaryScreenHeight)
        spliter.Height = SystemParameters.PrimaryScreenHeight - location.Y;
}

The problem areas are spliter.Width = SystemParameters.PrimaryScreenWidth - location.X; and spliter.Height = SystemParameters.PrimaryScreenHeight - location.Y.

A simple change like below fixes the issue, but it could be better:

public static void ComputeSpliterLocation(Popup spliter, Point location, Size size)
{
    if (location.X < 0)
    {
        spliter.HorizontalOffset = 0;
        spliter.Width = size.Width + location.X;
    }
    if (location.Y < 0)
    {
        spliter.VerticalOffset = 0;
        spliter.Height = size.Height + location.Y;
    }
    if (location.X + size.Width > SystemParameters.PrimaryScreenWidth)
    {
        if ((SystemParameters.PrimaryScreenWidth - location.X) > 0)
        {
            spliter.Width = SystemParameters.PrimaryScreenWidth - location.X;
        }

    }
    if (location.Y + size.Height > SystemParameters.PrimaryScreenHeight)
    {
        if ((SystemParameters.PrimaryScreenHeight - location.Y) > 0)
        {
            spliter.Height = SystemParameters.PrimaryScreenHeight - location.Y;
        }
    }
}
@yzylovepmn
Copy link
Owner

Thanks for the correction, i will go check it out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants