public V4DataCollection(string filename) : base("", 0) { FileStream fs = null; V4DataCollection dataSet = null; string[] vectInfo; Dictionary <Vector2, Complex> dict_new = new Dictionary <Vector2, Complex>(); try { fs = new FileStream(filename, FileMode.Open); StreamReader istream = new StreamReader(fs); string parsingArg = istream.ReadLine(); if (parsingArg == null) { throw new Exception("no measure\n"); } string measures = parsingArg; parsingArg = istream.ReadLine(); if (parsingArg == null) { throw new Exception("no freq info\n"); } double frequency = Convert.ToDouble(parsingArg); while ((parsingArg = istream.ReadLine()) != null) { vectInfo = parsingArg.Split(' '); if (vectInfo.Length != 4) { throw new Exception("length problem\n"); } dict_new.Add(new Vector2(Convert.ToSingle(vectInfo[0]), Convert.ToSingle(vectInfo[1])), new Complex(Convert.ToDouble(vectInfo[2]), Convert.ToDouble(vectInfo[3]))); } measures_info = measures; frequency_info = frequency; } catch (Exception e) { dataSet = null; System.Console.WriteLine("Parse error"); System.Console.WriteLine(e.Message); throw e; } finally { if (fs != null) { fs.Close(); } } dict = dict_new; }
public void AddDefaults() { Random rnd = new Random(); Grid2D just_object = new Grid2D((float)2.1, 4, (float)2.1, 4); V4DataOnGrid onGrid_object = new V4DataOnGrid("grid" + rnd.Next().ToString(), 2.3, just_object); V4DataCollection collection_object = new V4DataCollection("collection" + rnd.Next().ToString(), 2.3); int number_of_new_objects = 5; double minVal = 12.0; double maxVal = 24.0; for (int i = 0; i < 1; i++) { onGrid_object.InitRandom(minVal, maxVal); collection_object.InitRandom(number_of_new_objects, (float)rnd.NextDouble(), (float)rnd.NextDouble(), minVal, maxVal); list.Add(onGrid_object); list.Add(collection_object); CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); } }