Здравствуйте. На форме в PictureBox должен рисоваться график, но этого не происходит. Подскажите что не так.
Код:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Design;
using System.Drawing.Drawing2D;
using System.Text;
using System.Windows.Forms;
using ComplexConsole;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Image img;
public Pen pen;
public Graphics graphs;
public Random rand;
public Form1()
{
InitializeComponent();
rand = new Random();
img = new Bitmap(2000, 2000);
pen = new Pen(Color.Black, 5);
graphs = Graphics.FromImage(img);
graphs.Clear(Color.White);
pictureBox1.Image = img;
}
public ComplexDouble ZetA(ComplexDouble s, double alpha, double de, double tau, double rw, double l, double a, double b)
{
ComplexDouble lyambda, gamma, za;
lyambda = ComplexDouble.Pow(s, 1 - alpha / 2) * ComplexDouble.Sqrt(de / (1 + tau * s), 1 / 2);
gamma = (ComplexDouble.Pow(s, alpha / 2) / Math.Sqrt(de)) * ComplexDouble.Sqrt(1 + tau * s, 1 / 2);
za = -(rw/lyambda)*((a*lyambda-b*lyambda+a*l*lyambda*gamma)/(a*lyambda+gamma-l*lyambda*gamma));
return za;
}
private void button1_Click_1(object sender, EventArgs e)
{
graphs.Clear(Color.White);
pen.Color = Color.FromArgb(rand.Next(0, 255), rand.Next(0, 255), rand.Next(0, 255));
ComplexConsole.ComplexDouble s_end = new ComplexDouble(
(double)numericUpDownRes.Value,
(double)numericUpDownIms.Value),
s = s_end, z1 = new ComplexDouble(2000d, 0d), z2;
s.Im = 0.1d;
s_end.Im = 1000d;
double alpha = (double)numericUpDownAlpha.Value,
de = (double)numericUpDownDe.Value,
tau = (double)numericUpDownTau.Value,
rw = (double)numericUpDownRw.Value,
l = (double)numericUpDownL.Value,
a = (double)numericUpDownA.Value,
b = (double)numericUpDownB.Value;
while (s.Im < s_end.Im)
{
z2 = z1;
z1 = ZetA(s, alpha, de, tau, rw, l, a, b) * 2000d;
s.Im += 0.1d;
try
{
graphs.DrawLine(pen,
(int)(z1.Re), (int)(-z1.Im),
(int)(z2.Re), (int)(-z2.Im));
}
catch { }
}
pictureBox1.Image = (Image)img.Clone();
pictureBox1.Image.RotateFlip(RotateFlipType.RotateNoneFlipY);
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Design;
using System.Drawing.Drawing2D;
using System.Text;
using System.Windows.Forms;
using ComplexConsole;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Image img;
public Pen pen;
public Graphics graphs;
public Random rand;
public Form1()
{
InitializeComponent();
rand = new Random();
img = new Bitmap(2000, 2000);
pen = new Pen(Color.Black, 5);
graphs = Graphics.FromImage(img);
graphs.Clear(Color.White);
pictureBox1.Image = img;
}
public ComplexDouble ZetA(ComplexDouble s, double alpha, double de, double tau, double rw, double l, double a, double b)
{
ComplexDouble lyambda, gamma, za;
lyambda = ComplexDouble.Pow(s, 1 - alpha / 2) * ComplexDouble.Sqrt(de / (1 + tau * s), 1 / 2);
gamma = (ComplexDouble.Pow(s, alpha / 2) / Math.Sqrt(de)) * ComplexDouble.Sqrt(1 + tau * s, 1 / 2);
za = -(rw/lyambda)*((a*lyambda-b*lyambda+a*l*lyambda*gamma)/(a*lyambda+gamma-l*lyambda*gamma));
return za;
}
private void button1_Click_1(object sender, EventArgs e)
{
graphs.Clear(Color.White);
pen.Color = Color.FromArgb(rand.Next(0, 255), rand.Next(0, 255), rand.Next(0, 255));
ComplexConsole.ComplexDouble s_end = new ComplexDouble(
(double)numericUpDownRes.Value,
(double)numericUpDownIms.Value),
s = s_end, z1 = new ComplexDouble(2000d, 0d), z2;
s.Im = 0.1d;
s_end.Im = 1000d;
double alpha = (double)numericUpDownAlpha.Value,
de = (double)numericUpDownDe.Value,
tau = (double)numericUpDownTau.Value,
rw = (double)numericUpDownRw.Value,
l = (double)numericUpDownL.Value,
a = (double)numericUpDownA.Value,
b = (double)numericUpDownB.Value;
while (s.Im < s_end.Im)
{
z2 = z1;
z1 = ZetA(s, alpha, de, tau, rw, l, a, b) * 2000d;
s.Im += 0.1d;
try
{
graphs.DrawLine(pen,
(int)(z1.Re), (int)(-z1.Im),
(int)(z2.Re), (int)(-z2.Im));
}
catch { }
}
pictureBox1.Image = (Image)img.Clone();
pictureBox1.Image.RotateFlip(RotateFlipType.RotateNoneFlipY);
}
}
}
Код:
/*using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;*/
// ReSharper disable UnusedMember.Global
// ReSharper disable MemberCanBePrivate.Global
namespace ComplexConsole
{
/// <summary> Комплексне число (z = x+i*y), кожна складова (x,y) якого є double
/// (число подвійної точності з плаваючою точкою). </summary>
public struct ComplexDouble : System.IFormattable, System.IEquatable<ComplexDouble>
{
/// <summary> π=3.141592653589793238462643383279502884197169399311481966593000573842001111842089549379151. </summary>
public const double Pi = 3.141592653589793238462643383279502884197169399311481966593000573842001111842089549379151d;
/// <summary> Корінь квадратний від -1 (i=√-1, i*i=-1). </summary>
public static readonly ComplexDouble I = new ComplexDouble(0d, 1d);
/// <summary> Дійсна складова (x) комплексного числа. </summary>
public double Re { get; set; }
/// <summary> Уявна складова (y) комплексного числа. </summary>
public double Im { get; set; }
/// <summary> Модуль (√(x*x+y*y), абсолютне значення) комплексного числа. </summary>
public double Abs
{
get { return System.Math.Sqrt(SqrAbs); }
set { this *= value / Abs; }
}
/// <summary> Квадрат модуля (x*x+y*y) комплексного числа. </summary>
public double SqrAbs
{
get { return Re * Re + Im * Im; }
set { this *= System.Math.Sqrt(value / SqrAbs); }
}
/// <summary> Головне значення аргументу (-π,+π] (кут, фаза) комплексного числа. </summary>
public double Arg
{
get { return System.Math.Atan2(Im, Re); }
set
{
var abs = Abs;
Re = abs * System.Math.Cos(value);
Im = abs * System.Math.Sin(value);
}
}
/// <summary> Добуток i на дане число. </summary>
public ComplexDouble MultipleI { get { return new ComplexDouble(-Im, Re); } }
/// <summary> Добуток -i на дане число. </summary>
public ComplexDouble DivideI { get { return new ComplexDouble(Im, -Re); } }
/// <param name="x"> Дійсна складова (x) комплексного числа. </param>
/// <param name="y"> Уявна складова (y) комплексного числа. </param>
public ComplexDouble(double x, double y) : this() { Re = x; Im = y; }
//public ComplexDouble(double abs, double arg) { Abs = abs; Arg = arg; }
// (±™©‰®π¬°№§√)
#region Методи предків System.(Object, IFormattable, IEquatable<ComplexDouble>)
/// <summary> Визначає чи рівні два числа. </summary>
/// <param name="other"> Комплексне число, яке порівнюється з даним. </param>
/// <returns> true - рівні, false - не рівні. </returns>
public bool Equals(ComplexDouble other) { return Re.Equals(other.Re) && Im.Equals(other.Im); }
public override bool Equals(object obj)
{
try { return Equals((ComplexDouble)obj); }
catch { return false; }
}
public override int GetHashCode() { return Re.GetHashCode() + Im.GetHashCode(); }
public override string ToString()
{
return Re + (Im < 0 ? " " : " +") + Im + 'i';
}
public string ToString(string format, System.IFormatProvider provider)
{
return Re.ToString(format, provider) + (Im < 0 ? " " : " +") + Im.ToString(format, provider) + 'i';
}
#endregion
//
#region Тригонометричні функції
public static ComplexDouble Exp(ComplexDouble z)
{
return System.Math.Exp(z.Re) * (new ComplexDouble(System.Math.Cos(z.Im), System.Math.Sin(z.Im)));
}
public static ComplexDouble Log(ComplexDouble z) { return Log(z, 0); }
public static ComplexDouble Log(ComplexDouble z, int k)
{
return new ComplexDouble(System.Math.Log(z.Abs), z.Arg + 2d * k * Pi);
}
public static ComplexDouble Log(ComplexDouble z, int kz, ComplexDouble a, int ka) { return Log(z, kz) / Log(a, ka); }
public static ComplexDouble Pow(ComplexDouble z, double n)
{
return System.Math.Pow(z.Abs, n) * new ComplexDouble(System.Math.Cos(z.Arg * n), System.Math.Sin(z.Arg * n));
}
public static ComplexDouble Pow(ComplexDouble z, ComplexDouble n) { return Pow(z, n, 0); }
public static ComplexDouble Pow(ComplexDouble z, ComplexDouble n, int k) { return Exp(n * Log(z, k)); }
public static ComplexDouble Sqrt(ComplexDouble z, int k) { return Pow(z, new ComplexDouble(0.5d, 0d), k); }
//
public static ComplexDouble Sin(ComplexDouble z) { return Sinh(z.MultipleI).DivideI; }
public static ComplexDouble Cos(ComplexDouble z) { return Cosh(z.MultipleI); }
public static ComplexDouble Tan(ComplexDouble z) { return Tanh(z.MultipleI).DivideI; }
public static ComplexDouble Cot(ComplexDouble z) { return Coth(z.MultipleI).MultipleI; }
public static ComplexDouble Sec(ComplexDouble z) { return Sech(z.MultipleI); }
public static ComplexDouble Csc(ComplexDouble z) { return Csch(z.MultipleI).MultipleI; }
public static ComplexDouble Sinh(ComplexDouble z) { return Sinh2(z) / 2d; }
public static ComplexDouble Sinh2(ComplexDouble z) { return (Exp(z) - Exp(-z)); }
public static ComplexDouble Cosh(ComplexDouble z) { return Cosh2(z) / 2d; }
public static ComplexDouble Cosh2(ComplexDouble z) { return (Exp(z) + Exp(-z)); }
public static ComplexDouble Tanh(ComplexDouble z) { return Sinh2(z) / Cosh2(z); }
public static ComplexDouble Coth(ComplexDouble z) { return Cosh2(z) / Sinh2(z); }
public static ComplexDouble Sech(ComplexDouble z) { return 2d / Cosh2(z); }
public static ComplexDouble Csch(ComplexDouble z) { return 2d / Sinh2(z); }
//
public static ComplexDouble Asin(ComplexDouble z, int kLog, int kSqrt) { return Asinh(z.MultipleI, kLog, kSqrt).DivideI; }
public static ComplexDouble Acos(ComplexDouble z, int kLog, int kSqrt) { return Acosh(z, kLog, kSqrt).DivideI; }
public static ComplexDouble Atan(ComplexDouble z, int kLog) { return Atanh(z.DivideI, kLog).MultipleI; }
public static ComplexDouble Acot(ComplexDouble z, int kLog) { return Atan(1d / z, kLog); }
public static ComplexDouble Asec(ComplexDouble z, int kLog, int kSqrt) { return Acos(1d / z, kLog, kSqrt); }
public static ComplexDouble Acsc(ComplexDouble z, int kLog, int kSqrt) { return Asin(1d / z, kLog, kSqrt); }
public static ComplexDouble Asinh(ComplexDouble z, int kLog, int kSqrt) { return Log(z + Sqrt(z * z + 1d, kSqrt), kLog); }
public static ComplexDouble Acosh(ComplexDouble z, int kLog, int kSqrt) { return Log(z + Sqrt(z * z - 1d, kSqrt), kLog); }
public static ComplexDouble Atanh(ComplexDouble z, int kLog) { return Log((1d + z) / (1d - z), kLog) / 2d; }
public static ComplexDouble Acoth(ComplexDouble z, int kLog) { return Atanh(1d / z, kLog); }
public static ComplexDouble Asech(ComplexDouble z, int kLog, int kSqrt) { return Acosh(1d / z, kLog, kSqrt); }
public static ComplexDouble Acsch(ComplexDouble z, int kLog, int kSqrt) { return Asinh(1d / z, kLog, kSqrt); }
#endregion
//
#region Оператори
/// <summary><returns> Спряжене комплексне число. </returns></summary>
public static ComplexDouble operator ~(ComplexDouble z) { return new ComplexDouble(z.Re, -z.Im); }
/// <summary><returns> Спряжене комплексне число. </returns></summary>
public static ComplexDouble operator !(ComplexDouble z) { return ~z; }
public static ComplexDouble operator ++(ComplexDouble z) { return new ComplexDouble(++z.Re, z.Im); }
public static ComplexDouble operator --(ComplexDouble z) { return new ComplexDouble(--z.Re, z.Im); }
public static ComplexDouble operator +(ComplexDouble z) { return z; }
public static ComplexDouble operator -(ComplexDouble z) { return new ComplexDouble(-z.Re, -z.Im); }
public static ComplexDouble operator +(ComplexDouble z1, ComplexDouble z2) { return new ComplexDouble(z1.Re + z2.Re, z1.Im + z2.Im); }
public static ComplexDouble operator -(ComplexDouble z1, ComplexDouble z2) { return z1 + -z2; }
public static ComplexDouble operator *(ComplexDouble z1, ComplexDouble z2) { return new ComplexDouble(z1.Re * z2.Re - z1.Im * z2.Im, z1.Re * z2.Im + z1.Im * z2.Re); }
public static ComplexDouble operator /(ComplexDouble z1, ComplexDouble z2) { return z1 * ~z2 / z2.SqrAbs; }
public static ComplexDouble operator %(ComplexDouble z1, ComplexDouble z2) { return new ComplexDouble(z1.Re % z2.Re, z1.Im % z2.Im); }
public static ComplexDouble operator +(ComplexDouble z1, double d2) { return z1 + new ComplexDouble(d2, 0d); }
public static ComplexDouble operator -(ComplexDouble z1, double d2) { return z1 + -d2; }
public static ComplexDouble operator *(ComplexDouble z1, double d2) { return new ComplexDouble(z1.Re * d2, z1.Im * d2); }
public static ComplexDouble operator %(ComplexDouble z1, double d2) { return z1 % new ComplexDouble(d2, 0d); }
public static ComplexDouble operator /(ComplexDouble z1, double d2) { return z1 * (1d / d2); }
public static ComplexDouble operator +(double d1, ComplexDouble z2) { return z2 + d1; }
public static ComplexDouble operator -(double d1, ComplexDouble z2) { return -z2 + d1; }
public static ComplexDouble operator *(double d1, ComplexDouble z2) { return z2 * d1; }
public static ComplexDouble operator /(double d1, ComplexDouble z2) { return new ComplexDouble(d1, 0d) / z2; }
public static ComplexDouble operator %(double d1, ComplexDouble z2) { return new ComplexDouble(d1, 0d) % z2; }
public static bool operator ==(ComplexDouble z1, ComplexDouble z2) { return z1.Equals(z2); }
public static bool operator !=(ComplexDouble z1, ComplexDouble z2) { return !z1.Equals(z2); }
public static explicit operator ComplexDouble(double d) { return new ComplexDouble(d, 0d); }
#endregion
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;*/
// ReSharper disable UnusedMember.Global
// ReSharper disable MemberCanBePrivate.Global
namespace ComplexConsole
{
/// <summary> Комплексне число (z = x+i*y), кожна складова (x,y) якого є double
/// (число подвійної точності з плаваючою точкою). </summary>
public struct ComplexDouble : System.IFormattable, System.IEquatable<ComplexDouble>
{
/// <summary> π=3.141592653589793238462643383279502884197169399311481966593000573842001111842089549379151. </summary>
public const double Pi = 3.141592653589793238462643383279502884197169399311481966593000573842001111842089549379151d;
/// <summary> Корінь квадратний від -1 (i=√-1, i*i=-1). </summary>
public static readonly ComplexDouble I = new ComplexDouble(0d, 1d);
/// <summary> Дійсна складова (x) комплексного числа. </summary>
public double Re { get; set; }
/// <summary> Уявна складова (y) комплексного числа. </summary>
public double Im { get; set; }
/// <summary> Модуль (√(x*x+y*y), абсолютне значення) комплексного числа. </summary>
public double Abs
{
get { return System.Math.Sqrt(SqrAbs); }
set { this *= value / Abs; }
}
/// <summary> Квадрат модуля (x*x+y*y) комплексного числа. </summary>
public double SqrAbs
{
get { return Re * Re + Im * Im; }
set { this *= System.Math.Sqrt(value / SqrAbs); }
}
/// <summary> Головне значення аргументу (-π,+π] (кут, фаза) комплексного числа. </summary>
public double Arg
{
get { return System.Math.Atan2(Im, Re); }
set
{
var abs = Abs;
Re = abs * System.Math.Cos(value);
Im = abs * System.Math.Sin(value);
}
}
/// <summary> Добуток i на дане число. </summary>
public ComplexDouble MultipleI { get { return new ComplexDouble(-Im, Re); } }
/// <summary> Добуток -i на дане число. </summary>
public ComplexDouble DivideI { get { return new ComplexDouble(Im, -Re); } }
/// <param name="x"> Дійсна складова (x) комплексного числа. </param>
/// <param name="y"> Уявна складова (y) комплексного числа. </param>
public ComplexDouble(double x, double y) : this() { Re = x; Im = y; }
//public ComplexDouble(double abs, double arg) { Abs = abs; Arg = arg; }
// (±™©‰®π¬°№§√)
#region Методи предків System.(Object, IFormattable, IEquatable<ComplexDouble>)
/// <summary> Визначає чи рівні два числа. </summary>
/// <param name="other"> Комплексне число, яке порівнюється з даним. </param>
/// <returns> true - рівні, false - не рівні. </returns>
public bool Equals(ComplexDouble other) { return Re.Equals(other.Re) && Im.Equals(other.Im); }
public override bool Equals(object obj)
{
try { return Equals((ComplexDouble)obj); }
catch { return false; }
}
public override int GetHashCode() { return Re.GetHashCode() + Im.GetHashCode(); }
public override string ToString()
{
return Re + (Im < 0 ? " " : " +") + Im + 'i';
}
public string ToString(string format, System.IFormatProvider provider)
{
return Re.ToString(format, provider) + (Im < 0 ? " " : " +") + Im.ToString(format, provider) + 'i';
}
#endregion
//
#region Тригонометричні функції
public static ComplexDouble Exp(ComplexDouble z)
{
return System.Math.Exp(z.Re) * (new ComplexDouble(System.Math.Cos(z.Im), System.Math.Sin(z.Im)));
}
public static ComplexDouble Log(ComplexDouble z) { return Log(z, 0); }
public static ComplexDouble Log(ComplexDouble z, int k)
{
return new ComplexDouble(System.Math.Log(z.Abs), z.Arg + 2d * k * Pi);
}
public static ComplexDouble Log(ComplexDouble z, int kz, ComplexDouble a, int ka) { return Log(z, kz) / Log(a, ka); }
public static ComplexDouble Pow(ComplexDouble z, double n)
{
return System.Math.Pow(z.Abs, n) * new ComplexDouble(System.Math.Cos(z.Arg * n), System.Math.Sin(z.Arg * n));
}
public static ComplexDouble Pow(ComplexDouble z, ComplexDouble n) { return Pow(z, n, 0); }
public static ComplexDouble Pow(ComplexDouble z, ComplexDouble n, int k) { return Exp(n * Log(z, k)); }
public static ComplexDouble Sqrt(ComplexDouble z, int k) { return Pow(z, new ComplexDouble(0.5d, 0d), k); }
//
public static ComplexDouble Sin(ComplexDouble z) { return Sinh(z.MultipleI).DivideI; }
public static ComplexDouble Cos(ComplexDouble z) { return Cosh(z.MultipleI); }
public static ComplexDouble Tan(ComplexDouble z) { return Tanh(z.MultipleI).DivideI; }
public static ComplexDouble Cot(ComplexDouble z) { return Coth(z.MultipleI).MultipleI; }
public static ComplexDouble Sec(ComplexDouble z) { return Sech(z.MultipleI); }
public static ComplexDouble Csc(ComplexDouble z) { return Csch(z.MultipleI).MultipleI; }
public static ComplexDouble Sinh(ComplexDouble z) { return Sinh2(z) / 2d; }
public static ComplexDouble Sinh2(ComplexDouble z) { return (Exp(z) - Exp(-z)); }
public static ComplexDouble Cosh(ComplexDouble z) { return Cosh2(z) / 2d; }
public static ComplexDouble Cosh2(ComplexDouble z) { return (Exp(z) + Exp(-z)); }
public static ComplexDouble Tanh(ComplexDouble z) { return Sinh2(z) / Cosh2(z); }
public static ComplexDouble Coth(ComplexDouble z) { return Cosh2(z) / Sinh2(z); }
public static ComplexDouble Sech(ComplexDouble z) { return 2d / Cosh2(z); }
public static ComplexDouble Csch(ComplexDouble z) { return 2d / Sinh2(z); }
//
public static ComplexDouble Asin(ComplexDouble z, int kLog, int kSqrt) { return Asinh(z.MultipleI, kLog, kSqrt).DivideI; }
public static ComplexDouble Acos(ComplexDouble z, int kLog, int kSqrt) { return Acosh(z, kLog, kSqrt).DivideI; }
public static ComplexDouble Atan(ComplexDouble z, int kLog) { return Atanh(z.DivideI, kLog).MultipleI; }
public static ComplexDouble Acot(ComplexDouble z, int kLog) { return Atan(1d / z, kLog); }
public static ComplexDouble Asec(ComplexDouble z, int kLog, int kSqrt) { return Acos(1d / z, kLog, kSqrt); }
public static ComplexDouble Acsc(ComplexDouble z, int kLog, int kSqrt) { return Asin(1d / z, kLog, kSqrt); }
public static ComplexDouble Asinh(ComplexDouble z, int kLog, int kSqrt) { return Log(z + Sqrt(z * z + 1d, kSqrt), kLog); }
public static ComplexDouble Acosh(ComplexDouble z, int kLog, int kSqrt) { return Log(z + Sqrt(z * z - 1d, kSqrt), kLog); }
public static ComplexDouble Atanh(ComplexDouble z, int kLog) { return Log((1d + z) / (1d - z), kLog) / 2d; }
public static ComplexDouble Acoth(ComplexDouble z, int kLog) { return Atanh(1d / z, kLog); }
public static ComplexDouble Asech(ComplexDouble z, int kLog, int kSqrt) { return Acosh(1d / z, kLog, kSqrt); }
public static ComplexDouble Acsch(ComplexDouble z, int kLog, int kSqrt) { return Asinh(1d / z, kLog, kSqrt); }
#endregion
//
#region Оператори
/// <summary><returns> Спряжене комплексне число. </returns></summary>
public static ComplexDouble operator ~(ComplexDouble z) { return new ComplexDouble(z.Re, -z.Im); }
/// <summary><returns> Спряжене комплексне число. </returns></summary>
public static ComplexDouble operator !(ComplexDouble z) { return ~z; }
public static ComplexDouble operator ++(ComplexDouble z) { return new ComplexDouble(++z.Re, z.Im); }
public static ComplexDouble operator --(ComplexDouble z) { return new ComplexDouble(--z.Re, z.Im); }
public static ComplexDouble operator +(ComplexDouble z) { return z; }
public static ComplexDouble operator -(ComplexDouble z) { return new ComplexDouble(-z.Re, -z.Im); }
public static ComplexDouble operator +(ComplexDouble z1, ComplexDouble z2) { return new ComplexDouble(z1.Re + z2.Re, z1.Im + z2.Im); }
public static ComplexDouble operator -(ComplexDouble z1, ComplexDouble z2) { return z1 + -z2; }
public static ComplexDouble operator *(ComplexDouble z1, ComplexDouble z2) { return new ComplexDouble(z1.Re * z2.Re - z1.Im * z2.Im, z1.Re * z2.Im + z1.Im * z2.Re); }
public static ComplexDouble operator /(ComplexDouble z1, ComplexDouble z2) { return z1 * ~z2 / z2.SqrAbs; }
public static ComplexDouble operator %(ComplexDouble z1, ComplexDouble z2) { return new ComplexDouble(z1.Re % z2.Re, z1.Im % z2.Im); }
public static ComplexDouble operator +(ComplexDouble z1, double d2) { return z1 + new ComplexDouble(d2, 0d); }
public static ComplexDouble operator -(ComplexDouble z1, double d2) { return z1 + -d2; }
public static ComplexDouble operator *(ComplexDouble z1, double d2) { return new ComplexDouble(z1.Re * d2, z1.Im * d2); }
public static ComplexDouble operator %(ComplexDouble z1, double d2) { return z1 % new ComplexDouble(d2, 0d); }
public static ComplexDouble operator /(ComplexDouble z1, double d2) { return z1 * (1d / d2); }
public static ComplexDouble operator +(double d1, ComplexDouble z2) { return z2 + d1; }
public static ComplexDouble operator -(double d1, ComplexDouble z2) { return -z2 + d1; }
public static ComplexDouble operator *(double d1, ComplexDouble z2) { return z2 * d1; }
public static ComplexDouble operator /(double d1, ComplexDouble z2) { return new ComplexDouble(d1, 0d) / z2; }
public static ComplexDouble operator %(double d1, ComplexDouble z2) { return new ComplexDouble(d1, 0d) % z2; }
public static bool operator ==(ComplexDouble z1, ComplexDouble z2) { return z1.Equals(z2); }
public static bool operator !=(ComplexDouble z1, ComplexDouble z2) { return !z1.Equals(z2); }
public static explicit operator ComplexDouble(double d) { return new ComplexDouble(d, 0d); }
#endregion
}
}
Step 1
ОбЪявить события pictureBox1_Pain
Код:
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
}
{
}
Cut code из button1_Click_1
Step 3
Paste code в pictureBox1_Paint
Код:
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
//Ваш код из button1_Click_1
}
{
//Ваш код из button1_Click_1
}
Paste next string button1_Click_1
Код:
private void button1_Click_1(object sender, EventArgs e)
{
// Connect the Paint event of the PictureBox to the event handler method.
pictureBox1.Paint -= new System.Windows.Forms.PaintEventHandler(this.pictureBox1_Paint);
pictureBox1.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBox1_Paint);
// Управляющие данные графиком
}
{
// Connect the Paint event of the PictureBox to the event handler method.
pictureBox1.Paint -= new System.Windows.Forms.PaintEventHandler(this.pictureBox1_Paint);
pictureBox1.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBox1_Paint);
// Управляющие данные графиком
}