Exemplo n.º 1
0
 public MapAdder(int sx, int sy)
 {
     sizeX = sx;
     sizeY = sy;
     Map   = new double[sizeX][];
     for (int x = 0; x < sizeX; x++)
     {
         Map[x] = new double[sizeY];
     }
     generationStatistics = new GenerationStatistics();
 }
Exemplo n.º 2
0
        public void OnClick(List <Label> labelList, List <NumericUpDown> numericList,
                            string choise, string path)
        {
            var labesText = labelList.Skip(4).Select(lab1 => lab1.Text);
            var list      = numericList.Skip(4).Select(el => (int)el.Value).ToList();
            var resD      = labesText.Zip(list, (w1, w2) => (w1, w2))
                            .ToDictionary(p => p.w1, p => p.w2);
            var names = generatorsNamesParameters[choise];
            var f     = container.Get <IGeneratorFactory>();

            try
            {
                var width  = (int)(numericList[0].Value);
                var height = (int)numericList[1].Value;
                var n      = (int)numericList[2].Value;
                var coeff  = (int)numericList[3].Value;
                var name   = choise;
                var gen    = f.CreateGenerator(name);
                var prop   = gen
                             .GetType()
                             .GetProperties()
                             .Where(p => !p.IsPrivate())
                             .Where(fld => names.Contains(fld.Name));
                foreach (var pr in prop)
                {
                    pr.SetValue(gen, resD[pr.Name]);
                }
                string res;
                if (mapAdder == null)
                {
                    Program.GenerateHeightMapPic(gen, width, height, false, path);
                    var gs = new GenerationStatistics();
                    res = gs.GetStatistics(gen, n, width, height);
                }
                else
                {
                    mapAdder.Add(gen.GetMap(width, height), coeff, gen, n);
                    Program.ResultHeightMapPic(mapAdder.Map, width, height, false, path);
                    res = mapAdder.generationStatistics.TimeMeasurer.sv.ToDetailedString();
                    Console.WriteLine(res);
                }
                GetOnlyLabel("STATISTICS\n" + res);
            }
            catch (ArgumentException e)
            {
                GetOnlyLabel("ERROR\n" + e.Message.ToString());
            }
        }