📄 fmain.cs
字号:
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace Fractals
{
enum DrawMode { Mandelbrot, Julia };
/// <summary>
/// Summary description for Form1.
/// </summary>
public class FMain : System.Windows.Forms.Form
{
Mandelbrot _man;
Julia _jul;
DrawMode _DrawMode = DrawMode.Mandelbrot;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.PictureBox pictureBox;
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.MenuItem menuItem3;
private System.Windows.Forms.MenuItem menuItem5;
private System.Windows.Forms.MenuItem mnuFileSave;
private System.Windows.Forms.MenuItem mnuFileExit;
private System.Windows.Forms.MenuItem mnuDrawMandelbrot;
private System.Windows.Forms.MenuItem mnuDrawJulia;
private System.Windows.Forms.TextBox txtIterations;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.TextBox txtReal;
private System.Windows.Forms.TextBox txtImaginary;
private System.Windows.Forms.TextBox txtScale;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Button btnZoomIn;
private System.Windows.Forms.Button btnZoomOut;
private System.Windows.Forms.MenuItem menuItem2;
private System.Windows.Forms.MenuItem mnuSetColors;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Button btnDraw;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.MenuItem mnuFileSaveJulia;
private System.Windows.Forms.MenuItem mnuFileSaveMandelbrot;
private System.Windows.Forms.MenuItem mnuFileLoadJulia;
private System.Windows.Forms.MenuItem mnuFileLoadMandelbrot;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox txtRealC;
private System.Windows.Forms.TextBox txtImaginaryC;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public FMain()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
label1.Text = "Mandelbrot";
txtIterations.Text = "512";
txtReal.Text = "0.0";
txtImaginary.Text = "0.0";
txtScale.Text = "0.01";
groupBox2.Visible = false;
_man = new Mandelbrot();
_man.ReadoutsDelegate = new Mandelbrot.UpdateReadoutsDelegate( UpdateManReadouts );
_man.RealCenter = double.Parse( txtReal.Text );
_man.ImgCenter = double.Parse( txtImaginary.Text );
_man.Scale = double.Parse( txtScale.Text );
_man.Iterations = int.Parse( txtIterations.Text );
_jul = new Julia();
_jul.ReadoutsDelegate = new Julia.UpdateReadoutsDelegate( UpdateJuliaReadouts );
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.txtIterations = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.pictureBox = new System.Windows.Forms.PictureBox();
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.mnuFileSave = new System.Windows.Forms.MenuItem();
this.mnuFileSaveJulia = new System.Windows.Forms.MenuItem();
this.mnuFileSaveMandelbrot = new System.Windows.Forms.MenuItem();
this.mnuFileLoadJulia = new System.Windows.Forms.MenuItem();
this.mnuFileLoadMandelbrot = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
this.mnuFileExit = new System.Windows.Forms.MenuItem();
this.menuItem5 = new System.Windows.Forms.MenuItem();
this.mnuDrawMandelbrot = new System.Windows.Forms.MenuItem();
this.mnuDrawJulia = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.mnuSetColors = new System.Windows.Forms.MenuItem();
this.label6 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.txtReal = new System.Windows.Forms.TextBox();
this.txtImaginary = new System.Windows.Forms.TextBox();
this.txtScale = new System.Windows.Forms.TextBox();
this.label8 = new System.Windows.Forms.Label();
this.btnZoomIn = new System.Windows.Forms.Button();
this.btnZoomOut = new System.Windows.Forms.Button();
this.panel1 = new System.Windows.Forms.Panel();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.label2 = new System.Windows.Forms.Label();
this.txtRealC = new System.Windows.Forms.TextBox();
this.txtImaginaryC = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.btnDraw = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.panel1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// txtIterations
//
this.txtIterations.Location = new System.Drawing.Point(80, 248);
this.txtIterations.Name = "txtIterations";
this.txtIterations.Size = new System.Drawing.Size(80, 20);
this.txtIterations.TabIndex = 5;
this.txtIterations.Text = "";
//
// label5
//
this.label5.Location = new System.Drawing.Point(8, 248);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(64, 23);
this.label5.TabIndex = 10;
this.label5.Text = "Iterations";
this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// pictureBox
//
this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.pictureBox.Location = new System.Drawing.Point(176, 0);
this.pictureBox.Name = "pictureBox";
this.pictureBox.Size = new System.Drawing.Size(584, 777);
this.pictureBox.TabIndex = 11;
this.pictureBox.TabStop = false;
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem1,
this.menuItem5,
this.menuItem2});
//
// menuItem1
//
this.menuItem1.Index = 0;
this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.mnuFileSave,
this.mnuFileSaveJulia,
this.mnuFileSaveMandelbrot,
this.mnuFileLoadJulia,
this.mnuFileLoadMandelbrot,
this.menuItem3,
this.mnuFileExit});
this.menuItem1.Text = "&File";
//
// mnuFileSave
//
this.mnuFileSave.Index = 0;
this.mnuFileSave.Text = "&Save Image";
this.mnuFileSave.Click += new System.EventHandler(this.mnuFileSave_Click);
//
// mnuFileSaveJulia
//
this.mnuFileSaveJulia.Index = 1;
this.mnuFileSaveJulia.Text = "Save &Julia Parameters";
this.mnuFileSaveJulia.Click += new System.EventHandler(this.mnuFileSaveJulia_Click);
//
// mnuFileSaveMandelbrot
//
this.mnuFileSaveMandelbrot.Index = 2;
this.mnuFileSaveMandelbrot.Text = "Save &Mandelbrot Parameters";
this.mnuFileSaveMandelbrot.Click += new System.EventHandler(this.mnuFileSaveMandelbrot_Click);
//
// mnuFileLoadJulia
//
this.mnuFileLoadJulia.Index = 3;
this.mnuFileLoadJulia.Text = "Load Julia Parameters";
this.mnuFileLoadJulia.Click += new System.EventHandler(this.mnuFileLoadJulia_Click);
//
// mnuFileLoadMandelbrot
//
this.mnuFileLoadMandelbrot.Index = 4;
this.mnuFileLoadMandelbrot.Text = "Load Mandelbrot Parameters";
this.mnuFileLoadMandelbrot.Click += new System.EventHandler(this.mnuFileLoadMandelbrot_Click);
//
// menuItem3
//
this.menuItem3.Index = 5;
this.menuItem3.Text = "-";
//
// mnuFileExit
//
this.mnuFileExit.Index = 6;
this.mnuFileExit.Text = "E&xit";
this.mnuFileExit.Click += new System.EventHandler(this.mnuFileExit_Click);
//
// menuItem5
//
this.menuItem5.Index = 1;
this.menuItem5.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.mnuDrawMandelbrot,
this.mnuDrawJulia});
this.menuItem5.Text = "&Draw";
//
// mnuDrawMandelbrot
//
this.mnuDrawMandelbrot.Index = 0;
this.mnuDrawMandelbrot.Text = "&Mandelbrot";
this.mnuDrawMandelbrot.Click += new System.EventHandler(this.mnuDrawMandelbrot_Click);
//
// mnuDrawJulia
//
this.mnuDrawJulia.Index = 1;
this.mnuDrawJulia.Text = "&Julia";
this.mnuDrawJulia.Click += new System.EventHandler(this.mnuDrawJulia_Click);
//
// menuItem2
//
this.menuItem2.Index = 2;
this.menuItem2.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.mnuSetColors});
this.menuItem2.Text = "&Set";
//
// mnuSetColors
//
this.mnuSetColors.Index = 0;
this.mnuSetColors.Text = "&Colors";
this.mnuSetColors.Click += new System.EventHandler(this.mnuSetColors_Click);
//
// label6
//
this.label6.Location = new System.Drawing.Point(12, 32);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(136, 20);
this.label6.TabIndex = 12;
this.label6.Text = "Real";
this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label7
//
this.label7.Location = new System.Drawing.Point(12, 96);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(136, 20);
this.label7.TabIndex = 13;
this.label7.Text = "Imaginary";
this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// txtReal
//
this.txtReal.Location = new System.Drawing.Point(12, 56);
this.txtReal.Name = "txtReal";
this.txtReal.Size = new System.Drawing.Size(136, 20);
this.txtReal.TabIndex = 14;
this.txtReal.Text = "";
//
// txtImaginary
//
this.txtImaginary.Location = new System.Drawing.Point(20, 208);
this.txtImaginary.Name = "txtImaginary";
this.txtImaginary.Size = new System.Drawing.Size(136, 20);
this.txtImaginary.TabIndex = 15;
this.txtImaginary.Text = "";
//
// txtScale
//
this.txtScale.Location = new System.Drawing.Point(12, 312);
this.txtScale.Name = "txtScale";
this.txtScale.Size = new System.Drawing.Size(152, 20);
this.txtScale.TabIndex = 16;
this.txtScale.Text = "";
//
// label8
//
this.label8.Location = new System.Drawing.Point(12, 288);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(152, 20);
this.label8.TabIndex = 17;
this.label8.Text = "Scale";
this.label8.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// btnZoomIn
//
this.btnZoomIn.Location = new System.Drawing.Point(51, 344);
this.btnZoomIn.Name = "btnZoomIn";
this.btnZoomIn.TabIndex = 18;
this.btnZoomIn.Text = "Zoom In";
this.btnZoomIn.Click += new System.EventHandler(this.btnZoomIn_Click);
//
// btnZoomOut
//
this.btnZoomOut.Location = new System.Drawing.Point(51, 376);
this.btnZoomOut.Name = "btnZoomOut";
this.btnZoomOut.TabIndex = 19;
this.btnZoomOut.Text = "Zoom Out";
this.btnZoomOut.Click += new System.EventHandler(this.btnZoomOut_Click);
//
// panel1
//
this.panel1.Controls.AddRange(new System.Windows.Forms.Control[] {
this.groupBox2,
this.label1,
this.btnDraw,
this.txtImaginary,
this.label8,
this.txtScale,
this.btnZoomIn,
this.btnZoomOut,
this.txtIterations,
this.label5,
this.groupBox1});
this.panel1.Dock = System.Windows.Forms.DockStyle.Left;
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(176, 777);
this.panel1.TabIndex = 20;
//
// groupBox2
//
this.groupBox2.Controls.AddRange(new System.Windows.Forms.Control[] {
this.label2,
this.txtRealC,
this.txtImaginaryC,
this.label3});
this.groupBox2.Location = new System.Drawing.Point(8, 408);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(160, 152);
this.groupBox2.TabIndex = 23;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "C for Julia Set";
//
// label2
//
this.label2.Location = new System.Drawing.Point(12, 96);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(136, 20);
this.label2.TabIndex = 17;
this.label2.Text = "Imaginary";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// txtRealC
//
this.txtRealC.Location = new System.Drawing.Point(12, 56);
this.txtRealC.Name = "txtRealC";
this.txtRealC.Size = new System.Drawing.Size(136, 20);
this.txtRealC.TabIndex = 18;
this.txtRealC.Text = "";
//
// txtImaginaryC
//
this.txtImaginaryC.Location = new System.Drawing.Point(12, 120);
this.txtImaginaryC.Name = "txtImaginaryC";
this.txtImaginaryC.Size = new System.Drawing.Size(136, 20);
this.txtImaginaryC.TabIndex = 19;
this.txtImaginaryC.Text = "";
//
// label3
//
this.label3.Location = new System.Drawing.Point(12, 32);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(136, 20);
this.label3.TabIndex = 16;
this.label3.Text = "Real";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label1
//
this.label1.Location = new System.Drawing.Point(20, 16);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(136, 23);
this.label1.TabIndex = 21;
this.label1.Text = "Mandelbrot";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -