private void commandGuideToolStripMenuItem_Click(object sender, EventArgs e)
{
Dictionary<string, Command> newCommands = new Dictionary<string, Command>();
SQLiteConnection con = new SQLiteConnection("Data Source=" + System.Windows.Forms.Application.StartupPath + @"\Data\Commands.sqlite;Version=3;");
con.Open();
Command c;
SQLiteCommand com = new SQLiteCommand("select * from commands order by id asc", con);
SQLiteDataReader reader = com.ExecuteReader();
if (reader != null)
{
while (reader.Read())
{
string name = reader["name"].ToString();
if (Int32.Parse(reader["numberofparameters"].ToString()) != 0)
{
List<string> parameterNames = new List<string>();
SQLiteCommand com2 = new SQLiteCommand("select name from parameternames where id = " + Byte.Parse(reader["id"].ToString()), con);
SQLiteDataReader reader2 = com2.ExecuteReader();
while (reader2.Read())
{
parameterNames.Add(reader2["name"].ToString());
}
List<byte> parameterLengths = new List<byte>();
com2 = new SQLiteCommand("select length from parameterlengths where id = " + Byte.Parse(reader["id"].ToString()), con);
reader2 = com2.ExecuteReader();
while (reader2.Read())
{
parameterLengths.Add(Byte.Parse(reader2["length"].ToString()));
}
c = new Command(UInt16.Parse(reader["id"].ToString()), Byte.Parse(reader["numberofparameters"].ToString()), parameterNames.ToArray(), parameterLengths.ToArray());
}
else
{
c = new Command(UInt16.Parse(reader["id"].ToString()), Byte.Parse(reader["numberofparameters"].ToString()));
}
newCommands.Add(name, c);
}
}
con.Close();
foreach (string s in commands.Keys)
{
newCommands.Add(s, commands[s]);
}
Form newForm = new Form2(newCommands, superCommands);
newForm.Show();
}