This commit is contained in:
Jsj
2007-11-20 20:12:45 +00:00
parent d0793524be
commit 6e00716c47
149 changed files with 71953 additions and 0 deletions

View File

@@ -0,0 +1,483 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Xml;
namespace VEPROMS.CSLA.Library
{
#region DocStyles
[TypeConverter(typeof(ExpandableObjectConverter))]
public class DocStyles : vlnFormatItem
{
[Description("Document Styles Name")]
private LazyLoad<string> _Name;
public string Name
{
get
{
return LazyLoad(ref _Name, "@Name");
}
}
private DocStyleList _DocStyleList;
public DocStyleList DocStyleList
{
get
{
return (_DocStyleList == null) ? _DocStyleList = new DocStyleList(SelectNodes("DocStyle")): _DocStyleList;
}
set { _DocStyleList = value; }
}
public DocStyles(XmlNode xmlNode) : base(xmlNode) { }
}
#endregion
#region DocStyleAll
#region DocStyle
[TypeConverter(typeof(ExpandableObjectConverter))]
public class DocStyle : vlnFormatItem
{
public DocStyle(XmlNode xmlNode) : base(xmlNode) { }
public DocStyle() : base() { }
#region IndexName
private LazyLoad<int?> _Index;
public int? Index
{
get
{
return LazyLoad(ref _Index, "@Index");
}
}
[Description("Document Styles Name")]
private LazyLoad<string> _Name;
public string Name
{
get
{
return LazyLoad(ref _Name, "@Name");
}
}
#endregion
#region Font
private VE_Font _Font;
[Category("Font")]
[DisplayName("Font")]
[Description("Font")]
public VE_Font Font
{
get
{
return(_Font == null) ?_Font = new VE_Font(XmlNode): _Font;
}
}
#endregion
#region numberingsequence
[Category("Miscellaneous")]
[Description("Numbering Sequence")]
private LazyLoad<E_NumberingSequence?> _NumberingSequence;
public E_NumberingSequence? NumberingSequence
{
get
{
return LazyLoad<E_NumberingSequence>(ref _NumberingSequence, "@NumberingSequence");
}
}
#endregion
#region Oldtonew
[Category("Miscellaneous")]
[Description("Convert from old to new")]
private LazyLoad<int?> _OldToNew;
public int? OldToNew
{
get
{
return LazyLoad(ref _OldToNew, "@OldToNew");
}
}
#endregion
#region pagestyle
private PageStyle _pagestyle;
[Category("Miscellaneous")]
[DisplayName("Page Style")]
[Description("Page Style")]
public PageStyle pagestyle
{
get
{
string str = "//PageStyles/PageStyle[" + (IntLookup("@PageStyle") + 1).ToString() + "]";
XmlNode xn = SelectSingleNode(str);
if (_pagestyle == null) _pagestyle = new PageStyle(SelectSingleNode("//PageStyles/PageStyle[" + (IntLookup("@PageStyle") + 1).ToString() + "]"));
return _pagestyle;
}
}
#endregion
#region SubElements
private Layout _Layout;
public Layout Layout
{
get
{
return (_Layout == null ? _Layout = new Layout(SelectSingleNode("Layout")) : _Layout);
}
}
private Continue _Continue;
public Continue Continue
{
get
{
return (_Continue == null ? _Continue = new Continue(SelectSingleNode("Continue")) : _Continue);
}
}
private End _End;
public End End
{
get
{
return (_End == null ? _End = new End(SelectSingleNode("End")) : _End);
}
}
private Final _Final;
public Final Final
{
get
{
return (_Final == null ? _Final = new Final(SelectSingleNode("Final")) : _Final);
}
}
private StructureStyle _StructureStyle;
public StructureStyle StructureStyle
{
get
{
return (_StructureStyle == null ? _StructureStyle = new StructureStyle(SelectSingleNode("StructureStyle")) : _StructureStyle);
}
}
#endregion
public override string ToString()
{
return String.Format("{0:D2} - {1}", Index, Name);
}
}
#endregion
#region DocStyleList
[TypeConverter(typeof(vlnListConverter<DocStyleList, DocStyle>))]
public class DocStyleList : vlnFormatList<DocStyle>
{
public DocStyleList(XmlNodeList xmlNodeList) : base(xmlNodeList) { }
}
#endregion
#region Layout
[TypeConverter(typeof(ExpandableObjectConverter))]
public class Layout : vlnFormatItem
{
public Layout(XmlNode xmlNode) : base(xmlNode) { }
public Layout() : base() { }
#region TopRow
private LazyLoad<int?> _TopRow;
[Category("Layout")]
[DisplayName("Top Row on Printed Page")]
[Description("Top Row on Printed Page")]
public int? TopRow
{
get
{
return LazyLoad(ref _TopRow, "@TopRow");
}
}
#endregion
#region FooterLength
private LazyLoad<int?> _FooterLength;
[Category("Location")]
[DisplayName("Number of lines required for footer")]
[Description("Number of lines required for footer")]
public int? FooterLength
{
get
{
return LazyLoad(ref _FooterLength, "@FooterLength");
}
}
#endregion
#region LeftMargin
private LazyLoad<int?> _LeftMargin;
[Category("Location")]
[DisplayName("Size of left margin")]
[Description("Size of left margin")]
public int? LeftMargin
{
get
{
return LazyLoad(ref _LeftMargin, "@LeftMargin");
}
}
#endregion
#region PageLength
private LazyLoad<int?> _PageLength;
[Category("Location")]
[DisplayName("Length of Page")]
[Description("Length of Page")]
public int? PageLength
{
get
{
return LazyLoad(ref _PageLength, "@PageLength");
}
}
#endregion
#region PageWidth
private LazyLoad<int?> _PageWidth;
[Category("Location")]
[DisplayName("Width of Page")]
[Description("Width of Page")]
public int? PageWidth
{
get
{
return LazyLoad(ref _PageWidth, "@PageWidth");
}
}
#endregion
}
#endregion
#region ContinueAll
#region Continue
[TypeConverter(typeof(ExpandableObjectConverter))]
public class Continue : vlnFormatItem
{
public Continue(XmlNode xmlNode) : base(xmlNode) { }
public Continue() : base() { }
#region Font
private VE_Font _Font;
[Category("Continue Msg")]
[DisplayName("Font")]
[Description("Font")]
public VE_Font Font
{
get
{
return (_Font == null ? _Font = new VE_Font(base.XmlNode) : _Font);
}
}
#endregion
#region SubElements
private Top _Top;
public Top Top
{
get
{
return (_Top == null? _Top = new Top(SelectSingleNode("Top")): _Top);
}
}
private Bottom _Bottom;
public Bottom Bottom
{
get
{
return (_Bottom == null ? _Bottom = new Bottom(SelectSingleNode("Bottom")) : _Bottom);
}
}
#endregion
}
#endregion
#region Top
[TypeConverter(typeof(ExpandableObjectConverter))]
public class Top : vlnFormatItem
{
public Top(XmlNode xmlNode) : base(xmlNode) { }
public Top() : base() { }
#region Margin
private LazyLoad<int?> _Margin;
[Category("Continue Msg")]
[DisplayName("Margin for top msg")]
[Description("Margin for top msg")]
public int? Margin
{
get
{
return LazyLoad(ref _Margin, "@Margin");
}
}
#endregion
#region HLS
private LazyLoad<int?> _HLS;
[Category("Continue Msg")]
[DisplayName("Include HLS in top continue msg")]
[Description("Include HLS in top continue msg")]
public int? HLS
{
get
{
return LazyLoad(ref _HLS, "@HLS");
}
}
#endregion
#region Message
private LazyLoad<string> _Message;
[Category("Continue Msg")]
[DisplayName("Top Continue Msg")]
[Description("Top Continue Msg")]
public string Message
{
get
{
return LazyLoad(ref _Message, "@Message");
}
}
#endregion
}
#endregion
#region Bottom
[TypeConverter(typeof(ExpandableObjectConverter))]
public class Bottom : vlnFormatItem
{
public Bottom(XmlNode xmlNode) : base(xmlNode) { }
public Bottom() : base() { }
#region Margin
private LazyLoad<int?> _Margin;
[Category("Continue Msg")]
[DisplayName("Margin for bottom msg")]
[Description("Margin for bottom msg")]
public int? Margin
{
get
{
return LazyLoad(ref _Margin, "@Margin");
}
}
#endregion
#region Location
[Category("Continue Msg")]
[Description("Bottom Continue Location")]
private LazyLoad<E_NumberingSequence?> _NumberingSequence;
public E_NumberingSequence? NumberingSequence
{
get
{
return LazyLoad<E_NumberingSequence>(ref _NumberingSequence, "@NumberingSequence");
}
}
private LazyLoad<E_ContBottomLoc?> _Location;
public E_ContBottomLoc? Location
{
get
{
return LazyLoad<E_ContBottomLoc>(ref _Location, "@Location");
}
}
#endregion
#region Message
private LazyLoad<string> _Message;
[Category("Continue Msg")]
[DisplayName("Bottom Continue Msg")]
[Description("Bottom Continue Msg")]
public string Message
{
get
{
return LazyLoad(ref _Message, "@Message");
}
}
#endregion
}
#endregion
#endregion
#region End
[TypeConverter(typeof(ExpandableObjectConverter))]
public class End : vlnFormatItem
{
public End(XmlNode xmlNode) : base(xmlNode) { }
public End() : base() { }
#region Font
private VE_Font _Font;
[Category("End Msg")]
[DisplayName("Font")]
[Description("Font")]
public VE_Font Font
{
get
{
return (_Font == null ? _Font = new VE_Font(XmlNode) : _Font);
}
}
#endregion
#region Flag
private LazyLoad<int?> _Flag;
[Category("End Msg")]
[DisplayName("End Msg Exists")]
[Description("End Msg Exists")]
public int? Flag
{
get
{
return LazyLoad(ref _Flag, "@Flag");
}
}
#endregion
#region Message
private LazyLoad<string> _Message;
[Category("End Msg")]
[DisplayName("End Message")]
[Description("End Message")]
public string Message
{
get
{
return LazyLoad(ref _Message, "@Message");
}
}
#endregion
}
#endregion
#region Final
[TypeConverter(typeof(ExpandableObjectConverter))]
public class Final : vlnFormatItem
{
public Final(XmlNode xmlNode) : base(xmlNode) { }
public Final() : base() { }
private LazyLoad<string> _Message;
[Category("Final Msg")]
[DisplayName("Final Message")]
[Description("Final Message")]
public string Message
{
get
{
return LazyLoad(ref _Message, "@Message");
}
}
}
#endregion
#region StructureStyle
[TypeConverter(typeof(ExpandableObjectConverter))]
public class StructureStyle : vlnFormatItem
{
public StructureStyle(XmlNode xmlNode) : base(xmlNode) { }
public StructureStyle() : base() { }
#region Where
[Category("Structure Style")]
[Description("Where Used")]
private LazyLoad<E_DocStyleUse?> _Where;
public E_DocStyleUse? Where
{
get
{
return LazyLoad<E_DocStyleUse>(ref _Where, "@Where");
}
}
#endregion
#region Style
[Category("Structure Style")]
[Description("Style")]
private LazyLoad<E_DocStructStyle?> _Style;
public E_DocStructStyle? Style
{
get
{
return LazyLoad<E_DocStructStyle>(ref _Style, "@Style");
}
}
#endregion
}
#endregion
#endregion
}

