Merge pull request #3090 from kc284/custom_fields

Fixed some issues around custom fields
This commit is contained in:
Konstantina Chremmou 2023-03-01 14:31:18 +00:00 committed by GitHub
commit fddca73f08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 795 additions and 1645 deletions

View File

@ -1,104 +0,0 @@
using XenAdmin.CustomFields;
using XenAdmin.XenSearch;
using System;
using XenAPI;
using XenAdmin.Core;
namespace XenAdmin.Dialogs
{
partial class CustomFieldsDialog
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
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
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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;
}
}

View File

@ -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;
}
}
}

View File

@ -1,306 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace"/>
<xsd:element msdata:IsDataSet="true" name="root">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="0" name="value" type="xsd:string"/>
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required"/>
<xsd:attribute name="type" type="xsd:string"/>
<xsd:attribute name="mimetype" type="xsd:string"/>
<xsd:attribute ref="xml:space"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string"/>
<xsd:attribute name="name" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="0" msdata:Ordinal="1" name="value" type="xsd:string"/>
<xsd:element minOccurs="0" msdata:Ordinal="2" name="comment" type="xsd:string"/>
</xsd:sequence>
<xsd:attribute msdata:Ordinal="1" name="name" type="xsd:string" use="required"/>
<xsd:attribute msdata:Ordinal="3" name="type" type="xsd:string"/>
<xsd:attribute msdata:Ordinal="4" name="mimetype" type="xsd:string"/>
<xsd:attribute ref="xml:space"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="0" msdata:Ordinal="1" name="value" type="xsd:string"/>
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required"/>
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<data name="btnClose.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Right</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
<data name="btnClose.Font" type="System.Drawing.Font, System.Drawing">
<value>Segoe UI, 9pt</value>
</data>
<data name="btnClose.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="btnClose.Location" type="System.Drawing.Point, System.Drawing">
<value>179, 203</value>
</data>
<data name="btnClose.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 3, 5, 3</value>
</data>
<data name="btnClose.Size" type="System.Drawing.Size, System.Drawing">
<value>75, 23</value>
</data>
<assembly alias="mscorlib" name="mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<data name="btnClose.TabIndex" type="System.Int32, mscorlib">
<value>4</value>
</data>
<data name="btnClose.Text" xml:space="preserve">
<value>閉じる</value>
</data>
<data name="&gt;&gt;btnClose.Name" xml:space="preserve">
<value>btnClose</value>
</data>
<data name="&gt;&gt;btnClose.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;btnClose.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;btnClose.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="btnDelete.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
</data>
<data name="btnDelete.Font" type="System.Drawing.Font, System.Drawing">
<value>Segoe UI, 9pt</value>
</data>
<data name="btnDelete.Location" type="System.Drawing.Point, System.Drawing">
<value>179, 54</value>
</data>
<data name="btnDelete.Size" type="System.Drawing.Size, System.Drawing">
<value>75, 23</value>
</data>
<data name="btnDelete.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
</data>
<data name="btnDelete.Text" xml:space="preserve">
<value>削除(&amp;D)</value>
</data>
<data name="&gt;&gt;btnDelete.Name" xml:space="preserve">
<value>btnDelete</value>
</data>
<data name="&gt;&gt;btnDelete.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;btnDelete.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;btnDelete.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="btnAdd.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
</data>
<data name="btnAdd.Font" type="System.Drawing.Font, System.Drawing">
<value>Segoe UI, 9pt</value>
</data>
<data name="btnAdd.Location" type="System.Drawing.Point, System.Drawing">
<value>179, 25</value>
</data>
<data name="btnAdd.Size" type="System.Drawing.Size, System.Drawing">
<value>75, 23</value>
</data>
<data name="btnAdd.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
</data>
<data name="btnAdd.Text" xml:space="preserve">
<value>追加(&amp;A)...</value>
</data>
<data name="&gt;&gt;btnAdd.Name" xml:space="preserve">
<value>btnAdd</value>
</data>
<data name="&gt;&gt;btnAdd.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;btnAdd.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;btnAdd.ZOrder" xml:space="preserve">
<value>2</value>
</data>
<data name="CustomFieldsLabel.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="CustomFieldsLabel.Font" type="System.Drawing.Font, System.Drawing">
<value>Segoe UI, 9pt</value>
</data>
<data name="CustomFieldsLabel.Location" type="System.Drawing.Point, System.Drawing">
<value>9, 9</value>
</data>
<data name="CustomFieldsLabel.Size" type="System.Drawing.Size, System.Drawing">
<value>174, 21</value>
</data>
<data name="CustomFieldsLabel.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
</data>
<data name="CustomFieldsLabel.Text" xml:space="preserve">
<value>現在のカスタム フィールド(&amp;C):</value>
</data>
<data name="&gt;&gt;CustomFieldsLabel.Name" xml:space="preserve">
<value>CustomFieldsLabel</value>
</data>
<data name="&gt;&gt;CustomFieldsLabel.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;CustomFieldsLabel.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;CustomFieldsLabel.ZOrder" xml:space="preserve">
<value>3</value>
</data>
<data name="lbCustomFields.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Bottom, Left, Right</value>
</data>
<data name="lbCustomFields.Font" type="System.Drawing.Font, System.Drawing">
<value>Segoe UI, 9pt</value>
</data>
<data name="lbCustomFields.HorizontalScrollbar" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="lbCustomFields.IntegralHeight" type="System.Boolean, mscorlib">
<value>False</value>
</data>
<data name="lbCustomFields.ItemHeight" type="System.Int32, mscorlib">
<value>15</value>
</data>
<data name="lbCustomFields.Location" type="System.Drawing.Point, System.Drawing">
<value>12, 25</value>
</data>
<data name="lbCustomFields.Size" type="System.Drawing.Size, System.Drawing">
<value>161, 201</value>
</data>
<data name="lbCustomFields.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
</data>
<data name="&gt;&gt;lbCustomFields.Name" xml:space="preserve">
<value>lbCustomFields</value>
</data>
<data name="&gt;&gt;lbCustomFields.Type" xml:space="preserve">
<value>System.Windows.Forms.ListBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;lbCustomFields.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;lbCustomFields.ZOrder" xml:space="preserve">
<value>4</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
<value>96, 96</value>
</data>
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
<value>268, 238</value>
</data>
<data name="$this.Font" type="System.Drawing.Font, System.Drawing">
<value>Tahoma, 8pt</value>
</data>
<data name="$this.Text" xml:space="preserve">
<value>カスタム フィールド</value>
</data>
<data name="&gt;&gt;$this.Name" xml:space="preserve">
<value>CustomFieldsDialog</value>
</data>
<data name="&gt;&gt;$this.Type" xml:space="preserve">
<value>XenAdmin.Dialogs.XenDialogBase, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</value>
</data>
</root>

View File

