private void buttonConditionApply_Click(object sender, EventArgs e) { if (this.treeView.SelectedNode.Level == 3) { TreeNode selectedNode = this.treeView.SelectedNode; TreeNode parent = selectedNode.Parent; TreeNode parent2 = parent.Parent; TreeNode parent3 = parent2.Parent; if (parent.Index == 0) { if (this.richTextBoxDataDump.Enabled) { string[] array = this.richTextBoxDataDump.Text.Split(new char[] { '-' }); this.block[parent3.Index].record[parent2.Index].condition[selectedNode.Index].length = array.Length + 8; this.block[parent3.Index].record[parent2.Index].condition[selectedNode.Index].data = new byte[this.block[parent3.Index].record[parent2.Index].condition[selectedNode.Index].length - 8]; for (int num = 0; num != array.Length; num++) { this.block[parent3.Index].record[parent2.Index].condition[selectedNode.Index].data[num] = byte.Parse(array[num], NumberStyles.HexNumber); } } else { string[] array2 = new string[0]; string[] array3 = new string[0]; Condition condition = new Condition(); condition.part_count("0x" + this.block[parent3.Index].record[parent2.Index].condition[selectedNode.Index].command.ToString("X"), ref array2, ref array3, this.executableDirectoryName); int num2 = 0; for (int num = 0; num != array3.Length; num++) { if (array3[num] == "Int32") { int value = Convert.ToInt32(this.dataGridView.Rows[0].Cells[num].Value); byte[] bytes = BitConverter.GetBytes(value); for (int num3 = 0; num3 != 4; num3++) { this.block[parent3.Index].record[parent2.Index].condition[selectedNode.Index].data[num2] = bytes[num3]; num2++; } } else if (array3[num] == "Int16") { short value2 = Convert.ToInt16(this.dataGridView.Rows[0].Cells[num].Value); byte[] bytes2 = BitConverter.GetBytes(value2); for (int num3 = 0; num3 != 2; num3++) { this.block[parent3.Index].record[parent2.Index].condition[selectedNode.Index].data[num2] = bytes2[num3]; num2++; } } else if (array3[num] == "Byte") { this.block[parent3.Index].record[parent2.Index].condition[selectedNode.Index].data[num2] = Convert.ToByte(this.dataGridView.Rows[0].Cells[num].Value); num2++; } else if (array3[num] == "Operator32") { this.block[parent3.Index].record[parent2.Index].condition[selectedNode.Index].data[num2] = this.operator_to_byte(this.dataGridView.Rows[0].Cells[num].Value.ToString()); num2 += 4; } else if (array3[num] == "Operator16") { this.block[parent3.Index].record[parent2.Index].condition[selectedNode.Index].data[num2] = this.operator_to_byte(this.dataGridView.Rows[0].Cells[num].Value.ToString()); num2 += 2; } else if (array3[num] == "Operator") { this.block[parent3.Index].record[parent2.Index].condition[selectedNode.Index].data[num2] = this.operator_to_byte(this.dataGridView.Rows[0].Cells[num].Value.ToString()); num2++; } else if (array3[num] == "Trigger") { short num4 = Convert.ToInt16(this.dataGridView.Rows[0].Cells[num].Value.ToString().Length + 1); byte[] data = this.block[parent3.Index].record[parent2.Index].condition[selectedNode.Index].data; this.block[parent3.Index].record[parent2.Index].condition[selectedNode.Index].data = new byte[num2 + 2 + (int)num4 + 1]; for (int num5 = 0; num5 != num2; num5++) { this.block[parent3.Index].record[parent2.Index].condition[selectedNode.Index].data[num5] = data[num5]; } char[] array4 = this.dataGridView.Rows[0].Cells[num].Value.ToString().ToCharArray(); byte[] bytes3 = BitConverter.GetBytes(num4); for (int num3 = 0; num3 != 2; num3++) { this.block[parent3.Index].record[parent2.Index].condition[selectedNode.Index].data[num2] = bytes3[num3]; num2++; } for (int num3 = 0; num3 != this.dataGridView.Rows[0].Cells[num].Value.ToString().Length; num3++) { int value3 = Convert.ToInt32(array4[num3].ToString()) + 48; this.block[parent3.Index].record[parent2.Index].condition[selectedNode.Index].data[num2] = Convert.ToByte(value3); num2++; } this.block[parent3.Index].record[parent2.Index].condition[selectedNode.Index].length = num2 + 2 + 8; } } } } else if (parent.Index == 1) { if (this.richTextBoxDataDump.Enabled) { string[] array = this.richTextBoxDataDump.Text.Split(new char[] { '-' }); this.block[parent3.Index].record[parent2.Index].action[selectedNode.Index].length = array.Length + 8; this.block[parent3.Index].record[parent2.Index].action[selectedNode.Index].data = new byte[this.block[parent3.Index].record[parent2.Index].action[selectedNode.Index].length - 8]; for (int num = 0; num != array.Length; num++) { this.block[parent3.Index].record[parent2.Index].action[selectedNode.Index].data[num] = Convert.ToByte(array[num]); } } else { string[] array2 = new string[0]; string[] array3 = new string[0]; Action action = new Action(); action.part_count("0x" + this.block[parent3.Index].record[parent2.Index].action[selectedNode.Index].command.ToString("X"), ref array2, ref array3, this.executableDirectoryName); int num2 = 0; for (int num = 0; num != array3.Length; num++) { if (array3[num] == "Int32") { int value = Convert.ToInt32(this.dataGridView.Rows[0].Cells[num].Value); byte[] bytes = BitConverter.GetBytes(value); for (int num3 = 0; num3 != 4; num3++) { this.block[parent3.Index].record[parent2.Index].action[selectedNode.Index].data[num2] = bytes[num3]; num2++; } } else if (array3[num] == "Int16") { short value2 = Convert.ToInt16(this.dataGridView.Rows[0].Cells[num].Value); byte[] bytes2 = BitConverter.GetBytes(value2); for (int num3 = 0; num3 != 2; num3++) { this.block[parent3.Index].record[parent2.Index].action[selectedNode.Index].data[num2] = bytes2[num3]; num2++; } } else if (array3[num] == "Byte") { this.block[parent3.Index].record[parent2.Index].action[selectedNode.Index].data[num2] = Convert.ToByte(this.dataGridView.Rows[0].Cells[num].Value); num2++; } else if (array3[num] == "Operator32") { this.block[parent3.Index].record[parent2.Index].action[selectedNode.Index].data[num2] = this.operator_to_byte(this.dataGridView.Rows[0].Cells[num].Value.ToString()); num2 += 4; } else if (array3[num] == "Operator16") { this.block[parent3.Index].record[parent2.Index].action[selectedNode.Index].data[num2] = this.operator_to_byte(this.dataGridView.Rows[0].Cells[num].Value.ToString()); num2 += 2; } else if (array3[num] == "Operator") { this.block[parent3.Index].record[parent2.Index].action[selectedNode.Index].data[num2] = this.operator_to_byte(this.dataGridView.Rows[0].Cells[num].Value.ToString()); num2++; } else if (array3[num] == "Trigger") { short num4 = Convert.ToInt16(this.dataGridView.Rows[0].Cells[num].Value.ToString().Length + 1); byte[] data = this.block[parent3.Index].record[parent2.Index].action[selectedNode.Index].data; this.block[parent3.Index].record[parent2.Index].action[selectedNode.Index].data = new byte[num2 + 2 + (int)num4 + 1]; for (int num5 = 0; num5 != num2; num5++) { this.block[parent3.Index].record[parent2.Index].action[selectedNode.Index].data[num5] = data[num5]; } char[] array4 = this.dataGridView.Rows[0].Cells[num].Value.ToString().ToCharArray(); byte[] bytes3 = BitConverter.GetBytes(num4); for (int num3 = 0; num3 != 2; num3++) { this.block[parent3.Index].record[parent2.Index].action[selectedNode.Index].data[num2] = bytes3[num3]; num2++; } for (int num3 = 0; num3 != this.dataGridView.Rows[0].Cells[num].Value.ToString().Length; num3++) { int value3 = Convert.ToInt32(array4[num3].ToString()) + 48; this.block[parent3.Index].record[parent2.Index].action[selectedNode.Index].data[num2] = Convert.ToByte(value3); num2++; } this.block[parent3.Index].record[parent2.Index].action[selectedNode.Index].length = num2 + 2 + 8; } } } } } }
private void changeByToolStripMenuItem_Click(object sender, EventArgs e) { TreeNode selectedNode = this.treeView.SelectedNode; TreeNode parent = selectedNode.Parent; TreeNode parent2 = parent.Parent; TreeNode parent3 = parent2.Parent; if (parent.Index == 0) { ChangeDataDialog changeDataDialog = new ChangeDataDialog(); changeDataDialog.import_opcode_condition(this.executableDirectoryName); if (changeDataDialog.ShowDialog() == DialogResult.OK) { selectedNode.Text = changeDataDialog.data_select + " (" + changeDataDialog.opcode_select + ")"; if (changeDataDialog.data_select == "Unknow Opcode") { this.block[parent3.Index].record[parent2.Index].condition[selectedNode.Index].command = int.Parse(changeDataDialog.opcode_select.Remove(0, 2), NumberStyles.HexNumber); this.block[parent3.Index].record[parent2.Index].condition[selectedNode.Index].length = 8; this.block[parent3.Index].record[parent2.Index].condition[selectedNode.Index].data = new byte[1]; } else { string[] array = new string[0]; string[] array2 = new string[0]; Condition condition = new Condition(); condition.part_count(changeDataDialog.opcode_select, ref array, ref array2, this.executableDirectoryName); this.dataGridView.ColumnCount = array.Length; this.richTextBoxDataDump.Text = ""; this.block[parent3.Index].record[parent2.Index].condition[selectedNode.Index].command = int.Parse(changeDataDialog.opcode_select.Remove(0, 2), NumberStyles.HexNumber); int num = 0; for (int num2 = 0; num2 != array.Length; num2++) { if (array2[num2] == "Int32") { this.dataGridView.Columns[num2].Name = array[num2] + " (" + array2[num2] + ")"; this.richTextBoxDataDump.Text = this.richTextBoxDataDump.Text + "0-0-0-0"; num += 4; this.dataGridView.Rows[0].Cells[num2].Value = 0; } else if (array2[num2] == "Byte") { this.dataGridView.Columns[num2].Name = array[num2] + " (" + array2[num2] + ")"; this.richTextBoxDataDump.Text = this.richTextBoxDataDump.Text + "-0"; num++; this.dataGridView.Rows[0].Cells[num2].Value = 0; } else if (array2[num2] == "Int16") { this.dataGridView.Columns[num2].Name = array[num2] + " (" + array2[num2] + ")"; this.richTextBoxDataDump.Text = this.richTextBoxDataDump.Text + "-0-0"; num += 2; this.dataGridView.Rows[0].Cells[num2].Value = 0; } else if (array2[num2] == "Operator32") { this.dataGridView.Columns[num2].Name = array[num2] + " (" + array2[num2] + ")"; this.richTextBoxDataDump.Text = this.richTextBoxDataDump.Text + "0-0-0-0"; num += 4; this.dataGridView.Rows[0].Cells[num2].Value = "=="; } else if (array2[num2] == "Operator16") { this.dataGridView.Columns[num2].Name = array[num2] + " (" + array2[num2] + ")"; this.richTextBoxDataDump.Text = this.richTextBoxDataDump.Text + "-0-0"; num += 2; this.dataGridView.Rows[0].Cells[num2].Value = "=="; } else if (array2[num2] == "Operator") { this.dataGridView.Columns[num2].Name = array[num2] + " (" + array2[num2] + ")"; this.richTextBoxDataDump.Text = this.richTextBoxDataDump.Text + "-0"; num++; this.dataGridView.Rows[0].Cells[num2].Value = "=="; } else if (array2[num2] == "Trigger") { this.dataGridView.Columns[num2].Name = array[num2] + " (" + array2[num2] + ")"; this.richTextBoxDataDump.Text = this.richTextBoxDataDump.Text + "-02-0-30-0-0"; num += 5; this.dataGridView.Rows[0].Cells[num2].Value = "Null(Give it a value rapidly)"; } } this.block[parent3.Index].record[parent2.Index].condition[selectedNode.Index].length = num + 8; this.block[parent3.Index].record[parent2.Index].condition[selectedNode.Index].data = new byte[num]; } } } else if (parent.Index == 1) { ChangeDataDialog changeDataDialog = new ChangeDataDialog(); changeDataDialog.import_opcode_action(this.executableDirectoryName); if (changeDataDialog.ShowDialog() == DialogResult.OK) { selectedNode.Text = changeDataDialog.data_select + " (" + changeDataDialog.opcode_select + ")"; if (changeDataDialog.data_select == "Unknow Opcode") { this.block[parent3.Index].record[parent2.Index].action[selectedNode.Index].command = int.Parse(changeDataDialog.opcode_select.Remove(0, 2), NumberStyles.HexNumber); this.block[parent3.Index].record[parent2.Index].action[selectedNode.Index].length = 8; this.block[parent3.Index].record[parent2.Index].action[selectedNode.Index].data = new byte[1]; } else { string[] array = new string[0]; string[] array2 = new string[0]; Action action = new Action(); action.part_count(changeDataDialog.opcode_select, ref array, ref array2, this.executableDirectoryName); this.dataGridView.ColumnCount = array.Length; this.richTextBoxDataDump.Text = ""; this.block[parent3.Index].record[parent2.Index].action[selectedNode.Index].command = int.Parse(changeDataDialog.opcode_select.Remove(0, 2), NumberStyles.HexNumber); int num = 0; for (int num2 = 0; num2 != array.Length; num2++) { if (array2[num2] == "Int32") { this.dataGridView.Columns[num2].Name = array[num2] + " (" + array2[num2] + ")"; this.richTextBoxDataDump.Text = this.richTextBoxDataDump.Text + "0-0-0-0"; num += 4; this.dataGridView.Rows[0].Cells[num2].Value = 0; } else if (array2[num2] == "Byte") { this.dataGridView.Columns[num2].Name = array[num2] + " (" + array2[num2] + ")"; this.richTextBoxDataDump.Text = this.richTextBoxDataDump.Text + "-0"; num++; this.dataGridView.Rows[0].Cells[num2].Value = 0; } else if (array2[num2] == "Int16") { this.dataGridView.Columns[num2].Name = array[num2] + " (" + array2[num2] + ")"; this.richTextBoxDataDump.Text = this.richTextBoxDataDump.Text + "-0"; num += 2; this.dataGridView.Rows[0].Cells[num2].Value = 0; } else if (array2[num2] == "Operator32") { this.dataGridView.Columns[num2].Name = array[num2] + " (" + array2[num2] + ")"; this.richTextBoxDataDump.Text = this.richTextBoxDataDump.Text + "0-0-0-0"; num += 4; this.dataGridView.Rows[0].Cells[num2].Value = "=="; } else if (array2[num2] == "Operator16") { this.dataGridView.Columns[num2].Name = array[num2] + " (" + array2[num2] + ")"; this.richTextBoxDataDump.Text = this.richTextBoxDataDump.Text + "-0-0"; num += 2; this.dataGridView.Rows[0].Cells[num2].Value = "=="; } else if (array2[num2] == "Operator") { this.dataGridView.Columns[num2].Name = array[num2] + " (" + array2[num2] + ")"; this.richTextBoxDataDump.Text = this.richTextBoxDataDump.Text + "-0"; num++; this.dataGridView.Rows[0].Cells[num2].Value = "=="; } else if (array2[num2] == "Trigger") { this.dataGridView.Columns[num2].Name = array[num2] + " (" + array2[num2] + ")"; this.richTextBoxDataDump.Text = this.richTextBoxDataDump.Text + "-02-0-30-0-0"; num += 5; this.dataGridView.Rows[0].Cells[num2].Value = "Null(Give it a value rapidly)"; } } this.block[parent3.Index].record[parent2.Index].action[selectedNode.Index].length = num + 8; this.block[parent3.Index].record[parent2.Index].action[selectedNode.Index].data = new byte[num]; } } } }
private void treeView_AfterSelect(object sender, TreeViewEventArgs e) { if (this.treeView.SelectedNode.Level == 0) { this.treeView.ContextMenuStrip = this.contextMenuStripBlock; } else if (this.treeView.SelectedNode.Level == 1) { this.treeView.ContextMenuStrip = this.contextMenuStripRecord; } else if (this.treeView.SelectedNode.Level == 2 && this.treeView.SelectedNode.Index == 0) { this.treeView.ContextMenuStrip = this.contextMenuStripCondition; } else if (this.treeView.SelectedNode.Level == 2 && this.treeView.SelectedNode.Index == 1) { this.treeView.ContextMenuStrip = this.contextMenuStripAction; } else if (this.treeView.SelectedNode.Level == 3) { this.treeView.ContextMenuStrip = this.contextMenuStripData; TreeNode parent = this.treeView.SelectedNode.Parent; if (parent.Index == 0) { TreeNode parent2 = parent.Parent; TreeNode parent3 = parent2.Parent; this.richTextBoxDataDump.Text = ""; this.richTextBoxDataDump.Text = this.block[parent3.Index].record[parent2.Index].condition[this.treeView.SelectedNode.Index].data[0].ToString("X"); for (int num = 1; num != this.block[parent3.Index].record[parent2.Index].condition[this.treeView.SelectedNode.Index].data.Length; num++) { this.richTextBoxDataDump.Text = this.richTextBoxDataDump.Text + "-" + this.block[parent3.Index].record[parent2.Index].condition[this.treeView.SelectedNode.Index].data[num].ToString("X"); } string[] array = new string[0]; string[] array2 = new string[0]; Condition condition = new Condition(); if (condition.part_count("0x" + this.block[parent3.Index].record[parent2.Index].condition[this.treeView.SelectedNode.Index].command.ToString("X"), ref array, ref array2, this.executableDirectoryName)) { this.richTextBoxDataDump.Enabled = false; this.dataGridView.Show(); this.dataGridView.ColumnCount = array.Length; int num2 = 0; for (int num = 0; num != array.Length; num++) { this.dataGridView.Columns[num].Name = array[num] + " (" + array2[num] + ")"; if (array2[num] == "Int32") { int num3 = BitConverter.ToInt32(this.block[parent3.Index].record[parent2.Index].condition[this.treeView.SelectedNode.Index].data, num2); this.dataGridView.Rows[0].Cells[num].Value = num3.ToString(); num2 += 4; } else if (array2[num] == "Byte") { byte b = this.block[parent3.Index].record[parent2.Index].condition[this.treeView.SelectedNode.Index].data[num2]; this.dataGridView.Rows[0].Cells[num].Value = b.ToString(); num2++; } else if (array2[num] == "Int16") { short num4 = BitConverter.ToInt16(this.block[parent3.Index].record[parent2.Index].condition[this.treeView.SelectedNode.Index].data, num2); this.dataGridView.Rows[0].Cells[num].Value = num4.ToString(); num2 += 2; } else if (array2[num] == "Operator32") { string value = this.byte_to_operator(this.block[parent3.Index].record[parent2.Index].condition[this.treeView.SelectedNode.Index].data[num2]); this.dataGridView.Rows[0].Cells[num].Value = value; num2 += 4; } else if (array2[num] == "Operator16") { string value = this.byte_to_operator(this.block[parent3.Index].record[parent2.Index].condition[this.treeView.SelectedNode.Index].data[num2]); this.dataGridView.Rows[0].Cells[num].Value = value; num2 += 2; } else if (array2[num] == "Operator") { string value = this.byte_to_operator(this.block[parent3.Index].record[parent2.Index].condition[this.treeView.SelectedNode.Index].data[num2]); this.dataGridView.Rows[0].Cells[num].Value = value; num2++; } else if (array2[num] == "Trigger") { short num5 = BitConverter.ToInt16(this.block[parent3.Index].record[parent2.Index].condition[this.treeView.SelectedNode.Index].data, num2); if (num5 >= 2) { num2 += 2; int num6 = 0; for (int num7 = 0; num7 != (int)(num5 - 2); num7++) { num6 += (int)(this.block[parent3.Index].record[parent2.Index].condition[this.treeView.SelectedNode.Index].data[num2] - 30); } this.dataGridView.Rows[0].Cells[num].Value = num6; num2 += (int)num5; } } else { this.dataGridView.Rows[0].Cells[num].Value = "Null(Give it a value rapidly)"; } } } else { this.richTextBoxDataDump.Enabled = true; this.dataGridView.Hide(); } } else if (parent.Index == 1) { TreeNode parent2 = parent.Parent; TreeNode parent3 = parent2.Parent; this.richTextBoxDataDump.Text = ""; this.richTextBoxDataDump.Text = this.block[parent3.Index].record[parent2.Index].action[this.treeView.SelectedNode.Index].data[0].ToString("X"); for (int num = 1; num != this.block[parent3.Index].record[parent2.Index].action[this.treeView.SelectedNode.Index].data.Length; num++) { this.richTextBoxDataDump.Text = this.richTextBoxDataDump.Text + "-" + this.block[parent3.Index].record[parent2.Index].action[this.treeView.SelectedNode.Index].data[num].ToString("X"); } string[] array = new string[0]; string[] array2 = new string[0]; Action action = new Action(); if (action.part_count("0x" + this.block[parent3.Index].record[parent2.Index].action[this.treeView.SelectedNode.Index].command.ToString("X"), ref array, ref array2, this.executableDirectoryName)) { this.richTextBoxDataDump.Enabled = false; this.dataGridView.Show(); this.dataGridView.ColumnCount = array.Length; int num2 = 0; for (int num = 0; num != array.Length; num++) { this.dataGridView.Columns[num].Name = array[num] + " (" + array2[num] + ")"; if (array2[num] == "Int32") { int num3 = BitConverter.ToInt32(this.block[parent3.Index].record[parent2.Index].action[this.treeView.SelectedNode.Index].data, num2); this.dataGridView.Rows[0].Cells[num].Value = num3.ToString(); num2 += 4; } else if (array2[num] == "Byte") { byte b = this.block[parent3.Index].record[parent2.Index].action[this.treeView.SelectedNode.Index].data[num2]; this.dataGridView.Rows[0].Cells[num].Value = b.ToString(); num2++; } else if (array2[num] == "Int16") { short num4 = BitConverter.ToInt16(this.block[parent3.Index].record[parent2.Index].action[this.treeView.SelectedNode.Index].data, num2); this.dataGridView.Rows[0].Cells[num].Value = num4.ToString(); num2 += 2; } else if (array2[num] == "Operator32") { string value = this.byte_to_operator(this.block[parent3.Index].record[parent2.Index].action[this.treeView.SelectedNode.Index].data[num2]); this.dataGridView.Rows[0].Cells[num].Value = value; num2 += 4; } else if (array2[num] == "Operator16") { string value = this.byte_to_operator(this.block[parent3.Index].record[parent2.Index].action[this.treeView.SelectedNode.Index].data[num2]); this.dataGridView.Rows[0].Cells[num].Value = value; num2 += 2; } else if (array2[num] == "Operator") { string value = this.byte_to_operator(this.block[parent3.Index].record[parent2.Index].action[this.treeView.SelectedNode.Index].data[num2]); this.dataGridView.Rows[0].Cells[num].Value = value; num2++; } else if (array2[num] == "Trigger") { short num5 = BitConverter.ToInt16(this.block[parent3.Index].record[parent2.Index].action[this.treeView.SelectedNode.Index].data, num2); if (num5 >= 2) { num2 += 2; string text = ""; for (int num7 = 0; num7 != (int)(num5 - 1); num7++) { text += ((int)(this.block[parent3.Index].record[parent2.Index].action[this.treeView.SelectedNode.Index].data[num2] - 48)).ToString(); num2++; } this.dataGridView.Rows[0].Cells[num].Value = text; num2 += (int)num5; } else { this.dataGridView.Rows[0].Cells[num].Value = "Null(Give it a value rapidly)"; } } } } else { this.richTextBoxDataDump.Enabled = true; this.dataGridView.Hide(); } } } }