using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Text; using System.Windows.Forms; namespace Milkshake.Editors.Components { public delegate void ValueChangedEventHandler(object sender, EventArgs e); public class AutoControl : UserControl { private bool _initialized; private String _previousValue; private String _defaultValue; public ValueChangedEventHandler ValueChanged; protected int LabelPadding { get { return 0; } } public AutoControl() { } public AutoControl(String defaultValue) { _initialized = false; _defaultValue = defaultValue; } public virtual void SetFriendlyName(String value) { } public virtual void SetFriendlyNameWidth(int width) { } public virtual void SetValue(String value) { if (_initialized == true && _previousValue != null && _previousValue != value) { MilkshakeForm.Instance.SceneWasModified = true; } _initialized = true; _previousValue = value; } protected virtual bool IsValueValid(string value) { return true; } protected virtual void RestoreValue(String errorMessage) { if (_initialized) { SetValue(_previousValue); MilkshakeForm.ShowErrorMessage(errorMessage); } else { SetValue(_defaultValue); } } public virtual object GetValue() { return null; } protected void OnValueChanged(EventArgs e) { if (ValueChanged != null) { ValueChanged(this, e); } } } }
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)