@ -1,306 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="btnClose.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Right</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="btnClose.Font" type="System.Drawing.Font, System.Drawing">
<value>Segoe UI, 9pt</value>
</data>
<data name="btnClose.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="btnClose.Location" type="System.Drawing.Point, System.Drawing">
<value>179, 203</value>
</data>
<data name="btnClose.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 3, 5, 3</value>
</data>
<data name="btnClose.Size" type="System.Drawing.Size, System.Drawing">
<value>75, 23</value>
</data>
<assembly alias="mscorlib" name="mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="btnClose.TabIndex" type="System.Int32, mscorlib">
<value>4</value>
</data>
<data name="btnClose.Text" xml:space="preserve">
<value>Close</value>
</data>
<data name="&gt;&gt;btnClose.Name" xml:space="preserve">
<value>btnClose</value>
</data>
<data name="&gt;&gt;btnClose.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;btnClose.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;btnClose.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="btnDelete.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
</data>
<data name="btnDelete.Font" type="System.Drawing.Font, System.Drawing">
<value>Segoe UI, 9pt</value>
</data>
<data name="btnDelete.Location" type="System.Drawing.Point, System.Drawing">
<value>179, 54</value>
</data>
<data name="btnDelete.Size" type="System.Drawing.Size, System.Drawing">
<value>75, 23</value>
</data>
<data name="btnDelete.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
</data>
<data name="btnDelete.Text" xml:space="preserve">
<value>&amp;Delete</value>
</data>
<data name="&gt;&gt;btnDelete.Name" xml:space="preserve">
<value>btnDelete</value>
</data>
<data name="&gt;&gt;btnDelete.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;btnDelete.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;btnDelete.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="btnAdd.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
</data>
<data name="btnAdd.Font" type="System.Drawing.Font, System.Drawing">
<value>Segoe UI, 9pt</value>
</data>
<data name="btnAdd.Location" type="System.Drawing.Point, System.Drawing">
<value>179, 25</value>
</data>
<data name="btnAdd.Size" type="System.Drawing.Size, System.Drawing">
<value>75, 23</value>
</data>
<data name="btnAdd.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
</data>
<data name="btnAdd.Text" xml:space="preserve">
<value>&amp;Add...</value>
</data>
<data name="&gt;&gt;btnAdd.Name" xml:space="preserve">
<value>btnAdd</value>
</data>
<data name="&gt;&gt;btnAdd.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;btnAdd.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;btnAdd.ZOrder" xml:space="preserve">
<value>2</value>
</data>
<data name="CustomFieldsLabel.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="CustomFieldsLabel.Font" type="System.Drawing.Font, System.Drawing">
<value>Segoe UI, 9pt</value>
</data>
<data name="CustomFieldsLabel.Location" type="System.Drawing.Point, System.Drawing">
<value>9, 9</value>
</data>
<data name="CustomFieldsLabel.Size" type="System.Drawing.Size, System.Drawing">
<value>124, 15</value>
</data>
<data name="CustomFieldsLabel.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
</data>
<data name="CustomFieldsLabel.Text" xml:space="preserve">
<value>&amp;Current custom fields:</value>
</data>
<data name="&gt;&gt;CustomFieldsLabel.Name" xml:space="preserve">
<value>CustomFieldsLabel</value>
</data>
<data name="&gt;&gt;CustomFieldsLabel.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;CustomFieldsLabel.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;CustomFieldsLabel.ZOrder" xml:space="preserve">
<value>3</value>
</data>
<data name="lbCustomFields.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Bottom, Left, Right</value>
</data>
<data name="lbCustomFields.Font" type="System.Drawing.Font, System.Drawing">
<value>Segoe UI, 9pt</value>
</data>
<data name="lbCustomFields.HorizontalScrollbar" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="lbCustomFields.IntegralHeight" type="System.Boolean, mscorlib">
<value>False</value>
</data>
<data name="lbCustomFields.ItemHeight" type="System.Int32, mscorlib">
<value>15</value>
</data>
<data name="lbCustomFields.Location" type="System.Drawing.Point, System.Drawing">
<value>12, 25</value>
</data>
<data name="lbCustomFields.Size" type="System.Drawing.Size, System.Drawing">
<value>161, 201</value>
</data>
<data name="lbCustomFields.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
</data>
<data name="&gt;&gt;lbCustomFields.Name" xml:space="preserve">
<value>lbCustomFields</value>
</data>
<data name="&gt;&gt;lbCustomFields.Type" xml:space="preserve">
<value>System.Windows.Forms.ListBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;lbCustomFields.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;lbCustomFields.ZOrder" xml:space="preserve">
<value>4</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
<value>96, 96</value>
</data>
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
<value>268, 238</value>
</data>
<data name="$this.Font" type="System.Drawing.Font, System.Drawing">
<value>Tahoma, 8pt</value>
</data>
<data name="$this.Text" xml:space="preserve">
<value>Custom Fields</value>
</data>
<data name="&gt;&gt;$this.Name" xml:space="preserve">
<value>CustomFieldsDialog</value>
</data>
<data name="&gt;&gt;$this.Type" xml:space="preserve">
<value>XenAdmin.Dialogs.XenDialogBase, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</value>
</data>
</root>

View File

@ -1,306 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace"/>
<xsd:element msdata:IsDataSet="true" name="root">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="0" name="value" type="xsd:string"/>
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required"/>
<xsd:attribute name="type" type="xsd:string"/>
<xsd:attribute name="mimetype" type="xsd:string"/>
<xsd:attribute ref="xml:space"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string"/>
<xsd:attribute name="name" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="0" msdata:Ordinal="1" name="value" type="xsd:string"/>
<xsd:element minOccurs="0" msdata:Ordinal="2" name="comment" type="xsd:string"/>
</xsd:sequence>
<xsd:attribute msdata:Ordinal="1" name="name" type="xsd:string" use="required"/>
<xsd:attribute msdata:Ordinal="3" name="type" type="xsd:string"/>
<xsd:attribute msdata:Ordinal="4" name="mimetype" type="xsd:string"/>
<xsd:attribute ref="xml:space"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="0" msdata:Ordinal="1" name="value" type="xsd:string"/>
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required"/>
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<data name="btnClose.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Right</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
<data name="btnClose.Font" type="System.Drawing.Font, System.Drawing">
<value>Segoe UI, 9pt</value>
</data>
<data name="btnClose.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="btnClose.Location" type="System.Drawing.Point, System.Drawing">
<value>179, 203</value>
</data>
<data name="btnClose.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 3, 5, 3</value>
</data>
<data name="btnClose.Size" type="System.Drawing.Size, System.Drawing">
<value>75, 23</value>
</data>
<assembly alias="mscorlib" name="mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<data name="btnClose.TabIndex" type="System.Int32, mscorlib">
<value>4</value>
</data>
<data name="btnClose.Text" xml:space="preserve">
<value>关闭</value>
</data>
<data name="&gt;&gt;btnClose.Name" xml:space="preserve">
<value>btnClose</value>
</data>
<data name="&gt;&gt;btnClose.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;btnClose.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;btnClose.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="btnDelete.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
</data>
<data name="btnDelete.Font" type="System.Drawing.Font, System.Drawing">
<value>Segoe UI, 9pt</value>
</data>
<data name="btnDelete.Location" type="System.Drawing.Point, System.Drawing">
<value>179, 54</value>
</data>
<data name="btnDelete.Size" type="System.Drawing.Size, System.Drawing">
<value>75, 23</value>
</data>
<data name="btnDelete.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
</data>
<data name="btnDelete.Text" xml:space="preserve">
<value>删除(&amp;D)</value>
</data>
<data name="&gt;&gt;btnDelete.Name" xml:space="preserve">
<value>btnDelete</value>
</data>
<data name="&gt;&gt;btnDelete.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;btnDelete.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;btnDelete.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="btnAdd.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
</data>
<data name="btnAdd.Font" type="System.Drawing.Font, System.Drawing">
<value>Segoe UI, 9pt</value>
</data>
<data name="btnAdd.Location" type="System.Drawing.Point, System.Drawing">
<value>179, 25</value>
</data>
<data name="btnAdd.Size" type="System.Drawing.Size, System.Drawing">
<value>75, 23</value>
</data>
<data name="btnAdd.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
</data>
<data name="btnAdd.Text" xml:space="preserve">
<value>添加(&amp;A)...</value>
</data>
<data name="&gt;&gt;btnAdd.Name" xml:space="preserve">
<value>btnAdd</value>
</data>
<data name="&gt;&gt;btnAdd.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;btnAdd.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;btnAdd.ZOrder" xml:space="preserve">
<value>2</value>
</data>
<data name="CustomFieldsLabel.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="CustomFieldsLabel.Font" type="System.Drawing.Font, System.Drawing">
<value>Segoe UI, 9pt</value>
</data>
<data name="CustomFieldsLabel.Location" type="System.Drawing.Point, System.Drawing">
<value>9, 8</value>
</data>
<data name="CustomFieldsLabel.Size" type="System.Drawing.Size, System.Drawing">
<value>124, 15</value>
</data>
<data name="CustomFieldsLabel.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
</data>
<data name="CustomFieldsLabel.Text" xml:space="preserve">
<value>当前自定义字段(&amp;C):</value>
</data>
<data name="&gt;&gt;CustomFieldsLabel.Name" xml:space="preserve">
<value>CustomFieldsLabel</value>
</data>
<data name="&gt;&gt;CustomFieldsLabel.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;CustomFieldsLabel.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;CustomFieldsLabel.ZOrder" xml:space="preserve">
<value>3</value>
</data>
<data name="lbCustomFields.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Bottom, Left, Right</value>
</data>
<data name="lbCustomFields.Font" type="System.Drawing.Font, System.Drawing">
<value>Segoe UI, 9pt</value>
</data>
<data name="lbCustomFields.HorizontalScrollbar" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="lbCustomFields.IntegralHeight" type="System.Boolean, mscorlib">
<value>False</value>
</data>
<data name="lbCustomFields.ItemHeight" type="System.Int32, mscorlib">
<value>15</value>
</data>
<data name="lbCustomFields.Location" type="System.Drawing.Point, System.Drawing">
<value>12, 25</value>
</data>
<data name="lbCustomFields.Size" type="System.Drawing.Size, System.Drawing">
<value>161, 201</value>
</data>
<data name="lbCustomFields.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
</data>
<data name="&gt;&gt;lbCustomFields.Name" xml:space="preserve">
<value>lbCustomFields</value>
</data>
<data name="&gt;&gt;lbCustomFields.Type" xml:space="preserve">
<value>System.Windows.Forms.ListBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;lbCustomFields.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;lbCustomFields.ZOrder" xml:space="preserve">
<value>4</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
<value>96, 96</value>
</data>
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
<value>268, 238</value>
</data>
<data name="$this.Font" type="System.Drawing.Font, System.Drawing">
<value>Tahoma, 8pt</value>
</data>
<data name="$this.Text" xml:space="preserve">
<value>自定义字段</value>
</data>
<data name="&gt;&gt;$this.Name" xml:space="preserve">
<value>CustomFieldsDialog</value>
</data>
<data name="&gt;&gt;$this.Type" xml:space="preserve">
<value>XenAdmin.Dialogs.XenDialogBase, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</value>
</data>
</root>

