This commit is contained in:
2006-11-14 14:33:33 +00:00
commit a0cad33b0f
180 changed files with 40199 additions and 0 deletions

View File

@@ -0,0 +1,329 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
namespace Volian.CSLA.Library
{
[Serializable]
[TypeConverter(typeof(ExpandableObjectConverter))]
public class FolderConfig:INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(String info)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(info));
}
private XMLProperties _Xp;
private XMLProperties Xp
{
get { return _Xp; }
}
public FolderConfig(string xml)
{
if (xml == string.Empty) xml = "<config/>";
_Xp = new XMLProperties(xml);
}
public FolderConfig()
{
_Xp = new XMLProperties();
}
public override string ToString()
{
string s = _Xp.ToString();
if (s == "<config/>" || s == "<config></config>") return string.Empty;
return s;
}
#region FormatCategory
public enum FormatColumns : int
{
Default=0,OneColumn,TwoColumn,ThreeColumn,FourColumns
}
[Category("Format")]
[DisplayName("Column Layout")]
[RefreshProperties(RefreshProperties.All)]
[Description("Column Layout")]
public FormatColumns Format_Columns
{
get
{
string s = _Xp["format", "columns"];
if (s == string.Empty) return (FormatColumns)0;
return (FormatColumns)int.Parse(_Xp["format", "columns"]);
//return Enum.Parse(typeof(FormatColumns),_Xp["format", "columns"]);
}
set
{
if (value == 0) _Xp["format", "columns"] = string.Empty;
else _Xp["format", "columns"] = ((int)value).ToString();
OnPropertyChanged("Format_Columns");
}
}
[Category("Format")]
[DisplayName("Plant Format Name")]
[RefreshProperties(RefreshProperties.All)]
[Description("Default Plant Format")]
public string Format_Plant
{
get
{ return _Xp["format", "plant"];
}
set
{
_Xp["format", "plant"] = value;
OnPropertyChanged("Format_Plant");
}
}
#endregion
#region DefaultsCategory
[Category("Defaults")]
[DisplayName("Default Setpoint Prefix")]
[RefreshProperties(RefreshProperties.All)]
[Description("Default Setpoint Prefix")]
public string Default_SPPrefix
{
get { return _Xp["default", "spprefix"]; }
set
{
_Xp["default", "spprefix"] = value;
OnPropertyChanged("Default_SPPrefix");
}
}
[Category("Defaults")]
[DisplayName("Default Image Prefix")]
[RefreshProperties(RefreshProperties.All)]
[Description("Default Image Prefix")]
public string Default_IMPrefix
{
get { return _Xp["default", "imprefix"]; }
set
{
_Xp["default", "imprefix"] = value;
OnPropertyChanged("RO_IMPrefix");
}
}
#endregion
#region PrintSettingsCategory
[Category("Print Settings")]
[DisplayName("Number of Copies")]
[RefreshProperties(RefreshProperties.All)]
[Description("Number of Copies")]
public int Print_NumCopies
{
get
{
string s = _Xp["PrintSettings", "numcopies"];
if (s == string.Empty) return 1;
return int.Parse(_Xp["PrintSettings", "numcopies"]);
}
set
{
_Xp["PrintSettings", "numcopies"] = value.ToString();
OnPropertyChanged("Print_NumCopies");
}
}
public enum PrintPagination : int
{
Free = 0, Fixed, Auto
}
[Category("Print Settings")]
[DisplayName("Pagination")]
[RefreshProperties(RefreshProperties.All)]
[Description("Pagination")]
public PrintPagination Print_Pagination
{
get
{
string s = _Xp["PrintSettings", "Pagination"];
if (s == string.Empty) return PrintPagination.Auto;
return (PrintPagination)int.Parse(_Xp["PrintSettings", "Pagination"]);
}
set
{
if (value == PrintPagination.Auto) _Xp["PrintSettings", "Pagination"] = string.Empty;
else _Xp["PrintSettings", "Pagination"] = ((int)value).ToString();
OnPropertyChanged("Print_Pagination");
}
}
public enum PrintWatermark : int
{
None = 0, Reference, Draft, Master, Sample, InformationOnly
}
[Category("Print Settings")]
[DisplayName("Watermark")]
[RefreshProperties(RefreshProperties.All)]
[Description("Watermark")]
public PrintWatermark Print_Watermark
{
get
{
string s = _Xp["PrintSettings", "Watermark"];
if (s == string.Empty) return PrintWatermark.Draft;
return (PrintWatermark)int.Parse(_Xp["PrintSettings", "Watermark"]);
}
set
{
if (value == PrintWatermark.Draft) _Xp["PrintSettings", "Watermark"] = string.Empty;
else _Xp["PrintSettings", "Watermark"] = ((int)value).ToString();
OnPropertyChanged("Print_Watermark");
}
}
[Category("Print Settings")]
[DisplayName("Disable Duplex Printing")]
[RefreshProperties(RefreshProperties.All)]
[Description("Disable Duplex Printing")]
public bool Print_DisableDuplex
{
get
{
string s = _Xp["PrintSettings", "disableduplex"];
if (s == string.Empty) return false;
return bool.Parse(_Xp["PrintSettings", "disableduplex"]);
}
set
{
_Xp["PrintSettings", "disableduplex"] = value.ToString();
OnPropertyChanged("Print_DisableDuplex");
}
}
// Change Bar Use from 16-bit code:
// No Default
// Without Change Bars
// With Default Change Bars
// With User Specified Change Bars
public enum PrintChangeBar : int
{
NoDefault=0, Without, WithDefault, WithUserSpecified
}
[Category("Print Settings")]
[DisplayName("Change Bar")]
[RefreshProperties(RefreshProperties.All)]
[Description("Change Bar Use")]
public PrintChangeBar Print_ChangeBar
{
get
{
string s = _Xp["PrintSettings", "ChangeBar"];
if (s == string.Empty) return PrintChangeBar.NoDefault;
return (PrintChangeBar)int.Parse(_Xp["PrintSettings", "ChangeBar"]);
}
set
{
if (value == PrintChangeBar.NoDefault) _Xp["PrintSettings", "ChangeBar"] = string.Empty;
else _Xp["PrintSettings", "ChangeBar"] = ((int)value).ToString();
OnPropertyChanged("Print_ChangeBar");
}
}
// User Specified Change Bar Location from16-bit code:
// With Text
// Outside Box
// AER on LEFT, RNO on Right
// To the Left of Text
public enum PrintChangeBarLoc : int
{
WithText = 0, OutsideBox, AERleftRNOright, LeftOfText
}
[Category("Print Settings")]
[DisplayName("Change Bar Location")]
[RefreshProperties(RefreshProperties.All)]
[Description("User Specified Change Bar Location")]
public PrintChangeBarLoc Print_ChangeBarLoc
{
get
{
string s = _Xp["PrintSettings", "ChangeBarLoc"];
if (s == string.Empty) return PrintChangeBarLoc.WithText;
return (PrintChangeBarLoc)int.Parse(_Xp["PrintSettings", "ChangeBarLoc"]);
}
set
{
if (value == PrintChangeBarLoc.WithText) _Xp["PrintSettings", "ChangeBarLoc"] = string.Empty;
else _Xp["PrintSettings", "ChangeBarLoc"] = ((int)value).ToString();
OnPropertyChanged("Print_ChangeBarLoc");
}
}
// Change Bar Text from16-bit code:
// Date and Change ID
// Revision Number
// Change ID
// No Change Bar Message
// User Defined Message
public enum PrintChangeBarText : int
{
DateChgID = 0, RevNum, ChgID, None, UserDef
}
[Category("Print Settings")]
[DisplayName("Change Bar Text")]
[RefreshProperties(RefreshProperties.All)]
[Description("Change Bar Text")]
public PrintChangeBarText Print_ChangeBarText
{
get
{
string s = _Xp["PrintSettings", "ChangeBarText"];
if (s == string.Empty) return PrintChangeBarText.DateChgID;
return (PrintChangeBarText)int.Parse(_Xp["PrintSettings", "ChangeBarText"]);
}
set
{
if (value == PrintChangeBarText.DateChgID) _Xp["PrintSettings", "ChangeBarText"] = string.Empty;
else _Xp["PrintSettings", "ChangeBarText"] = ((int)value).ToString();
OnPropertyChanged("Print_ChangeBarText");
}
}
[Category("Print Settings")]
[DisplayName("User Format")]
[RefreshProperties(RefreshProperties.All)]
[Description("User Format")]
public string Print_UserFormat
{
get
{
return _Xp["PrintSettings", "userformat"];
}
set
{
_Xp["PrintSettings", "userformat"] = value;
OnPropertyChanged("Print_UserFormat");
}
}
[Category("Print Settings")]
[DisplayName("User Change Bar Message1")]
[RefreshProperties(RefreshProperties.All)]
[Description("User Change Bar Message1")]
public string Print_UserCBMess1
{
get
{
return _Xp["PrintSettings", "usercbmess1"];
}
set
{
_Xp["PrintSettings", "usercbmess1"] = value;
OnPropertyChanged("Print_UserCBMess1");
}
}
[Category("Print Settings")]
[DisplayName("User Change Bar Message2")]
[RefreshProperties(RefreshProperties.All)]
[Description("User Change Bar Message2")]
public string Print_UserCBMess2
{
get
{
return _Xp["PrintSettings", "usercbmess2"];
}
set
{
_Xp["PrintSettings", "usercbmess2"] = value;
OnPropertyChanged("Print_UserCBMess2");
}
}
#endregion
}
}

