Прямоугольник узла автоматизации управления: нижняя часть не может быть больше или равна верху

Я получаю сообщение о том, что нижняя часть не может быть больше или равна верху.

Я использую RectangleКонструктор описываемая здесь: https://docs.microsoft.com/en-us/dotnet/api/system.management.automation.host.rectangle.-ctor?view=powershellsdk-1.1.0#System_Management_Automation_Host_Rectangle__ctor_System_Int32_System_Int32_System_Int32_System_Int32_

Это мой соответствующий раздел кода;

                  Console.WriteLine("setting rectangles: " + sizex +", " +sizey);
            int screenTop = sizey;
            int screenBottom = 1;
            int statusTop = 1;
            int statusBottom = 0;
            Console.WriteLine ("screen top bottom; "+screenTop + " > " + screenBottom );
            Console.WriteLine ("status top bottom; "+statusTop + " > " + statusBottom );
            
         // Rectangle(int left, int top, int right, int bottom);
            System.Management.Automation.Host.Rectangle screenWindowRect = new Rectangle(0,screenTop,sizex,screenBottom);
            System.Management.Automation.Host.Rectangle statusLineRect = new Rectangle(0,statusTop,sizex,statusBottom);
            Console.WriteLine("rectangles set");

Я вижу строки отладки перед конструкторами, но никогда не вижу сообщение «установлены прямоугольники».

Это результат;

      setting rectangles: 241, 28
screen top bottom; 28 > 1
status top bottom; 1 > 0
Out-Less: "bottom" cannot be greater than or equal to "top".

Я вижу, что верх больше, чем низ, но я продолжаю получать ошибку; "bottom" cannot be greater than or equal to "top"

Это ошибка, ошибка документации или что-то мне не хватает.

1 ответ

Сообщение об ошибке неверно указывает фактическое состояние ошибки:

"bottom" cannot be greater than or equal to "top"

должно быть:

"bottom" cannot be less than "top"

Другими словами : bottomаргумент должен быть больше или равенtopаргумент - и, аналогично, rightдолжно быть равно или больше, чем left:

Вы можете проверить это в самом PowerShell:

      # OK: 1 -ge 1
# Arguments are: left, top, right, bottom
[System.Management.Automation.Host.Rectangle]::new(0, 1, 0, 1)

# OK: 2 -ge 1
[System.Management.Automation.Host.Rectangle]::new(0, 1, 0, 2)

# !! EXCEPTION: 0 -ge 1 is NOT true.
[System.Management.Automation.Host.Rectangle]::new(0, 1, 0, 0)
Другие вопросы по тегам