View File

@ -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;
}
}

View File

@ -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();
}
}
}

View File

@ -112,16 +112,16 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="btnCancel.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Right</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="btnCancel.Font" type="System.Drawing.Font, System.Drawing">
<value>Segoe UI, 9pt</value>
</data>
@ -129,17 +129,14 @@
<value>NoControl</value>
</data>
<data name="btnCancel.Location" type="System.Drawing.Point, System.Drawing">
<value>222, 98</value>
</data>
<data name="btnCancel.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>4, 3, 0, 3</value>
<value>246, 135</value>
</data>
<data name="btnCancel.Size" type="System.Drawing.Size, System.Drawing">
<value>75, 23</value>
</data>
<assembly alias="mscorlib" name="mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="btnCancel.TabIndex" type="System.Int32, mscorlib">
<value>5</value>
<value>7</value>
</data>
<data name="btnCancel.Text" xml:space="preserve">
<value>Cancel</value>
@ -148,10 +145,10 @@
<value>btnCancel</value>
</data>
<data name="&gt;&gt;btnCancel.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;btnCancel.Parent" xml:space="preserve">
<value>$this</value>
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;btnCancel.ZOrder" xml:space="preserve">
<value>4</value>
@ -166,16 +163,13 @@
<value>NoControl</value>
</data>
<data name="okButton.Location" type="System.Drawing.Point, System.Drawing">
<value>140, 98</value>
</data>
<data name="okButton.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 8, 3, 3</value>
<value>165, 135</value>
</data>
<data name="okButton.Size" type="System.Drawing.Size, System.Drawing">
<value>75, 23</value>
</data>
<data name="okButton.TabIndex" type="System.Int32, mscorlib">
<value>4</value>
<value>6</value>
</data>
<data name="okButton.Text" xml:space="preserve">
<value>OK</value>
@ -184,175 +178,253 @@
<value>okButton</value>
</data>
<data name="&gt;&gt;okButton.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;okButton.Parent" xml:space="preserve">
<value>$this</value>
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;okButton.ZOrder" xml:space="preserve">
<value>6</value>
<value>7</value>
</data>
<data name="NameTextBox.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Left, Right</value>
<data name="textBoxName.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Left, Right</value>
</data>
<data name="NameTextBox.Font" type="System.Drawing.Font, System.Drawing">
<value>Segoe UI, 9pt</value>
</data>
<data name="NameTextBox.Location" type="System.Drawing.Point, System.Drawing">
<value>74, 13</value>
</data>
<data name="NameTextBox.Size" type="System.Drawing.Size, System.Drawing">
<value>223, 23</value>
</data>
<data name="NameTextBox.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
</data>
<data name="&gt;&gt;NameTextBox.Name" xml:space="preserve">
<value>NameTextBox</value>
</data>
<data name="&gt;&gt;NameTextBox.Type" xml:space="preserve">
<value>System.Windows.Forms.TextBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;NameTextBox.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;NameTextBox.ZOrder" xml:space="preserve">
<value>5</value>
</data>
<data name="label1.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="label1.Font" type="System.Drawing.Font, System.Drawing">
<value>Segoe UI, 9pt</value>
</data>
<data name="label1.Location" type="System.Drawing.Point, System.Drawing">
<value>13, 16</value>
</data>
<data name="label1.Size" type="System.Drawing.Size, System.Drawing">
<value>42, 15</value>
</data>
<data name="label1.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
</data>
<data name="label1.Text" xml:space="preserve">
<value>&amp;Name:</value>
</data>
<data name="&gt;&gt;label1.Name" xml:space="preserve">
<value>label1</value>
</data>
<data name="&gt;&gt;label1.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;label1.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;label1.ZOrder" xml:space="preserve">
<data name="tableLayoutPanel1.ColumnCount" type="System.Int32, mscorlib">
<value>3</value>
</data>
<data name="label2.AutoSize" type="System.Boolean, mscorlib">
<data name="labelBlurb.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="label2.Font" type="System.Drawing.Font, System.Drawing">
<data name="labelBlurb.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
</data>
<data name="labelBlurb.Font" type="System.Drawing.Font, System.Drawing">
<value>Segoe UI, 9pt</value>
</data>
<data name="label2.Location" type="System.Drawing.Point, System.Drawing">
<value>13, 62</value>
<data name="labelBlurb.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 0</value>
</data>
<data name="label2.Size" type="System.Drawing.Size, System.Drawing">
<value>36, 15</value>
<data name="labelBlurb.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 0, 3, 15</value>
</data>
<data name="label2.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
<data name="labelBlurb.Size" type="System.Drawing.Size, System.Drawing">
<value>318, 30</value>
</data>
<data name="label2.Text" xml:space="preserve">
<value>&amp;Type:</value>
<data name="labelBlurb.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
</data>
<data name="&gt;&gt;label2.Name" xml:space="preserve">
<value>label2</value>
<data name="labelBlurb.Text" xml:space="preserve">
<value>Enter a name for the new custom field and select its type. The new field will be available to all resources in the pool.</value>
</data>
<data name="&gt;&gt;label2.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<data name="&gt;&gt;labelBlurb.Name" xml:space="preserve">
<value>labelBlurb</value>
</data>
<data name="&gt;&gt;label2.Parent" xml:space="preserve">
<value>$this</value>
<data name="&gt;&gt;labelBlurb.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;label2.ZOrder" xml:space="preserve">
<value>2</value>
<data name="&gt;&gt;labelBlurb.Parent" xml:space="preserve">
<value>tableLayoutPanel1</value>
</data>
<data name="TypeComboBox.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Left, Right</value>
<data name="&gt;&gt;labelBlurb.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="TypeComboBox.Font" type="System.Drawing.Font, System.Drawing">
<data name="comboBoxType.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Left, Right</value>
</data>
<data name="comboBoxType.Font" type="System.Drawing.Font, System.Drawing">
<value>Segoe UI, 9pt</value>
</data>
<data name="TypeComboBox.Items" xml:space="preserve">
<data name="comboBoxType.Items" xml:space="preserve">
<value>Text</value>
</data>
<data name="TypeComboBox.Items1" xml:space="preserve">
<data name="comboBoxType.Items1" xml:space="preserve">
<value>Date &amp; Time</value>
</data>
<data name="TypeComboBox.Location" type="System.Drawing.Point, System.Drawing">
<value>74, 59</value>
<data name="comboBoxType.Location" type="System.Drawing.Point, System.Drawing">
<value>51, 94</value>
</data>
<data name="TypeComboBox.Size" type="System.Drawing.Size, System.Drawing">
<value>223, 23</value>
<data name="comboBoxType.Size" type="System.Drawing.Size, System.Drawing">
<value>270, 23</value>
</data>
<data name="TypeComboBox.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
<data name="comboBoxType.TabIndex" type="System.Int32, mscorlib">
<value>5</value>
</data>
<data name="&gt;&gt;TypeComboBox.Name" xml:space="preserve">
<value>TypeComboBox</value>
<data name="&gt;&gt;comboBoxType.Name" xml:space="preserve">
<value>comboBoxType</value>
</data>
<data name="&gt;&gt;TypeComboBox.Type" xml:space="preserve">
<value>System.Windows.Forms.ComboBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<data name="&gt;&gt;comboBoxType.Type" xml:space="preserve">
<value>System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;TypeComboBox.Parent" xml:space="preserve">
<value>$this</value>
<data name="&gt;&gt;comboBoxType.Parent" xml:space="preserve">
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;TypeComboBox.ZOrder" xml:space="preserve">
<value>1</value>
<data name="&gt;&gt;comboBoxType.ZOrder" xml:space="preserve">
<value>2</value>
</data>
<data name="DuplicateWarning.AutoSize" type="System.Boolean, mscorlib">
<data name="labelDuplicate.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="DuplicateWarning.Font" type="System.Drawing.Font, System.Drawing">
<data name="labelDuplicate.Font" type="System.Drawing.Font, System.Drawing">
<value>Segoe UI, 9pt</value>
</data>
<data name="DuplicateWarning.Location" type="System.Drawing.Point, System.Drawing">
<value>71, 39</value>
<data name="labelDuplicate.Location" type="System.Drawing.Point, System.Drawing">
<value>51, 74</value>
</data>
<data name="DuplicateWarning.Size" type="System.Drawing.Size, System.Drawing">
<value>195, 15</value>
<data name="labelDuplicate.Size" type="System.Drawing.Size, System.Drawing">
<value>241, 15</value>
</data>
<data name="DuplicateWarning.TabIndex" type="System.Int32, mscorlib">
<value>6</value>
<data name="labelDuplicate.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
</data>
<data name="DuplicateWarning.Text" xml:space="preserve">
<value>Cannot add duplicate custom fields</value>
<data name="labelDuplicate.Text" xml:space="preserve">
<value>A custom filed with this name already exists.</value>
</data>
<data name="DuplicateWarning.Visible" type="System.Boolean, mscorlib">
<data name="labelDuplicate.Visible" type="System.Boolean, mscorlib">
<value>False</value>
</data>
<data name="&gt;&gt;DuplicateWarning.Name" xml:space="preserve">
<value>DuplicateWarning</value>
<data name="&gt;&gt;labelDuplicate.Name" xml:space="preserve">
<value>labelDuplicate</value>
</data>
<data name="&gt;&gt;DuplicateWarning.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<data name="&gt;&gt;labelDuplicate.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;DuplicateWarning.Parent" xml:space="preserve">
<value>$this</value>
<data name="&gt;&gt;labelDuplicate.Parent" xml:space="preserve">
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;DuplicateWarning.ZOrder" xml:space="preserve">
<data name="&gt;&gt;labelDuplicate.ZOrder" xml:space="preserve">
<value>3</value>
</data>
<data name="labelName.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Left</value>
</data>
<data name="labelName.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="labelName.Font" type="System.Drawing.Font, System.Drawing">
<value>Segoe UI, 9pt</value>
</data>
<data name="labelName.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 52</value>
</data>
<data name="labelName.Size" type="System.Drawing.Size, System.Drawing">
<value>42, 15</value>
</data>
<data name="labelName.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
</data>
<data name="labelName.Text" xml:space="preserve">
<value>&amp;Name:</value>
</data>
<data name="&gt;&gt;labelName.Name" xml:space="preserve">
<value>labelName</value>
</data>
<data name="&gt;&gt;labelName.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;labelName.Parent" xml:space="preserve">
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;labelName.ZOrder" xml:space="preserve">
<value>5</value>
</data>
<data name="labelType.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Left</value>
</data>
<data name="labelType.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="labelType.Font" type="System.Drawing.Font, System.Drawing">
<value>Segoe UI, 9pt</value>
</data>
<data name="labelType.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 98</value>
</data>
<data name="labelType.Size" type="System.Drawing.Size, System.Drawing">
<value>34, 15</value>
</data>
<data name="labelType.TabIndex" type="System.Int32, mscorlib">
<value>4</value>
</data>
<data name="labelType.Text" xml:space="preserve">
<value>&amp;Type:</value>
</data>
<data name="&gt;&gt;labelType.Name" xml:space="preserve">
<value>labelType</value>
</data>
<data name="&gt;&gt;labelType.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;labelType.Parent" xml:space="preserve">
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;labelType.ZOrder" xml:space="preserve">
<value>6</value>
</data>
<data name="tableLayoutPanel1.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
</data>
<data name="tableLayoutPanel1.Font" type="System.Drawing.Font, System.Drawing">
<value>Segoe UI, 9pt</value>
</data>
<data name="tableLayoutPanel1.Location" type="System.Drawing.Point, System.Drawing">
<value>10, 10</value>
</data>
<data name="tableLayoutPanel1.RowCount" type="System.Int32, mscorlib">
<value>5</value>
</data>
<data name="tableLayoutPanel1.Size" type="System.Drawing.Size, System.Drawing">
<value>324, 161</value>
</data>
<data name="tableLayoutPanel1.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<data name="&gt;&gt;tableLayoutPanel1.Name" xml:space="preserve">
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;tableLayoutPanel1.Type" xml:space="preserve">
<value>System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;tableLayoutPanel1.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;tableLayoutPanel1.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="tableLayoutPanel1.LayoutSettings" type="System.Windows.Forms.TableLayoutSettings, System.Windows.Forms">
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls&gt;&lt;Control Name="labelBlurb" Row="0" RowSpan="1" Column="0" ColumnSpan="3" /&gt;&lt;Control Name="textBoxName" Row="1" RowSpan="1" Column="1" ColumnSpan="2" /&gt;&lt;Control Name="comboBoxType" Row="3" RowSpan="1" Column="1" ColumnSpan="2" /&gt;&lt;Control Name="labelDuplicate" Row="2" RowSpan="1" Column="1" ColumnSpan="2" /&gt;&lt;Control Name="btnCancel" Row="4" RowSpan="1" Column="2" ColumnSpan="1" /&gt;&lt;Control Name="labelName" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="labelType" Row="3" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="okButton" Row="4" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="AutoSize,0,Percent,100,AutoSize,0" /&gt;&lt;Rows Styles="AutoSize,0,AutoSize,0,Absolute,17,AutoSize,0,Percent,100" /&gt;&lt;/TableLayoutSettings&gt;</value>
</data>
<data name="textBoxName.Font" type="System.Drawing.Font, System.Drawing">
<value>Segoe UI, 9pt</value>
</data>
<data name="textBoxName.Location" type="System.Drawing.Point, System.Drawing">
<value>51, 48</value>
</data>
<data name="textBoxName.Size" type="System.Drawing.Size, System.Drawing">
<value>270, 23</value>
</data>
<data name="textBoxName.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
</data>
<data name="&gt;&gt;textBoxName.Name" xml:space="preserve">
<value>textBoxName</value>
</data>
<data name="&gt;&gt;textBoxName.Type" xml:space="preserve">
<value>System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;textBoxName.Parent" xml:space="preserve">
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;textBoxName.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
<value>96, 96</value>
</data>
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
<value>310, 127</value>
<value>344, 181</value>
</data>
<data name="$this.Font" type="System.Drawing.Font, System.Drawing">
<value>Tahoma, 8pt</value>
@ -367,6 +439,6 @@
<value>NewCustomFieldDialog</value>
</data>
<data name="&gt;&gt;$this.Type" xml:space="preserve">
<value>XenAdmin.Dialogs.XenDialogBase, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</value>
<value>XenAdmin.Dialogs.XenDialogBase, [XenCenter_No_Space], Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</value>
</data>
</root>