View File

@@ -0,0 +1,127 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Serialization;
using System.Xml;
namespace Volian.CSLA.Library
{
[Serializable()]
class XMLProperties
{
#region Constructors
public XMLProperties()
{
_XmlContents = new XmlDocument();
_XmlContents.LoadXml("<config/>");
}
public XMLProperties(string xml)
{
_XmlContents = new XmlDocument();
_XmlContents.LoadXml(xml);
}
#endregion
#region BusinessMethods
[NonSerialized]
XmlDocument _XmlContents;
public XmlDocument XmlContents
{
get { return _XmlContents; }
}
private XmlNode GetGroup(string group)
{
XmlNodeList xl = _XmlContents.DocumentElement.SelectNodes(string.Format("//{0}", group));
switch (xl.Count)
{
case 0: // No nodes found
return null;
case 1: // Found the node
XmlNode xn = xl[0];
if (xn.GetType() == typeof(XmlElement)) return xn;
throw new XmlPropertiesException("Retrieved {0} while looking for XmlElement //{1}", xn.GetType().ToString(), group);
default: // Found more than 1 node
throw new XmlPropertiesException("Found more than one node //{0}", group);
}
}
private XmlAttribute GetItem(XmlNode xx, string item)
{
XmlNodeList xl = xx.SelectNodes(string.Format("@{0}", item));
switch (xl.Count)
{
case 0: // No nodes found
return null;
case 1: // Found the node
XmlNode xn = xl[0];
if (xn.GetType() == typeof(XmlAttribute)) return (XmlAttribute)xn;
throw new XmlPropertiesException("Retrieved {0} while looking for XmlAttribute @{1}", xn.GetType().ToString(), item);
default: // Found more than 1 node
throw new XmlPropertiesException("Found more than one node @{0}", item);
}
}
public string this[string group, string item]
{
get
{
XmlNode xn = GetGroup(group);
if (xn == null) return string.Empty;
XmlNode xa = GetItem(xn, item);
if (xa == null) return string.Empty;
return xa.InnerText;
}
set
{
if (value == null) value = string.Empty;
XmlNode xn = GetGroup(group);
if (xn == null)
{
if (value != string.Empty)// Add Group and Item
{
xn = _XmlContents.DocumentElement.AppendChild(_XmlContents.CreateElement(group));
XmlAttribute xa = xn.Attributes.Append(_XmlContents.CreateAttribute(item));
xa.Value = value;
}
}
else
{
XmlAttribute xa = GetItem(xn, item);
if (xa == null)
{
if (value != string.Empty) // Add Item
{
xa = xn.Attributes.Append(_XmlContents.CreateAttribute(item));
xa.Value = value;
}
}
else
{
if (value != string.Empty) // Add Item
{
xa.Value = value;
}
else
{
xn.Attributes.Remove(xa);
if (xn.Attributes.Count == 0)
_XmlContents.DocumentElement.RemoveChild(xn);
}
}
}
}
}
public override string ToString()
{
return _XmlContents.OuterXml;
}
#endregion
#region XmlPropertiesException
public class XmlPropertiesException : Exception
{
public XmlPropertiesException() : base() { ;}
public XmlPropertiesException(string message) : base(message) { ;}
public XmlPropertiesException(string messageFormat,params object [] args) : base(string.Format(messageFormat,args)) { ;}
public XmlPropertiesException(SerializationInfo info, StreamingContext context) : base(info, context) { ;}
public XmlPropertiesException(string message,Exception innerException) : base(message, innerException) { ;}
}
#endregion
}
}