Exemple #1
0
 public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
 {
     if (value != null)
     {
         V4DataOnGrid items = (V4DataOnGrid)value;
         if (items.array.Length != 0)
         {
             double max = items.array[0, 0].Magnitude;
             double min = items.array[0, 0].Magnitude;
             foreach (var item in items)
             {
                 if (item.compl.Magnitude > max)
                 {
                     max = item.compl.Magnitude;
                 }
                 if (item.compl.Magnitude < min)
                 {
                     min = item.compl.Magnitude;
                 }
             }
             return("Max abs: " + max + "\nMin abs: " + min);
         }
     }
     return("");
 }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value as V4DataOnGrid == null)
            {
                return(value?.ToString());
            }
            if (parameter as int? == null)
            {
                return("parameter error : " + parameter?.ToString() + " (" + parameter?.GetType() + ")");
            }
            int          param = (int)parameter;
            V4DataOnGrid data  = (V4DataOnGrid)value;
            double       returned;

            if (param < 0)
            // Output min
            {
                returned = data.Aggregate((max, v) => v.electromagnet_field.Magnitude > max.electromagnet_field.Magnitude ? v : max).electromagnet_field.Magnitude;
                return(returned.ToString() + " - max magn");
            }
            else
            // Output max
            {
                returned = data.Aggregate((min, v) => v.electromagnet_field.Magnitude < min.electromagnet_field.Magnitude ? v : min).electromagnet_field.Magnitude;
                return(returned.ToString() + " - min magn");
            }
        }
Exemple #3
0
        private void Add_Default_V4DataOnGrid_Click(object sender, RoutedEventArgs e)
        {
            Grid2D gr = new Grid2D(1, 2, 3, 5);

            V4DataOnGrid item = new V4DataOnGrid("random V4DOG", 8d, gr);

            item.InitRandom(1, 9);
            V4MC.Add(item);
        }
Exemple #4
0
 private void Item_DefaultGrid_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         var          rand = new Random();
         V4DataOnGrid coll = new V4DataOnGrid("default DataOnGrid", 12.3, new Grid2D((float)rand.NextDouble() * 5, 4, (float)rand.NextDouble() * 5, 4));
         coll.InitRandom(0, 1);
         MainColl.Add(coll);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Item_DefaultGrid_Click \n" + ex.Message);
     }
 }
 private void Add_Element_from_File_Click(object sender, RoutedEventArgs e)
 {
     Microsoft.Win32.OpenFileDialog dialog = new Microsoft.Win32.OpenFileDialog();
     if (dialog.ShowDialog() == true)
     {
         try
         {
             V4DataOnGrid DataOnGrid_Item = new V4DataOnGrid("Item from the file", 2, dialog.FileName);
             V4Item.Add(DataOnGrid_Item);
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
 public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
 {
     if (value != null)
     {
         V4DataOnGrid item = (V4DataOnGrid)value;
         double min = Complex.Abs(item.values[0, 0]);
         double max = Complex.Abs(item.values[0, 0]);
         for (int i = 0; i < item.grid.num_Ox; i++)
             for (int j = 0; j < item.grid.num_Oy; j++)
             {
                 if (Complex.Abs(item.values[i, j]) < min)
                     min = Complex.Abs(item.values[i, j]);
                 if (Complex.Abs(item.values[i, j]) > max)
                     max = Complex.Abs(item.values[i, j]);
             }
         return "Max Abs Value: " + max + " Min Abs Value: " + min;
     }
     else
         return "";
 }