diff --git a/XenAdmin/Dialogs/CustomFieldsDialog.Designer.cs b/XenAdmin/Dialogs/CustomFieldsDialog.Designer.cs
deleted file mode 100644
index 80a9ff567..000000000
--- a/XenAdmin/Dialogs/CustomFieldsDialog.Designer.cs
+++ /dev/null
@@ -1,104 +0,0 @@
-using XenAdmin.CustomFields;
-using XenAdmin.XenSearch;
-using System;
-using XenAPI;
-using XenAdmin.Core;
-namespace XenAdmin.Dialogs
-{
- partial class CustomFieldsDialog
- {
- ///
- /// 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)
- {
- CustomFieldsManager.CustomFieldsChanged -= CustomFields_CustomFieldsChanged;
-
- 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()
- {
- System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CustomFieldsDialog));
- this.btnClose = new System.Windows.Forms.Button();
- this.btnDelete = new System.Windows.Forms.Button();
- this.btnAdd = new System.Windows.Forms.Button();
- this.CustomFieldsLabel = new System.Windows.Forms.Label();
- this.lbCustomFields = new System.Windows.Forms.ListBox();
- this.SuspendLayout();
- //
- // btnClose
- //
- resources.ApplyResources(this.btnClose, "btnClose");
- this.btnClose.DialogResult = System.Windows.Forms.DialogResult.Yes;
- this.btnClose.Name = "btnClose";
- this.btnClose.UseVisualStyleBackColor = true;
- //
- // btnDelete
- //
- resources.ApplyResources(this.btnDelete, "btnDelete");
- this.btnDelete.Name = "btnDelete";
- this.btnDelete.UseVisualStyleBackColor = true;
- this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click);
- //
- // btnAdd
- //
- resources.ApplyResources(this.btnAdd, "btnAdd");
- this.btnAdd.Name = "btnAdd";
- this.btnAdd.UseVisualStyleBackColor = true;
- this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click);
- //
- // CustomFieldsLabel
- //
- resources.ApplyResources(this.CustomFieldsLabel, "CustomFieldsLabel");
- this.CustomFieldsLabel.BackColor = System.Drawing.Color.Transparent;
- this.CustomFieldsLabel.Name = "CustomFieldsLabel";
- //
- // lbCustomFields
- //
- resources.ApplyResources(this.lbCustomFields, "lbCustomFields");
- this.lbCustomFields.Name = "lbCustomFields";
- this.lbCustomFields.SelectedIndexChanged += new System.EventHandler(this.lbCustomFields_SelectedIndexChanged);
- //
- // CustomFieldsDialog
- //
- this.AcceptButton = this.btnClose;
- resources.ApplyResources(this, "$this");
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
- this.CancelButton = this.btnClose;
- this.Controls.Add(this.btnClose);
- this.Controls.Add(this.btnDelete);
- this.Controls.Add(this.btnAdd);
- this.Controls.Add(this.CustomFieldsLabel);
- this.Controls.Add(this.lbCustomFields);
- this.Name = "CustomFieldsDialog";
- this.ResumeLayout(false);
- this.PerformLayout();
-
- }
-
- #endregion
-
- private System.Windows.Forms.Button btnClose;
- private System.Windows.Forms.Button btnDelete;
- private System.Windows.Forms.Button btnAdd;
- private System.Windows.Forms.Label CustomFieldsLabel;
- private System.Windows.Forms.ListBox lbCustomFields;
- }
-}
\ No newline at end of file
diff --git a/XenAdmin/Dialogs/CustomFieldsDialog.cs b/XenAdmin/Dialogs/CustomFieldsDialog.cs
deleted file mode 100644
index 6c502568f..000000000
--- a/XenAdmin/Dialogs/CustomFieldsDialog.cs
+++ /dev/null
@@ -1,136 +0,0 @@
-/* Copyright (c) Cloud Software Group, Inc.
- *
- * Redistribution and use in source and binary forms,
- * with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * * Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the
- * following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the
- * following disclaimer in the documentation and/or other
- * materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-using System;
-using System.Windows.Forms;
-using XenAdmin.CustomFields;
-using XenAdmin.Network;
-using XenAPI;
-using XenAdmin.Actions;
-
-
-namespace XenAdmin.Dialogs
-{
- public partial class CustomFieldsDialog : XenDialogBase
- {
- public CustomFieldsDialog(IXenConnection connection) : base(connection)
- {
- InitializeComponent();
-
- Build();
-
- CustomFieldsManager.CustomFieldsChanged += CustomFields_CustomFieldsChanged;
- }
-
- void CustomFields_CustomFieldsChanged()
- {
- Build();
- }
-
- private void Build()
- {
- lbCustomFields.BeginUpdate();
-
- try
- {
- lbCustomFields.Items.Clear();
-
- lbCustomFields.Items.AddRange(CustomFieldsManager.GetCustomFields(connection).ToArray());
-
- btnDelete.Enabled = false;
- }
- finally
- {
- lbCustomFields.EndUpdate();
- }
- }
-
- private void btnAdd_Click(object sender, EventArgs e)
- {
- NewCustomFieldDialog dialog = new NewCustomFieldDialog(connection);
- if (dialog.ShowDialog() != DialogResult.OK)
- return;
-
- CustomFieldDefinition definition = dialog.Definition;
-
- DelegatedAsyncAction action = new DelegatedAsyncAction(connection,
- String.Format(Messages.ADD_CUSTOM_FIELD, definition.Name),
- String.Format(Messages.ADDING_CUSTOM_FIELD, definition.Name),
- String.Format(Messages.ADDED_CUSTOM_FIELD, definition.Name),
- delegate(Session session)
- {
- CustomFieldsManager.AddCustomField(session, connection, definition);
- });
- action.RunAsync();
- }
-
- private void btnDelete_Click(object sender, EventArgs e)
- {
- CustomFieldDefinition customFieldDefinition = lbCustomFields.SelectedItem as CustomFieldDefinition;
- if (customFieldDefinition == null)
- return;
-
- string name = customFieldDefinition.Name.Ellipsise(50);
-
- if (!Program.RunInAutomatedTestMode)
- using (var dialog = new WarningDialog(string.Format(Messages.MESSAGEBOX_DELETE_CUSTOM_FIELD, name),
- ThreeButtonDialog.ButtonYes, ThreeButtonDialog.ButtonNo)
- {WindowTitle = Messages.MESSAGEBOX_CONFIRM})
- {
- if (dialog.ShowDialog(Program.MainWindow) != DialogResult.Yes)
- return;
- }
-
- if (connection != null && !connection.IsConnected)
- {
- MainWindow.ShowDisconnectedMessage(Program.MainWindow);
- return;
- }
-
- int selIdx = lbCustomFields.SelectedIndex;
-
- lbCustomFields.Items.RemoveAt(selIdx);
- DelegatedAsyncAction action = new DelegatedAsyncAction(connection,
- String.Format(Messages.DELETE_CUSTOM_FIELD, name),
- String.Format(Messages.DELETING_CUSTOM_FIELD, name),
- String.Format(Messages.DELETED_CUSTOM_FIELD, name),
- delegate(Session session)
- {
- CustomFieldsManager.RemoveCustomField(session, connection, customFieldDefinition);
- });
- action.RunAsync();
- }
-
- private void lbCustomFields_SelectedIndexChanged(object sender, EventArgs e)
- {
- btnDelete.Enabled = lbCustomFields.SelectedIndex >= 0;
- }
- }
-}
\ No newline at end of file
diff --git a/XenAdmin/Dialogs/CustomFieldsDialog.ja.resx b/XenAdmin/Dialogs/CustomFieldsDialog.ja.resx
deleted file mode 100644
index add0bc868..000000000
--- a/XenAdmin/Dialogs/CustomFieldsDialog.ja.resx
+++ /dev/null
@@ -1,306 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
-
- Bottom, Right
-
-
-
- Segoe UI, 9pt
-
-
- NoControl
-
-
- 179, 203
-
-
- 3, 3, 5, 3
-
-
- 75, 23
-
-
-
- 4
-
-
- 閉じる
-
-
- btnClose
-
-
- System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- $this
-
-
- 0
-
-
- Top, Right
-
-
- Segoe UI, 9pt
-
-
- 179, 54
-
-
- 75, 23
-
-
- 3
-
-
- 削除(&D)
-
-
- btnDelete
-
-
- System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- $this
-
-
- 1
-
-
- Top, Right
-
-
- Segoe UI, 9pt
-
-
- 179, 25
-
-
- 75, 23
-
-
- 2
-
-
- 追加(&A)...
-
-
- btnAdd
-
-
- System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- $this
-
-
- 2
-
-
- True
-
-
- Segoe UI, 9pt
-
-
- 9, 9
-
-
- 174, 21
-
-
- 0
-
-
- 現在のカスタム フィールド(&C):
-
-
- CustomFieldsLabel
-
-
- System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- $this
-
-
- 3
-
-
- Top, Bottom, Left, Right
-
-
- Segoe UI, 9pt
-
-
- True
-
-
- False
-
-
- 15
-
-
- 12, 25
-
-
- 161, 201
-
-
- 1
-
-
- lbCustomFields
-
-
- System.Windows.Forms.ListBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- $this
-
-
- 4
-
-
- True
-
-
- 96, 96
-
-
- 268, 238
-
-
- Tahoma, 8pt
-
-
- カスタム フィールド
-
-
- CustomFieldsDialog
-
-
- XenAdmin.Dialogs.XenDialogBase, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
-
-
\ No newline at end of file
diff --git a/XenAdmin/Dialogs/CustomFieldsDialog.resx b/XenAdmin/Dialogs/CustomFieldsDialog.resx
deleted file mode 100644
index fccfb5322..000000000
--- a/XenAdmin/Dialogs/CustomFieldsDialog.resx
+++ /dev/null
@@ -1,306 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
-
- Bottom, Right
-
-
-
- Segoe UI, 9pt
-
-
- NoControl
-
-
- 179, 203
-
-
- 3, 3, 5, 3
-
-
- 75, 23
-
-
-
- 4
-
-
- Close
-
-
- btnClose
-
-
- System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- $this
-
-
- 0
-
-
- Top, Right
-
-
- Segoe UI, 9pt
-
-
- 179, 54
-
-
- 75, 23
-
-
- 3
-
-
- &Delete
-
-
- btnDelete
-
-
- System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- $this
-
-
- 1
-
-
- Top, Right
-
-
- Segoe UI, 9pt
-
-
- 179, 25
-
-
- 75, 23
-
-
- 2
-
-
- &Add...
-
-
- btnAdd
-
-
- System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- $this
-
-
- 2
-
-
- True
-
-
- Segoe UI, 9pt
-
-
- 9, 9
-
-
- 124, 15
-
-
- 0
-
-
- &Current custom fields:
-
-
- CustomFieldsLabel
-
-
- System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- $this
-
-
- 3
-
-
- Top, Bottom, Left, Right
-
-
- Segoe UI, 9pt
-
-
- True
-
-
- False
-
-
- 15
-
-
- 12, 25
-
-
- 161, 201
-
-
- 1
-
-
- lbCustomFields
-
-
- System.Windows.Forms.ListBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- $this
-
-
- 4
-
-
- True
-
-
- 96, 96
-
-
- 268, 238
-
-
- Tahoma, 8pt
-
-
- Custom Fields
-
-
- CustomFieldsDialog
-
-
- XenAdmin.Dialogs.XenDialogBase, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
-
-
\ No newline at end of file
diff --git a/XenAdmin/Dialogs/CustomFieldsDialog.zh-CN.resx b/XenAdmin/Dialogs/CustomFieldsDialog.zh-CN.resx
deleted file mode 100644
index b66031c9b..000000000
--- a/XenAdmin/Dialogs/CustomFieldsDialog.zh-CN.resx
+++ /dev/null
@@ -1,306 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
-
- Bottom, Right
-
-
-
- Segoe UI, 9pt
-
-
- NoControl
-
-
- 179, 203
-
-
- 3, 3, 5, 3
-
-
- 75, 23
-
-
-
- 4
-
-
- 关闭
-
-
- btnClose
-
-
- System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- $this
-
-
- 0
-
-
- Top, Right
-
-
- Segoe UI, 9pt
-
-
- 179, 54
-
-
- 75, 23
-
-
- 3
-
-
- 删除(&D)
-
-
- btnDelete
-
-
- System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- $this
-
-
- 1
-
-
- Top, Right
-
-
- Segoe UI, 9pt
-
-
- 179, 25
-
-
- 75, 23
-
-
- 2
-
-
- 添加(&A)...
-
-
- btnAdd
-
-
- System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- $this
-
-
- 2
-
-
- True
-
-
- Segoe UI, 9pt
-
-
- 9, 8
-
-
- 124, 15
-
-
- 0
-
-
- 当前自定义字段(&C):
-
-
- CustomFieldsLabel
-
-
- System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- $this
-
-
- 3
-
-
- Top, Bottom, Left, Right
-
-
- Segoe UI, 9pt
-
-
- True
-
-
- False
-
-
- 15
-
-
- 12, 25
-
-
- 161, 201
-
-
- 1
-
-
- lbCustomFields
-
-
- System.Windows.Forms.ListBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- $this
-
-
- 4
-
-
- True
-
-
- 96, 96
-
-
- 268, 238
-
-
- Tahoma, 8pt
-
-
- 自定义字段
-
-
- CustomFieldsDialog
-
-
- XenAdmin.Dialogs.XenDialogBase, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
-
-
\ No newline at end of file
diff --git a/XenAdmin/Dialogs/NewCustomFieldDialog.Designer.cs b/XenAdmin/Dialogs/NewCustomFieldDialog.Designer.cs
index 4f7f42d4c..8a17f25ed 100644
--- a/XenAdmin/Dialogs/NewCustomFieldDialog.Designer.cs
+++ b/XenAdmin/Dialogs/NewCustomFieldDialog.Designer.cs
@@ -31,11 +31,14 @@ namespace XenAdmin.Dialogs
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(NewCustomFieldDialog));
this.btnCancel = new System.Windows.Forms.Button();
this.okButton = new System.Windows.Forms.Button();
- this.NameTextBox = new System.Windows.Forms.TextBox();
- this.label1 = new System.Windows.Forms.Label();
- this.label2 = new System.Windows.Forms.Label();
- this.TypeComboBox = new System.Windows.Forms.ComboBox();
- this.DuplicateWarning = new System.Windows.Forms.Label();
+ this.textBoxName = new System.Windows.Forms.TextBox();
+ this.labelName = new System.Windows.Forms.Label();
+ this.labelType = new System.Windows.Forms.Label();
+ this.comboBoxType = new System.Windows.Forms.ComboBox();
+ this.labelDuplicate = new System.Windows.Forms.Label();
+ this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
+ this.labelBlurb = new System.Windows.Forms.Label();
+ this.tableLayoutPanel1.SuspendLayout();
this.SuspendLayout();
//
// btnCancel
@@ -52,37 +55,59 @@ namespace XenAdmin.Dialogs
this.okButton.Name = "okButton";
this.okButton.UseVisualStyleBackColor = true;
//
- // NameTextBox
+ // textBoxName
//
- resources.ApplyResources(this.NameTextBox, "NameTextBox");
- this.NameTextBox.Name = "NameTextBox";
- this.NameTextBox.TextChanged += new System.EventHandler(this.NameTextBox_TextChanged);
+ resources.ApplyResources(this.textBoxName, "textBoxName");
+ this.tableLayoutPanel1.SetColumnSpan(this.textBoxName, 2);
+ this.textBoxName.Name = "textBoxName";
+ this.textBoxName.TextChanged += new System.EventHandler(this.NameTextBox_TextChanged);
//
- // label1
+ // labelName
//
- resources.ApplyResources(this.label1, "label1");
- this.label1.Name = "label1";
+ resources.ApplyResources(this.labelName, "labelName");
+ this.labelName.Name = "labelName";
//
- // label2
+ // labelType
//
- resources.ApplyResources(this.label2, "label2");
- this.label2.Name = "label2";
+ resources.ApplyResources(this.labelType, "labelType");
+ this.labelType.Name = "labelType";
//
- // TypeComboBox
+ // comboBoxType
//
- resources.ApplyResources(this.TypeComboBox, "TypeComboBox");
- this.TypeComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
- this.TypeComboBox.FormattingEnabled = true;
- this.TypeComboBox.Items.AddRange(new object[] {
- resources.GetString("TypeComboBox.Items"),
- resources.GetString("TypeComboBox.Items1")});
- this.TypeComboBox.Name = "TypeComboBox";
+ resources.ApplyResources(this.comboBoxType, "comboBoxType");
+ this.tableLayoutPanel1.SetColumnSpan(this.comboBoxType, 2);
+ this.comboBoxType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.comboBoxType.FormattingEnabled = true;
+ this.comboBoxType.Items.AddRange(new object[] {
+ resources.GetString("comboBoxType.Items"),
+ resources.GetString("comboBoxType.Items1")});
+ this.comboBoxType.Name = "comboBoxType";
//
- // DuplicateWarning
+ // labelDuplicate
//
- resources.ApplyResources(this.DuplicateWarning, "DuplicateWarning");
- this.DuplicateWarning.ForeColor = System.Drawing.Color.Red;
- this.DuplicateWarning.Name = "DuplicateWarning";
+ resources.ApplyResources(this.labelDuplicate, "labelDuplicate");
+ this.tableLayoutPanel1.SetColumnSpan(this.labelDuplicate, 2);
+ this.labelDuplicate.ForeColor = System.Drawing.Color.Red;
+ this.labelDuplicate.Name = "labelDuplicate";
+ //
+ // tableLayoutPanel1
+ //
+ resources.ApplyResources(this.tableLayoutPanel1, "tableLayoutPanel1");
+ this.tableLayoutPanel1.Controls.Add(this.labelBlurb, 0, 0);
+ this.tableLayoutPanel1.Controls.Add(this.textBoxName, 1, 1);
+ this.tableLayoutPanel1.Controls.Add(this.comboBoxType, 1, 3);
+ this.tableLayoutPanel1.Controls.Add(this.labelDuplicate, 1, 2);
+ this.tableLayoutPanel1.Controls.Add(this.btnCancel, 2, 4);
+ this.tableLayoutPanel1.Controls.Add(this.labelName, 0, 1);
+ this.tableLayoutPanel1.Controls.Add(this.labelType, 0, 3);
+ this.tableLayoutPanel1.Controls.Add(this.okButton, 1, 4);
+ this.tableLayoutPanel1.Name = "tableLayoutPanel1";
+ //
+ // labelBlurb
+ //
+ resources.ApplyResources(this.labelBlurb, "labelBlurb");
+ this.tableLayoutPanel1.SetColumnSpan(this.labelBlurb, 3);
+ this.labelBlurb.Name = "labelBlurb";
//
// NewCustomFieldDialog
//
@@ -90,27 +115,24 @@ namespace XenAdmin.Dialogs
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.CancelButton = this.btnCancel;
- this.Controls.Add(this.DuplicateWarning);
- this.Controls.Add(this.TypeComboBox);
- this.Controls.Add(this.label2);
- this.Controls.Add(this.label1);
- this.Controls.Add(this.btnCancel);
- this.Controls.Add(this.NameTextBox);
- this.Controls.Add(this.okButton);
+ this.Controls.Add(this.tableLayoutPanel1);
this.Name = "NewCustomFieldDialog";
+ this.tableLayoutPanel1.ResumeLayout(false);
+ this.tableLayoutPanel1.PerformLayout();
this.ResumeLayout(false);
- this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button btnCancel;
- private System.Windows.Forms.TextBox NameTextBox;
+ private System.Windows.Forms.TextBox textBoxName;
private System.Windows.Forms.Button okButton;
- private System.Windows.Forms.Label label1;
- private System.Windows.Forms.Label label2;
- private System.Windows.Forms.ComboBox TypeComboBox;
- private System.Windows.Forms.Label DuplicateWarning;
+ private System.Windows.Forms.Label labelName;
+ private System.Windows.Forms.Label labelType;
+ private System.Windows.Forms.ComboBox comboBoxType;
+ private System.Windows.Forms.Label labelDuplicate;
+ private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
+ private System.Windows.Forms.Label labelBlurb;
}
}
\ No newline at end of file
diff --git a/XenAdmin/Dialogs/NewCustomFieldDialog.cs b/XenAdmin/Dialogs/NewCustomFieldDialog.cs
index 04a7b9081..deeb5811f 100644
--- a/XenAdmin/Dialogs/NewCustomFieldDialog.cs
+++ b/XenAdmin/Dialogs/NewCustomFieldDialog.cs
@@ -29,6 +29,7 @@
*/
using System;
+using System.Linq;
using XenAdmin.CustomFields;
using XenAdmin.Network;
@@ -41,36 +42,32 @@ namespace XenAdmin.Dialogs
{
InitializeComponent();
- okButton.Enabled = !string.IsNullOrEmpty(NameTextBox.Text);
- TypeComboBox.SelectedIndex = 0;
+ comboBoxType.SelectedIndex = 0;
+ UpdateControls();
}
- public CustomFieldDefinition Definition
+ public CustomFieldDefinition Definition =>
+ new CustomFieldDefinition(textBoxName.Text.Trim(), (CustomFieldDefinition.Types)comboBoxType.SelectedIndex);
+
+ private void UpdateControls()
{
- get
+ if (string.IsNullOrWhiteSpace(textBoxName.Text))
{
- return new CustomFieldDefinition(NameTextBox.Text.Trim(),
- (CustomFieldDefinition.Types)TypeComboBox.SelectedIndex);
+ okButton.Enabled = false;
+ labelDuplicate.Visible = false;
+ return;
}
+
+ var existingCustomFields = CustomFieldsManager.GetCustomFields(connection);
+ var isDuplicate = existingCustomFields.Any(f => f.Name.Trim() == textBoxName.Text.Trim());
+
+ okButton.Enabled = !isDuplicate;
+ labelDuplicate.Visible = isDuplicate;
}
private void NameTextBox_TextChanged(object sender, EventArgs e)
{
- okButton.Enabled = EnableOKButton();
- DuplicateWarning.Visible = IsDuplicate();
- }
-
- private bool IsDuplicate()
- {
- foreach (CustomFieldDefinition customFieldDefinition in CustomFieldsManager.GetCustomFields(connection))
- if (customFieldDefinition.Name.Trim() == Definition.Name.Trim())
- return true;
- return false;
- }
-
- private bool EnableOKButton()
- {
- return !string.IsNullOrEmpty(NameTextBox.Text.Trim()) && !IsDuplicate();
+ UpdateControls();
}
}
}
\ No newline at end of file
diff --git a/XenAdmin/Dialogs/NewCustomFieldDialog.resx b/XenAdmin/Dialogs/NewCustomFieldDialog.resx
index bf8cad3c0..7318ddf68 100644
--- a/XenAdmin/Dialogs/NewCustomFieldDialog.resx
+++ b/XenAdmin/Dialogs/NewCustomFieldDialog.resx
@@ -112,16 +112,16 @@
2.0
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
+
Bottom, Right
-
+
Segoe UI, 9pt
@@ -129,17 +129,14 @@
NoControl
- 222, 98
-
-
- 4, 3, 0, 3
+ 246, 135
75, 23
-
+
- 5
+ 7
Cancel
@@ -148,10 +145,10 @@
btnCancel
- System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- $this
+ tableLayoutPanel1
4
@@ -166,16 +163,13 @@
NoControl
- 140, 98
-
-
- 3, 8, 3, 3
+ 165, 135
75, 23
- 4
+ 6
OK
@@ -184,175 +178,253 @@
okButton
- System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- $this
+ tableLayoutPanel1
- 6
+ 7
-
- Top, Left, Right
+
+ Left, Right
-
- Segoe UI, 9pt
-
-
- 74, 13
-
-
- 223, 23
-
-
- 1
-
-
- NameTextBox
-
-
- System.Windows.Forms.TextBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- $this
-
-
- 5
-
-
- True
-
-
- Segoe UI, 9pt
-
-
- 13, 16
-
-
- 42, 15
-
-
- 0
-
-
- &Name:
-
-
- label1
-
-
- System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- $this
-
-
+
3
-
+
True
-
+
+ Fill
+
+
Segoe UI, 9pt
-
- 13, 62
+
+ 3, 0
-
- 36, 15
+
+ 3, 0, 3, 15
-
- 2
+
+ 318, 30
-
- &Type:
+
+ 0
-
- label2
+
+ Enter a name for the new custom field and select its type. The new field will be available to all resources in the pool.
-
- System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ labelBlurb
-
- $this
+
+ System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
- 2
+
+ tableLayoutPanel1
-
- Top, Left, Right
+
+ 0
-
+
+ Left, Right
+
+
Segoe UI, 9pt
-
+
Text
-
+
Date & Time
-
- 74, 59
+
+ 51, 94
-
- 223, 23
+
+ 270, 23
-
- 3
+
+ 5
-
- TypeComboBox
+
+ comboBoxType
-
- System.Windows.Forms.ComboBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
- $this
+
+ tableLayoutPanel1
-
- 1
+
+ 2
-
+
True
-
+
Segoe UI, 9pt
-
- 71, 39
+
+ 51, 74
-
- 195, 15
+
+ 241, 15
-
- 6
+
+ 3
-
- Cannot add duplicate custom fields
+
+ A custom filed with this name already exists.
-
+
False
-
- DuplicateWarning
+
+ labelDuplicate
-
- System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
- $this
+
+ tableLayoutPanel1
-
+
+ 3
+
+
+ Left
+
+
+ True
+
+
+ Segoe UI, 9pt
+
+
+ 3, 52
+
+
+ 42, 15
+
+
+ 1
+
+
+ &Name:
+
+
+ labelName
+
+
+ System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ tableLayoutPanel1
+
+
+ 5
+
+
+ Left
+
+
+ True
+
+
+ Segoe UI, 9pt
+
+
+ 3, 98
+
+
+ 34, 15
+
+
+ 4
+
+
+ &Type:
+
+
+ labelType
+
+
+ System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ tableLayoutPanel1
+
+
+ 6
+
+
+ Fill
+
+
+ Segoe UI, 9pt
+
+
+ 10, 10
+
+
+ 5
+
+
+ 324, 161
+
+
0
-
+
+ tableLayoutPanel1
+
+
+ System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ $this
+
+
+ 0
+
+
+ <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="labelBlurb" Row="0" RowSpan="1" Column="0" ColumnSpan="3" /><Control Name="textBoxName" Row="1" RowSpan="1" Column="1" ColumnSpan="2" /><Control Name="comboBoxType" Row="3" RowSpan="1" Column="1" ColumnSpan="2" /><Control Name="labelDuplicate" Row="2" RowSpan="1" Column="1" ColumnSpan="2" /><Control Name="btnCancel" Row="4" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="labelName" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="labelType" Row="3" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="okButton" Row="4" RowSpan="1" Column="1" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,0,Percent,100,AutoSize,0" /><Rows Styles="AutoSize,0,AutoSize,0,Absolute,17,AutoSize,0,Percent,100" /></TableLayoutSettings>
+
+
+ Segoe UI, 9pt
+
+
+ 51, 48
+
+
+ 270, 23
+
+
+ 2
+
+
+ textBoxName
+
+
+ System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ tableLayoutPanel1
+
+
+ 1
+
+
True
96, 96
- 310, 127
+ 344, 181
Tahoma, 8pt
@@ -367,6 +439,6 @@
NewCustomFieldDialog
- XenAdmin.Dialogs.XenDialogBase, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
+ XenAdmin.Dialogs.XenDialogBase, [XenCenter_No_Space], Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
\ No newline at end of file
diff --git a/XenAdmin/SettingsPanels/CustomFieldsDisplayPage.cs b/XenAdmin/SettingsPanels/CustomFieldsDisplayPage.cs
index 75fa539d7..7b4f833a2 100644
--- a/XenAdmin/SettingsPanels/CustomFieldsDisplayPage.cs
+++ b/XenAdmin/SettingsPanels/CustomFieldsDisplayPage.cs
@@ -32,6 +32,7 @@ using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
+using System.Linq;
using System.Windows.Forms;
using XenAdmin.Actions;
@@ -44,12 +45,21 @@ namespace XenAdmin.SettingsPanels
{
public partial class CustomFieldsDisplayPage : UserControl, IEditPage
{
- private readonly Dictionary> controls = new Dictionary>();
+ ///
+ /// This is not ideal, but we need something in the last row of the tableLayoutPanel
+ /// that fills all the way to the bottom of the page; if we leave the controls in the
+ /// last row, they align vertically in its middle because they don't have vertical
+ /// anchoring (because they have different heights and it's a pain to get the vertical
+ /// alignment right by fiddling with the margins)
+ ///
+ private readonly Panel _panelDummy;
+ private IXenObject _xenObject;
+ private readonly List _fieldRows = new List();
public CustomFieldsDisplayPage()
{
InitializeComponent();
-
+ _panelDummy = new Panel { Size = new Size(0, 0), Margin = new Padding(0) };
Text = Messages.CUSTOM_FIELDS;
}
@@ -57,39 +67,35 @@ namespace XenAdmin.SettingsPanels
public AsyncAction SaveSettings()
{
- List customFields = new List();
+ var customFields = new List();
- foreach (KeyValuePair> kvp in controls)
+ foreach (var row in _fieldRows)
{
- object currentValue = CustomFieldsManager.GetCustomFieldValue(xenObject, kvp.Key);
- object newValue = GetValue(kvp.Key, kvp.Value.Value);
+ object currentValue = CustomFieldsManager.GetCustomFieldValue(_xenObject, row.CustomFieldDefinition);
+ object newValue = row.GetValue();
if (currentValue == null && newValue == null)
continue;
- customFields.Add(new CustomField(kvp.Key, newValue));
+ customFields.Add(new CustomField(row.CustomFieldDefinition, newValue));
}
- return new SaveCustomFieldsAction(xenObject, customFields, true);
+ return new SaveCustomFieldsAction(_xenObject, customFields, true);
}
- private IXenObject xenObject;
public void SetXenObjects(IXenObject orig, IXenObject clone)
{
CustomFieldsManager.CustomFieldsChanged -= CustomFields_CustomFieldsChanged;
- xenObject = clone;
+ _xenObject = clone;
- if (xenObject != null)
+ if (_xenObject != null)
{
CustomFieldsManager.CustomFieldsChanged += CustomFields_CustomFieldsChanged;
Rebuild(true);
}
}
- public bool ValidToSave
- {
- get { return true; }
- }
+ public bool ValidToSave => true;
public void ShowLocalValidationMessages()
{
@@ -107,10 +113,10 @@ namespace XenAdmin.SettingsPanels
{
get
{
- foreach (KeyValuePair> kvp in controls)
+ foreach (var row in _fieldRows)
{
- Object currentValue = CustomFieldsManager.GetCustomFieldValue(xenObject, kvp.Key);
- Object newValue = GetValue(kvp.Key, kvp.Value.Value);
+ object currentValue = CustomFieldsManager.GetCustomFieldValue(_xenObject, row.CustomFieldDefinition);
+ object newValue = row.GetValue();
if (currentValue == null && newValue == null)
continue;
@@ -132,26 +138,26 @@ namespace XenAdmin.SettingsPanels
#region IVerticalTab Members
- public String SubText
+ public string SubText
{
get
{
- List fields = new List();
+ List fields = new List();
- foreach (KeyValuePair> kvp in controls)
+ foreach (var row in _fieldRows)
{
- Object newValue = GetValue(kvp.Key, kvp.Value.Value);
+ object newValue = row.GetValue();
- if (newValue == null || newValue.ToString() == String.Empty)
+ if (newValue == null || newValue.ToString() == string.Empty)
continue;
- fields.Add(kvp.Key.Name + Messages.GENERAL_PAGE_KVP_SEPARATOR + newValue);
+ fields.Add(row.CustomFieldDefinition.Name + Messages.GENERAL_PAGE_KVP_SEPARATOR + newValue);
}
if (fields.Count == 0)
return Messages.NONE;
- return string.Join(", ", fields.ToArray());
+ return string.Join(", ", fields);
}
}
@@ -164,192 +170,262 @@ namespace XenAdmin.SettingsPanels
Rebuild(false);
}
- private Object GetValue(CustomFieldDefinition definition, Control control)
+ private void Rebuild(bool resetValues)
{
- switch (definition.Type)
- {
- case CustomFieldDefinition.Types.Date:
- {
- DateTimePicker dateControl = (DateTimePicker)control;
- if (!dateControl.Checked)
- return null;
- DateTimePicker timeControl = (DateTimePicker)dateControl.Tag;
- DateTime date = dateControl.Value;
- DateTime time = timeControl.Value;
-
- return new DateTime(date.Year, date.Month, date.Day, time.Hour, time.Minute, time.Second);
- }
-
- case CustomFieldDefinition.Types.String:
- TextBox textBox = control as TextBox;
- if (textBox == null)
- return null;
-
- string text = textBox.Text;
- return (text == "" ? null : text);
-
- default:
- throw new InvalidEnumArgumentException();
- }
- }
-
- private void SetValue(CustomFieldDefinition definition, Control control, Object value)
- {
- switch (definition.Type)
- {
- case CustomFieldDefinition.Types.Date:
- {
- DateTimePicker dateControl = (DateTimePicker)control;
- DateTimePicker timeControl = (DateTimePicker)dateControl.Tag;
-
- if (value != null)
- {
- dateControl.Checked = true;
- dateControl.Value = (DateTime)value;
- timeControl.Value = (DateTime)value;
- }
- else
- dateControl.Checked = false;
- }
- break;
-
- case CustomFieldDefinition.Types.String:
- TextBox textBox = control as TextBox;
- if (textBox == null)
- return;
-
- textBox.Text = (String)value;
- break;
- }
- }
-
- private void Rebuild(bool revertValues)
- {
- CustomFieldDefinition[] customFieldDefinitions = CustomFieldsManager.GetCustomFields(xenObject.Connection).ToArray();
+ var customFieldDefinitions = CustomFieldsManager.GetCustomFields(_xenObject.Connection).ToArray();
tableLayoutPanel.SuspendLayout();
+ tableLayoutPanel.Controls.Remove(_panelDummy);
// Add new custom fields
- foreach (CustomFieldDefinition customFieldDefinition in customFieldDefinitions)
+ foreach (var definition in customFieldDefinitions)
{
- Object value = CustomFieldsManager.GetCustomFieldValue(xenObject, customFieldDefinition);
+ object value = CustomFieldsManager.GetCustomFieldValue(_xenObject, definition);
+ var row = _fieldRows.FirstOrDefault(r => r.CustomFieldDefinition.Equals(definition));
- if (!controls.ContainsKey(customFieldDefinition))
+ if (row == null)
{
- // Create the display label
- Label lblKey = new Label();
- lblKey.Text = customFieldDefinition.Name.EscapeAmpersands();
- lblKey.Margin = new Padding(3, 7, 3, 3);
- lblKey.Font = Program.DefaultFont;
- lblKey.Width = (int)tableLayoutPanel.ColumnStyles[0].Width;
- lblKey.AutoEllipsis = true;
- lblKey.AutoSize = false;
+ row = new CustomFieldRow(definition, value);
+ row.DeleteCustomFieldClicked += DeleteCustomFieldClicked_Click;
- tableLayoutPanel.Controls.Add(lblKey);
+ _fieldRows.Add(row);
+ tableLayoutPanel.Controls.AddRange(row.Controls);
- // Create value field
- Control control;
-
- switch (customFieldDefinition.Type)
- {
- case CustomFieldDefinition.Types.String:
- TextBox textBox = new TextBox();
- textBox.Text = (String)value;
-
- tableLayoutPanel.Controls.Add(textBox);
- tableLayoutPanel.SetColumnSpan(textBox, 2);
- textBox.Dock = DockStyle.Fill;
- control = textBox;
- break;
-
- case CustomFieldDefinition.Types.Date:
- DateTimePicker date = new DateTimePicker();
- date.MinDate = DateTime.MinValue;
- date.MaxDate = DateTime.MaxValue;
- date.Dock = DockStyle.Fill;
- date.MinimumSize = new Size(0, 24);
- date.ShowCheckBox = true;
- date.Format = DateTimePickerFormat.Long;
- if (value != null)
- {
- date.Value = (DateTime)value;
- date.Checked = true;
- }
- else
- date.Checked = false;
- tableLayoutPanel.Controls.Add(date);
-
- DateTimePicker time = new DateTimePicker();
- time.MinDate = DateTime.MinValue;
- time.MaxDate = DateTime.MaxValue;
- time.Dock = DockStyle.Fill;
- time.MinimumSize = new Size(0, 24);
- time.Format = DateTimePickerFormat.Time;
- time.ShowUpDown = true;
- if (value != null)
- {
- time.Value = (DateTime)value;
- time.Enabled = true;
- }
- else
- time.Enabled = false;
- tableLayoutPanel.Controls.Add(time);
- // Tag so we can remove this control later
- date.Tag = time;
- date.ValueChanged += delegate(Object sender, EventArgs e)
- {
- time.Enabled = date.Checked;
- };
-
- control = date;
- break;
-
- default:
- throw new InvalidEnumArgumentException();
- }
-
- controls[customFieldDefinition] = new KeyValuePair