View File

@ -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<CustomFieldDefinition, KeyValuePair<Label, Control>> controls = new Dictionary<CustomFieldDefinition, KeyValuePair<Label, Control>>();
/// <summary>
/// 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)
/// </summary>
private readonly Panel _panelDummy;
private IXenObject _xenObject;
private readonly List<CustomFieldRow> _fieldRows = new List<CustomFieldRow>();
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<CustomField> customFields = new List<CustomField>();
var customFields = new List<CustomField>();
foreach (KeyValuePair<CustomFieldDefinition, KeyValuePair<Label, Control>> 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<CustomFieldDefinition, KeyValuePair<Label, Control>> 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<String> fields = new List<String>();
List<string> fields = new List<string>();
foreach (KeyValuePair<CustomFieldDefinition, KeyValuePair<Label, Control>> 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<Label, Control>(lblKey, control);
if (1 < row.Controls.Length && row.Controls.Length < tableLayoutPanel.ColumnCount)
tableLayoutPanel.SetColumnSpan(row.Controls[1], 2); //this is the textbox
}
else if (revertValues)
else if (resetValues)
{
KeyValuePair<Label, Control> kvp = controls[customFieldDefinition];
SetValue(customFieldDefinition, kvp.Value, value);
row.SetValue(value);
}
}
// Remove old ones
CustomFieldDefinition[] definitions = new CustomFieldDefinition[controls.Keys.Count];
controls.Keys.CopyTo(definitions, 0);
tableLayoutPanel.Controls.Add(_panelDummy);
foreach (CustomFieldDefinition definition in definitions)
var extraRows = _fieldRows.Where(r => !customFieldDefinitions.Contains(r.CustomFieldDefinition)).ToList();
foreach (var row in extraRows)
{
if (Array.IndexOf<CustomFieldDefinition>(customFieldDefinitions, definition) > -1)
continue;
row.DeleteCustomFieldClicked -= DeleteCustomFieldClicked_Click;
_fieldRows.Remove(row);
KeyValuePair<Label, Control> kvp = controls[definition];
tableLayoutPanel.Controls.Remove(kvp.Value);
tableLayoutPanel.Controls.Remove(kvp.Key);
DateTimePicker timeControl = kvp.Value.Tag as DateTimePicker;
if (timeControl != null)
foreach (var control in row.Controls)
{
tableLayoutPanel.Controls.Remove(timeControl);
tableLayoutPanel.Controls.Remove(control);
control.Dispose();
}
controls.Remove(definition);
kvp.Key.Dispose();
kvp.Value.Dispose();
}
tableLayoutPanel.ResumeLayout();
}
private void buttonEditCustomFields_Click(object sender, EventArgs e)
private void buttonNewCustomField_Click(object sender, EventArgs e)
{
new CustomFieldsDialog(xenObject.Connection).ShowDialog(this);
using (var dialog = new NewCustomFieldDialog(_xenObject.Connection))
{
if (dialog.ShowDialog() == DialogResult.OK)
new AddCustomFieldAction(_xenObject.Connection, dialog.Definition).RunAsync();
}
}
private void DeleteCustomFieldClicked_Click(CustomFieldRow row)
{
string name = row.CustomFieldDefinition.Name.Ellipsise(50);
if (!Program.RunInAutomatedTestMode)
{
using (var dialog = new WarningDialog(string.Format(Messages.MESSAGEBOX_DELETE_CUSTOM_FIELD, name),
ThreeButtonDialog.ButtonYes, ThreeButtonDialog.ButtonNo))
{
if (dialog.ShowDialog(Program.MainWindow) != DialogResult.Yes)
return;
}
}
if (_xenObject.Connection != null && _xenObject.Connection.IsConnected)
{
new RemoveCustomFieldAction(_xenObject.Connection, row.CustomFieldDefinition).RunAsync();
}
else if (!Program.RunInAutomatedTestMode)
{
using (var dlg = new ErrorDialog(Messages.DISCONNECTED_BEFORE_ACTION_STARTED))
dlg.ShowDialog(this);
}
}
private class CustomFieldRow
{
private readonly TextBox _textBox;
private readonly DateTimePicker _datePicker;
private readonly DateTimePicker _timePicker;
public event Action<CustomFieldRow> DeleteCustomFieldClicked;
public CustomFieldRow(CustomFieldDefinition definition, object value)
{
CustomFieldDefinition = definition;
var controls = new List<Control>();
var label = CreateNewLabel(definition);
controls.Add(label);
switch (definition.Type)
{
case CustomFieldDefinition.Types.String:
_textBox = CreateNewTextBox(value as string);
controls.Add(_textBox);
break;
case CustomFieldDefinition.Types.Date:
_datePicker = CreateNewDatePicker(value as DateTime?);
_timePicker = CreateNewTimePicker(value as DateTime?);
controls.Add(_datePicker);
controls.Add(_timePicker);
break;
default:
throw new InvalidEnumArgumentException(nameof(definition));
}
var deleteButton = CreateNewDeleteButton();
controls.Add(deleteButton);
Controls = controls.ToArray();
UpdateDateTImePickerState();
}
public CustomFieldDefinition CustomFieldDefinition { get; }
public Control[] Controls { get; }
public object GetValue()
{
if (_textBox != null && !string.IsNullOrEmpty(_textBox.Text))
return _textBox.Text;
if (_datePicker != null && _timePicker != null && _datePicker.Checked)
{
DateTime date = _datePicker.Value;
DateTime time = _timePicker.Value;
return new DateTime(date.Year, date.Month, date.Day, time.Hour, time.Minute, time.Second);
}
return null;
}
public void SetValue(object value)
{
if (_textBox != null)
{
_textBox.Text = value as string;
return;
}
if (_datePicker != null && _timePicker != null)
{
if (value != null)
{
_datePicker.Checked = true;
_datePicker.Value = (DateTime)value;
_timePicker.Value = (DateTime)value;
}
else
{
_datePicker.Checked = false;
}
}
}
private Label CreateNewLabel(CustomFieldDefinition customFieldDefinition)
{
return new Label
{
Anchor = AnchorStyles.Left | AnchorStyles.Right,
Text = customFieldDefinition.Name.EscapeAmpersands().Ellipsise(25),
Font = Program.DefaultFont,
AutoSize = true,
AutoEllipsis = false
};
}
private TextBox CreateNewTextBox(string text)
{
return new TextBox
{
Anchor = AnchorStyles.Left | AnchorStyles.Right,
Text = text ?? string.Empty
};
}
private DateTimePicker CreateNewDatePicker(DateTime? value)
{
var date = new DateTimePicker
{
Anchor = AnchorStyles.Left | AnchorStyles.Right,
MinDate = DateTime.MinValue,
MaxDate = DateTime.MaxValue,
ShowCheckBox = true,
Format = DateTimePickerFormat.Long,
Checked = value.HasValue
};
if (value.HasValue)
date.Value = (DateTime)value;
date.ValueChanged += Date_ValueChanged;
return date;
}
private DateTimePicker CreateNewTimePicker(DateTime? value)
{
var time = new DateTimePicker
{
Anchor = AnchorStyles.Left | AnchorStyles.Right,
MinDate = DateTime.MinValue,
MaxDate = DateTime.MaxValue,
Format = DateTimePickerFormat.Time,
ShowUpDown = true,
Enabled = value.HasValue
};
if (value.HasValue)
time.Value = (DateTime)value;
return time;
}
private Button CreateNewDeleteButton()
{
var buttonDelete = new Button
{
Anchor = AnchorStyles.Left,
BackColor = Color.Transparent,
FlatStyle = FlatStyle.Flat,
Image = Images.StaticImages._000_Abort_h32bit_16,
Size = new Size(22, 22),
Text = string.Empty,
};
buttonDelete.FlatAppearance.BorderSize = 0;
buttonDelete.Click += buttonDelete_Click;
return buttonDelete;
}
private void UpdateDateTImePickerState()
{
if (_datePicker != null && _timePicker != null)
_timePicker.Enabled = _datePicker.Checked;
}
private void Date_ValueChanged(object sender, EventArgs e)
{
UpdateDateTImePickerState();
}
private void buttonDelete_Click(object sender, EventArgs e)
{
DeleteCustomFieldClicked?.Invoke(this);
}
}
}
}

