public override void Update(HaloPlugins.Objects.MetaNode node) { // Check to see if the new node is of the correct type. if (node.FieldType != HaloPlugins.Objects.FieldType.Value) { throw new Exception("Tried to bind an incompatible MetaNode object to Value control!"); } // Bind to the new Value object. this.value = (HaloPlugins.Objects.Data.Value)node; // Update the value in the textbox. this.txtValue.Text = this.value.DataValue.ToString(); }
public Value(HaloPlugins.Objects.Data.Value value) { // Initialize the form. InitializeComponent(); // Set a custom OnDefaultWidthChanged handler. this.DefaultWidthChanged += new DefaultWidthChangedHandler(Value_DefaultWidthChanged); // Save the value object. this.value = value; // Setup the tootip. this.lblName.Text = this.value.Name; this.toolTipController1.SetTitle(lblName, this.value.Name); // Set the correct data type for the tooltip. string type = ""; switch (this.value.DataType.ToString()) { case "System.Int16": type = "Short"; break; case "System.UInt16": type = "UShort"; break; case "System.Int32": type = "Int"; break; case "System.UInt32": type = "UInt"; break; case "System.Single": type = "Float"; break; default: { // Unknown data type. throw new Exception(string.Format("Unknown data type {0} passed to Value control!", this.value.DataType.ToString())); break; } } // Format the string. this.toolTipController1.SetToolTip(this.lblName, string.Format("Type: {0}", type)); // Set the textbox text to the data value. this.txtValue.Text = this.value.DataValue.ToString(); }