using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
namespace AggregateLibrary.UserControls
{
public partial class UserControlHarmonics : UserControl
{
private ElasticConsole console;
private double[][] harm = new double[0][];
private double[] inc = new double[0];
public UserControlHarmonics()
{
InitializeComponent();
}
internal ElasticConsole Console
{
get
{
return console;
}
set
{
console = value;
Fill();
}
}
internal void Update()
{
dataGridViewHarm.CommitEdit(DataGridViewDataErrorContexts.Commit);
int n = dataTableHarm.Rows.Count;
inc = new double[2 * n];
harm = new double[n][];
for (int i = 0; i < n; i++)
{
double[] hh = new double[15];
DataRow row = dataTableHarm.Rows[i]; //dataGridViewHarm.Rows[i];
for (int j = 0; j < hh.Length; j++)
{
hh[j] = (double)row[j];
}
for (int j = 0; j < 2; j++)
{
inc[2 * i + j] = (double)row[15 + j];
}
harm[i] = hh;
}
//console.Harmonics = harm;
//Array.Copy(h, 0, console.InitialState, 13, h.Length);
}
internal double[][] Harmonics
{
get
{
return harm;
}
}
internal double[] Initial
{
get
{
return inc;
}
}
void Fill()
{
if (console == null)
{
return;
}
//dataGridViewHarm.Rows.Clear();
double[][] harm = console.Harmonics;
for (int i = 0; i < harm.Length; i++)
{
object[] o = new object[17];
double[] h = harm[i];
for (int j = 0; j < h.Length; j++)
{
o[j] = h[j];
}
for (int j = 0; j < 2; j++)
{
o[j + 15] = console.InitialState[j + 13 + 2 * i];
}
dataTableHarm.Rows.Add(o);
}
}
private void dataGridViewHarm_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
{
// int k =
}
}
}