View File

@ -34,7 +34,7 @@ namespace XenAdmin.SettingsPanels
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CustomFieldsDisplayPage));
this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
this.buttonEditCustomFields = new System.Windows.Forms.Button();
this.buttonNewtCustomField = new System.Windows.Forms.Button();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.label1 = new System.Windows.Forms.Label();
this.tableLayoutPanel1.SuspendLayout();
@ -43,22 +43,21 @@ namespace XenAdmin.SettingsPanels
// tableLayoutPanel
//
resources.ApplyResources(this.tableLayoutPanel, "tableLayoutPanel");
this.tableLayoutPanel.MaximumSize = new System.Drawing.Size(480, 999999);
this.tableLayoutPanel.MinimumSize = new System.Drawing.Size(480, 190);
this.tableLayoutPanel.Name = "tableLayoutPanel";
//
// buttonEditCustomFields
// buttonNewtCustomField
//
resources.ApplyResources(this.buttonEditCustomFields, "buttonEditCustomFields");
this.buttonEditCustomFields.Name = "buttonEditCustomFields";
this.buttonEditCustomFields.UseVisualStyleBackColor = true;
this.buttonEditCustomFields.Click += new System.EventHandler(this.buttonEditCustomFields_Click);
resources.ApplyResources(this.buttonNewtCustomField, "buttonNewtCustomField");
this.buttonNewtCustomField.Image = global::XenAdmin.Properties.Resources.more_16;
this.buttonNewtCustomField.Name = "buttonNewtCustomField";
this.buttonNewtCustomField.UseVisualStyleBackColor = true;
this.buttonNewtCustomField.Click += new System.EventHandler(this.buttonNewCustomField_Click);
//
// tableLayoutPanel1
//
resources.ApplyResources(this.tableLayoutPanel1, "tableLayoutPanel1");
this.tableLayoutPanel1.Controls.Add(this.label1, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.buttonEditCustomFields, 0, 1);
this.tableLayoutPanel1.Controls.Add(this.buttonNewtCustomField, 0, 1);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
//
// label1
@ -79,13 +78,14 @@ namespace XenAdmin.SettingsPanels
this.tableLayoutPanel1.ResumeLayout(false);
this.tableLayoutPanel1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel;
private System.Windows.Forms.Button buttonEditCustomFields;
private System.Windows.Forms.Button buttonNewtCustomField;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private System.Windows.Forms.Label label1;
}

