diff --git a/Server/Forms/FrmRegValueEditMultiString.Designer.cs b/Server/Forms/FrmRegValueEditMultiString.Designer.cs new file mode 100644 index 00000000..b84faab6 --- /dev/null +++ b/Server/Forms/FrmRegValueEditMultiString.Designer.cs @@ -0,0 +1,159 @@ +namespace xServer.Forms +{ + partial class FrmRegValueEditMultiString + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + 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.valueDataTxtBox = new System.Windows.Forms.TextBox(); + this.flowLayoutPanel1.SuspendLayout(); + this.SuspendLayout(); + // + // valueNameTxtBox + // + this.valueNameTxtBox.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.valueNameTxtBox.Location = new System.Drawing.Point(15, 25); + this.valueNameTxtBox.Name = "valueNameTxtBox"; + this.valueNameTxtBox.ReadOnly = true; + this.valueNameTxtBox.Size = new System.Drawing.Size(346, 20); + this.valueNameTxtBox.TabIndex = 5; + // + // label1 + // + this.label1.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.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 9); + 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; + // + // label2 + // + this.label2.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.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(12, 53); + 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(24, 327); + this.flowLayoutPanel1.Name = "flowLayoutPanel1"; + this.flowLayoutPanel1.RightToLeft = System.Windows.Forms.RightToLeft.Yes; + this.flowLayoutPanel1.Size = new System.Drawing.Size(337, 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(259, 3); + this.cancelButton.Name = "cancelButton"; + this.cancelButton.Size = new System.Drawing.Size(75, 23); + this.cancelButton.TabIndex = 4; + this.cancelButton.Text = "Cancel"; + this.cancelButton.UseVisualStyleBackColor = true; + this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click); + // + // okButton + // + this.okButton.Location = new System.Drawing.Point(178, 3); + this.okButton.Name = "okButton"; + this.okButton.Size = new System.Drawing.Size(75, 23); + this.okButton.TabIndex = 5; + this.okButton.Text = "OK"; + this.okButton.UseVisualStyleBackColor = true; + this.okButton.Click += new System.EventHandler(this.okButton_Click); + // + // valueDataTxtBox + // + this.valueDataTxtBox.AcceptsReturn = true; + this.valueDataTxtBox.Location = new System.Drawing.Point(15, 69); + this.valueDataTxtBox.Multiline = true; + this.valueDataTxtBox.Name = "valueDataTxtBox"; + this.valueDataTxtBox.ScrollBars = System.Windows.Forms.ScrollBars.Both; + this.valueDataTxtBox.Size = new System.Drawing.Size(346, 252); + this.valueDataTxtBox.TabIndex = 9; + this.valueDataTxtBox.WordWrap = false; + // + // FrmRegValueEditMultiString + // + this.AcceptButton = this.okButton; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.cancelButton; + this.ClientSize = new System.Drawing.Size(373, 365); + this.Controls.Add(this.valueDataTxtBox); + this.Controls.Add(this.flowLayoutPanel1); + this.Controls.Add(this.label2); + this.Controls.Add(this.valueNameTxtBox); + this.Controls.Add(this.label1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "FrmRegValueEditMultiString"; + this.ShowIcon = false; + this.Text = "Edit Multi-String"; + this.Load += new System.EventHandler(this.FrmRegValueEditMultiString_Load); + this.flowLayoutPanel1.ResumeLayout(false); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + 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 System.Windows.Forms.TextBox valueDataTxtBox; + } +} \ No newline at end of file diff --git a/Server/Forms/FrmRegValueEditMultiString.cs b/Server/Forms/FrmRegValueEditMultiString.cs new file mode 100644 index 00000000..2ec9ecc1 --- /dev/null +++ b/Server/Forms/FrmRegValueEditMultiString.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using xServer.Core.Networking; +using xServer.Core.Registry; + +namespace xServer.Forms +{ + public partial class FrmRegValueEditMultiString : Form + { + private readonly Client _connectClient; + + private readonly RegValueData _value; + + private readonly string _keyPath; + + #region Constants + + private const string WARNING_MSG = "Data of type REG_MULTI_SZ cannot contain empty strings Registry Editor will remove the empty string found."; + + #endregion + + public FrmRegValueEditMultiString(string keyPath, RegValueData value, Client c) + { + _connectClient = c; + _keyPath = keyPath; + _value = value; + + InitializeComponent(); + + this.valueNameTxtBox.Text = value.Name; + this.valueDataTxtBox.Lines = (string[])value.Data; + } + + private void FrmRegValueEditMultiString_Load(object sender, EventArgs e) + { + this.valueDataTxtBox.Select(); + this.valueDataTxtBox.Focus(); + } + + private void okButton_Click(object sender, EventArgs e) + { + string[] lines = valueDataTxtBox.Lines; + if (lines.Length > 0) + { + string[] valueData = GetSanitizedStrings(lines); + if (valueData.Length != lines.Length) + { + ShowWarning(); + } + 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(); + } + + private string[] GetSanitizedStrings(string[] strs) + { + List sanitized = new List(); + foreach (string str in strs) + { + if (!String.IsNullOrWhiteSpace(str) && !String.IsNullOrEmpty(str)) + { + sanitized.Add(str); + } + } + return sanitized.ToArray(); + } + + private void ShowWarning() + { + MessageBox.Show(WARNING_MSG, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } +} diff --git a/Server/Forms/FrmRegValueEditMultiString.resx b/Server/Forms/FrmRegValueEditMultiString.resx new file mode 100644 index 00000000..1af7de15 --- /dev/null +++ b/Server/Forms/FrmRegValueEditMultiString.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Server/Forms/FrmRegistryEditor.cs b/Server/Forms/FrmRegistryEditor.cs index cc446eb0..6daa3d07 100644 --- a/Server/Forms/FrmRegistryEditor.cs +++ b/Server/Forms/FrmRegistryEditor.cs @@ -826,10 +826,15 @@ private Form GetEditForm(string keyPath, RegValueData value) switch (value.Kind) { case RegistryValueKind.String: + case RegistryValueKind.ExpandString: return new FrmRegValueEditString(keyPath, value, _connectClient); case RegistryValueKind.DWord: case RegistryValueKind.QWord: return new FrmRegValueEditWord(keyPath, value, _connectClient); + case RegistryValueKind.MultiString: + return new FrmRegValueEditMultiString(keyPath, value, _connectClient); + case RegistryValueKind.Binary: + default: return null; } diff --git a/Server/Server.csproj b/Server/Server.csproj index 5658a4cc..4c35394d 100644 --- a/Server/Server.csproj +++ b/Server/Server.csproj @@ -307,6 +307,12 @@ FrmRegistryEditor.cs + + Form + + + FrmRegValueEditMultiString.cs + Form @@ -428,6 +434,9 @@ FrmRegistryEditor.cs + + FrmRegValueEditMultiString.cs + FrmRegValueEditString.cs