View File

@@ -0,0 +1,199 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.ComponentModel;
namespace VEPROMS.CSLA.Library
{
#region ENums
[Flags]
public enum E_PurchaseOptions : uint
{
APPROVEONE = 0x0001,
ACCPAGINATION = 0x0002,
LIBMAINT = 0x0004,
TRANSFER = 0x0008,
STREES = 0x0010,
DATECHGSUMRPT = 0x0020,
SETPOINTUSAGE = 0x0040,
REPLACE = 0x0080,
FLOPPYTRANSFER = 0x0100,
APPROVEGENERICBACK = 0x0200,
DISTRIBUTEAPPROVED = 0x0400,
OUTSIDETRANSITIONS = 0x0800,
ENHANCEDBACKGROUNDS = 0x1000,
ENHANCEDDEVIATIONS = 0x2000,
AUTOTABLEOFCONTENTS = 0x4000,
AUTOPLACEKEEPER = 0x8000
}
[Flags]
public enum E_Style : uint
{
// Fonts removed, not used here.
NONE = 0,
UNDERLINE = 64, BOLD = 128, LANDSCAPE = 256, ITALICS = 512, BOXED = 1024, BOXELEMENT = 0x00000800,
TBCENTERED = 4096, RTCHECKOFF = 8192, LTCHECKOFF = 16384, BIGSCRIPT = 32768, HLTEXTHL = 65536,
RTCHECKOFFWITHASTERISK = 131072, DB_UNDERLINE = 262144, COLDOTS = 524288,
MMBOLD = 1048576, RIGHTJUSTIFY = 2097152, SUBSCRIPT = 4194304, SUPERSCRIPT = 8388608,
PAGELISTITEM = 16777216, PRINTONTOPOFLINE = 33554432, HORZCENTER = 67108864,
CIRCLESTRING2 = 0x08000000, ALIGNWITHUP1 = 0x10000000, ALIGNWSECNUM = 0x20000000,
MATCHCOLUMNMODE = 0x40000000, KEEPRNOSUBSTYLE = 0x80000000
};
public enum E_ChangeBarMessage : uint
{
DATEANDUSERID = 0,
REVNUMBER = 1,
USERID = 2,
NOTHING = 3
}
public enum E_EMode : uint
{
INSERT = 0,
OVERRIDE = 1
}
public enum E_ViewMode : uint
{
VIEW = 0,
EDIT = 1
}
public enum E_EditPrintMode : uint
{
EDIT = 0,
PRINT = 1
}
[Flags]
public enum E_Justify : uint
{
PSCENTER = 0, // Page style, center field
PSLEFT = 1, // Page style, left justify
PSRIGHT = 2, // Page style, right justify
// *** PS modifiers: ***
PSBOTTOM = 4, // Page style, always use bottom half line
PSTOP = 8, // Page style, always use top half line
PSTRUE = 16, // page style, don't adjust per CPI* (not needed after 4.0)
PSNOTFIRST = 32, // page style, don't put this token on the first page of section
PSONLYFIRST = 64, // page style, only put this token on the first page of section
PSRELROW = 128, // place in RelPageList
PSNOHALFLINE = 256, // DontDoHalflines for his paglist row item
PSNOTLAST = 0x200, // 512 - use this token on all but the last page of this section
PSRTFONLY = 0x400, // Only use this token when the driver is rtf
PSRTFNOT = 0x800, // Do NOT use token when driver is rtf
PSGDIONLY = 0X1000, // Only use this token when the driver is GDI
PSGDINOT = 0x2000, // Do NOT use token when driver is GDI
PSADJBNGROW = 0x4000 // If the pagelist item exceeds the row it's printed on,
// then adjust the starting row for the procedure body
};
public enum E_NumberingSequence : uint
{
NOPAGENUM = 0,
INCLUDEWOTHSTEPS = 1,
WITHINSECTIONS = 2,
WITHINACCESSORY = 3
};
public enum E_ContBottomLoc : uint
{
ENDOFTEXT = 0,
BTWNTEXTANDBOTTOM = 1,
BOTTOMOFPAGE = 2
};
[Flags]
public enum E_DocStructStyle : uint
{
//USEONALLPAGES = 0, // Default
//USEONFIRSTPAGE = 1, // Use only on the first page
//USEONALLBUTFIRSTPAGE = 2, // Use on all but the first page
//USEONLASTPAGE = 4, // NO LOGIC exists for this selection. Use only on the last page
NONE = 0,
USESECTIONFOLDOUT = 8, // Attach section foldouts (only active if using SectionLevelFoldouts_ON
DONTCOUNTFOLDOUTPGS = 16, // Used with the USESECTIONFOLDOUT flag. Keeps foldout pages from
// being included in the section total page count.
TABLEOFCONTENTS = 32,
DONTCOUNTINTABOFCONT = 64,
PLACEKEEPER = 128,
ALIGN1STLEVSUBWHLS = 0x00000100, // guess?
DOUBLEBOXHLS = 0x00000200,
USEALTCNTRLINE = 0x00000400,
DONTNUMBERINTOC = 0x00000800, // Don't include page number for this section in the Table of Contents
USESPECIALFIGFRAME = 0x00001000, // for use with stp55 and 55a in bge
HLSUSELETTERS = 0x00002000, // docstyles with this bit set in the DocStructStyle will
// default to using letters for HLSteps
NOSECTIONINSTEPCONTINUE = 0x00004000, // don't include the section number in the step continue
BOTTOMSECTIONCONTINUE = 0x00008000, // print the continue message if the section continues
ALWAYSDOTSTEP = 0x00010000, // put the period after step number in the continue message
XBLANKW1STLEVSUB = 0x00020000, // insert an extra blank line before a 1st level substep
AFFECTEDPAGES = 0x00040000,
DSS_TREATASTRUESECTNUM = 0x00080000, // in conjunction with tietabtolevel, takes section number
// from the last space and appends a period
SAMPLEWATERMARK = 0x00100000, // Will force "SAMPLE" to be printed across the page
// on all pages in this section
DSS_PAGEBREAKHLS = 0x00200000, // Page Breaks on all high level steps
DSS_NOCHKIFCONTTYPEHIGH = 0x00400000, // Will suppress the checkoff if type is HIGH and the
// step is continued on the next page
DSS_WIDTHOVRDSTDHLS = 0x00800000, // Width Override for Standard HLStep in this section
DSS_ADDDOTZEROSTDHLS = 0x01000000, // Append .0 to the Standard HLStep for this section
DSS_SECTIONCOMPRESS = 0x02000000, // Compress all the steps of this section (i.e. use 7 LPI)
DSS_PRINTSECTONFIRST = 0x04000000, // Prints section title/number <SECTIONLEVELTITLE> only on the first
// page of an attachment section, assuming numberingsequence is not 1
DSS_UNNUMLIKEROMAN = 0x08000000, // the substeps underneath unnumbered HLSteps will have same tabs as romans
DSS_DONTCHANGEROMANLEVEL = 0x10000000, // Dont alter the the substep level for roman-numeral-tabbed hlsteps
DSS_SKIPTWOSTEPLEVELS = 0x20000000, // Skip two step levels for this doc style
DSS_SKIPONESTEPLEVEL = 0x40000000, // Skip one step level for this doc style
DSS_SIMPLETOPSECTIONCONTINUE = 0x80000000, // Use the Top continue message as the section continue */
};
public enum E_DocStyleUse : uint
{
USEONALLPAGES = 0, USEONFIRSTPAGE = 1, USEONALLBUTFIRSTPAGE = 2, USEONLASTPAGE = 4
};
[Flags]
// acceptence list for adding Tables, Cautions, Notes, Substeps, Next, Previous and RNO
public enum E_AccStep : uint
{
ADDING_CAUTION = 1,
ADDING_NOTE = 2,
ADDING_RNO = 4,
ADDING_SUB = 8,
ADDING_TABLE = 16,
ADDING_NEXT = 32,
ADDING_PREV = 64
}
[Flags]
public enum E_ReplaceFlags : uint
{
// Generally used: HIGH, RNO, CAUTION, NOTE, TABLE, SUBSTEP, ATTACH
// ANONOP: BKGD, TOC, INSECTITLE, TRAN
// BGEEOP: BKGD, PLACKEEP, TOC, PARTIALS
// CAL1 & WCN & WEP (various): STATTREE, HLSSETPNT
// CAL2 & CPL: SETPOINT
// HLP: CASEINSENS
// CPLSSD: DIFFUNIT, TOC, STATTREE, HLSSETPNT
// CWE: CASEINSENS, DIFFUNIT
// MYA: CASEINSENSALL
HIGH = 0x0001, // Do ReplaceWords in HIGH LEVEL STEPS
RNO = 0x0002, // Do ReplaceWords in RNOS
CAUTION = 0x0004, // Do ReplaceWords in CAUTIONS
NOTE = 0x0008, // Do ReplaceWords in NOTES
TABLE = 0x0010, // Do ReplaceWords in TABLES
SUBSTEP = 0x0020, // Do ReplaceWords in SUBSTEPS
ATTACH = 0x0040, // Do ReplaceWords in ATTACHMENTS
BKGD = 0x0080, // Do ReplaceWords in BACKGROUNDS
DIFFUNIT = 0x0100, // Do ReplaceWords ONLY for different UNIT #
TOC = 0x0200, // Do in auto table-of-contents
STATTREE = 0x0400,
HLSSETPNT = 0x0800, // Do ReplaceWords in HighLevelStep SETPoiNTs
TRAN = 0x1000, // Do ReplaceWords in TRANSITIONS
SETPOINT = 0x2000, // Do ReplaceWords in SETPOINTS
// Case Sensitivity Flags - default is off (Case Sensitive Replace)
CASEINSENS = 0x0000C000, // Do ReplaceWords for all words thatmatch, regardless of case,
// and replace with the ReplaceWith string as is
CASEINSENSFIRST = 0x4000, // Do ReplaceWords for all words thatexactly match the ReplaceWord,
// except the case of the first character may be different
CASEINSENSALL = 0x8000, // Do ReplaceWords for all words that match the ReplaceWord, regardless of case
PARTIALS = 0x10000, // Do replace even on partial matches
PLACKEEP = 0x20000, // Do replace in PlaceKeepers
INSECTITLE = 0x40000
}
#endregion
}

