From 8fd6c2eac4a3ac518802b56b0abdb2bb1b86802d Mon Sep 17 00:00:00 2001 From: Rich Date: Tue, 25 May 2010 16:11:23 +0000 Subject: [PATCH] - Added ShortPath Property to ItemInfo - Added MacroList Added CheckOff data Added CheckOff and ChangeBar Fixed inheritance --- .../VEPROMS.CSLA.Library/Extension/ItemExt.cs | 59 ++++ .../VEPROMS.CSLA.Library/Format/DocStyles.cs | 12 + .../Format/PlantFormat.cs | 286 +++++++++++++----- .../VEPROMS.CSLA.Library/Format/vlnFormat.cs | 140 +++++++-- 4 files changed, 402 insertions(+), 95 deletions(-) diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs index 31565fe4..2ffecbef 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs @@ -1172,6 +1172,22 @@ namespace VEPROMS.CSLA.Library } } } + public string ShortPath + { + get + { + string number = (MyContent.Type >= 20000 ? Ordinal.ToString() + "." : ((DisplayNumber ?? "") == "" ? DisplayText : DisplayNumber)); + ItemInfo parent = this; + while (parent.MyPrevious != null) parent = parent.MyPrevious; + if (parent.ItemPartCount == 0) + return number; + else + { + PartInfo partInfo = parent.ItemParts[0]; + return partInfo.MyContent.ContentItems.Items[0].ShortPath + "." + ((E_FromType)partInfo.FromType).ToString().Substring(0,1) + number; + } + } + } public ContentInfo ParentContent { get @@ -1880,6 +1896,49 @@ namespace VEPROMS.CSLA.Library } } #endregion + #region Macro List + [NonSerialized] + protected List _MyMacros; + protected bool _MacrosSetup = false; + public List MyMacros + { + get + { + if (!_MacrosSetup) SetupMacros(); + return _MyMacros; + } + set + { + _MyMacros = value; + } + } + private void SetupMacros() + { + // see if each macro should be printed based on its attributes and the item we're on. + // Attributes to check are NotInRNO, i.e. only add this macro to the result list if + // the item is not in the RNO column. Also, Groupings is used to only have the macro if + // there are N or more of the type in the grouping. + List tmp = new List(); + foreach (Macro macro in ActiveFormat.PlantFormat.FormatData.StepDataList[FormatStepType].TabData.MacroList) + { + bool addToList = true; + if (macro.NotInRNO && IsInRNO) addToList = false; + if (macro.Grouping != null && macro.Grouping > 0) + { + int count = 0; + ItemInfo ii = FirstSibling; + while (ii != null) + { + if (ii.MyContent.Type == MyContent.Type) count++; + ii = ii.NextItem; + } + if (count < macro.Grouping) addToList = false; + } + if (addToList) tmp.Add(macro); + } + if (tmp.Count > 0) _MyMacros = tmp; + } + #endregion } #endregion ItemInfo #region Tab diff --git a/PROMS/VEPROMS.CSLA.Library/Format/DocStyles.cs b/PROMS/VEPROMS.CSLA.Library/Format/DocStyles.cs index 6f6b4bb6..2ed12b8c 100644 --- a/PROMS/VEPROMS.CSLA.Library/Format/DocStyles.cs +++ b/PROMS/VEPROMS.CSLA.Library/Format/DocStyles.cs @@ -94,6 +94,18 @@ namespace VEPROMS.CSLA.Library } } #endregion + #region UseCheckOffs + [Category("Miscellaneous")] + [Description("Section Uses Checkoffs")] + private LazyLoad _UseCheckOffs; + public bool UseCheckOffs + { + get + { + return LazyLoad(ref _UseCheckOffs, "@UseCheckOffs"); + } + } + #endregion #region Oldtonew [Category("Miscellaneous")] [Description("Convert from old to new")] diff --git a/PROMS/VEPROMS.CSLA.Library/Format/PlantFormat.cs b/PROMS/VEPROMS.CSLA.Library/Format/PlantFormat.cs index 78ee0cad..21950d46 100644 --- a/PROMS/VEPROMS.CSLA.Library/Format/PlantFormat.cs +++ b/PROMS/VEPROMS.CSLA.Library/Format/PlantFormat.cs @@ -777,14 +777,6 @@ namespace VEPROMS.CSLA.Library public class CheckOffData : vlnFormatItem { public CheckOffData(XmlNode xmlNode) : base(xmlNode) { } - private RightCheckOffBoxList _RightCheckOffBoxList; - public RightCheckOffBoxList RightCheckOffBoxList - { - get - { - return _RightCheckOffBoxList == null? _RightCheckOffBoxList = new RightCheckOffBoxList(SelectNodes("RightCheckOffBoxList/RightCheckOffBox"),MyFormat):_RightCheckOffBoxList; - } - } private CheckOffList _CheckOffList; public CheckOffList CheckOffList { @@ -801,13 +793,29 @@ namespace VEPROMS.CSLA.Library return _CheckOffHeaderList == null? _CheckOffHeaderList = new CheckOffHeaderList(SelectNodes("CheckOffHeaderList/CheckOffHeader"),MyFormat): _CheckOffHeaderList; } } - private LazyLoad _UseCheckOffsIn; - public int? UseCheckOffsIn - { - get + private LazyLoad _Menu; + public string Menu + { + get { - return LazyLoad(ref _UseCheckOffsIn, "@UseCheckOffsIn"); - } + return LazyLoad(ref _Menu, "@Menu"); + } + } + private LazyLoad _AllowSectEdit; + public bool AllowSectEdit + { + get + { + return LazyLoad(ref _AllowSectEdit, "@AllowSectEdit"); + } + } + private LazyLoad _AllowStepEdit; + public bool AllowStepEdit + { + get + { + return LazyLoad(ref _AllowStepEdit, "@AllowStepEdit"); + } } private LazyLoad _CheckOffAdjustment; public int? CheckOffAdjustment @@ -817,6 +825,14 @@ namespace VEPROMS.CSLA.Library return LazyLoad(ref _CheckOffAdjustment, "@CheckOffAdjustment"); } } + private LazyLoad _CheckOffXtraLines; + public int? CheckOffXtraLines + { + get + { + return LazyLoad(ref _CheckOffXtraLines, "@CheckOffXtraLines"); + } + } private LazyLoad _DropCheckOff; public bool DropCheckOff { @@ -833,60 +849,67 @@ namespace VEPROMS.CSLA.Library return LazyLoad(ref _CheckOffOnHLSOnly, "@CheckOffOnHLSOnly"); } } - } - #endregion - #region RightCheckOffBox - [TypeConverter(typeof(ExpandableObjectConverter))] - public class RightCheckOffBox : vlnFormatItem, IVlnIndexedFormatItem - { - public RightCheckOffBox(XmlNode xmlNode) : base(xmlNode) { } - public RightCheckOffBox() : base() { } - private LazyLoad _Index; - public int? Index - { - get - { - return LazyLoad(ref _Index, "@Index"); - } - } - private LazyLoad _RightCheckOffBoxChar; - public int? RightCheckOffBoxChar - { - get - { - return LazyLoad(ref _RightCheckOffBoxChar, "@RightCheckOffBoxChar"); - } - } - public override string GetPDDisplayName() - { return string.Format("[{0}]", Index); } - public override string GetPDDescription() - { return string.Format("[{0}] - {1}", Index, RightCheckOffBoxChar); } - public override string GetPDCategory() - { return "RightCheckOffBox Data"; } - public override string ToString() - { - return RightCheckOffBoxChar.ToString(); - } - } - #endregion - #region RightCheckOffBoxList - [TypeConverter(typeof(vlnIndexedListConverter))] - public class RightCheckOffBoxList : vlnIndexedFormatList - { - public RightCheckOffBoxList(XmlNodeList xmlNodeList,IFormatOrFormatInfo myFormat) : base(xmlNodeList,myFormat) { } - public override vlnIndexedFormatList InheritedList + private LazyLoad _SkipSpaces; + public bool SkipSpaces { get { - IFormatOrFormatInfo parentFormat = MyFormat.MyIParent; - if (parentFormat != null) - return parentFormat.PlantFormat.FormatData.ProcData.CheckOffData.RightCheckOffBoxList; - return null; + return LazyLoad(ref _SkipSpaces, "@SkipSpaces"); } } - } #endregion + //#region RightCheckOffBox + //[TypeConverter(typeof(ExpandableObjectConverter))] + //public class RightCheckOffBox : vlnFormatItem, IVlnIndexedFormatItem + //{ + // public RightCheckOffBox(XmlNode xmlNode) : base(xmlNode) { } + // public RightCheckOffBox() : base() { } + // private LazyLoad _Index; + // public int? Index + // { + // get + // { + // return LazyLoad(ref _Index, "@Index"); + // } + // } + // private LazyLoad _RightCheckOffBoxChar; + // public int? RightCheckOffBoxChar + // { + // get + // { + // return LazyLoad(ref _RightCheckOffBoxChar, "@RightCheckOffBoxChar"); + // } + // } + // public override string GetPDDisplayName() + // { return string.Format("[{0}]", Index); } + // public override string GetPDDescription() + // { return string.Format("[{0}] - {1}", Index, RightCheckOffBoxChar); } + // public override string GetPDCategory() + // { return "RightCheckOffBox Data"; } + // public override string ToString() + // { + // return RightCheckOffBoxChar.ToString(); + // } + //} + //#endregion + //#region RightCheckOffBoxList + //[TypeConverter(typeof(vlnIndexedListConverter))] + //public class RightCheckOffBoxList : vlnIndexedFormatList + //{ + // public RightCheckOffBoxList(XmlNodeList xmlNodeList,IFormatOrFormatInfo myFormat) : base(xmlNodeList,myFormat) { } + // public override vlnIndexedFormatList InheritedList + // { + // get + // { + // IFormatOrFormatInfo parentFormat = MyFormat.MyIParent; + // if (parentFormat != null) + // return parentFormat.PlantFormat.FormatData.ProcData.CheckOffData.RightCheckOffBoxList; + // return null; + // } + // } + //} + //#endregion #region CheckOff [TypeConverter(typeof(ExpandableObjectConverter))] public class CheckOff : vlnFormatItem,IVlnIndexedFormatItem @@ -901,12 +924,12 @@ namespace VEPROMS.CSLA.Library return LazyLoad(ref _Index, "@Index"); } } - private LazyLoad _RightCheckOffChars; - public int? RightCheckOffChars + private LazyLoad _UIMark; + public int? UIMark { get { - return LazyLoad(ref _RightCheckOffChars, "@RightCheckOffChars"); + return LazyLoad(ref _UIMark, "@UIMark"); } } private LazyLoad _CheckOffWidAdjust; @@ -917,23 +940,31 @@ namespace VEPROMS.CSLA.Library return LazyLoad(ref _CheckOffWidAdjust, "@CheckOffWidAdjust"); } } - private LazyLoad _RightCheckOffPrompt; - public string RightCheckOffPrompt + private LazyLoad _MenuItem; + public string MenuItem { get - { - return LazyLoad(ref _RightCheckOffPrompt, "@RightCheckOffPrompt"); + { + return LazyLoad(ref _MenuItem, "@MenuItem"); } } + private LazyLoad _Macro; + public string Macro + { + get + { + return LazyLoad(ref _Macro, "@Macro"); + } + } public override string GetPDDisplayName() { return string.Format("[{0}]",Index); } public override string GetPDDescription() - { return string.Format("[{0}] - {1}", Index, RightCheckOffPrompt); } + { return string.Format("[{0}] - {1}", Index, MenuItem); } public override string GetPDCategory() { return "Checkoff Data"; } public override string ToString() { - return RightCheckOffPrompt; + return MenuItem; } } #endregion @@ -1019,6 +1050,14 @@ namespace VEPROMS.CSLA.Library public class ChangeBarData : vlnFormatItem { public ChangeBarData(XmlNode xmlNode) : base(xmlNode) { } + private LazyLoad _DefaultCBLoc; + public string DefaultCBLoc + { + get + { + return LazyLoad(ref _DefaultCBLoc, "@DefaultCBLoc"); + } + } private LazyLoad _ChangeBarMessage; public string ChangeBarMessage { @@ -3946,6 +3985,14 @@ namespace VEPROMS.CSLA.Library : base(xmlNode) { } + private MacroList _MacroList; + public MacroList MacroList + { + get + { + return _MacroList == null ? _MacroList = new MacroList(SelectNodes("TabData/MacroList/Macro")) : _MacroList; + } + } private LazyLoad _IdentEdit; public string IdentEdit { @@ -3994,14 +4041,14 @@ namespace VEPROMS.CSLA.Library return LazyLoad(ref _Justify, "TabData/@Justify"); } } - private LazyLoad _CheckOff; - public string CheckOff - { - get - { - return LazyLoad(ref _CheckOff, "TabData/@CheckOff"); - } - } + //private LazyLoad _CheckOff; + //public string CheckOff + //{ + // get + // { + // return LazyLoad(ref _CheckOff, "TabData/@CheckOff"); + // } + //} private LazyLoad _UsePreviousStyle; public bool UsePreviousStyle { @@ -4019,8 +4066,91 @@ namespace VEPROMS.CSLA.Library return (_Font == null ? _Font = new VE_Font(xn) : _Font); } } + } #endregion + #region MacroList + [TypeConverter(typeof(vlnListConverter))] + public class MacroList : vlnNamedFormatList + { + public MacroList(XmlNodeList xmlNodeList) : base(xmlNodeList, null) { } + public override vlnNamedFormatList InheritedList + { + get + { + + return null; + } + } + } + #endregion + #region Macro + [TypeConverter(typeof(ExpandableObjectConverter))] + public class Macro : vlnFormatItem, IVlnNamedFormatItem + { + public Macro(XmlNode xmlNode) : base(xmlNode) { } + public Macro() : base() { } + private LazyLoad _Name; + public string Name + { + get + { + return LazyLoad(ref _Name, "@Name"); + } + } + private LazyLoad _MacroDef; + public string MacroDef + { + get + { + if (_Inherited == null) SetupStepInheritance(); + return LazyLoad(ref _MacroDef, "@Macro"); + } + } + private LazyLoad _Grouping; + public int? Grouping + { + get + { + if (_Inherited == null) SetupStepInheritance(); + return LazyLoad(ref _Grouping, "@Grouping"); + } + } + private LazyLoad _NotInRNO; + public bool NotInRNO + { + get + { + if (_Inherited == null) SetupStepInheritance(); + return LazyLoad(ref _NotInRNO, "@NotInRNO"); + } + } + private bool? _Inherited; + public bool Inherited + { + get + { + if (_Inherited == null) SetupStepInheritance(); + return (bool) _Inherited; + } + } + private void SetupStepInheritance() + { + if (_Inherited != null) return; + LazyLoad macroName = null; + _Inherited = (LazyLoad(ref macroName, "@Macro") == null); + // No MacroName, Find parent that has data + string path = string.Format("TabData/MacroList/Macro[@Name='{0}' and @Macro]", Name); + XmlNode xn = vlnFormatDocument.LookupSingleStepNode(XmlNode.ParentNode.ParentNode.ParentNode, path); + if (xn != null) + { + _MacroDef = new LazyLoad(RetrieveString(xn.SelectSingleNode("@Macro"))); + _Grouping = new LazyLoad(RetrieveInt("@Grouping" ,xn.SelectSingleNode("@Grouping"))); + _NotInRNO = new LazyLoad(RetrieveBool( xn.SelectSingleNode("@NotInRNO"))); + } + } + } +#endregion #endregion #region BoxDataAll #region Box diff --git a/PROMS/VEPROMS.CSLA.Library/Format/vlnFormat.cs b/PROMS/VEPROMS.CSLA.Library/Format/vlnFormat.cs index 0f5187bc..980b2e93 100644 --- a/PROMS/VEPROMS.CSLA.Library/Format/vlnFormat.cs +++ b/PROMS/VEPROMS.CSLA.Library/Format/vlnFormat.cs @@ -322,20 +322,27 @@ namespace VEPROMS.CSLA.Library if (ll == null) { XmlNode xn = SelectSingleNode(xPath); - string tstr = xn != null ? xn.InnerText : "FALSE"; - ll = new LazyLoad(tstr.ToUpper() == "TRUE" ? true : false); + ll = new LazyLoad(RetrieveBool(xn)); } return ll.Value; } + protected static bool RetrieveBool(XmlNode xn) + { + return xn != null && xn.InnerText.ToUpper() == "TRUE"; + } public string LazyLoad(ref LazyLoad ll, string xPath) { if (ll == null) { XmlNode xn = SelectSingleNode(xPath); - ll = new LazyLoad(xn != null ? xn.InnerText : null); + ll = new LazyLoad(RetrieveString(xn)); } return ll.Value; } + protected static string RetrieveString(XmlNode xn) + { + return xn != null ? xn.InnerText : null; + } public string MyPath { get @@ -356,23 +363,26 @@ namespace VEPROMS.CSLA.Library { if (ll == null) { - int? value=null; - XmlNode xn = this._XmlNode; - xn = SelectSingleNode(xPath); - if (xn != null) - { - int iValue =0; - if (!int.TryParse(xn.InnerText, out iValue)) - { - Console.WriteLine(string.Format("'{0}'\r\n'{1}'\r\n'{2}' could not be converted to int?", MyFormat.FullName, MyPath + "/" + xPath, xn.InnerText)); - throw (new Exception(string.Format("{0} = '{1}' could not be converted to int?",xPath, xn.InnerText))); - } - value = iValue; - } - ll = new LazyLoad(value); + XmlNode xn = SelectSingleNode(xPath); + ll = new LazyLoad(RetrieveInt(xPath, xn)); } return ll.Value; } + protected int? RetrieveInt(string xPath, XmlNode xn) + { + int? value = null; + if (xn != null) + { + int iValue = 0; + if (!int.TryParse(xn.InnerText, out iValue)) + { + Console.WriteLine(string.Format("'{0}'\r\n'{1}'\r\n'{2}' could not be converted to int?", MyFormat.FullName, MyPath + "/" + xPath, xn.InnerText)); + throw (new Exception(string.Format("{0} = '{1}' could not be converted to int?", xPath, xn.InnerText))); + } + value = iValue; + } + return value; + } public Nullable LazyLoad(ref LazyLoad> ll, string xPath) where T:struct { @@ -405,6 +415,13 @@ namespace VEPROMS.CSLA.Library int? Index { get; } } #endregion + #region IVlnNamedFormatItem + public partial interface IVlnNamedFormatItem + { + string Name { get; } + bool Inherited { get; } + } + #endregion #region LazyLoad public class LazyLoad { @@ -595,6 +612,95 @@ namespace VEPROMS.CSLA.Library #endregion } #endregion + #region vlnNamedFormatList + public class vlnNamedFormatList : vlnFormatList, ICustomTypeDescriptor + where T : vlnFormatItem, IVlnNamedFormatItem, new() + { + public vlnNamedFormatList(XmlNodeList xmlNodeList, IFormatOrFormatInfo myFormat) + : base(xmlNodeList) + { + MyFormat = myFormat; + } + public vlnNamedFormatList() : base() { } + public virtual vlnNamedFormatList InheritedList { get { return null; } } + public new T this[string name] + { + get + { + foreach (T tmp in this) + { + if (tmp.Name == name) + return tmp; + } + vlnNamedFormatList ttlParent = InheritedList; //Check Inherited Value + if (ttlParent != null) + return ttlParent[name]; + return null; + // None found - Can I find it in another format? + return null; + } + } + public new T this[int index] + { + get + { + if(base.Count > index) + return base[index]; + vlnNamedFormatList ttlParent = InheritedList; //Check Inherited Value + if (ttlParent != null) + return ttlParent[index]; + return null; + // None found - Can I find it in another format? + return null; + } + } + public new int Count + { + get + { + return base.Count; + } + } + #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, T>(this, i)); + } + // return the property descriptor collection + return pds; + } + #endregion + } + #endregion #region vlnListConverter internal class vlnListConverter : ExpandableObjectConverter where T : vlnFormatList