public StatesOutput(int neighborhoodSize, double nWeight, double cWeight, ArrayList activationValues) { this.activationValues = activationValues; Console.WriteLine( "neighborhoodsize in StatesOutput constructor: {0}", neighborhoodSize); // // Required for Windows Form Designer support // InitializeComponent(); stateRules = new ArrayList(); NeighborWeight = nWeight; CenterWeight = cWeight; bool isOuter = false; if (cWeight == .04D) { isOuter = true; } for (int i = 0; i <= neighborhoodSize; ++i) { StateRule stateRule = new StateRule(i, isOuter, false); stateRules.Add(stateRule); foreach (double actVal in activationValues) { if ( Math.Abs(actVal - (((double)i) * this.NeighborWeight)) <= (0.0001D)) { stateRule.ResultIsAlive = true; } } if (Math.Abs(CenterWeight - .04D) <= (0.0001D)) { stateRule = new StateRule(i, isOuter, true); stateRules.Add(stateRule); foreach (double actVal in activationValues) { double linksSummation = ((double)i) * this.NeighborWeight + this.CenterWeight; if (Math.Abs(actVal - linksSummation) <= (0.00001D)) { stateRule.ResultIsAlive = true; } } } Console.WriteLine("i in States add is {0}", i); Console.WriteLine( "neighborhoodsize in States add: {0}", neighborhoodSize); } this.SuspendLayout(); int j = 0; foreach (StateRule stateRule in stateRules) { Console.WriteLine("j in States attributes is {0}", j); stateRule.Location = new System.Drawing.Point(0, 32 * j); stateRule.Name = "stateRule" + 1; //stateRule.Size = new System.Drawing.Size(400, 32); stateRule.TabIndex = j; panel1.Controls.Add(stateRule); stateRule.result.CheckedChanged += new EventHandler(outputChange); ++j; } int calculatedHeight = ((StateRule)stateRules[1]).Size.Height * (neighborhoodSize + 1) * (isOuter?2:1); if (calculatedHeight < 600) { panel1.Size = new Size(416, calculatedHeight); } else { panel1.Size = new Size(416, 600); } this.ClientSize = new System.Drawing.Size( panel1.Size.Width + panel1.Location.X * 2, panel1.Size.Height + panel1.Location.Y); this.ResumeLayout(false); }
public StatesOutput() { int neighborhoodSize = 8; Console.WriteLine( "neighborhoodsize in StatesOutput constructor: {0}", neighborhoodSize); // // Required for Windows Form Designer support // InitializeComponent(); stateRules = new ArrayList(); bool isOuter = true; for (int i = 0; i <= neighborhoodSize; ++i) { StateRule stateRule = new StateRule(i, isOuter, false); if (i == 3) { stateRule.ResultIsAlive = true; } stateRules.Add(stateRule); if (isOuter) { stateRule = new StateRule(i, isOuter, true); if (i == 2 || i == 3) { stateRule.ResultIsAlive = true; } stateRules.Add(stateRule); } Console.WriteLine("i in States add is {0}", i); Console.WriteLine("neighborhoodsize in States add: {0}", neighborhoodSize); } if (isOuter) { CenterWeight = .04D; } else { CenterWeight = .0D; } NeighborWeight = .12D; this.SuspendLayout(); int j = 0; foreach (StateRule stateRule in stateRules) { Console.WriteLine("j in States attributes is {0}", j); stateRule.Location = new System.Drawing.Point(0, 32 * j); stateRule.Name = "stateRule" + 1; stateRule.TabIndex = j; panel1.Controls.Add(stateRule); stateRule.result.CheckedChanged += new EventHandler(outputChange); ++j; } int calculatedHeight = ((StateRule)stateRules[1]).Size.Height * (neighborhoodSize + 1) * (isOuter?2:1); if (calculatedHeight < 600) { panel1.Size = new Size(416, calculatedHeight); } else { panel1.Size = new Size(416, 600); } this.ClientSize = new System.Drawing.Size( panel1.Size.Width + panel1.Location.X * 2, panel1.Size.Height + panel1.Location.Y); this.ResumeLayout(false); }