View File

@ -112,36 +112,40 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="mscorlib" name="mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="tableLayoutPanel.AutoScroll" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="tableLayoutPanel.ColumnCount" type="System.Int32, mscorlib">
<value>3</value>
<value>4</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="tableLayoutPanel.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="tableLayoutPanel.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 82</value>
<value>0, 85</value>
</data>
<data name="tableLayoutPanel.RowCount" type="System.Int32, mscorlib">
<value>1</value>
</data>
<data name="tableLayoutPanel.Size" type="System.Drawing.Size, System.Drawing">
<value>480, 190</value>
<value>480, 187</value>
</data>
<data name="tableLayoutPanel.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
<value>1</value>
</data>
<data name="&gt;&gt;tableLayoutPanel.Name" xml:space="preserve">
<value>tableLayoutPanel</value>
</data>
<data name="&gt;&gt;tableLayoutPanel.Type" xml:space="preserve">
<value>System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;tableLayoutPanel.Parent" xml:space="preserve">
<value>$this</value>
@ -149,42 +153,50 @@
<data name="&gt;&gt;tableLayoutPanel.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="tableLayoutPanel.LayoutSettings" type="System.Windows.Forms.TableLayoutSettings, System.Windows.Forms">
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls /&gt;&lt;Columns Styles="Absolute,140,Percent,65,Percent,35" /&gt;&lt;Rows Styles="AutoSize,0" /&gt;&lt;/TableLayoutSettings&gt;</value>
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls /&gt;&lt;Columns Styles="AutoSize,0,Percent,45,Percent,35,Percent,20" /&gt;&lt;Rows Styles="AutoSize,0" /&gt;&lt;/TableLayoutSettings&gt;</value>
</data>
<data name="buttonEditCustomFields.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<data name="buttonNewtCustomField.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
</data>
<data name="buttonEditCustomFields.AutoSize" type="System.Boolean, mscorlib">
<data name="buttonNewtCustomField.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="buttonEditCustomFields.Location" type="System.Drawing.Point, System.Drawing">
<value>365, 52</value>
<data name="buttonNewtCustomField.Location" type="System.Drawing.Point, System.Drawing">
<value>350, 52</value>
</data>
<data name="buttonEditCustomFields.Size" type="System.Drawing.Size, System.Drawing">
<value>112, 23</value>
<data name="buttonNewtCustomField.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 3, 3, 10</value>
</data>
<data name="buttonEditCustomFields.TabIndex" type="System.Int32, mscorlib">
<value>4</value>
<data name="buttonNewtCustomField.Size" type="System.Drawing.Size, System.Drawing">
<value>127, 23</value>
</data>
<data name="buttonEditCustomFields.Text" xml:space="preserve">
<value>&amp;Edit Custom Fields...</value>
</data>
<data name="&gt;&gt;buttonEditCustomFields.Name" xml:space="preserve">
<value>buttonEditCustomFields</value>
</data>
<data name="&gt;&gt;buttonEditCustomFields.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;buttonEditCustomFields.Parent" xml:space="preserve">
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;buttonEditCustomFields.ZOrder" xml:space="preserve">
<data name="buttonNewtCustomField.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
</data>
<data name="tableLayoutPanel1.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Left, Right</value>
<data name="buttonNewtCustomField.Text" xml:space="preserve">
<value>&amp;New Custom Field...</value>
</data>
<data name="buttonNewtCustomField.TextImageRelation" type="System.Windows.Forms.TextImageRelation, System.Windows.Forms">
<value>ImageBeforeText</value>
</data>
<data name="&gt;&gt;buttonNewtCustomField.Name" xml:space="preserve">
<value>buttonNewtCustomField</value>
</data>
<data name="&gt;&gt;buttonNewtCustomField.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;buttonNewtCustomField.Parent" xml:space="preserve">
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;buttonNewtCustomField.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="tableLayoutPanel1.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="tableLayoutPanel1.AutoSizeMode" type="System.Windows.Forms.AutoSizeMode, System.Windows.Forms">
<value>GrowAndShrink</value>
</data>
<data name="tableLayoutPanel1.ColumnCount" type="System.Int32, mscorlib">
<value>1</value>
@ -196,13 +208,13 @@
<value>Fill</value>
</data>
<data name="label1.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 0</value>
<value>3, 0</value>
</data>
<data name="label1.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 0, 0, 0</value>
<value>3, 0, 3, 10</value>
</data>
<data name="label1.Size" type="System.Drawing.Size, System.Drawing">
<value>480, 49</value>
<value>474, 39</value>
</data>
<data name="label1.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
@ -214,7 +226,7 @@
<value>label1</value>
</data>
<data name="&gt;&gt;label1.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;label1.Parent" xml:space="preserve">
<value>tableLayoutPanel1</value>
@ -222,6 +234,9 @@
<data name="&gt;&gt;label1.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="tableLayoutPanel1.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Top</value>
</data>
<data name="tableLayoutPanel1.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 0</value>
</data>
@ -229,16 +244,16 @@
<value>2</value>
</data>
<data name="tableLayoutPanel1.Size" type="System.Drawing.Size, System.Drawing">
<value>480, 82</value>
<value>480, 85</value>
</data>
<data name="tableLayoutPanel1.TabIndex" type="System.Int32, mscorlib">
<value>5</value>
<value>0</value>
</data>
<data name="&gt;&gt;tableLayoutPanel1.Name" xml:space="preserve">
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;tableLayoutPanel1.Type" xml:space="preserve">
<value>System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;tableLayoutPanel1.Parent" xml:space="preserve">
<value>$this</value>
@ -247,9 +262,9 @@
<value>1</value>
</data>
<data name="tableLayoutPanel1.LayoutSettings" type="System.Windows.Forms.TableLayoutSettings, System.Windows.Forms">
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls&gt;&lt;Control Name="label1" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="buttonEditCustomFields" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="Percent,50" /&gt;&lt;Rows Styles="Percent,50,Absolute,33" /&gt;&lt;/TableLayoutSettings&gt;</value>
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls&gt;&lt;Control Name="label1" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="buttonNewtCustomField" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="Percent,100" /&gt;&lt;Rows Styles="AutoSize,0,AutoSize,0" /&gt;&lt;/TableLayoutSettings&gt;</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
@ -265,6 +280,6 @@
<value>CustomFieldsDisplayPage</value>
</data>
<data name="&gt;&gt;$this.Type" xml:space="preserve">
<value>System.Windows.Forms.UserControl, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.UserControl, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
</root>

