Skip to content

WinForms: Allow detached legend to be redrawn programmatically #2153

@swharden

Description

@swharden

I think the issue described in #2131 can be resolved by making this function public

private void RefreshLegendImage()
{
FormsPlot.Refresh();
Legend.UpdateLegendItems(FormsPlot.Plot, includeHidden: true);
System.Drawing.Image originalImage = PictureBoxLegend.Image;
PictureBoxLegend.Image = Legend.GetBitmap(false);
if (originalImage is not null)
originalImage.Dispose();
}

Discussed in #2131

Originally posted by Z0ld3n September 21, 2022
Hi, thanks for this amazing library.

I have a question. If I hide series programmatically (by changing .IsVisible in IPlottable) when the legend is detached it is not picking up state change automatically. Is there a way to force refresh/update the legend when it is in a detached state other than force closing FormsPlotLegendViewer and opening a new one?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Good First IssueThis issue has limited complexity and may be a good start for new contributors

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions