-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEditorMandelbrot.cs
More file actions
43 lines (38 loc) · 1.16 KB
/
EditorMandelbrot.cs
File metadata and controls
43 lines (38 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
namespace CS_GRAPHICS
{
public partial class EditorMandelbrot : EditorBase
{
public EditorMandelbrot()
{
InitializeComponent();
// load iterations into cmb box
int[] iterations = { 64, 128, 256, 512, 768, 1024, 2048 };
foreach (int iter in iterations)
{
cmbMaxIter.Items.Add(iter);
}
cmbMaxIter.SelectedIndex = 0;
}
public override void LoadState(object item)
{
if (item is not Mandelbrot mandel)
return;
// Loads mandelbrot fractal data
int idx = cmbMaxIter.Items.IndexOf(mandel.MaxIterations);
if (idx != -1)
cmbMaxIter.SelectedIndex = idx;
else
cmbMaxIter.SelectedIndex = 0;
}
public override void SaveState(object item)
{
if (item is not Mandelbrot mandel)
return;
// Saves mandelbrot fractal data
if (cmbMaxIter.SelectedItem is int iterations)
{
mandel.MaxIterations = iterations;
}
}
}
}