124 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			124 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
using System;
 | 
						|
using System.Collections.Generic;
 | 
						|
using System.Text;
 | 
						|
using System.ComponentModel;
 | 
						|
using System.Drawing;
 | 
						|
using DescriptiveEnum;
 | 
						|
 | 
						|
namespace VEPROMS.CSLA.Library
 | 
						|
{
 | 
						|
	[Serializable]
 | 
						|
	[TypeConverter(typeof(ExpandableObjectConverter))]
 | 
						|
	public class RevisionConfig : ConfigDynamicTypeDescriptor, INotifyPropertyChanged
 | 
						|
	{
 | 
						|
		#region DynamicTypeDescriptor
 | 
						|
		internal override bool IsReadOnly
 | 
						|
		{
 | 
						|
			get { return false; }//_Section == null; }
 | 
						|
		}
 | 
						|
		#endregion
 | 
						|
		#region XML
 | 
						|
		private XMLProperties _Xp;
 | 
						|
		private XMLProperties Xp
 | 
						|
		{
 | 
						|
			get { return _Xp; }
 | 
						|
		}
 | 
						|
		#endregion
 | 
						|
		#region Constructors
 | 
						|
		private Revision _Revision;
 | 
						|
    private RevisionInfo _RevisionInfo;
 | 
						|
		[Browsable(false)]
 | 
						|
		public bool ParentLookup
 | 
						|
		{
 | 
						|
			get { return _Xp.ParentLookup; }
 | 
						|
			set { _Xp.ParentLookup = value; }
 | 
						|
		}
 | 
						|
		public RevisionConfig(Revision revision)
 | 
						|
		{
 | 
						|
			_Revision = revision;
 | 
						|
			string xml = revision.Config;
 | 
						|
			if (xml == string.Empty) xml = "<Config/>";
 | 
						|
			_Xp = new XMLProperties(xml);
 | 
						|
		}
 | 
						|
		public RevisionConfig(RevisionInfo revisionInfo)
 | 
						|
		{
 | 
						|
			_RevisionInfo = revisionInfo;
 | 
						|
			string xml = revisionInfo.Config;
 | 
						|
			if (xml == string.Empty) xml = "<Config/>";
 | 
						|
			_Xp = new XMLProperties(xml);
 | 
						|
		}
 | 
						|
		public RevisionConfig(string xml)
 | 
						|
		{
 | 
						|
			if (xml == string.Empty) xml = "<Config/>";
 | 
						|
			_Xp = new XMLProperties(xml);
 | 
						|
		}
 | 
						|
		public RevisionConfig()
 | 
						|
		{
 | 
						|
			_Xp = new XMLProperties();
 | 
						|
		}
 | 
						|
		internal string GetValue(string group, string item)
 | 
						|
		{
 | 
						|
			return _Xp[group, item];
 | 
						|
		}
 | 
						|
		#endregion
 | 
						|
		#region Properties and Methods
 | 
						|
		// This is needed for the Data Loader
 | 
						|
		[Category("History")]
 | 
						|
		[Browsable(false)]
 | 
						|
		[DisplayName("Start Date")]
 | 
						|
		[RefreshProperties(RefreshProperties.All)]
 | 
						|
		[Description("Start date used for change bars")]
 | 
						|
		public DateTime History_StartDate
 | 
						|
		{
 | 
						|
			get
 | 
						|
			{
 | 
						|
				string s = _Xp["History", "StartDate"];
 | 
						|
				if (s == string.Empty) return DateTime.MinValue;
 | 
						|
				return DateTime.Parse(s);
 | 
						|
			}
 | 
						|
			set
 | 
						|
			{
 | 
						|
				string s = _Xp["History", "StartDate"];
 | 
						|
				if (s == value.ToString("MM/dd/yyyy HH:mm:ss")) return;
 | 
						|
				_Xp["History", "StartDate"] = value.ToString("MM/dd/yyyy HH:mm:ss");
 | 
						|
				OnPropertyChanged("History_StartDate");
 | 
						|
			}
 | 
						|
		}
 | 
						|
		//jcb 20120618
 | 
						|
		[Category("Applicability")]
 | 
						|
		[Browsable(false)]
 | 
						|
		[DisplayName("Index")]
 | 
						|
		[RefreshProperties(RefreshProperties.All)]
 | 
						|
		[Description("Index for unit")]
 | 
						|
		public int Applicability_Index
 | 
						|
		{
 | 
						|
			get
 | 
						|
			{
 | 
						|
				string s = _Xp["Applicability", "Index"];
 | 
						|
				if (s == string.Empty) return 0;
 | 
						|
				return int.Parse(s);
 | 
						|
			}
 | 
						|
			set
 | 
						|
			{
 | 
						|
				string s = _Xp["Applicability", "Index"];
 | 
						|
				if (s == value.ToString()) return;
 | 
						|
				_Xp["Applicability", "Index"] = value.ToString();
 | 
						|
				OnPropertyChanged("Applicability_Index");
 | 
						|
			}
 | 
						|
		}
 | 
						|
		//end jcb 20120618
 | 
						|
		public void Save()
 | 
						|
		{
 | 
						|
			if (_Revision != null)
 | 
						|
				_Revision.Config = this.ToString();
 | 
						|
		}
 | 
						|
		public override string ToString()
 | 
						|
		{
 | 
						|
			string s = _Xp.ToString();
 | 
						|
			if (s == "<Config/>" || s == "<Config></Config>") return string.Empty;
 | 
						|
			return s;
 | 
						|
		}
 | 
						|
		#endregion
 | 
						|
	}
 | 
						|
}
 |