namespace SHNDecryptHK { using System; using System.ComponentModel; using System.Data; using System.Drawing; using System.Windows.Forms; public class rowTally : Form { private Button button1; private ComboBox columnsCB; private IContainer components; private Label label1; private Label label3; private frmMain mainRT; private SHNFile original; private TextBox textBox1; public rowTally(frmMain main) { this.InitializeComponent(); this.mainRT = main; if (main.file == null) { base.Close(); } else { this.original = main.file; } } private void button1_Click(object sender, EventArgs e) { if (this.original != null) { if (this.columnsCB.SelectedItem == null) { MessageBox.Show("Please select a column."); } else { string str = (this.original.table.Rows.Count - 1).ToString(); if ((MessageBox.Show("Are you sure you want to recount the rows in this column? (" + this.textBox1.Text + " - " + str + ")", "Row Recount", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes) && (this.original.table.Rows.Count > 0)) { try { if (this.original.table.Columns[this.columnsCB.SelectedItem.ToString()].ToString().Equals(this.columnsCB.SelectedItem.ToString())) { for (int i = Convert.ToInt32(this.textBox1.Text); i < this.original.table.Rows.Count; i++) { DataRow row = this.original.table.Rows[i]; row[this.columnsCB.SelectedItem.ToString()] = i; } } } catch (NullReferenceException) { MessageBox.Show("Could not find the selected column."); } catch (Exception exception) { MessageBox.Show("An unknown error occured: " + Environment.NewLine + exception.Message); } } } } } protected override void Dispose(bool disposing) { if (disposing && (this.components != null)) { this.components.Dispose(); } base.Dispose(disposing); } private void InitializeComponent() { ComponentResourceManager manager = new ComponentResourceManager(typeof(rowTally)); this.button1 = new Button(); this.label1 = new Label(); this.columnsCB = new ComboBox(); this.label3 = new Label(); this.textBox1 = new TextBox(); base.SuspendLayout(); this.button1.Location = new Point(0x4b, 0x40); this.button1.Name = "button1"; this.button1.Size = new Size(0x84, 0x1c); this.button1.TabIndex = 7; this.button1.Text = "Start"; this.button1.UseVisualStyleBackColor = true; this.button1.Click += new EventHandler(this.button1_Click); this.label1.AutoSize = true; this.label1.Location = new Point(0x18, 15); this.label1.Name = "label1"; this.label1.Size = new Size(0x2d, 13); this.label1.TabIndex = 6; this.label1.Text = "Column:"; this.columnsCB.DropDownStyle = ComboBoxStyle.DropDownList; this.columnsCB.FormattingEnabled = true; this.columnsCB.Location = new Point(0x4a, 11); this.columnsCB.Name = "columnsCB"; this.columnsCB.Size = new Size(0x84, 0x15); this.columnsCB.TabIndex = 10; this.columnsCB.KeyDown += new KeyEventHandler(this.textBox1_KeyDown); this.label3.AutoSize = true; this.label3.Location = new Point(8, 0x29); this.label3.Name = "label3"; this.label3.Size = new Size(0x3d, 13); this.label3.TabIndex = 12; this.label3.Text = "Start Index:"; this.textBox1.Location = new Point(0x4b, 0x26); this.textBox1.MaxLength = 0x20; this.textBox1.Name = "textBox1"; this.textBox1.Size = new Size(0x85, 20); this.textBox1.TabIndex = 11; this.textBox1.Text = "0"; this.textBox1.KeyDown += new KeyEventHandler(this.textBox1_KeyDown); this.textBox1.KeyPress += new KeyPressEventHandler(this.textBox1_KeyPress); base.AutoScaleDimensions = new SizeF(6f, 13f); base.AutoScaleMode = AutoScaleMode.Font; base.ClientSize = new Size(0xd8, 0x62); base.Controls.Add(this.label3); base.Controls.Add(this.textBox1); base.Controls.Add(this.columnsCB); base.Controls.Add(this.button1); base.Controls.Add(this.label1); base.FormBorderStyle = FormBorderStyle.FixedSingle; base.Icon = (Icon) manager.GetObject("$this.Icon"); base.MaximizeBox = false; base.MinimizeBox = false; base.Name = "rowTally"; base.StartPosition = FormStartPosition.CenterParent; this.Text = "Row Tally"; base.Load += new EventHandler(this.rowTally_Load); base.ResumeLayout(false); base.PerformLayout(); } private void rowTally_Load(object sender, EventArgs e) { this.columnsCB.Items.Clear(); for (int i = 0; i < this.original.table.Columns.Count; i++) { this.columnsCB.Items.Add(this.original.table.Columns[i].ColumnName); } this.columnsCB.SelectedIndex = 0; } private void textBox1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { this.button1.PerformClick(); e.SuppressKeyPress = true; } } private void textBox1_KeyPress(object sender, KeyPressEventArgs e) { if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar)) { e.Handled = true; } } } }