private void btnDone_Click(object sender, System.EventArgs e) { this.StartStop.Enabled = true; this.btnDone.Enabled = false; this.btnSave.Enabled = true; this.btnLoad.Enabled = true; panel1.Paint -= new PaintEventHandler(panel1_PaintCenter); panel1.Invalidate(); ArrayList neighborhood = new ArrayList(); foreach (Cell cell in cells) { if ((cell.Color == Color.Crimson) && !((cell.X == cells[cellsWide / 2, cellsHigh / 2].X) && (cell.Y == cells[cellsWide / 2, cellsHigh / 2].Y)) ) { neighborhood.Add(new Position( (cell.X / cellSize) - (cells[cellsWide / 2, cellsHigh / 2].X / cellSize), (cell.Y / cellSize) - (cells[cellsWide / 2, cellsHigh / 2].Y / cellSize) )); } } this.IgnoreClicks = true; crntStatesOutput = new StatesOutput(neighborhood.Count); crntStatesOutput.ShowDialog(); if (crntStatesOutput.ActivationValues != null) { modeling.RequestAutomaton( neighborhood, crntStatesOutput.ActivationValues, crntStatesOutput.NeighborWeight, crntStatesOutput.CenterWeight ); } this.IgnoreClicks = false; this.StartStop.Enabled = true; this.btnDone.Enabled = false; this.btnCurrentAuto.Enabled = true; this.automaton.Enabled = true; this.Focus(); }
private void btnCurrentAuto_Click(object sender, System.EventArgs e) { this.StartStop.Enabled = false; this.StartStop.Text = "Start"; modeling.RequestPause(); panel1.Paint += new PaintEventHandler(panel1_PaintCenter); panel1.Invalidate(); foreach (Cell cell in cells) { modeling.RequestUpdate( new Position(cell.X / cellSize, cell.Y / cellSize), false); } modeling.RequestActivateNeighbors( new Position( cells[cellsWide / 2, cellsHigh / 2].X / cellSize, cells[cellsWide / 2, cellsHigh / 2].Y / cellSize ) ); ArrayList neighborhood = new ArrayList(); foreach (Cell cell in cells) { if ((cell.Color == Color.Crimson) && !((cell.X == cells[cellsWide / 2, cellsHigh / 2].X) && (cell.Y == cells[cellsWide / 2, cellsHigh / 2].Y)) ) { neighborhood.Add(new Position( (cell.X / cellSize) - (cells[cellsWide / 2, cellsHigh / 2].X / cellSize), (cell.Y / cellSize) - (cells[cellsWide / 2, cellsHigh / 2].Y / cellSize) )); } } this.IgnoreClicks = true; Node node = modeling.GetNode(0); double nodeCenterWeight = 0D; double nodeNWeight = 0D; foreach (Link link in node.links) { if (link.Destin.Equals(node)) { nodeCenterWeight = link.Weight; } else { nodeNWeight = link.Weight; } } crntStatesOutput = new StatesOutput( neighborhood.Count, nodeNWeight, nodeCenterWeight, modeling.ActivationValues); crntStatesOutput.ShowDialog(); if (crntStatesOutput.ActivationValues != null) { modeling.RequestAutomaton( neighborhood, crntStatesOutput.ActivationValues, crntStatesOutput.NeighborWeight, crntStatesOutput.CenterWeight ); } this.IgnoreClicks = false; panel1.Paint -= new PaintEventHandler(panel1_PaintCenter); panel1.Invalidate(); this.StartStop.Enabled = true; this.btnDone.Enabled = false; this.Focus(); }