✅ Help with creating shapes on a windows form app

I have created a windows form app to display shapes on a bitmap, my circle function works fine but my rectangle will work regardless of the text I put in, for example..

circle 40
will draw a circle with a radius of 40 as it should
bingbong 30,20
will still draw a rectangle even though the string is incorrect

else if (CommandSplit[0].Equals("rectangle") == true) ; /// RECTANGLE FUNCTION

{
    try
    {
        ParameterSplit = CommandSplit[1].Split(",".ToCharArray());

        int width = int.Parse(ParameterSplit[0]);
        int height = int.Parse(ParameterSplit[1]);
        ErrorHandlingWindow.Clear();

        MyCanvass.DrawRectangle(width, height);
        Refresh();
        return;
    }

    catch (FormatException)
    {
        ErrorHandlingWindow.Text = FormatExceptionErrorMessage;
        return;
    }
    catch (IndexOutOfRangeException)
    {
        ErrorHandlingWindow.Text = IndexOutOfRangeExceptionMessage;
        return;

    }
Was this page helpful?