Skip to content

Improve design time error messages in plot controls#1052

Merged
swharden merged 7 commits intoScottPlot:masterfrom
bclehmann:avaplot-designer-show-error
May 22, 2021
Merged

Improve design time error messages in plot controls#1052
swharden merged 7 commits intoScottPlot:masterfrom
bclehmann:avaplot-designer-show-error

Conversation

@bclehmann
Copy link
Member

@bclehmann bclehmann commented May 22, 2021

Warning: My WPF designer, WinForms designer, and half of Visual Studio broke at work today :/. I have not been able to test the changes to WPF or WinForms, so I cannot say whether they work as intended or not.

Purpose:
#1048 (comment)

@swharden swharden changed the title Avaplot designer show plot in designer Improve design time error messages in plot controls May 22, 2021
@swharden
Copy link
Member

swharden commented May 22, 2021

lol this came around full circle... if we are try/catching in controls, we can just test against Render() itself

if (DesignerProperties.GetIsInDesignMode(this))
{
    try
    {
        Plot.Title($"ScottPlot {Plot.Version}");
        Plot.Render();
    }
    catch (Exception e)
    {
        InitializeComponent();
        PlotImage.Visibility = System.Windows.Visibility.Hidden;
        ErrorLabel.Text = e.ToString();
        return;
    }
}

@swharden
Copy link
Member

swharden commented May 22, 2021

Thanks for this PR @bclehmann! The 3 controls are now all checking for design time crashes the same way.

I think the strategy try/catching a Render() is okay, but if you disagree we can discuss it more in #1048 #1043

@swharden swharden merged commit 2a4232e into ScottPlot:master May 22, 2021
@swharden swharden linked an issue May 22, 2021 that may be closed by this pull request
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

Successfully merging this pull request may close these issues.

Improve appearance of controls in designer mode

2 participants