View File

@ -1146,12 +1146,6 @@
<Compile Include="Dialogs\AddServerDialog.Designer.cs">
<DependentUpon>AddServerDialog.cs</DependentUpon>
</Compile>
<Compile Include="Dialogs\CustomFieldsDialog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Dialogs\CustomFieldsDialog.Designer.cs">
<DependentUpon>CustomFieldsDialog.cs</DependentUpon>
</Compile>
<Compile Include="Dialogs\NewCustomFieldDialog.cs">
<SubType>Form</SubType>
</Compile>
@ -2559,10 +2553,6 @@
<DependentUpon>AttachDiskDialog.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Dialogs\CustomFieldsDialog.resx">
<DependentUpon>CustomFieldsDialog.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Dialogs\CopyVMDialog.resx">
<DependentUpon>CopyVMDialog.cs</DependentUpon>
<SubType>Designer</SubType>
@ -2868,7 +2858,6 @@
<Compile Include="Commands\DestroyHostCommand.cs" />
<Compile Include="Commands\MigrateVirtualDiskCommand.cs" />
<Compile Include="Actions\GUIActions\GeneralEditPageAction.cs" />
<Compile Include="Actions\GUIActions\SaveCustomFieldsAction.cs" />
<Compile Include="Commands\Controls\CommandButton.cs">
<SubType>Component</SubType>
</Compile>
@ -5193,12 +5182,6 @@
<EmbeddedResource Include="Dialogs\CopyVMDialog.zh-CN.resx">
<DependentUpon>CopyVMDialog.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Dialogs\CustomFieldsDialog.ja.resx">
<DependentUpon>CustomFieldsDialog.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Dialogs\CustomFieldsDialog.zh-CN.resx">
<DependentUpon>CustomFieldsDialog.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Dialogs\DateFilterDialog.ja.resx">
<DependentUpon>DateFilterDialog.cs</DependentUpon>
</EmbeddedResource>

View File

