using System;
using System.ComponentModel;
namespace VEPROMS.CSLA.Library
{
[Serializable]
[TypeConverter(typeof(ExpandableObjectConverter))]
public class DocumentConfig : ConfigDynamicTypeDescriptor, INotifyPropertyChanged
{
#region XML
private readonly XMLProperties _Xp;
#endregion
#region Constructors
public Document _Document;
private readonly DocumentInfo _DocumentInfo;
public DocumentConfig(Document document)
{
_Document = document;
string xml = _Document.Config;
if (xml == string.Empty) xml = "";
_Xp = new XMLProperties(xml);
}
public DocumentConfig(DocumentInfo documentInfo)
{
_DocumentInfo = documentInfo;
string xml = _DocumentInfo.Config;
if (xml == string.Empty) xml = "";
_Xp = new XMLProperties(xml);
}
internal string GetValue(string group, string item) => _Xp[group, item];
#endregion
#region Properties
[Category("General")]
[DisplayName("Name")]
[Description("Name")]
public string Name
{
get { return (_Document != null ? _Document.LibTitle : _DocumentInfo.LibTitle); }
set { if (_Document != null) _Document.LibTitle = value; }
}
[Category("General")]
[DisplayName("Comment")]
[RefreshProperties(RefreshProperties.All)]
[Description("Comment")]
public string LibDoc_Comment
{
get
{
string s = _Xp["LibDoc", "Comment"];// get the saved value
return s;
}
set
{
_Xp["LibDoc", "Comment"] = value;
OnPropertyChanged("LibDoc_Comment");
}
}
[Category("Edit")]
[DisplayName("Initialized")]
[Description("Initialized")]
public bool Edit_Initialized
{
get
{
string s = _Xp["Edit", "Initialized"];
if (s == string.Empty) // If there is no value, then default to false
s = "false"; // default
return bool.Parse(s);
}
set
{
_Xp["Edit", "Initialized"] = value.ToString();
OnPropertyChanged("Edit_Initialized");
}
}
[Category("History")]
[DisplayName("Original File Name")]
[Description("File Name from 16-Bit Data")]
public string History_OriginalFileName
{
get
{
return _Xp["History", "OriginalFileName"];
}
set
{
_Xp["History", "OriginalFileName"] = value;
OnPropertyChanged("History_OriginalFileName");
}
}
#endregion
#region ToString
public override string ToString()
{
string s = _Xp.ToString();
return s == "" || s == "" ? string.Empty : s;
}
#endregion
}
}