namespace SHNDecryptHK { using System; using System.ComponentModel; using System.Drawing; using System.Windows.Forms; public class columnCreate : Form { private Button button1; private ComboBox cmbTypes; private IContainer components; private Label label1; private Label label2; private Label label3; private Label label4; private frmMain mainfrm; private TextBox txtColName; private TextBox txtDefault; private Label txtInfo; private TextBox txtLen; public columnCreate(frmMain main) { this.mainfrm = main; this.InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { try { int len = int.Parse(this.txtLen.Text); if (len < 0) { MessageBox.Show("Please enter a valid len"); } else { this.mainfrm.file.CreateColumn(this.txtColName.Text, len, uint.Parse(this.cmbTypes.Text.Substring(0, 2)), this.txtDefault.Text); base.Close(); } } catch (Exception exception) { MessageBox.Show(exception.Message); } } private void cmbTypes_MouseClick(object sender, MouseEventArgs e) { } private void cmbTypes_TextChanged(object sender, EventArgs e) { byte type = byte.Parse(this.cmbTypes.Text.Substring(0, 2)); this.txtLen.Text = this.GetDefLen(type).ToString(); } private void CreateColumn_Load(object sender, EventArgs e) { } protected override void Dispose(bool disposing) { if (disposing && (this.components != null)) { this.components.Dispose(); } base.Dispose(disposing); } public int GetDefLen(int type) { switch (type) { case 1: return 1; case 2: return 2; case 3: return 4; case 13: return 2; } return -1; } public void init() { if (this.mainfrm.file.table != null) { this.txtInfo.Text = (this.mainfrm.file.table.Rows.Count - 1) + " rows will be created"; this.cmbTypes.Items.Clear(); this.cmbTypes.Items.Add("24: string (enter len)"); this.cmbTypes.Items.Add("13: short"); this.cmbTypes.Items.Add("03: uint"); this.cmbTypes.Items.Add("02: ushort"); this.cmbTypes.Items.Add("01: byte"); this.cmbTypes.SelectedIndex = this.cmbTypes.Items.Count - 1; } } private void InitializeComponent() { ComponentResourceManager manager = new ComponentResourceManager(typeof(columnCreate)); this.label1 = new Label(); this.label2 = new Label(); this.label3 = new Label(); this.txtColName = new TextBox(); this.txtDefault = new TextBox(); this.txtInfo = new Label(); this.button1 = new Button(); this.label4 = new Label(); this.txtLen = new TextBox(); this.cmbTypes = new ComboBox(); base.SuspendLayout(); this.label1.AutoSize = true; this.label1.Location = new Point(9, 10); this.label1.Name = "label1"; this.label1.Size = new Size(0x4c, 13); this.label1.TabIndex = 0; this.label1.Text = "Column Name:"; this.label2.AutoSize = true; this.label2.Location = new Point(9, 0x26); this.label2.Name = "label2"; this.label2.Size = new Size(0x48, 13); this.label2.TabIndex = 1; this.label2.Text = "Column Type:"; this.label3.AutoSize = true; this.label3.Location = new Point(9, 0x4a); this.label3.Name = "label3"; this.label3.Size = new Size(0x49, 13); this.label3.TabIndex = 2; this.label3.Text = "Default value:"; this.txtColName.Location = new Point(0x58, 9); this.txtColName.Name = "txtColName"; this.txtColName.Size = new Size(0x99, 20); this.txtColName.TabIndex = 1; this.txtDefault.Location = new Point(0x58, 0x47); this.txtDefault.Name = "txtDefault"; this.txtDefault.Size = new Size(0x98, 20); this.txtDefault.TabIndex = 3; this.txtInfo.AutoSize = true; this.txtInfo.Location = new Point(0x6b, 0x91); this.txtInfo.Name = "txtInfo"; this.txtInfo.Size = new Size(0x23, 13); this.txtInfo.TabIndex = 6; this.txtInfo.Text = "label4"; this.txtInfo.TextAlign = ContentAlignment.MiddleCenter; this.button1.Location = new Point(15, 0xa1); this.button1.Name = "button1"; this.button1.Size = new Size(0xe4, 30); this.button1.TabIndex = 5; this.button1.Text = "Create"; this.button1.UseVisualStyleBackColor = true; this.button1.Click += new EventHandler(this.button1_Click); this.label4.AutoSize = true; this.label4.Location = new Point(9, 0x75); this.label4.Name = "label4"; this.label4.Size = new Size(0x42, 13); this.label4.TabIndex = 10; this.label4.Text = "Column Len:"; this.txtLen.Location = new Point(0x58, 0x72); this.txtLen.Name = "txtLen"; this.txtLen.Size = new Size(0x98, 20); this.txtLen.TabIndex = 4; this.txtLen.Text = "1"; this.txtLen.TextAlign = HorizontalAlignment.Right; this.cmbTypes.DropDownStyle = ComboBoxStyle.DropDownList; this.cmbTypes.FormattingEnabled = true; this.cmbTypes.Location = new Point(0x58, 0x26); this.cmbTypes.Name = "cmbTypes"; this.cmbTypes.Size = new Size(0x98, 0x15); this.cmbTypes.TabIndex = 2; this.cmbTypes.TextChanged += new EventHandler(this.cmbTypes_TextChanged); this.cmbTypes.MouseClick += new MouseEventHandler(this.cmbTypes_MouseClick); base.AutoScaleDimensions = new SizeF(6f, 13f); base.AutoScaleMode = AutoScaleMode.Font; base.ClientSize = new Size(0x101, 0xcb); base.Controls.Add(this.cmbTypes); base.Controls.Add(this.txtLen); base.Controls.Add(this.label4); base.Controls.Add(this.button1); base.Controls.Add(this.txtInfo); base.Controls.Add(this.txtDefault); base.Controls.Add(this.txtColName); base.Controls.Add(this.label3); base.Controls.Add(this.label2); base.Controls.Add(this.label1); base.Icon = (Icon) manager.GetObject("$this.Icon"); base.MaximizeBox = false; base.MinimizeBox = false; base.Name = "columnCreate"; base.StartPosition = FormStartPosition.CenterParent; this.Text = "Column Creation"; base.Load += new EventHandler(this.CreateColumn_Load); base.ResumeLayout(false); base.PerformLayout(); } } }