@ -0,0 +1,59 @@
/* 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 XenAdmin.CustomFields;
using XenAdmin.Network;
namespace XenAdmin.Actions
{
/// <summary>
/// Adds a new custom field definition in the pool.
/// </summary>
public class AddCustomFieldAction : AsyncAction
{
private readonly CustomFieldDefinition _definition;
public AddCustomFieldAction(IXenConnection connection, CustomFieldDefinition definition)
: base(connection, string.Format(Messages.ADD_CUSTOM_FIELD, definition.Name),
string.Format(Messages.ADDING_CUSTOM_FIELD, definition.Name), false)
{
_definition = definition;
ApiMethodsToRoleCheck.AddWithKey("pool.add_to_gui_config", CustomFieldsManager.CUSTOM_FIELD_BASE_KEY);
ApiMethodsToRoleCheck.AddWithKey("pool.remove_from_gui_config", CustomFieldsManager.CUSTOM_FIELD_BASE_KEY);
}
protected override void Run()
{
CustomFieldsManager.AddCustomField(Session, Connection, _definition);
Description = string.Format(Messages.ADDED_CUSTOM_FIELD, _definition.Name);
}
}
}

View File

@ -0,0 +1,67 @@
/* 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 XenAdmin.CustomFields;
using XenAdmin.Network;
namespace XenAdmin.Actions
{
/// <summary>
/// Removes a custom field definition from the pool.
/// </summary>
public class RemoveCustomFieldAction : AsyncAction
{
private readonly CustomFieldDefinition _definition;
public RemoveCustomFieldAction(IXenConnection connection, CustomFieldDefinition definition)
: base(connection, string.Format(Messages.DELETE_CUSTOM_FIELD, definition.Name),
string.Format(Messages.DELETING_CUSTOM_FIELD, definition.Name), false)
{
_definition = definition;
string key = CustomFieldsManager.GetCustomFieldKey(definition);
ApiMethodsToRoleCheck.AddWithKey("pool.add_to_gui_config", CustomFieldsManager.CUSTOM_FIELD_BASE_KEY);
ApiMethodsToRoleCheck.AddWithKey("pool.remove_from_gui_config", CustomFieldsManager.CUSTOM_FIELD_BASE_KEY);
ApiMethodsToRoleCheck.AddWithKey("pool.remove_from_other_config", key);
ApiMethodsToRoleCheck.AddWithKey("host.remove_from_other_config", key);
ApiMethodsToRoleCheck.AddWithKey("VM.remove_from_other_config", key);
ApiMethodsToRoleCheck.AddWithKey("SR.remove_from_other_config", key);
ApiMethodsToRoleCheck.AddWithKey("VDI.remove_from_other_config", key);
ApiMethodsToRoleCheck.AddWithKey("Network.remove_from_other_config", key);
}
protected override void Run()
{
CustomFieldsManager.RemoveCustomField(Session, Connection, _definition);
Description = string.Format(Messages.DELETED_CUSTOM_FIELD, _definition.Name);
}
}
}

View File

@ -36,6 +36,9 @@ using XenAdmin.Core;
namespace XenAdmin.Actions
{
/// <summary>
/// Sets custom field values on a given API object.
/// </summary>
public class SaveCustomFieldsAction : AsyncAction
{
private readonly IXenObject xenObject;

View File

@ -46,14 +46,14 @@ namespace XenAdmin.CustomFields
/// "XenCenter.CustomFields.foo1" value
/// "XenCenter.CustomFields.foo2" value
/// </summary>
public class CustomFieldsManager
public static class CustomFieldsManager
{
#region These functions deal with caching the list of custom fields
private static readonly CustomFieldsCache customFieldsCache = new CustomFieldsCache();
private const String CUSTOM_FIELD_DELIM = ".";
public const String CUSTOM_FIELD_BASE_KEY = "XenCenter.CustomFields";
public const String CUSTOM_FIELD = "CustomField:";
public static event Action CustomFieldsChanged;
@ -109,15 +109,52 @@ namespace XenAdmin.CustomFields
public static void RemoveCustomField(Session session, IXenConnection connection, CustomFieldDefinition definition)
{
List<CustomFieldDefinition> customFields = customFieldsCache.GetCustomFields(connection);
if (customFields.Remove(definition))
{
SaveCustomFields(session, connection, customFields);
// Remove from all Objects
RemoveCustomFieldsFrom(session, connection.Cache.VMs, definition);
RemoveCustomFieldsFrom(session, connection.Cache.Hosts, definition);
RemoveCustomFieldsFrom(session, connection.Cache.Pools, definition);
RemoveCustomFieldsFrom(session, connection.Cache.SRs, definition);
// theoretically any object type with other_config may have a custom field set,
// but the object types more likely to have one are those shown on the treeview,
// i.e. pools, hosts, VMs (including snapshots and templates), SRs, VDIs, and networks
string customFieldKey = GetCustomFieldKey(definition);
foreach (var pool in connection.Cache.Pools)
{
if (pool.other_config.ContainsKey(customFieldKey))
Pool.remove_from_other_config(session, pool.opaque_ref, customFieldKey);
}
foreach (var host in connection.Cache.Hosts)
{
if (host.other_config.ContainsKey(customFieldKey))
Host.remove_from_other_config(session, host.opaque_ref, customFieldKey);
}
foreach (var vm in connection.Cache.VMs)
{
if (vm.other_config.ContainsKey(customFieldKey))
VM.remove_from_other_config(session, vm.opaque_ref, customFieldKey);
}
foreach (var sr in connection.Cache.SRs)
{
if (sr.other_config.ContainsKey(customFieldKey))
SR.remove_from_other_config(session, sr.opaque_ref, customFieldKey);
}
foreach (var vdi in connection.Cache.VDIs)
{
if (vdi.other_config.ContainsKey(customFieldKey))
VDI.remove_from_other_config(session, vdi.opaque_ref, customFieldKey);
}
foreach (var network in connection.Cache.Networks)
{
if (network.other_config.ContainsKey(customFieldKey))
XenAPI.Network.remove_from_other_config(session, network.opaque_ref, customFieldKey);
}
}
}
@ -155,25 +192,14 @@ namespace XenAdmin.CustomFields
return CUSTOM_FIELD_BASE_KEY + CUSTOM_FIELD_DELIM + customFieldDefinition.Name;
}
private static void RemoveCustomFieldsFrom(Session session, IEnumerable<IXenObject> os, CustomFieldDefinition customFieldDefinition)
{
InvokeHelper.AssertOffEventThread();
string customFieldKey = GetCustomFieldKey(customFieldDefinition);
foreach (IXenObject o in os)
{
Helpers.RemoveFromOtherConfig(session, o, customFieldKey);
}
}
private static void SaveCustomFields(Session session, IXenConnection connection, List<CustomFieldDefinition> customFields)
{
Pool pool = Helpers.GetPoolOfOne(connection);
if (pool != null)
{
String customFieldXML = GetCustomFieldDefinitionXML(customFields);
Helpers.SetGuiConfig(session, pool, CUSTOM_FIELD_BASE_KEY, customFieldXML);
string customFieldXML = GetCustomFieldDefinitionXML(customFields);
Pool.remove_from_gui_config(session, pool.opaque_ref, CUSTOM_FIELD_BASE_KEY);
Pool.add_to_gui_config(session, pool.opaque_ref, CUSTOM_FIELD_BASE_KEY, customFieldXML);
}
}

View File

@ -23984,7 +23984,7 @@ namespace XenAdmin {
}
/// <summary>
/// Looks up a localized string similar to This will delete &apos;{0}&apos; permanently, destroying all data associated with it. Continue?.
/// Looks up a localized string similar to This will delete &apos;{0}&apos; permanently, making it unavailable to all resources in the pool and destroying all data associated with it. Do you want to continue?.
/// </summary>
public static string MESSAGEBOX_DELETE_CUSTOM_FIELD {
get {

View File

@ -8334,7 +8334,7 @@ This will permanently delete and reinitialize all local storage on the servers.
<value>Deactivate Virtual Disk</value>
</data>
<data name="MESSAGEBOX_DELETE_CUSTOM_FIELD" xml:space="preserve">
<value>This will delete '{0}' permanently, destroying all data associated with it. Continue?</value>
<value>This will delete '{0}' permanently, making it unavailable to all resources in the pool and destroying all data associated with it. Do you want to continue?</value>
</data>
<data name="MESSAGEBOX_DELETE_ISO" xml:space="preserve">
<value>This will delete {0} permanently, destroying the data on it. Continue?</value>

View File

@ -609,21 +609,6 @@ namespace XenAdmin.Core
return o.Get("gui_config") as Dictionary<String, String>;
}
public static void SetGuiConfig(Session session, IXenObject o, String key, String value)
{
//Program.AssertOffEventThread();
o.Do("remove_from_gui_config", session, o.opaque_ref, key);
o.Do("add_to_gui_config", session, o.opaque_ref, key, value);
}
public static void RemoveFromGuiConfig(Session session, IXenObject o, string key)
{
//Program.AssertOffEventThread();
o.Do("remove_from_gui_config", session, o.opaque_ref, key);
}
#endregion
public enum DataSourceCategory

View File

@ -63,6 +63,9 @@
<Link>Properties\CommonAssemblyInfo.cs</Link>
</Compile>
<Compile Include="Actions\ActionBase.cs" />
<Compile Include="Actions\CustomFields\AddCustomFieldAction.cs" />
<Compile Include="Actions\CustomFields\RemoveCustomFieldAction.cs" />
<Compile Include="Actions\CustomFields\SaveCustomFieldsAction.cs" />
<Compile Include="Actions\HealthCheck\DisableHealthCheckAction.cs" />
<Compile Include="Actions\CancellingAction.cs" />
<Compile Include="Actions\DockerContainer\DockerContainerLifetimeAction.cs" />