private void pictureBox1_MouseClick(object sender, MouseEventArgs e) { MyPoint mp; if (e.Button == System.Windows.Forms.MouseButtons.Left) { //синий круг 1 mp = new MyPoint(e.X - x0, y0 - e.Y, 1); } else { //красный круг -1 mp = new MyPoint(e.X - x0, y0 - e.Y, -1); } listPoints.Add(mp); // isCanChange = true; isCanChange = false; Thread.Sleep(200); int[] size = new int[2]; size[0] = 2; size[1] = 2; //nn = new NN(0.001, size); nn = new NeuroNet(0.01, size); isCanChange = true; if (th == null) { th = new Thread(Learning); th.Start(); } }
private void загрузитьToolStripMenuItem_Click(object sender, EventArgs e) { isCanChange = false; Thread.Sleep(200); BinaryFormatter formatter = new BinaryFormatter(); // десериализация из файла people.dat using (FileStream fs = new FileStream("NeuroNetwork.dat", FileMode.OpenOrCreate)) { nn = (NeuroNet)formatter.Deserialize(fs); } bm.Dispose(); bm = new Bitmap(sizeX, sizeY); graphics = Graphics.FromImage(bm); pictureBox1.Image = (Image)bm; listPoints.Clear(); isCanChange = true; }
private void pictureBox1_MouseClick(object sender, MouseEventArgs e) { if (th == null) { int[] size = new int[3]; size[0] = 3; size[1] = 3; size[2] = 2; nn = new NeuroNet(0.01, size, fAct); sizeX = pictureBox1.Width; sizeY = pictureBox1.Height; bm = new Bitmap(sizeX, sizeY); graphics = Graphics.FromImage(bm); x0 = (double)sizeX / 2; y0 = (double)sizeY / 2; } MyPoint mp; if (e.Button == System.Windows.Forms.MouseButtons.Left) { //синий круг 1 mp = new MyPoint((e.X - x0) / x0, (y0 - e.Y) / y0, 1); } else { //красный круг -1 mp = new MyPoint((e.X - x0) / x0, (y0 - e.Y) / y0, -1); } listPoints.Add(mp); if (th == null) { th = new Thread(Learning); th.Start(); isCanChange = true; } }