From 712700e5634a055f64259e51e016e917c784b4ab Mon Sep 17 00:00:00 2001 From: LjungErik Date: Fri, 22 Apr 2016 10:24:46 +0200 Subject: [PATCH] Small improvements to 'FrmRegValueEditBinary' * Removed unnecessary close and load code * Prevented close of editor after invalid input * Set correct tab indices --- .../Forms/FrmRegValueEditBinary.Designer.cs | 38 +++++-------------- Server/Forms/FrmRegValueEditBinary.cs | 20 +++------- 2 files changed, 14 insertions(+), 44 deletions(-) diff --git a/Server/Forms/FrmRegValueEditBinary.Designer.cs b/Server/Forms/FrmRegValueEditBinary.Designer.cs index 98c5dcd3..a51f35e5 100644 --- a/Server/Forms/FrmRegValueEditBinary.Designer.cs +++ b/Server/Forms/FrmRegValueEditBinary.Designer.cs @@ -31,11 +31,9 @@ this.valueNameTxtBox = new System.Windows.Forms.TextBox(); this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); - this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); this.cancelButton = new System.Windows.Forms.Button(); this.okButton = new System.Windows.Forms.Button(); this.hexEditor = new xServer.Controls.HexEditor.HexEditor(); - this.flowLayoutPanel1.SuspendLayout(); this.SuspendLayout(); // // valueNameTxtBox @@ -45,7 +43,7 @@ this.valueNameTxtBox.Name = "valueNameTxtBox"; this.valueNameTxtBox.ReadOnly = true; this.valueNameTxtBox.Size = new System.Drawing.Size(341, 20); - this.valueNameTxtBox.TabIndex = 5; + this.valueNameTxtBox.TabIndex = 3; // // label1 // @@ -56,7 +54,6 @@ this.label1.Location = new System.Drawing.Point(9, 15); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(66, 13); - this.label1.TabIndex = 4; this.label1.Text = "Value name:"; this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // @@ -69,42 +66,27 @@ this.label2.Location = new System.Drawing.Point(9, 54); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(61, 13); - this.label2.TabIndex = 6; this.label2.Text = "Value data:"; this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // - // flowLayoutPanel1 - // - this.flowLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.flowLayoutPanel1.Controls.Add(this.cancelButton); - this.flowLayoutPanel1.Controls.Add(this.okButton); - this.flowLayoutPanel1.Location = new System.Drawing.Point(12, 270); - this.flowLayoutPanel1.Name = "flowLayoutPanel1"; - this.flowLayoutPanel1.RightToLeft = System.Windows.Forms.RightToLeft.Yes; - this.flowLayoutPanel1.Size = new System.Drawing.Size(341, 29); - this.flowLayoutPanel1.TabIndex = 8; - // // cancelButton // this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.cancelButton.Location = new System.Drawing.Point(263, 3); + this.cancelButton.Location = new System.Drawing.Point(278, 273); this.cancelButton.Name = "cancelButton"; this.cancelButton.Size = new System.Drawing.Size(75, 23); - this.cancelButton.TabIndex = 4; + this.cancelButton.TabIndex = 2; this.cancelButton.Text = "Cancel"; this.cancelButton.UseVisualStyleBackColor = true; - this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click); // // okButton // - this.okButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.okButton.Location = new System.Drawing.Point(182, 3); + this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK; + this.okButton.Location = new System.Drawing.Point(197, 273); this.okButton.Name = "okButton"; this.okButton.Size = new System.Drawing.Size(75, 23); - this.okButton.TabIndex = 5; + this.okButton.TabIndex = 1; this.okButton.Text = "OK"; this.okButton.UseVisualStyleBackColor = true; this.okButton.Click += new System.EventHandler(this.okButton_Click); @@ -120,7 +102,7 @@ this.hexEditor.Margin = new System.Windows.Forms.Padding(0, 2, 3, 3); this.hexEditor.Name = "hexEditor"; this.hexEditor.Size = new System.Drawing.Size(341, 196); - this.hexEditor.TabIndex = 6; + this.hexEditor.TabIndex = 0; this.hexEditor.VScrollBarVisisble = true; // // FrmRegValueEditBinary @@ -130,8 +112,9 @@ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.cancelButton; this.ClientSize = new System.Drawing.Size(365, 304); + this.Controls.Add(this.cancelButton); this.Controls.Add(this.hexEditor); - this.Controls.Add(this.flowLayoutPanel1); + this.Controls.Add(this.okButton); this.Controls.Add(this.label2); this.Controls.Add(this.valueNameTxtBox); this.Controls.Add(this.label1); @@ -141,8 +124,6 @@ this.Name = "FrmRegValueEditBinary"; this.ShowIcon = false; this.Text = "Edit Binary"; - this.Load += new System.EventHandler(this.FrmRegValueEditBinary_Load); - this.flowLayoutPanel1.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); @@ -153,7 +134,6 @@ private System.Windows.Forms.TextBox valueNameTxtBox; private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label2; - private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; private System.Windows.Forms.Button cancelButton; private System.Windows.Forms.Button okButton; private Controls.HexEditor.HexEditor hexEditor; diff --git a/Server/Forms/FrmRegValueEditBinary.cs b/Server/Forms/FrmRegValueEditBinary.cs index 703380b8..3ec2509a 100644 --- a/Server/Forms/FrmRegValueEditBinary.cs +++ b/Server/Forms/FrmRegValueEditBinary.cs @@ -36,7 +36,6 @@ namespace xServer.Forms this.valueNameTxtBox.Text = value.Name; - if (value.Kind == Microsoft.Win32.RegistryValueKind.Binary) { hexEditor.HexTable = (byte[])value.Data; @@ -63,18 +62,12 @@ namespace xServer.Forms } } - private void FrmRegValueEditBinary_Load(object sender, EventArgs e) - { - hexEditor.Select(); - hexEditor.Focus(); - } - #region Help function private object GetData() { byte[] bytes = hexEditor.HexTable; - if (bytes != null && bytes.Length > 0) + if (bytes != null) { try { @@ -126,14 +119,11 @@ namespace xServer.Forms if (valueData != null) { new xServer.Core.Packets.ServerPackets.DoChangeRegistryValue(_keyPath, new RegValueData(_value.Name, _value.Kind, valueData)).Execute(_connectClient); - - this.Close(); } - } - - private void cancelButton_Click(object sender, EventArgs e) - { - this.Close(); + else + { + DialogResult = DialogResult.None; + } } #endregion