PlotStyle: styling information that simplifies storing, recalling, and copying plot styles#4025
PlotStyle: styling information that simplifies storing, recalling, and copying plot styles#4025swharden merged 12 commits intoScottPlot:mainfrom
Conversation
|
Hi @StendProg, thanks so much for this PR! The timing is great as I was about to start working on #3955 I may refactor this a bit before merging it in, but I'll have it merged before the next release for sure. I look forward to reviewing this! 🚀 |
|
great~ |
performs byte-for-byte comparison of the rendered PNG output and asserts equality
|
I think I've recreated the original behavior... customized style settings can be recognized and preserved even as new styles are applied. I'll probably put this down for tonight and pick it up again tomorrow, but I'm encouraged by the direction that this is going 😄 public Form1()
{
InitializeComponent();
var sig1 = formsPlot1.Plot.Add.Signal(Generate.Sin());
sig1.LegendText = "Sin";
var sig2 = formsPlot1.Plot.Add.Signal(Generate.Cos());
sig2.LegendText = "Cos";
// apply custom styling options
formsPlot1.Plot.Legend.BackgroundColor = Colors.Magenta;
formsPlot1.Plot.Legend.FontColor = Colors.White;
// prepare the two styles we will be switching between later
PlotStyle lightStyle = new ScottPlot.PlotStyles.Light();
// the WinForms control customizes light style by setting background to match the form
lightStyle.FigureBackground = ScottPlot.Color.FromColor(SystemColors.Control);
PlotStyle darkStyle = new ScottPlot.PlotStyles.Dark();
PlotStyle customStyle = formsPlot1.Plot.GetStyle().WhereDifferentFrom(lightStyle);
checkBox1.CheckedChanged += (s, e) =>
{
// apply light or dark mode
if (checkBox1.Checked)
formsPlot1.Plot.SetStyle(darkStyle);
else
formsPlot1.Plot.SetStyle(lightStyle);
// apply the customized style options
formsPlot1.Plot.SetStyle(customStyle);
formsPlot1.Refresh();
};
} |
|
Hi @swharden. This PR is already closed, but I have some comments/suggestions. ScottPlot/src/ScottPlot5/ScottPlot5/Primitives/PlotStyle.cs Lines 12 to 13 in 723f187 For consistency, change ScottPlot/src/ScottPlot5/ScottPlot5/Primitives/PlotStyle.cs Lines 20 to 21 in 723f187
|
|
Good point @kebox7, thanks for pointing that out! I meant to rename all those properties but I forgot to before merging... I opened #4036 to track the fix and added my recommended names there. If you get to it before I do and create a pull request, I'd be happy to merge it in! Otherwise I'll pick it up next time I work on this project 👍 |


This PR adds the
Plot.Style.IsDarkModeproperty.This property allows you to toggle the display mode light/dark. If the user has changed any colors manually, these colors are not affected by the switch and remain as configured by the user.
Calling the
Plot.Style.GrabLightSettings()method allows you to save the changes made by the user as light theme settings.IsDarkModeis not a good name for the set value property. The more appropriateDarkModeis already taken up by theDarkMode()method. Renaming it would be a breaking change.DarkMode.mp4