- #1
DivergentSpectrum
- 149
- 15
Hi, I am working on an n-body solver.
The previous window got the variable "numpart" (number of particles), and then this current window displays 7 times numpart textboxes, for input on the position and velocity and mass.
the items
xcoord
ycoord
zcoord
xvel
yvel
zvel
mass
are all arrays of textboxes, and normally id use mass.Text to get the string value of mass, but when theyre arrays i get a lot of errorsI used an the event handler "calculate" , which is activated when a button is clicked, and where you see the ? i have no idea what to doto simplify my question, I am trying to open a new window with parameters, and the parameters are arrays.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Wpftrajectory
{
/// <summary>
/// Interaction logic for Infogetter.xaml
/// </summary>
public partial class Infogetter : Window
{
public Infogetter(String numberit, String endt, String numpart)
{
InitializeComponent();
TextBox[] xcoord = new TextBox[Convert.ToInt32(numpart)];
TextBox[] ycoord = new TextBox[Convert.ToInt32(numpart)];
TextBox[] zcoord = new TextBox[Convert.ToInt32(numpart)];
TextBox[] xvel = new TextBox[Convert.ToInt32(numpart)];
TextBox[] yvel = new TextBox[Convert.ToInt32(numpart)];
TextBox[] zvel = new TextBox[Convert.ToInt32(numpart)];
TextBox[] mass = new TextBox[Convert.ToInt32(numpart)];
int i = 0;
while(i<Convert.ToInt32(numpart))
{
xcoord[i]=new TextBox();
ycoord[i] = new TextBox();
zcoord[i] = new TextBox();
xvel[i] = new TextBox();
yvel[i] = new TextBox();
zvel[i] = new TextBox();
mass[i] = new TextBox();
xcoord[i].Width=120;
xcoord[i].Height=20;
ycoord[i].Width=120;
ycoord[i].Height=20;
zcoord[i].Width=120;
zcoord[i].Height=20;
xvel[i].Width=120;
xvel[i].Height=20;
yvel[i].Width=120;
yvel[i].Height=20;
zvel[i].Width=120;
zvel[i].Height=20;
mass[i].Width = 120;
mass[i].Height = 20;
canvas.Children.Add(xcoord[i]);
canvas.Children.Add(ycoord[i]);
canvas.Children.Add(zcoord[i]);
canvas.Children.Add(xvel[i]);
canvas.Children.Add(yvel[i]);
canvas.Children.Add(zvel[i]);
canvas.Children.Add(mass[i]);
xcoord[i].Margin = new Thickness(0,25 * i ,0,0);
ycoord[i].Margin = new Thickness(125,25 * i ,0,0);
zcoord[i].Margin = new Thickness(250,25 * i,0,0);
xvel[i].Margin = new Thickness(375,25 * i ,0,0);
yvel[i].Margin = new Thickness(500,25 * i ,0,0);
zvel[i].Margin = new Thickness(625,25 * i ,0,0);
mass[i].Margin = new Thickness(750,25*i,0,0);
i++;
}
}
public void calculate(object sender, RoutedEventArgs e)
{
DisplayWindow displaywindow= new DisplayWindow(? );
displaywindow.Show();
}
} }
}
The previous window got the variable "numpart" (number of particles), and then this current window displays 7 times numpart textboxes, for input on the position and velocity and mass.
the items
xcoord
ycoord
zcoord
xvel
yvel
zvel
mass
are all arrays of textboxes, and normally id use mass.Text to get the string value of mass, but when theyre arrays i get a lot of errorsI used an the event handler "calculate" , which is activated when a button is clicked, and where you see the ? i have no idea what to doto simplify my question, I am trying to open a new window with parameters, and the parameters are arrays.
Last edited: