public CustomDataCollection(V3DataCollection collect_) { collect = collect_; x = 0; y = 0; val = 0; }
public override string ToLongString() { string res = this.ToString(); foreach (DataItem cur in collect) { res += '\n' + cur.ToString(); } return(res); }
static void Main(string[] args) { Grid1D temp1 = new Grid1D(0.5f, 5); Grid1D temp2 = new Grid1D(0.4f, 4); DateTime date1 = new DateTime(2020, 10, 21); V3DataOnGrid obj1 = new V3DataOnGrid("1111", date1, temp1, temp2); obj1.array = new double[2, 3]; obj1.InitRandom(4.5, 6.1); Console.WriteLine(obj1.ToLongString()); Console.WriteLine(); V3DataCollection obj2 = (V3DataCollection)obj1; Console.WriteLine(obj2.ToLongString()); Console.WriteLine(); V3MainCollection obj3 = new V3MainCollection(); obj3.AddDefaults(); Console.WriteLine(obj3.ToString()); int number = 1; Vector2 v = new Vector2(1, 2); foreach (V3Data data in obj3) { Console.WriteLine(); Console.WriteLine($"Nearest for an element №{number} in V3MainCollection"); Vector2[] res = data.Nearest(v); for (int i = 0; i < res.Length; i++) { Console.WriteLine(res[i]); } number++; } Console.ReadKey(); }
private void CommandBinding_AddDataItem(object sender, ExecutedRoutedEventArgs e) { V3DataCollection col = (V3DataCollection)V3DataColElements.SelectedItem; DataItem item = new DataItem(new System.Numerics.Vector2(float.Parse(XCoordTextBox.Text), float.Parse(YCoordTextBox.Text)), double.Parse(ModuleTextBox.Text)); col.Add(item); currentCol.IsChanged = true; currentCol.Save("temp"); currentCol.Load("temp"); System.IO.File.Delete("temp"); }
private void AddDefaultsV3DataCollection_Click(object sender, RoutedEventArgs e) { V3DataCollection item = new V3DataCollection("default", new DateTime()); item.InitRandom(5, 10.0f, 10.0f, 0.0f, 0.0f); try { collection.Add(item); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void AddDefaultV3DataCollection(object sender, RoutedEventArgs args) { try { if (currentCol == null) { MessageBox.Show("Сначала создайте коллекцию.", "Ошибка."); return; } V3DataCollection col = new V3DataCollection("Base", DateTime.Now); currentCol.Add(col); } catch { MessageBox.Show("Не удалось добавить элемент в коллекцию.", "Ошибка."); } }
private void AddElementFromFile_Click(object sender, RoutedEventArgs e) { Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); try { if (dlg.ShowDialog() == true) { V3DataCollection item = new V3DataCollection(dlg.FileName); collection.Add(item); } } catch (Exception ex) { string output = "При открытии файла или создании объекта V3DataCollection проиозшла ошибка и было брошено исключение. Причина: \n" + ex.Message; MessageBox.Show(output); } }
private void AddFromFile(object sender, RoutedEventArgs args) { try { if (currentCol == null) { MessageBox.Show("Сначала создайте новую коллекцию.", "Ошибка."); return; } Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); if (dlg.ShowDialog() == true) { V3DataCollection col = new V3DataCollection(dlg.FileName); currentCol.Add(col); } } catch { MessageBox.Show("Ошибка при чтении из файла.", "Ошибка."); } }
static int Main() { try { V3MainCollection example = new V3MainCollection(); example.DataChanged += V3MainCollectionChangedHandler; V3DataOnGrid don1 = new V3DataOnGrid(new Grid1D(5.0f, 0), new Grid1D(5.0f, 0), "a", new DateTime(2020, 11, 20)); V3DataCollection dc1 = new V3DataCollection("a", new DateTime(2020, 11, 20)); V3DataOnGrid don2 = new V3DataOnGrid(new Grid1D(0.5f, 6), new Grid1D(0.5f, 6), "aa", new DateTime(2020, 11, 20)); don2.InitRandom(0.0f, 1.0f); example.add(don1); example.add(dc1); example.add(don2); example[0] = dc1; example.Remove("aa", new DateTime(2020, 11, 20)); example[1].Str = "new_value_of_test_string"; } catch (Exception ex) { Console.WriteLine(ex); } return(0); }
static int Main() { try { V3DataOnGrid dog = new V3DataOnGrid(new Grid1D(0.5f, 5), new Grid1D(0.6f, 3), "first_example", new DateTime(2020, 10, 10)); dog.InitRandom(0.0f, 10.0f); Console.WriteLine(dog.ToLongString()); V3DataCollection dc = (V3DataCollection)dog; Console.WriteLine(dc.ToLongString()); V3DataCollection test = new V3DataCollection("../../test.txt"); Console.WriteLine(test.ToLongString("F4")); V3MainCollection mc = new V3MainCollection(); mc.AddDefaults(); Console.WriteLine(mc.ToString()); Console.WriteLine("max_count: " + mc.max_count.ToString()); Console.WriteLine("max_distance: " + mc.max_distance.ToString()); var high_freq = (from dataitem in mc.high_freq_DataItem select dataitem.ToString()); string res = ""; foreach (DataItem dataitem in mc.high_freq_DataItem) { res += dataitem.ToString() + "\n"; } Console.WriteLine("high_freq_DataItem: " + res); Console.WriteLine("______\n"); foreach (DataItem dataitem in dc) { Console.WriteLine(dataitem.ToString() + "\n"); } Console.WriteLine("_____\n"); } catch (Exception ex) { Console.WriteLine(ex); } return(0); }
public CustomDataItem(V3DataCollection col) { this.col = col; }