public MainForm() { InitializeComponent(); mMandelbrotGenerator = new MandelbrotGenerator(Width, Height); mMandelbrotGenerator.Width = panel1.Width; mMandelbrotGenerator.Height = panel1.Height; mMandelbrotGenerator.FixAspect(); mMandelbrotGenerator.MandlebrotReady += MMandelbrotGenerator_MandlebrotReady; mMandelbrotGenerator.MandlebrotPaletteChanged += MMandelbrotGenerator_MandlebrotPaletteChanged; MouseWheel += Form1_MouseWheel; UpdateMandelbrot(); propertyGrid1.SelectedObject = mMandelbrotGenerator; //Load the presets from presets.xml (if it exists), and use the defaults otherwise string xmlpath = Path.GetDirectoryName(Application.ExecutablePath) + "\\presets.xml"; if (File.Exists(xmlpath)) { //try loading try { mPresets = MandelbrotPresets.FromXml(File.ReadAllText(xmlpath)); } catch { mPresets = MandelbrotPresets.GenerateDefault(); SavePresets(); } } else { mPresets = MandelbrotPresets.GenerateDefault(); SavePresets(); } UpdatePresets(); }
//When the reset presets button has been clicked private void toolStripButton3_Click(object sender, EventArgs e) { if (MessageBox.Show("Are you sure you want to result the presets to the defaults?", "Reset", MessageBoxButtons.YesNo) == DialogResult.Yes) { mPresets = MandelbrotPresets.GenerateDefault(); SavePresets(); UpdatePresets(); } }
public static MandelbrotPresets GenerateDefault() { MandelbrotPresets result = new MandelbrotPresets(); result.presets.Add(new MandelbrotPreset() { name = "Default", x = -2, y = -2, width = 4, height = 4, maxCount = 512, style = MandelbrotGenerator.MandelbrotColorStyle.SimpleRgb, palette = new int[0] }); result.presets.Add(new MandelbrotPreset() { name = "Fire Leaf", x = -0.11202303901237315, y = -0.92944262954527346, width = 0.013835606102545174, height = 0.0089072648146142352, maxCount = 128, style = MandelbrotGenerator.MandelbrotColorStyle.Paletted, palette = new int[] { Color.Green.ToArgb(), Color.Red.ToArgb(), Color.Orange.ToArgb(), Color.White.ToArgb(), Color.Black.ToArgb() } }); result.presets.Add(new MandelbrotPreset() { name = "Neptune's Trident", x = -0.561895714249722, y = -0.64233713371809176, width = 1.185069712557534E-05, height = 7.62939453125E-06, maxCount = 256, style = MandelbrotGenerator.MandelbrotColorStyle.Paletted, palette = new int[] { -16777152, -64, -8388480, -16727872, -1, -16777216 } }); result.presets.Add(new MandelbrotPreset() { name = "Milkyway", x = 0.43918663254571694, y = -0.251801694741495, width = 9.4647755985933241E-05, height = 7.2604610487025933E-05, maxCount = 128, style = MandelbrotGenerator.MandelbrotColorStyle.Paletted, palette = new int[] { -1, -16777184, -64, -16777216, } }); return(result); }