View File

@@ -0,0 +1,140 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Xml;
namespace VEPROMS.CSLA.Library
{
#region PageStyles
[TypeConverter(typeof(vlnListConverter<PageStyles, PageStyle>))]
public class PageStyles : vlnFormatList<PageStyle>
{
public PageStyles(XmlNodeList xmlNodeList) : base(xmlNodeList) { }
}
#endregion
#region PageStyle
public class PageStyle : vlnFormatItem
{
#region Constructor
public PageStyle(XmlNode xmlNode) : base(xmlNode) { }
public PageStyle() : base() { }
#endregion
#region Business Methods
private LazyLoad<string> _Name;
[DisplayName("Name")]
[Description("Page Style Name")]
public string Name
{
get
{
return LazyLoad(ref _Name, "@Name");
}
}
private LazyLoad<int?> _Index;
[DisplayName("Index")]
[Description("Page Style Index")]
public int? Index
{
get
{
return LazyLoad(ref _Index, "@Index");
}
}
private PageItems _PageItems;
public PageItems PageItems
{
get
{
return (_PageItems == null)? _PageItems = new PageItems(SelectNodes("Item")): _PageItems;
}
}
#endregion
#region Override ToString
public override string ToString()
{
return string.Format("{0:D2} - {1}", Index, Name);
}
#endregion
}
#endregion
#region PageItems
[TypeConverter(typeof(vlnListConverter<PageItems, PageItem>))]
public class PageItems : vlnFormatList<PageItem>
{
public PageItems(XmlNodeList xmlNodeList) : base(xmlNodeList) { }
}
#endregion
#region PageItem
public class PageItem : vlnFormatItem
{
#region Constructor
public PageItem(XmlNode xmlNode) : base(xmlNode) { }
public PageItem() : base() { }
#endregion
#region Business Methods
private VE_Font _Font;
[Category("Font")]
[DisplayName("Font")]
[Description("Font")]
public VE_Font Font
{
get
{
return (_Font == null) ?_Font = new VE_Font(XmlNode): _Font;
}
}
private LazyLoad<string> _Token;
[Category("Content")]
[DisplayName("Content")]
[Description("Item Content")]
public string Token
{
get
{
return LazyLoad(ref _Token, "@Token");
}
}
private LazyLoad<int?> _Row;
[Category("Location")]
[DisplayName("Vertical Position")]
[Description("Vertical Position")]
public int? Row
{
get
{
return LazyLoad(ref _Row, "@Row");
}
}
private LazyLoad<int?> _Col;
[Category("Location")]
[DisplayName("Horizontal Position")]
[Description("Horizontal Position")]
public int? Col
{
get
{
return LazyLoad(ref _Col, "@Col");
}
}
private LazyLoad<E_Justify?> _Justify;
public E_Justify? Justify
{
get
{
return LazyLoad<E_Justify>(ref _Justify, "@Justify");
}
}
#endregion
#region Override ToString
public override string ToString()
{
//return string.Format("({0:D5},{1:D5}) - {2}",Row,Col,Token);
return Token;
}
public override string GetPDDisplayName()
{ return string.Format("({0},{1})",Row,Col); }
#endregion
}
#endregion
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,428 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.ComponentModel;
namespace VEPROMS.CSLA.Library
{
#region vlnFormatDocument
public class vlnFormatDocument:XmlDocument
{
private static XmlElement mydocele;
public vlnFormatDocument(Format myFormat)
{
_MyFormat = myFormat;
LoadXml(MyFormat.Data);
mydocele = this.DocumentElement;
}
private Format _MyFormat;
public Format MyFormat
{
get { return _MyFormat; }
set { _MyFormat = value; }
}
public static XmlNode LookupSingleNode(XmlNode xmlNode, string path)
{
//original:
//if (xmlNode == null) return null;
//XmlNode xn = xmlNode.SelectSingleNode(path);
//if (xn != null) return xn;
//if (xmlNode.Name == "Step") xn = LookupSingleStepNode(xmlNode, path);
//if (xn != null) return xn;
//if (path.StartsWith("Font")) return LookupSingleFontNode(xmlNode, path);
//return InheritLookup(xmlNode, path);
if (path.StartsWith("Font"))
{
XmlNode xn = null;
if (xmlNode != null)
{
xn = xmlNode.SelectSingleNode(path);
if (xn != null) return xn;
}
else
{
xmlNode = LookupSingleNode(mydocele.FirstChild, "/PlantFormat/FormatData");
}
return LookupSingleFontNode(xmlNode, path);
}
else
{
if (xmlNode == null) return null;
XmlNode xn = xmlNode.SelectSingleNode(path);
if (xn != null) return xn;
if (xmlNode.Name == "Step") xn = LookupSingleStepNode(xmlNode, path);
if (xn != null) return xn;
if (path.StartsWith("Font")) return LookupSingleFontNode(xmlNode, path);
return InheritLookup(xmlNode, path, false);
}
}
public static XmlNode LookupSingleFontNode(XmlNode xmlNode, string path)
{
if (xmlNode == null) return null;
XmlNode tmpNode = xmlNode;
XmlNode xn = xmlNode.SelectSingleNode(path);
while (xn == null)//Walk-up the format tree to find a font node
{
if (xmlNode.NodeType == XmlNodeType.Document)
{
return LookupSingleNode(tmpNode, "/PlantFormat/FormatData/" + path);
}
xmlNode = xmlNode.ParentNode;
xn = xmlNode.SelectSingleNode(path);
}
return xn;
}
public static XmlNode LookupSingleStepNode(XmlNode xmlNode, string path)
{
if (xmlNode == null) return null;
XmlNode xn = xmlNode.SelectSingleNode(path);
XmlNode tmpNode = xmlNode;
XmlNode tmpNode2 = xmlNode;
while (xn == null) //Walk-up the format tree to find a step node
{
tmpNode = xmlNode;
xmlNode = xmlNode.ParentNode.SelectSingleNode(string.Format("Step[@Type='{0}']",xmlNode.Attributes["ParentType"].InnerText));
if (xmlNode == null && path.StartsWith("Font")) return LookupSingleFontNode(tmpNode, path);
if (xmlNode == null)
return InheritLookup(tmpNode2, path, true);
xn = xmlNode.SelectSingleNode(path);
}
return xn;
}
public static XmlNodeList LookupNodes(XmlNode xmlNode, string path)
{
if (xmlNode == null) return null;
XmlNodeList xl = xmlNode.SelectNodes(path);
if (xl == null) xl = InheritLookupNodes(xmlNode, path);
if (xl == null) return null;
return xl;
}
public static string Lookup(XmlNode xmlNode, string path)
{
//if (xmlNode == null) return null;
XmlNode xn = LookupSingleNode(xmlNode, path);
//if (xn == null) xn = InheritLookup(xmlNode, path);
if (xn == null) return null;
return xn.InnerText;
}
//public static string StepLookup(XmlNode xmlNode, string path)
//{
// //if (xmlNode == null) return null;
// XmlNode xn = LookupSingleStepNode(xmlNode, path);
// //if (xn == null) xn = InheritLookup(xmlNode, path);
// if (xn == null) return null;
// return xn.InnerText;
//}
public static T EnumLookup<T>(XmlNode xmlNode, string path)
{
string str = Lookup(xmlNode,path);
if (str == null) return default(T);
return (T)Enum.Parse(typeof(T), str);
}
public static int? IntLookup(XmlNode xmlNode, string path)
{
//if (xmlNode == null) return null;
//XmlNode xn = LookupSingleNode(xmlNode, path);
//if (xn == null) xn = InheritLookup(xmlNode, path);
//if (xn == null) return null;
//return int.Parse(xn.InnerText);
string str = Lookup(xmlNode, path);
if (str == null) return null;
return int.Parse(str);
}
public static int SiblingCount(XmlNode xmlNode)
{
int retval = 0;
string nodeName = xmlNode.Name;
for (XmlNode xn = xmlNode; xn != null; xn = xn.PreviousSibling)
{
if (xn.Name == nodeName) retval++;
}
return retval;
}
public static string Path(XmlNode xmlNode)
{
// Walk the path
string parentPath = (xmlNode.ParentNode == xmlNode.OwnerDocument ? "" : Path(xmlNode.ParentNode));
// Count Siblings with the Same Name
int sibCount = SiblingCount(xmlNode);
return string.Format("{0}/{1}[{2}]", parentPath, xmlNode.Name, sibCount);
}
public static XmlNode InheritLookup(XmlNode xmlNode, string path, bool stepLookup)
{
stepLookup = false; // 8/2 change for inheritance
if (xmlNode == null) return null;// No path to match
string xPath = Path(xmlNode);// Build xPath from xmlNode
vlnFormatDocument fd = (vlnFormatDocument)(xmlNode.OwnerDocument);//First Get the vlnFormatDocument
while(fd.MyFormat.MyParent != null)
{
fd = fd.MyFormat.MyParent.PlantFormat.XmlDoc;// Get the parents vlnFormatDocument
if (fd != null)
{
XmlNode xp;
if (path.StartsWith("/")) xp = fd.DocumentElement;
else xp = fd.SelectSingleNode(xPath);// Get the related node
if (xp != null)
{
XmlNode xn = null;
if (stepLookup)
xn = LookupSingleStepNode(xp, path);
else
xn = xp.SelectSingleNode(path);
if(xn != null) return xn;
}
}
}
return null;
}
public static XmlNodeList InheritLookupNodes(XmlNode xmlNode, string path)
{
if (xmlNode == null) return null;// No path to match
string xPath = Path(xmlNode);// Build xPath from xmlNode
vlnFormatDocument fd = (vlnFormatDocument)(xmlNode.OwnerDocument);//First Get the vlnFormatDocument
while (fd.MyFormat.MyParent != null)
{
fd = fd.MyFormat.MyParent.PlantFormat.XmlDoc;// Get the parents vlnFormatDocument
if (fd != null)
{
XmlNode xp = fd.SelectSingleNode(xPath);// Get the related node
if (xp != null)
{
XmlNodeList xl = xp.SelectNodes(path);
if (xl != null) return xl;
}
}
}
return null;
}
}
#endregion
#region vlnFormatItem
[TypeConverter(typeof(ExpandableObjectConverter))]
public class vlnFormatItem
{
public vlnFormatItem(XmlNode xmlNode)
{
_XmlNode = xmlNode;
}
public vlnFormatItem() { }
XmlNode _XmlNode;
internal XmlNode XmlNode
{
get { return _XmlNode; }
set { _XmlNode = value; }
}
public virtual string GetPDDisplayName()
{ return ToString(); }
public virtual string GetPDName()
{ return ToString(); }
public virtual string GetPDDescription()
{ return ToString(); }
public virtual string GetPDCategory()
{ return ToString(); }
public XmlNodeList SelectNodes(string path)
{
return vlnFormatDocument.LookupNodes(_XmlNode, path);
}
public XmlNode SelectSingleNode(string path)
{
return vlnFormatDocument.LookupSingleNode(_XmlNode, path);
}
public XmlNode SelectSingleFontNode(string path)
{
return vlnFormatDocument.LookupSingleFontNode(_XmlNode, path);
}
public string Lookup(string path)
{
return vlnFormatDocument.Lookup(_XmlNode, path);
}
public string Lookup(string path, ref string local)
{
return (local != null? local : local = Lookup(path));
}
//public string StepLookup(string path)
//{
// return vlnFormatDocument.StepLookup(_XmlNode, path);
//}
public int? IntLookup(string path)
{
return vlnFormatDocument.IntLookup(_XmlNode, path);
}
public int? IntLookup(string path, ref int? local)
{
return (local != null ? local : local = IntLookup(path));
}
public T EnumLookup<T>(string path)
{
return vlnFormatDocument.EnumLookup<T>(_XmlNode, path);
}
public string LazyLoad(ref LazyLoad<string> ll, string xPath)
{
if (ll == null)
{
XmlNode xn = SelectSingleNode(xPath);
ll = new LazyLoad<string>(xn != null ? xn.InnerText : null);
}
return ll.Value;
}
public int? LazyLoad(ref LazyLoad<int?> ll, string xPath)
{
if (ll == null)
{
XmlNode xn = SelectSingleNode(xPath);
ll = new LazyLoad<int?>(xn != null ? (int?)int.Parse(xn.InnerText) : null);
}
return ll.Value;
}
public Nullable<T> LazyLoad<T>(ref LazyLoad<Nullable<T>> ll, string xPath)
where T:struct
{
if (ll == null)
{
XmlNode xn = SelectSingleNode(xPath);
ll = new LazyLoad<Nullable<T>>(xn != null ? (Nullable<T>)Enum.Parse(typeof(T), xn.InnerText) : null);
}
return ll.Value;
}
}
#endregion
#region LazyLoad
public class LazyLoad<T>
{
public LazyLoad(T value)
{
_Value = value;
}
private T _Value;
public T Value
{
get { return _Value; }
set { _Value = value; }
}
}
#endregion
#region vlnFormatList, new()
public class vlnFormatList<T> : List<T>, ICustomTypeDescriptor
where T : vlnFormatItem, new()
{
private XmlNodeList _XmlNodeList;
internal XmlNodeList XmlNodeList
{
get { return _XmlNodeList; }
set { _XmlNodeList = value; }
}
public vlnFormatList(XmlNodeList xmlNodeList)
{
_XmlNodeList = xmlNodeList;
foreach (XmlNode xn in _XmlNodeList)
{
T tt = new T();
tt.XmlNode = xn;
Add(tt);
}
}
#region ICustomTypeDescriptor
public String GetClassName()
{ return TypeDescriptor.GetClassName(this, true); }
public AttributeCollection GetAttributes()
{ return TypeDescriptor.GetAttributes(this, true); }
public String GetComponentName()
{ return TypeDescriptor.GetComponentName(this, true); }
public TypeConverter GetConverter()
{ return TypeDescriptor.GetConverter(this, true); }
public EventDescriptor GetDefaultEvent()
{ return TypeDescriptor.GetDefaultEvent(this, true); }
public PropertyDescriptor GetDefaultProperty()
{ return TypeDescriptor.GetDefaultProperty(this, true); }
public object GetEditor(Type editorBaseType)
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
public EventDescriptorCollection GetEvents(Attribute[] attributes)
{ return TypeDescriptor.GetEvents(this, attributes, true); }
public EventDescriptorCollection GetEvents()
{ return TypeDescriptor.GetEvents(this, true); }
public object GetPropertyOwner(PropertyDescriptor pd)
{ return this; }
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{ return GetProperties(); }
public virtual PropertyDescriptorCollection GetProperties()
{
// Create a collection object to hold property descriptors
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
// Iterate the list
int i = 0;
for (i = 0; i < this.Count; i++)
{
// Create a property descriptor for the item and add to the property descriptor collection
pds.Add(new vlnPropertyDescriptor<vlnFormatList<T>, T>(this, i));
}
// return the property descriptor collection
return pds;
}
#endregion
}
#endregion
#region vlnListConverter
internal class vlnListConverter<T, C> : ExpandableObjectConverter
where T : vlnFormatList<C>
where C : vlnFormatItem, new()
{
private string Plural(string name)
{
if (name.EndsWith("y")) return name.Substring(0, name.Length - 1) + "ies";
if (name.EndsWith("ss")) return name + "es";
else return name + "s";
}
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is T)
{
// Return department and department role separated by comma.
return ((T)value).Count.ToString() + " " + (((T)value).Count == 1 ? typeof(C).Name : Plural(typeof(C).Name));
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
#region vlnPropertyDescriptor
public class vlnPropertyDescriptor<T, C> : PropertyDescriptor
where T : vlnFormatList<C>
where C : vlnFormatItem, new()
{
protected C _Item = null;
public vlnPropertyDescriptor(T itemList, int index)
: base("#" + index.ToString(), null)
{
_Item = itemList[index];
}
public override bool CanResetValue(object component)
{ return true; }
public override Type ComponentType
{ get { return _Item.GetType(); } }
public override object GetValue(object component)
{ return _Item; }
public override bool IsReadOnly
{ get { return true; } }
public override Type PropertyType
{ get { return _Item.GetType(); } }
public override void ResetValue(object component)
{ ;}
public override bool ShouldSerializeValue(object component)
{ return true; }
public override void SetValue(object component, object value)
{ /*_Item = value*/;}
//public override AttributeCollection Attributes
//{ get { return new AttributeCollection(null); } }
public override string DisplayName
{ get { return _Item.GetPDDisplayName(); } }
public override string Description
{ get { return _Item.GetPDDescription(); } }
public override string Name
{ get { return _Item.GetPDName(); } }
public override string Category
{ get { return _Item.GetPDCategory(); } }
} // Class
#endregion
}