CSLA - Format, Minimal, VEObject

This commit is contained in:
2026-09-01 08:30:06 -04:00
parent dab65dbfb6
commit dc5d547449
15 changed files with 2423 additions and 6420 deletions
+62 -86
View File
@@ -1,40 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Windows.Forms;
namespace VEPROMS.CSLA.Library
{
public class Comparator
{
private XmlDocument _ResultsDoc;
public XmlDocument ResultsDoc
{
get { return _ResultsDoc; }
set { _ResultsDoc = value; }
}
private XmlDocument _XDoc1;
public XmlDocument XDoc1
{
get { return _XDoc1; }
set { _XDoc1 = value; }
}
private XmlDocument _XDoc2;
public XmlDocument XDoc2
{
get { return _XDoc2; }
set { _XDoc2 = value; }
}
public Comparator(XmlDocument xdoc1, XmlDocument xdoc2)
public XmlDocument ResultsDoc { get; set; }
public XmlDocument XDoc1 { get; set; }
public XmlDocument XDoc2 { get; set; }
public Comparator(XmlDocument xdoc1, XmlDocument xdoc2)
{
XDoc1 = xdoc1;
XDoc2 = xdoc2;
ResultsDoc = new XmlDocument();
ResultsDoc.LoadXml(@"<PlantFormat></PlantFormat>");
}
public Comparator(string existingFC, string importedFC) //string fName1, string fName2)
public Comparator(string existingFC, string importedFC)
{
XDoc1 = new XmlDocument();
XDoc1.LoadXml(existingFC);
@@ -104,12 +87,12 @@ namespace VEPROMS.CSLA.Library
xnss1.Add(GetKey(xc1), xc1);
foreach (XmlNode xc2 in xns2.Values)
if (xnss1.ContainsKey(GetKey(xc2)))
Compare(xnss1[GetKey(xc2)], xc2, path + "/" + GetKey(xc2));
Compare(xnss1[GetKey(xc2)], xc2, $"{path}/{GetKey(xc2)}");
else
xnss2.Add(GetKey(xc2), xc2);
// element differences, if counts are different. xns1 elements are not found in xns2 and xns2 elements are not found in xns1
if (xns1.Count == 0 && xns2.Count == 0) return;
Console.WriteLine(" {0} {1} {2}", path + "/" + xn1.Name, xns1.Count, xns2.Count);
Console.WriteLine($" {path}/{xn1.Name} {xns1.Count} {xns2.Count}");
foreach (string key in xnss1.Keys)
{
if (xnss1[key].Attributes.Count > 0 || xnss1[key].ChildNodes.Count > 0)
@@ -210,18 +193,14 @@ namespace VEPROMS.CSLA.Library
public string GetKey1(XmlNode xn)
{
if (xn.Attributes == null) return xn.Name;
XmlAttribute xi = xn.Attributes.GetNamedItem("Index") as XmlAttribute;
if (xi != null)
{
XmlAttribute xa = xn.Attributes.GetNamedItem("Name") as XmlAttribute;
if (xa != null) return string.Format("{0}[{1}]", xn.Name, xa.Value);
return string.Format("{0}[{1}]", xn.Name, xi.Value);
}
XmlAttribute xt = xn.Attributes.GetNamedItem("Token") as XmlAttribute;
if(xt != null) return string.Format("{0}[{1}]", xn.Name, xt.Value);
XmlAttribute xw = xn.Attributes.GetNamedItem("ReplaceWord") as XmlAttribute;
if(xw != null) return string.Format("{0}[{1}]", xn.Name, xw.Value);
return xn.Name;
if (xn.Attributes.GetNamedItem("Index") is XmlAttribute xi)
{
if (xn.Attributes.GetNamedItem("Name") is XmlAttribute xa) return string.Format("{0}[{1}]", xn.Name, xa.Value);
return string.Format("{0}[{1}]", xn.Name, xi.Value);
}
if (xn.Attributes.GetNamedItem("Token") is XmlAttribute xt) return string.Format("{0}[{1}]", xn.Name, xt.Value);
if (xn.Attributes.GetNamedItem("ReplaceWord") is XmlAttribute xw) return string.Format("{0}[{1}]", xn.Name, xw.Value);
return xn.Name;
}
static private XmlNode makeXPath(XmlDocument doc, string xpath)
{
@@ -252,7 +231,6 @@ namespace VEPROMS.CSLA.Library
string name = nextNodeInXPath.Substring(indx, nextNodeInXPath.IndexOf("=",indx)-indx);
XmlAttribute xKeyd = doc.CreateAttribute(name);
indx = nextNodeInXPath.IndexOf("='",indx)+2;
string value = nextNodeInXPath.Substring(indx,nextNodeInXPath.IndexOf("'", indx) - indx);
xKeyd.Value = nextNodeInXPath.Substring(indx,nextNodeInXPath.IndexOf("'",indx)-indx);
node.Attributes.Append(xKeyd);
}
@@ -277,58 +255,56 @@ namespace VEPROMS.CSLA.Library
// go through attributes in first xml document, see if they exist in the 2nd xml document & are identical attribute
foreach (XmlAttribute xa1 in atts1)
{
XmlAttribute xa2 = atts2.GetNamedItem(xa1.Name) as XmlAttribute;
if (xa2 == null)
{
XmlNode xnr = MakeXPathFormat(path);
if (xnr != null)
{
XmlAttribute xKey = ResultsDoc.CreateAttribute(xa1.Name+"Old");
xKey.Value = xa1.Value;
xnr.Attributes.Append(xKey);
xKey = ResultsDoc.CreateAttribute("OldKey");
xKey.Value = GetKey(atts1Par);
if (xKey.Value != null) xnr.Attributes.Append(xKey);
}
}
else if (xa2.Value != xa1.Value)
{
XmlNode xnr = MakeXPathFormat(path);
if (xnr != null)
{
XmlAttribute xKey = ResultsDoc.CreateAttribute(xa1.Name + "Old");
xKey.Value = xa1.Value;
xnr.Attributes.Append(xKey);
XmlAttribute xKey2 = ResultsDoc.CreateAttribute(xa2.Name + "New");
xKey2.Value = xa2.Value;
xnr.Attributes.Append(xKey2);
xKey = ResultsDoc.CreateAttribute("OldKey");
xKey.Value = GetKey(atts1Par);
if (xKey.Value != null) xnr.Attributes.Append(xKey);
xKey = ResultsDoc.CreateAttribute("NewKey");
xKey.Value = GetKey(atts2Par);
if (xKey.Value != null) xnr.Attributes.Append(xKey);
}
}
}
if (!(atts2.GetNamedItem(xa1.Name) is XmlAttribute xa2))
{
XmlNode xnr = MakeXPathFormat(path);
if (xnr != null)
{
XmlAttribute xKey = ResultsDoc.CreateAttribute(xa1.Name + "Old");
xKey.Value = xa1.Value;
xnr.Attributes.Append(xKey);
xKey = ResultsDoc.CreateAttribute("OldKey");
xKey.Value = GetKey(atts1Par);
if (xKey.Value != null) xnr.Attributes.Append(xKey);
}
}
else if (xa2.Value != xa1.Value)
{
XmlNode xnr = MakeXPathFormat(path);
if (xnr != null)
{
XmlAttribute xKey = ResultsDoc.CreateAttribute(xa1.Name + "Old");
xKey.Value = xa1.Value;
xnr.Attributes.Append(xKey);
XmlAttribute xKey2 = ResultsDoc.CreateAttribute(xa2.Name + "New");
xKey2.Value = xa2.Value;
xnr.Attributes.Append(xKey2);
xKey = ResultsDoc.CreateAttribute("OldKey");
xKey.Value = GetKey(atts1Par);
if (xKey.Value != null) xnr.Attributes.Append(xKey);
xKey = ResultsDoc.CreateAttribute("NewKey");
xKey.Value = GetKey(atts2Par);
if (xKey.Value != null) xnr.Attributes.Append(xKey);
}
}
}
// go through attributes in 2nd xml document to see if they exist in the first xml document & are identical
foreach (XmlAttribute xa2 in atts2)
{
XmlAttribute xa1 = atts1.GetNamedItem(xa2.Name) as XmlAttribute;
if (xa1 == null)
{
XmlNode xnr = MakeXPathFormat(path);
if (xnr != null)
{
XmlAttribute xKey = ResultsDoc.CreateAttribute(xa2.Name+"New");
xKey.Value = xa2.Value;
xnr.Attributes.Append(xKey);
xKey = ResultsDoc.CreateAttribute("NewKey");
xKey.Value = GetKey(atts2Par);
if (xKey.Value != null) xnr.Attributes.Append(xKey);
}
}
}
if (!(atts1.GetNamedItem(xa2.Name) is XmlAttribute))
{
XmlNode xnr = MakeXPathFormat(path);
if (xnr != null)
{
XmlAttribute xKey = ResultsDoc.CreateAttribute(xa2.Name + "New");
xKey.Value = xa2.Value;
xnr.Attributes.Append(xKey);
xKey = ResultsDoc.CreateAttribute("NewKey");
xKey.Value = GetKey(atts2Par);
if (xKey.Value != null) xnr.Attributes.Append(xKey);
}
}
}
}
#endregion
}
File diff suppressed because it is too large Load Diff
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.ComponentModel;
namespace VEPROMS.CSLA.Library
{
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Xml;
using System.Linq;
@@ -32,54 +31,27 @@ namespace VEPROMS.CSLA.Library
private LazyLoad<string> _Name;
[DisplayName("Name")]
[Description("EP Viewer File Name")]
public string Name
{
get
{
return LazyLoad(ref _Name, "@Name");
}
}
public string Name => LazyLoad(ref _Name, "@Name");
// Name of the EP Viewer Format File
private LazyLoad<string> _Description;
[DisplayName("Description")]
[Description("EP Viewer Description")]
public string Description
{
get
{
return LazyLoad(ref _Description, "@Description");
}
}
public string Description => LazyLoad(ref _Description, "@Description");
// Id of Annotation Type Associated with this file
private LazyLoad<int?> _AnnotationTypeID;
[DisplayName("AnnotationTypeID")]
[Description("Id of Annotation Type Associated with this file")]
public int? AnnotationTypeID
{
get
{
return LazyLoad(ref _AnnotationTypeID, "@AnnotationTypeID");
}
}
public int? AnnotationTypeID => LazyLoad(ref _AnnotationTypeID, "@AnnotationTypeID");
// Return Name of Annotation that EP Format File is Attached to
public string AnnotationName()
{
return AnnotationTypeInfo.Get((int) AnnotationTypeID).Name;
}
public string AnnotationName() => AnnotationTypeInfo.Get((int)AnnotationTypeID).Name;
//if xml value is blank, should element export?
//defaults to true
private LazyLoad<bool> _exportblank;
[DisplayName("exportblank")]
[Description("if xml value is blank, should element export?")]
public bool exportblank
{
get
{
return LazyLoad(ref _exportblank, "@exportblank");
}
}
public bool exportblank => LazyLoad(ref _exportblank, "@exportblank");
// returns a list of fields that are defined in the EP format's structure
private EPFields _FieldList;
public EPFields FieldList
@@ -141,8 +113,10 @@ namespace VEPROMS.CSLA.Library
{
if (dr.Read())
{
XmlDocument xd = new XmlDocument();
xd.XmlResolver = null;
XmlDocument xd = new XmlDocument
{
XmlResolver = null
};
xd.LoadXml(dr.GetString("Data"));
return xd;
}
@@ -255,21 +229,9 @@ namespace VEPROMS.CSLA.Library
public EPField(XmlNode xmlNode) : base(xmlNode) { }
public EPField() : base() { }
private LazyLoad<string> _name;
public string name
{
get
{
return LazyLoad(ref _name, "@name");
}
}
public string name => LazyLoad(ref _name, "@name");
private LazyLoad<string> _type;
public string type
{
get
{
return LazyLoad(ref _type, "@type");
}
}
public string type => LazyLoad(ref _type, "@type");
private LazyLoad<string> _label;
public string label
{
@@ -284,22 +246,10 @@ namespace VEPROMS.CSLA.Library
}
}
private LazyLoad<string> _text;
public string text
{
get
{
return LazyLoad(ref _text, "@text");
}
}
public string text => LazyLoad(ref _text, "@text");
//roid of group item that individual sub-items will be the choices for the list/combobox for ROSINGLE and ROMULTI
private LazyLoad<string> _rosource;
public string rosource
{
get
{
return LazyLoad(ref _rosource, "@rosource");
}
}
public string rosource => LazyLoad(ref _rosource, "@rosource");
//the columns in the RO that will be included in the exports
private LazyLoad<string> _returncols;
public List<string> returncols()
+107 -256
View File
@@ -1,6 +1,3 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Xml;
@@ -23,44 +20,23 @@ namespace VEPROMS.CSLA.Library
#region Business Methods
// description to associate with a DocStyle
private LazyLoad<string> _Name;
[DisplayName("Name")]
[Description("Page Style Name")]
public string Name
{
get
{
return LazyLoad(ref _Name, "@Name");
}
}
[DisplayName("Name")]
[Description("Page Style Name")]
public string Name => LazyLoad(ref _Name, "@Name");
// a unuque number that is referenced from the DocStyles
private LazyLoad<int?> _Index;
[DisplayName("Index")]
[Description("Page Style Index")]
public int? Index
{
get
{
return LazyLoad(ref _Index, "@Index");
}
}
// a unuque number that is referenced from the DocStyles
private LazyLoad<int?> _Index;
[DisplayName("Index")]
[Description("Page Style Index")]
public int? Index => 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
}
private PageItems _PageItems;
public PageItems PageItems => _PageItems ?? (_PageItems = new PageItems(SelectNodes("Item")));
#endregion
#region Override ToString
public override string ToString() => string.Format("{0:D2} - {1}", Index, Name);
#endregion
}
#endregion
#region PageItems
[TypeConverter(typeof(vlnListConverter<PageItems, PageItem>))]
@@ -79,192 +55,91 @@ namespace VEPROMS.CSLA.Library
#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 RelatedItem _RelatedItem;
public RelatedItem RelatedItem
{
get
{
return (_RelatedItem == null) ? _RelatedItem = new RelatedItem(SelectSingleNode("RelatedItem")) : _RelatedItem;
}
}
[Category("Font")]
[DisplayName("Font")]
[Description("Font")]
public VE_Font Font => _Font ?? (_Font = new VE_Font(XmlNode));
private RelatedItem _RelatedItem;
public RelatedItem RelatedItem => _RelatedItem ?? (_RelatedItem = new RelatedItem(SelectSingleNode("RelatedItem")));
// this can be an actual token, in curly braces, that dynamically gets replaced with information, or just plain text
private LazyLoad<string> _Token;
[Category("Content")]
[DisplayName("Content")]
[Description("Item Content")]
public string Token
{
get
{
return LazyLoad(ref _Token, "@Token");
}
}
// this can be an actual token, in curly braces, that dynamically gets replaced with information, or just plain text
private LazyLoad<string> _Token;
[Category("Content")]
[DisplayName("Content")]
[Description("Item Content")]
public string Token => LazyLoad(ref _Token, "@Token");
// the row on the page to place the Item
private LazyLoad<float?> _Row;
[Category("Location")]
[DisplayName("Vertical Position")]
[Description("Vertical Position")]
public float? Row
{
get
{
return LazyLoad(ref _Row, "@Row");
}
}
// the row on the page to place the Item
private LazyLoad<float?> _Row;
[Category("Location")]
[DisplayName("Vertical Position")]
[Description("Vertical Position")]
public float? Row => LazyLoad(ref _Row, "@Row");
// the column on the page to place the Item
private LazyLoad<float?> _Col;
[Category("Location")]
[DisplayName("Horizontal Position")]
[Description("Horizontal Position")]
public float? Col
{
get
{
return LazyLoad(ref _Col, "@Col");
}
}
// the column on the page to place the Item
private LazyLoad<float?> _Col;
[Category("Location")]
[DisplayName("Horizontal Position")]
[Description("Horizontal Position")]
public float? Col => LazyLoad(ref _Col, "@Col");
// the justification at the Col position in which to print the Token information
private LazyLoad<E_Justify?> _Justify;
public E_Justify? Justify
{
get
{
return LazyLoad<E_Justify>(ref _Justify, "@Justify");
}
}
// the justification at the Col position in which to print the Token information
private LazyLoad<E_Justify?> _Justify;
public E_Justify? Justify => LazyLoad<E_Justify>(ref _Justify, "@Justify");
//run the PROMS Replace Words logic on the resulting text of Token
private LazyLoad<bool> _RepWords; // F2021-053: Do replace words in page list
public bool RepWords
{
get
{
return LazyLoad(ref _RepWords, "@RepWords");
}
}
//run the PROMS Replace Words logic on the resulting text of Token
private LazyLoad<bool> _RepWords; // F2021-053: Do replace words in page list
public bool RepWords => LazyLoad(ref _RepWords, "@RepWords");
//Flag to tell PROMS to get the alarm value information based on the specified Child applicability
private LazyLoad<bool> _ROLkUpMatch; // C2021-065 (BNPP Alarms format)
public bool ROLkUpMatch
{
get
{
return LazyLoad(ref _ROLkUpMatch, "@ROLkUpMatch");
}
}
//Flag to tell PROMS to get the alarm value information based on the specified Child applicability
private LazyLoad<bool> _ROLkUpMatch; // C2021-065 (BNPP Alarms format)
public bool ROLkUpMatch => LazyLoad(ref _ROLkUpMatch, "@ROLkUpMatch");
// Flag to specify if that PageStyle Item should be used in creating alarm point information
// for viewing in the PROMS step editor
// this information is displayed in a Note that it build on the fly when first opening an Alarm Point page
private LazyLoad<bool> _ROLkUpInEditor; // C2021-018 (BNPP Alarms format)
public bool ROLkUpInEditor
{
get
{
return LazyLoad(ref _ROLkUpInEditor, "@ROLkUpInEditor");
}
}
// Flag to specify if that PageStyle Item should be used in creating alarm point information
// for viewing in the PROMS step editor
// this information is displayed in a Note that it build on the fly when first opening an Alarm Point page
private LazyLoad<bool> _ROLkUpInEditor; // C2021-018 (BNPP Alarms format)
public bool ROLkUpInEditor => LazyLoad(ref _ROLkUpInEditor, "@ROLkUpInEditor");
// defines a maxium width before the resolved PSI token (procedure specific information) text is wrapped
// on to the next line
private LazyLoad<int?> _MaxWidth;
public int? MaxWidth
{
get
{
return (LazyLoad(ref _MaxWidth, "@MaxWidth"));
}
}
// defines a maxium width before the resolved PSI token (procedure specific information) text is wrapped
// on to the next line
private LazyLoad<int?> _MaxWidth;
public int? MaxWidth => LazyLoad(ref _MaxWidth, "@MaxWidth");
// MaxWidth, above, flagged that, if there was more than 1 line, the topmargin would be adjusted by however
// many lines the PSI item contained (for wst alarms). The MaxWidthCurPage is used when that adjustment
// should not be made, the length of the PSI item is only relevant for the current page.
// (see AdjustTopMarginForMultiLinePageListItems variable and how it is used)
private LazyLoad<int?> _MaxWidthCurPage;
public int? MaxWidthCurPage
{
get
{
return (LazyLoad(ref _MaxWidthCurPage, "@MaxWidthCurPage"));
}
}
// MaxWidth, above, flagged that, if there was more than 1 line, the topmargin would be adjusted by however
// many lines the PSI item contained (for wst alarms). The MaxWidthCurPage is used when that adjustment
// should not be made, the length of the PSI item is only relevant for the current page.
// (see AdjustTopMarginForMultiLinePageListItems variable and how it is used)
private LazyLoad<int?> _MaxWidthCurPage;
public int? MaxWidthCurPage => LazyLoad(ref _MaxWidthCurPage, "@MaxWidthCurPage");
// the resolved pagestype item font size will be reduce in order to fit within the defined width
private LazyLoad<int?> _FontShrinkAftLen; // F2021-066 & 070 (text len before shrinking font)
public int? FontShrinkAftLen
{
get
{
return (LazyLoad(ref _FontShrinkAftLen, "@FontShrinkAftLen"));
}
}
// the resolved pagestype item font size will be reduce in order to fit within the defined width
private LazyLoad<int?> _FontShrinkAftLen; // F2021-066 & 070 (text len before shrinking font)
public int? FontShrinkAftLen => LazyLoad(ref _FontShrinkAftLen, "@FontShrinkAftLen");
// used in Alarm Point Table page style values with FontShrinkAftLen set, will display this message if the text cannot be shrunk enough (and be readable) to fit within the defined width
private LazyLoad<string> _FontTooSmallMsg; // F2021-066 message if can't shrink enough
public string FontTooSmallMsg
{
get
{
return LazyLoad(ref _FontTooSmallMsg, "@FontTooSmallMsg");
}
}
// used in Alarm Point Table page style values with FontShrinkAftLen set, will display this message if the text cannot be shrunk enough (and be readable) to fit within the defined width
private LazyLoad<string> _FontTooSmallMsg; // F2021-066 message if can't shrink enough
public string FontTooSmallMsg => LazyLoad(ref _FontTooSmallMsg, "@FontTooSmallMsg");
// F2023-039 allow to select text color of a pagelist line
// sets a text color for the page style Item
private LazyLoad<string> _TextColor;
public string TextColor
{
get
{
return LazyLoad(ref _TextColor, "@TextColor");
}
}
// F2023-039 allow to select text color of a pagelist line
// sets a text color for the page style Item
private LazyLoad<string> _TextColor;
public string TextColor => LazyLoad(ref _TextColor, "@TextColor");
// set to a string, will remove the matching string from the end
// F2023-112 Vogtle Units 3 & Backgrounds - trim the ending "-B" from the procedure number (used in title box of page header)
private LazyLoad<string> _TrimEnding;
public string TrimEnding
{
get
{
return LazyLoad(ref _TrimEnding, "@TrimEnding");
}
}
// C2025-033 to specify to print pagestyle item for a specific Child procedure
private LazyLoad<int?> _ChildNum;
public int? ChildNum
{
get
{
return (LazyLoad(ref _ChildNum, "@ChildNum"));
}
}
// set to a string, will remove the matching string from the end
// F2023-112 Vogtle Units 3 & Backgrounds - trim the ending "-B" from the procedure number (used in title box of page header)
private LazyLoad<string> _TrimEnding;
public string TrimEnding => LazyLoad(ref _TrimEnding, "@TrimEnding");
// C2025-033 to specify to print pagestyle item for a specific Child procedure
private LazyLoad<int?> _ChildNum;
public int? ChildNum => LazyLoad(ref _ChildNum, "@ChildNum");
#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
#region Override ToString
public override string ToString() => Token;
public override string GetPDDisplayName() => string.Format("({0},{1})", Row, Col);
#endregion
}
#endregion
#region RelatedItem
// RelatedItem was added to allow a PSI logical to have an associated PSI item, and if both are
@@ -281,53 +156,29 @@ namespace VEPROMS.CSLA.Library
// the name of the PSI logical token to check
private LazyLoad<string> _Token;
[Category("RelatedContent")]
[DisplayName("RelatedContent")]
[Description("Item RelatedContent")]
public string Token
{
get
{
return LazyLoad(ref _Token, "@Token");
}
}
[Category("RelatedContent")]
[DisplayName("RelatedContent")]
[Description("Item RelatedContent")]
public string Token => LazyLoad(ref _Token, "@Token");
// new Row value to use for PageStyle Item
private LazyLoad<float?> _Row;
[Category("Location")]
[DisplayName("Vertical Position")]
[Description("Vertical Position")]
public float? Row
{
get
{
return LazyLoad(ref _Row, "@Row");
}
}
// new Row value to use for PageStyle Item
private LazyLoad<float?> _Row;
[Category("Location")]
[DisplayName("Vertical Position")]
[Description("Vertical Position")]
public float? Row => LazyLoad(ref _Row, "@Row");
// new Col value to use for PageStyle Item
private LazyLoad<float?> _Col;
[Category("Location")]
[DisplayName("Horizontal Position")]
[Description("Horizontal Position")]
public float? Col
{
get
{
return LazyLoad(ref _Col, "@Col");
}
}
// new Col value to use for PageStyle Item
private LazyLoad<float?> _Col;
[Category("Location")]
[DisplayName("Horizontal Position")]
[Description("Horizontal Position")]
public float? Col => LazyLoad(ref _Col, "@Col");
// new Justify value to use for PageStyle Item
private LazyLoad<E_Justify?> _Justify;
public E_Justify? Justify
{
get
{
return LazyLoad<E_Justify>(ref _Justify, "@Justify");
}
}
#endregion
}
// new Justify value to use for PageStyle Item
private LazyLoad<E_Justify?> _Justify;
public E_Justify? Justify => LazyLoad<E_Justify>(ref _Justify, "@Justify");
#endregion
}
#endregion
}
File diff suppressed because it is too large Load Diff
+159 -370
View File
@@ -12,47 +12,14 @@ namespace VEPROMS.CSLA.Library
private static XmlElement mydocele;
public vlnFormatDocument(IFormatOrFormatInfo myFormat)
{
_MyFormat = myFormat;
MyFormat = myFormat;
LoadXml(MyFormat.Data);
mydocele = this.DocumentElement;
mydocele = DocumentElement;
}
private IFormatOrFormatInfo _MyFormat;
public IFormatOrFormatInfo MyFormat
public IFormatOrFormatInfo MyFormat { get; set; }
public static XmlNode LookupSingleNode(XmlNode xmlNode, string path)
{
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);
/* RHM 20090821 -
if (path.StartsWith("Font"))
{
XmlNode xn = null;
if (xmlNode != null)
{
xn = xmlNode.SelectSingleNode(path);
// RHM 2008-12-15 - Added logic to keep looking if a blank attribute is found
if (xn != null && xn is XmlAttribute && (xn as XmlAttribute).Value != "") return xn;
//if (xn != null) return xn;
}
else
{
xmlNode = LookupSingleNode(mydocele.FirstChild, "/PlantFormat/FormatData");
}
if (path.Contains("Font")) Console.WriteLine("vlnFormatDocument.LookupSingleNode {0},{1}", xmlNode.Name == "Step" ? "Step." + xmlNode.Attributes["Type"].Value : xmlNode.Name, path);
return LookupSingleFontNode(xmlNode, path);
}
else
{
*/
if (xmlNode == null) return null;
XmlNode xn = xmlNode.SelectSingleNode(path);
if (xmlNode.Name == "Box") return xn; // if box, don't do inheritance.
@@ -72,7 +39,6 @@ namespace VEPROMS.CSLA.Library
if (xn != null) return xn;
if (path.StartsWith("Font")) return LookupSingleFontNode(xmlNode, path); // Then do Font Inheritance
return InheritLookup(xmlNode, path, false);
// }
}
public static XmlNode LookupSingleFontNode(XmlNode xmlNode, string path)
{
@@ -108,29 +74,15 @@ namespace VEPROMS.CSLA.Library
if (xmlNode == null) return null;
XmlNode xn = xmlNode.SelectSingleNode(path);
XmlNode tmpNode = xmlNode;
XmlNode tmpNode2 = xmlNode;
XmlNode tmpNode2 = xmlNode;
while (xn == null) //Walk-up the format tree to find a step node
{
//if (path.Contains("Font")) Console.WriteLine("vlnFormatDocument.LookupSingleStepNode -> Loop {0},{1}", xmlNode.Name == "Step" ? "Step." + xmlNode.Attributes["Type"].Value : xmlNode.Name, path);
tmpNode = xmlNode;
// RHM 20090831 Try doing a lookup of the parent. If no parent, go back to the original and do an inheritance lookup
XmlAttribute attr = xmlNode.Attributes["ParentType"];
//if (path.Contains("Font")) Console.WriteLine("vlnFormatDocument.LookupSingleStepNode -> Loop {0},{1}", xmlNode.Name == "Step" ? "Step." + xmlNode.Attributes["Type"].Value : xmlNode.Name, path);
// RHM 20090831 Try doing a lookup of the parent. If no parent, go back to the original and do an inheritance lookup
XmlAttribute attr = xmlNode.Attributes["ParentType"];
if (attr == null || attr.Value == string.Empty) // Cannot find ParentType so do an InheritanceLookup
return InheritLookup(tmpNode2, path, true);
//return InheritLookup(xmlNode, path, false);
xmlNode = xmlNode.ParentNode.SelectSingleNode(string.Format("Step[@Type='{0}']", xmlNode.Attributes["ParentType"].InnerText));
// Based upon our current data - the following conditions are never met.
//if (xmlNode == null && path.StartsWith("Font"))
//{
// //if (path.Contains("Font")) Console.WriteLine("vlnFormatDocument.LookupSingleStepNode -> Font {0},{1}", tmpNode.Name == "Step" ? "Step." + tmpNode.Attributes["Type"].Value : tmpNode.Name, path);
// return LookupSingleFontNode(tmpNode, path);
//}
//if (xmlNode == null)
//{
// //if (path.Contains("Font")) Console.WriteLine("vlnFormatDocument.LookupSingleStepNode -> Font {0},{1}", tmpNode2.Name == "Step" ? "Step." + tmpNode2.Attributes["Type"].Value : tmpNode2.Name, path);
// return InheritLookup(tmpNode2, path, true);
//}
xn = xmlNode.SelectSingleNode(path);
}
return xn;
@@ -145,38 +97,20 @@ namespace VEPROMS.CSLA.Library
}
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)
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)
return str == null ? default : (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)
return str == null ? null : (int?)int.Parse(str);
}
public static int SiblingCount(XmlNode xmlNode)
{
int retval = 0;
string nodeName = xmlNode.Name;
@@ -189,7 +123,7 @@ namespace VEPROMS.CSLA.Library
public static string Path(XmlNode xmlNode)
{
// Walk the path
string parentPath = (xmlNode.ParentNode == xmlNode.OwnerDocument ? "" : Path(xmlNode.ParentNode));
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);
@@ -204,7 +138,7 @@ namespace VEPROMS.CSLA.Library
string TransIndex = xmlNode.Attributes["Index"].Value;
xPath = System.Text.RegularExpressions.Regex.Replace(xPath, @"\[[0-9]*\]$", @"[@Index='" + TransIndex + @"']");
}
vlnFormatDocument fd = (vlnFormatDocument)(xmlNode.OwnerDocument);//First Get the vlnFormatDocument - This also ties it to a FormatInfo object
vlnFormatDocument fd = (vlnFormatDocument)xmlNode.OwnerDocument;//First Get the vlnFormatDocument - This also ties it to a FormatInfo object
while(fd.MyFormat.MyIParent != null)
{
fd = fd.MyFormat.MyIParent.PlantFormat.XmlDoc;// Get the parents vlnFormatDocument
@@ -215,8 +149,8 @@ namespace VEPROMS.CSLA.Library
else xp = fd.SelectSingleNode(xPath);// Get the related node
if (xp != null)
{
XmlNode xn = null;
if (stepLookup)
XmlNode xn;
if (stepLookup)
{
//if (path.Contains("Font")) Console.WriteLine("vlnFormatItem.SelectSingleNode {0},{1}", xp.Name == "Step" ? "Step." + xp.Attributes["Type"].Value : xp.Name, path);
xn = LookupSingleStepNode(xp, path);
@@ -233,7 +167,7 @@ namespace VEPROMS.CSLA.Library
{
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 - This also ties it to a FormatInfo object
vlnFormatDocument fd = (vlnFormatDocument)xmlNode.OwnerDocument;//First Get the vlnFormatDocument - This also ties it to a FormatInfo object
while (fd.MyFormat.MyIParent != null)
{
fd = fd.MyFormat.MyIParent.PlantFormat.XmlDoc;// Get the parents vlnFormatDocument
@@ -256,100 +190,41 @@ namespace VEPROMS.CSLA.Library
[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; }
}
private IFormatOrFormatInfo _MyFormat;
public vlnFormatItem(XmlNode xmlNode) => XmlNode = xmlNode;
public vlnFormatItem() { }
internal XmlNode XmlNode { get; set; }
private IFormatOrFormatInfo _MyFormat;
public IFormatOrFormatInfo MyFormat
{
get
{
if (_MyFormat == null)
{
vlnFormatDocument doc = (XmlNode.OwnerDocument) as vlnFormatDocument;
if(doc != null)
_MyFormat = doc.MyFormat;
}
if (XmlNode.OwnerDocument is vlnFormatDocument doc)
_MyFormat = doc.MyFormat;
}
return _MyFormat;
}
}
private IFormatOrFormatInfo _MyParentFormat;
public IFormatOrFormatInfo MyParentFormat
public IFormatOrFormatInfo MyParentFormat => MyFormat.MyIParent;
public virtual string GetPDDisplayName() => ToString();
public virtual string GetPDName() => ToString();
public virtual string GetPDDescription() => ToString();
public virtual string GetPDCategory() => ToString();
public XmlNodeList SelectNodes(string path) => vlnFormatDocument.LookupNodes(XmlNode, path);
public XmlNode SelectSingleNode(string path)
{
get
{
return MyFormat.MyIParent;
}
}
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)
{
//AdjustLookup(_XmlNode, path);
//if(path.Contains("Font")) Console.WriteLine("vlnFormatItem.SelectSingleNode {0},{1}", _XmlNode.Name == "Step" ? "Step." + _XmlNode.Attributes["Type"].Value : _XmlNode.Name, path);
return vlnFormatDocument.LookupSingleNode(_XmlNode, path);
return vlnFormatDocument.LookupSingleNode(XmlNode, path);
}
//public static string _LookUpNode;
//private static void AdjustLookup(XmlNode xmlNode,string path)
//{
// if (xmlNode.Name == "Step")
// {
// XmlAttribute attr = xmlNode.Attributes["Type"];
// if (attr != null) _LookUpNode = attr.Value;
// //Console.WriteLine("AdjustLookup Type = {0}/{1}", _LookUpNode, path);
// }
// else
// {
// //Console.WriteLine("AdjustLookup {0}", xmlNode.Name);
// }
//}
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 bool LazyLoad(ref LazyLoad<bool> ll, string xPath)
public XmlNode SelectSingleFontNode(string path) => vlnFormatDocument.LookupSingleFontNode(XmlNode, path);
public string Lookup(string path) => vlnFormatDocument.Lookup(XmlNode, path);
public string Lookup(string path, ref string local) => local ?? (local = Lookup(path));
public int? IntLookup(string path) => vlnFormatDocument.IntLookup(XmlNode, path);
public int? IntLookup(string path, ref int? local) => local != null ? local : local = IntLookup(path);
public T EnumLookup<T>(string path) => vlnFormatDocument.EnumLookup<T>(XmlNode, path);
public bool LazyLoad(ref LazyLoad<bool> ll, string xPath)
{
if (ll == null)
{
@@ -358,12 +233,9 @@ namespace VEPROMS.CSLA.Library
}
return ll.Value;
}
protected static bool RetrieveBool(XmlNode xn)
{
return xn != null && xn.InnerText.ToUpper() == "TRUE";
}
// a LaxyLoad that allows you to pass in the default setting
public bool LazyLoad(ref LazyLoad<bool> ll, string xPath, bool defaultReturn)
protected static bool RetrieveBool(XmlNode xn) => xn != null && xn.InnerText.ToUpper() == "TRUE";
// a LazyLoad that allows you to pass in the default setting
public bool LazyLoad(ref LazyLoad<bool> ll, string xPath, bool defaultReturn)
{
if (ll == null)
{
@@ -372,12 +244,9 @@ namespace VEPROMS.CSLA.Library
}
return ll.Value;
}
// if nothing is set for this node, then use the passed in default value
protected static bool RetrieveBool(XmlNode xn, bool defaultReturn)
{
return (xn != null) ? xn.InnerText.ToUpper() == "TRUE" : defaultReturn;
}
public string LazyLoad(ref LazyLoad<string> ll, string xPath)
// if nothing is set for this node, then use the passed in default value
protected static bool RetrieveBool(XmlNode xn, bool defaultReturn) => (xn != null) ? xn.InnerText.ToUpper() == "TRUE" : defaultReturn;
public string LazyLoad(ref LazyLoad<string> ll, string xPath)
{
if (ll == null)
{
@@ -386,16 +255,13 @@ namespace VEPROMS.CSLA.Library
}
return ll.Value;
}
protected static string RetrieveString(XmlNode xn)
{
return xn != null ? xn.InnerText : null;
}
public string MyPath
protected static string RetrieveString(XmlNode xn) => xn?.InnerText;
public string MyPath
{
get
{
StringBuilder sb = new StringBuilder();
XmlNode node = _XmlNode;
XmlNode node = XmlNode;
string prefix = "";
while (node != null)
{
@@ -429,14 +295,13 @@ namespace VEPROMS.CSLA.Library
int? value = null;
if (xn != null)
{
int iValue = 0;
if (!int.TryParse(xn.InnerText, out iValue))
{
if (xn.InnerText == "") return null;
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;
if (!int.TryParse(xn.InnerText, out int iValue))
{
if (xn.InnerText == "") return null;
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;
}
@@ -445,13 +310,12 @@ namespace VEPROMS.CSLA.Library
float? value = null;
if (xn != null)
{
float fValue = 0;
if (!float.TryParse(xn.InnerText, out fValue))
{
Console.WriteLine(string.Format("'{0}'\r\n'{1}'\r\n'{2}' could not be converted to float?", MyFormat.FullName, MyPath + "/" + xPath, xn.InnerText));
throw (new Exception(string.Format("{0} = '{1}' could not be converted to float?", xPath, xn.InnerText)));
}
value = fValue;
if (!float.TryParse(xn.InnerText, out float fValue))
{
Console.WriteLine(string.Format("'{0}'\r\n'{1}'\r\n'{2}' could not be converted to float?", MyFormat.FullName, MyPath + "/" + xPath, xn.InnerText));
throw new Exception(string.Format("{0} = '{1}' could not be converted to float?", xPath, xn.InnerText));
}
value = fValue;
}
return value;
}
@@ -460,9 +324,8 @@ namespace VEPROMS.CSLA.Library
{
if (ll == null)
{
XmlNode xn = this._XmlNode;
xn = SelectSingleNode(xPath);
if (xn == null)
XmlNode xn = SelectSingleNode(xPath);
if (xn == null)
ll = new LazyLoad<T?>(null);
else if (xn.Value == "")// No value specified - Use zero value if it is defined - GetName returns a null if it is not defined
ll = new LazyLoad<Nullable<T>>(Enum.GetName(typeof(T), 0) != null ? (Nullable<T>) Enum.Parse(typeof(T), "0") : null);
@@ -497,17 +360,10 @@ namespace VEPROMS.CSLA.Library
#region LazyLoad
public class LazyLoad<T>
{
public LazyLoad(T value)
{
_Value = value;
}
private T _Value;
public T Value
{
get { return _Value; }
set { _Value = value; }
}
}
public LazyLoad(T value) => Value = value;
public T Value { get; set; }
}
#endregion
#region vlnFormatList, new()
public class vlnFormatList<T> : List<T>, ICustomTypeDescriptor
@@ -522,9 +378,11 @@ namespace VEPROMS.CSLA.Library
_XmlNodeList = value;
foreach (XmlNode xn in _XmlNodeList)
{
T tt = new T();
tt.XmlNode = xn;
Add(tt);
T tt = new T
{
XmlNode = xn
};
Add(tt);
}
}
}
@@ -546,7 +404,7 @@ namespace VEPROMS.CSLA.Library
XmlNode node = _XmlNodeList[0]; // Get the first node in a list
vlnFormatDocument doc = null;
if (node != null)
doc = (node.OwnerDocument) as vlnFormatDocument; // Get the owner document as a vlnFormatDocument
doc = node.OwnerDocument as vlnFormatDocument; // Get the owner document as a vlnFormatDocument
if (doc != null)
_MyFormat = doc.MyFormat; // Get the Format associated with the vlnFormatDocument
}
@@ -557,36 +415,24 @@ namespace VEPROMS.CSLA.Library
_MyFormat = value;
}
}
#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()
#region ICustomTypeDescriptor
public string GetClassName() => TypeDescriptor.GetClassName(this, true);
public AttributeCollection GetAttributes() => TypeDescriptor.GetAttributes(this, true);
public string GetComponentName() => TypeDescriptor.GetComponentName(this, true);
public TypeConverter GetConverter() => TypeDescriptor.GetConverter(this, true);
public EventDescriptor GetDefaultEvent() => TypeDescriptor.GetDefaultEvent(this, true);
public PropertyDescriptor GetDefaultProperty() => TypeDescriptor.GetDefaultProperty(this, true);
public object GetEditor(Type editorBaseType) => TypeDescriptor.GetEditor(this, editorBaseType, true);
public EventDescriptorCollection GetEvents(Attribute[] attributes) => TypeDescriptor.GetEvents(this, attributes, true);
public EventDescriptorCollection GetEvents() => TypeDescriptor.GetEvents(this, true);
public object GetPropertyOwner(PropertyDescriptor pd) => this;
public PropertyDescriptorCollection GetProperties(Attribute[] attributes) => 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++)
// Iterate the list
for (int i = 0; i < 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));
@@ -601,13 +447,10 @@ namespace VEPROMS.CSLA.Library
public class vlnIndexedFormatList<T> : vlnFormatList<T>, ICustomTypeDescriptor
where T : vlnFormatItem,IVlnIndexedFormatItem, new()
{
public vlnIndexedFormatList(XmlNodeList xmlNodeList,IFormatOrFormatInfo myFormat) : base(xmlNodeList)
{
MyFormat = myFormat;
}
public vlnIndexedFormatList() : base() { }
public virtual vlnIndexedFormatList<T> InheritedList { get { return null; } }
public new T this[int index]
public vlnIndexedFormatList(XmlNodeList xmlNodeList, IFormatOrFormatInfo myFormat) : base(xmlNodeList) => MyFormat = myFormat;
public vlnIndexedFormatList() : base() { }
public virtual vlnIndexedFormatList<T> InheritedList => null;
public new T this[int index]
{
get
{
@@ -620,8 +463,6 @@ namespace VEPROMS.CSLA.Library
if (ttlParent != null)
return ttlParent[index];
return null;
// None found - Can I find it in another format?
return null;
}
}
public int MaxIndex
@@ -657,36 +498,25 @@ namespace VEPROMS.CSLA.Library
return max;
}
}
#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)
#region ICustomTypeDescriptor
public new string GetClassName() => TypeDescriptor.GetClassName(this, true);
public new AttributeCollection GetAttributes() => TypeDescriptor.GetAttributes(this, true);
public new string GetComponentName() => TypeDescriptor.GetComponentName(this, true);
public new TypeConverter GetConverter() => TypeDescriptor.GetConverter(this, true);
public new EventDescriptor GetDefaultEvent() => TypeDescriptor.GetDefaultEvent(this, true);
public new PropertyDescriptor GetDefaultProperty() => TypeDescriptor.GetDefaultProperty(this, true);
public new object GetEditor(Type editorBaseType) => TypeDescriptor.GetEditor(this, editorBaseType, true);
public new 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()
public new EventDescriptorCollection GetEvents() => TypeDescriptor.GetEvents(this, true);
public new object GetPropertyOwner(PropertyDescriptor pd) => this;
public new PropertyDescriptorCollection GetProperties(Attribute[] attributes) => GetProperties();
public new 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++)
for (int i = 0; i < 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));
@@ -701,14 +531,11 @@ namespace VEPROMS.CSLA.Library
public class vlnNamedFormatList<T> : vlnFormatList<T>, ICustomTypeDescriptor
where T : vlnFormatItem, IVlnNamedFormatItem, new()
{
public vlnNamedFormatList(XmlNodeList xmlNodeList, IFormatOrFormatInfo myFormat)
: base(xmlNodeList)
{
MyFormat = myFormat;
}
public vlnNamedFormatList() : base() { }
public virtual vlnNamedFormatList<T> InheritedList { get { return null; } }
public new T this[string name]
public vlnNamedFormatList(XmlNodeList xmlNodeList, IFormatOrFormatInfo myFormat)
: base(xmlNodeList) => MyFormat = myFormat;
public vlnNamedFormatList() : base() { }
public virtual vlnNamedFormatList<T> InheritedList => null;
public T this[string name]
{
get
{
@@ -721,8 +548,6 @@ namespace VEPROMS.CSLA.Library
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]
@@ -735,47 +560,27 @@ namespace VEPROMS.CSLA.Library
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()
public new int Count => base.Count;
#region ICustomTypeDescriptor
public new string GetClassName() => TypeDescriptor.GetClassName(this, true);
public new AttributeCollection GetAttributes() => TypeDescriptor.GetAttributes(this, true);
public new string GetComponentName() => TypeDescriptor.GetComponentName(this, true);
public new TypeConverter GetConverter() => TypeDescriptor.GetConverter(this, true);
public new EventDescriptor GetDefaultEvent() => TypeDescriptor.GetDefaultEvent(this, true);
public new PropertyDescriptor GetDefaultProperty() => TypeDescriptor.GetDefaultProperty(this, true);
public new object GetEditor(Type editorBaseType) => TypeDescriptor.GetEditor(this, editorBaseType, true);
public new EventDescriptorCollection GetEvents(Attribute[] attributes) => TypeDescriptor.GetEvents(this, attributes, true);
public new EventDescriptorCollection GetEvents() => TypeDescriptor.GetEvents(this, true);
public new object GetPropertyOwner(PropertyDescriptor pd) => this;
public new PropertyDescriptorCollection GetProperties(Attribute[] attributes) => GetProperties();
public new 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++)
for (int i = 0; i < 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));
@@ -793,16 +598,16 @@ namespace VEPROMS.CSLA.Library
{
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";
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)
if (destType == typeof(string) && value is T vart)
{
// 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 $"{vart.Count} {(vart.Count == 1 ? typeof(C).Name : Plural(typeof(C).Name))}";
}
return base.ConvertTo(context, culture, value, destType);
}
@@ -815,17 +620,16 @@ namespace VEPROMS.CSLA.Library
{
private string Plural(string name)
{
if (name.EndsWith("y")) return name.Substring(0, name.Length - 1) + "ies";
if (name.EndsWith("ss")) return name + "es";
if (name.EndsWith("x")) return name + "es";
else return name + "s";
}
if (name.EndsWith("y")) return $"{name.Substring(0, name.Length - 1)}ies";
if (name.EndsWith("ss")) return $"{name}es";
return name.EndsWith("x") ? $"{name}es" : $"{name}s";
}
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is T)
if (destType == typeof(string) && value is T vart)
{
// Return department and department role separated by comma.
return ((T)value).MaxIndex.ToString() + " " + (((T)value).MaxIndex == 1 ? typeof(C).Name : Plural(typeof(C).Name));
return $"{vart.MaxIndex} {(vart.MaxIndex == 1 ? typeof(C).Name : Plural(typeof(C).Name))}";
}
return base.ConvertTo(context, culture, value, destType);
}
@@ -837,38 +641,23 @@ namespace VEPROMS.CSLA.Library
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 vlnPropertyDescriptor(T itemList, int index)
: base("#" + index.ToString(), null) => _Item = itemList[index];
public override bool CanResetValue(object component) => true;
public override Type ComponentType => _Item.GetType();
public override object GetValue(object component) => _Item;
public override bool IsReadOnly => true;
public override Type PropertyType => _Item.GetType();
public override void ResetValue(object component)
{ ;}
public override bool ShouldSerializeValue(object component)
{ return true; }
public override void SetValue(object component, object value)
public override bool ShouldSerializeValue(object component) => 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
public override string DisplayName => _Item.GetPDDisplayName();
public override string Description => _Item.GetPDDescription();
public override string Name => _Item.GetPDName();
public override string Category => _Item.GetPDCategory();
} // Class
#endregion
}
@@ -1,21 +1,9 @@
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
using System.Text.RegularExpressions;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
//namespace VEPROMS.CSLA.Library;
// C2025-027 this new file is used to support (data retrival) for selecting Annotation types to display on the Annotation screen. This is related to Annotation type filtering through V->Options.
namespace VEPROMS.CSLA.Library
@@ -70,8 +58,8 @@ namespace VEPROMS.CSLA.Library
return dt;
}
catch (Exception ex)
{
catch (Exception)
{
//B2025-004
//if it fails loading previously open tabs, simply treat it as if no tabs were open
//instead of crashing
@@ -101,8 +89,8 @@ namespace VEPROMS.CSLA.Library
return dt;
}
catch (Exception ex)
{
catch (Exception)
{
//B2025-004
//if it fails loading previously open tabs, simply treat it as if no tabs were open
//instead of crashing
@@ -132,7 +120,7 @@ namespace VEPROMS.CSLA.Library
return dt;
}
catch (Exception ex)
catch (Exception)
{
//B2025-004
//if it fails loading previously open tabs, simply treat it as if no tabs were open
@@ -1,5 +1,4 @@
using System;
using Csla.Data;
using System.Data;
using System.Data.SqlClient;
@@ -1,5 +1,4 @@
using System;
using Csla.Data;
using System.Data;
using System.Data.SqlClient;
@@ -1,5 +1,4 @@
using System;
using Csla.Data;
using System.Data;
using System.Data.SqlClient;
@@ -1,5 +1,4 @@
using Csla.Data;
using System;
using System;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
@@ -1,5 +1,4 @@
using System;
using Csla.Data;
using System.Data;
using System.Data.SqlClient;
@@ -1,6 +1,3 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
namespace VEPROMS.CSLA.Library
@@ -9,7 +6,6 @@ namespace VEPROMS.CSLA.Library
public interface IVEDrillDownReadOnly
{
System.Collections.IList GetChildren(); // Returns a list of Business Objects
//bool ChildrenAreLoaded { get; }; // Have the Business Objects been Loaded
bool HasChildren { get; } // Identifies if Children are available
IVEDrillDownReadOnly ActiveParent { get; }
FormatInfo ActiveFormat { get; }
@@ -25,17 +21,6 @@ namespace VEPROMS.CSLA.Library
bool IsProcedure { get; }
bool IsSection { get; }
bool IsStep { get; }
//IVEDrillDown Get();
//bool HasStandardSteps();
// Ideas Authorization
//bool CanLock();
//bool CanUnlock();
//bool CanOpen();
//bool CanEdit();
//bool CanAdmin();
// Ideas Security
//bool Lock(string msg);
//bool Unlock();
}
[TypeConverter(typeof(ExpandableObjectConverter))]
public interface IVEDrillDown : IVEHasBrokenRules
+127 -481
View File
@@ -1,11 +1,6 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using Csla;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Reflection;
namespace VEPROMS.CSLA.Library
@@ -14,35 +9,19 @@ namespace VEPROMS.CSLA.Library
public class VETreeNodeEventArgs : EventArgs
{
public VETreeNodeEventArgs() { ; }
public VETreeNodeEventArgs(string info)
public VETreeNodeEventArgs(string info) => Info = info;
public VETreeNodeEventArgs(int value) => Value = value;
public VETreeNodeEventArgs(string info, int value)
{
_Info = info;
}
public VETreeNodeEventArgs(int value)
{
_Value = value;
}
public VETreeNodeEventArgs(string info, int value)
{
_Info = info;
_Value = value;
}
private int _Value;
public int Value
{
get { return _Value; }
set { _Value = value; }
}
private string _Info;
public string Info
{
get { return _Info; }
set { _Info = value; }
Info = info;
Value = value;
}
}
public int Value { get; set; }
public string Info { get; set; }
}
public class VETreeNode : TreeNode
{
#region Events
@@ -51,25 +30,13 @@ namespace VEPROMS.CSLA.Library
public event VETreeNodeEvent LoadingChildrenMax;
public event VETreeNodeEvent LoadingChildrenValue;
public event VETreeNodeEvent LoadingChildrenDone;
private void OnLoadingChildrenSQL(object sender, VETreeNodeEventArgs args)
{
if (LoadingChildrenSQL != null) LoadingChildrenSQL(sender, args);
}
private void OnLoadingChildrenMax(object sender, VETreeNodeEventArgs args)
{
if (LoadingChildrenMax != null) LoadingChildrenMax(sender, args);
}
private void OnLoadingChildrenValue(object sender, VETreeNodeEventArgs args)
{
if (LoadingChildrenValue != null) LoadingChildrenValue(sender, args);
}
private void OnLoadingChildrenDone(object sender, VETreeNodeEventArgs args)
{
if (LoadingChildrenDone != null) LoadingChildrenDone(sender, args);
}
#endregion
#region Business Methods
protected IVEDrillDownReadOnly _VEObject;
private void OnLoadingChildrenSQL(object sender, VETreeNodeEventArgs args) => LoadingChildrenSQL?.Invoke(sender, args);
private void OnLoadingChildrenMax(object sender, VETreeNodeEventArgs args) => LoadingChildrenMax?.Invoke(sender, args);
private void OnLoadingChildrenValue(object sender, VETreeNodeEventArgs args) => LoadingChildrenValue?.Invoke(sender, args);
private void OnLoadingChildrenDone(object sender, VETreeNodeEventArgs args) => LoadingChildrenDone?.Invoke(sender, args);
#endregion
#region Business Methods
protected IVEDrillDownReadOnly _VEObject;
public IVEDrillDownReadOnly VEObject
{
get { return _VEObject; }
@@ -80,11 +47,6 @@ namespace VEPROMS.CSLA.Library
ResetNode("Dummy Set_VEObject");
}
}
//public void Refresh()
//{
// if (_VEObject != null)
// Text = _VEObject.ToString();
//}
// Only load the Children Once
protected bool _ChildrenLoaded = false;
public bool ChildrenLoaded
@@ -104,16 +66,11 @@ namespace VEPROMS.CSLA.Library
get { return _InChildWindow; }
set { _InChildWindow = value; }
}
// Reset Node
//public void CloseNode()
//{
// ResetNode();
//}
private void SetProperty(string name)
{
PropertyInfo propertyInfoObj = _VEObject.GetType().GetProperty(name);
if (propertyInfoObj == null) return;
PropertyInfo propertyInfoThis = this.GetType().GetProperty(name);
PropertyInfo propertyInfoThis = GetType().GetProperty(name);
if (propertyInfoThis == null) return;
try
{
@@ -129,7 +86,7 @@ namespace VEPROMS.CSLA.Library
if (_VEObject!=null && _VEObject.HasChildren && _ChildrenLoaded == false && CheckForParts())
{
_ChildrenLoaded = false;// Reset the children loaded flag
this.Nodes.Add(dummy);// Add a Dummy Node so that the item will appear to be expanable.
Nodes.Add(dummy);// Add a Dummy Node so that the item will appear to be expanable.
}
else
{
@@ -167,38 +124,8 @@ namespace VEPROMS.CSLA.Library
tn.ResetNode("Dummy GetFolder");
return tn;
}
// public abstract void LoadChildren();
//private long _Start;
//private Dictionary<string, long> _Timings=new Dictionary<string,long>();
//private void tReset()
//{
// _Timings = new Dictionary<string, long>();
// _Start = DateTime.Now.Ticks;
//}
//private void tNext(string msg)
//{
// long tEnd = DateTime.Now.Ticks;
// long tDiff = tEnd - _Start;
// if (_Timings.ContainsKey(msg)) tDiff += _Timings[msg];
// _Timings[msg] = tDiff;
// _Start = DateTime.Now.Ticks;
//}
//private void tShowResults()
//{
// Console.WriteLine("Timings");
// long total=0;
// foreach (string msg in _Timings.Keys)
// {
// total += _Timings[msg];
// Console.WriteLine("{0}\t\"{1}\"", TimeSpan.FromTicks(_Timings[msg]).TotalMilliseconds, msg);
// }
// Console.WriteLine("{0}\t\"Total\"", TimeSpan.FromTicks(total).TotalMilliseconds);
//}
public virtual void LoadChildren()
{
LoadChildren(true);
}
private bool _allParts = true;
public virtual void LoadChildren() => LoadChildren(true);
private bool _allParts = true;
private bool _excludeTablesFigsEqu = false; // used for inserting Step Text transitions (BNPP)
public virtual void LoadChildren(bool allParts, bool excldTablesFigEq = false)
{
@@ -207,33 +134,23 @@ namespace VEPROMS.CSLA.Library
_excludeTablesFigsEqu = excldTablesFigEq;
if (!_ChildrenLoaded)
{
this.Nodes.Clear();
//tReset();
Nodes.Clear();
DateTime tStart = DateTime.Now;
//TVAddChildren(_VEObject, this);
OnLoadingChildrenSQL(this, new VETreeNodeEventArgs());
IList ol;
ItemInfo item = _VEObject as ItemInfo;
if (item != null) item.RefreshItemParts();
if (_VEObject.GetType() == typeof(StepInfo) || _VEObject.GetType() == typeof(SectionInfo) || _VEObject.GetType() == typeof(ItemInfo))
if (_VEObject is ItemInfo item) item.RefreshItemParts();
if (_VEObject.GetType() == typeof(StepInfo) || _VEObject.GetType() == typeof(SectionInfo) || _VEObject.GetType() == typeof(ItemInfo))
ol = ((ItemInfo)_VEObject).GetChildren(allParts);
else
ol = _VEObject.GetChildren();
//tNext("GetChildren");
if (ol != null)
{
OnLoadingChildrenMax(this, new VETreeNodeEventArgs(ol.Count));
//this.TreeView.BeginUpdate();
if (this.TreeView != null) this.TreeView.BeginUpdate();
if (TreeView != null) TreeView.BeginUpdate();
else _MyLog.WarnFormat("TreeView.BeginUpdate - Null");
ExpandChildren(ol);
//}
//tNext("Set Nodes");
//this.TreeView.EndUpdate();
if (this.TreeView != null) this.TreeView.EndUpdate();
if (TreeView != null) TreeView.EndUpdate();
else _MyLog.WarnFormat("TreeView.EndUpdate - Null");
//tNext("End Update");
//tShowResults();
}
_ChildrenLoaded = true;
OnLoadingChildrenDone(this, new VETreeNodeEventArgs(TimeSpan.FromTicks(DateTime.Now.Ticks - tStart.Ticks).TotalSeconds.ToString()));
@@ -247,7 +164,6 @@ namespace VEPROMS.CSLA.Library
foreach (IVEDrillDownReadOnly o in ol)
{
OnLoadingChildrenValue(this, new VETreeNodeEventArgs(++icnt));
//tNext("Cycle");
try
{
bool skipIt = false;
@@ -277,18 +193,14 @@ namespace VEPROMS.CSLA.Library
tmp.ExpandChildren(o.GetChildren());
tmp._ChildrenLoaded = true;
}
// OLD: RHM 20100115 : I don't think that the following lines are necessary since the "new VETreeNode(o)"
// above includes a similar function.
//else
// tmp.Nodes.Add(string.Format("dummy: {0}", o.GetType().Name));// Add a Dummy Node so that the item will appear to be expanable.
}
else
tmp._ChildrenLoaded = true;// Reset the children loaded flag
if (lastWasSection)
this.Nodes.Insert(0, tmp);
Nodes.Insert(0, tmp);
// B2024-019 don't show Tables, Figures, or Equations in step tree when inserting Text Transitions
else if (!_excludeTablesFigsEqu || !isTableFigEqu)
this.Nodes.Add(tmp);
Nodes.Add(tmp);
// if last thing was section & this is step, do insert - i.e. so that steps go before sections.
lastWasSection = (o is PartInfo && (o as PartInfo).PartType == E_FromType.Section);
}
@@ -302,16 +214,15 @@ namespace VEPROMS.CSLA.Library
private void TVAddChildren(IVEDrillDownReadOnly veobj, VETreeNode tn)
{
OnLoadingChildrenSQL(tn, new VETreeNodeEventArgs());
IList ol;
ItemInfo item = veobj as ItemInfo;
if (veobj.GetType() == typeof(StepInfo) || veobj.GetType() == typeof(SectionInfo) || veobj.GetType() == typeof(ItemInfo))
IList ol;
if (veobj.GetType() == typeof(StepInfo) || veobj.GetType() == typeof(SectionInfo) || veobj.GetType() == typeof(ItemInfo))
ol = ((ItemInfo)veobj).GetChildren(true);
else
ol = veobj.GetChildren();
if (ol != null)
{
OnLoadingChildrenMax(this, new VETreeNodeEventArgs(ol.Count));
this.TreeView.BeginUpdate();
TreeView.BeginUpdate();
int icnt = 0;
foreach (IVEDrillDownReadOnly o in ol)
{
@@ -333,46 +244,36 @@ namespace VEPROMS.CSLA.Library
Console.WriteLine("{0}\r\n{1}", ex.Message, ex.InnerException);
}
}
//}
this.TreeView.EndUpdate();
TreeView.EndUpdate();
}
}
void myItemInfo_Deleted(object sender)
{
VETreeNode parnode = Parent as VETreeNode;
if (parnode == null) return;
PartInfo pi = parnode.VEObject as PartInfo;
Remove();
// get rid of 'Steps', 'RNOs', i.e. grouping nodes, if there are no children.
if (pi != null && parnode.Nodes.Count == 0)
if (!(Parent is VETreeNode parnode)) return;
Remove();
// get rid of 'Steps', 'RNOs', i.e. grouping nodes, if there are no children.
if (parnode.VEObject is PartInfo && parnode.Nodes.Count == 0)
{
VETreeNode grndparnode = parnode.Parent as VETreeNode;
parnode.Remove();
// if only 'Steps' node is left, move steps 'up' a level.
if (grndparnode != null && grndparnode.Nodes.Count == 1)
parnode.Remove();
// if only 'Steps' node is left, move steps 'up' a level.
if (parnode.Parent is VETreeNode grndparnode && grndparnode.Nodes.Count == 1)
{
VETreeNode sibnode = grndparnode.Nodes[0] as VETreeNode;
PartInfo pisib = sibnode.VEObject as PartInfo;
if (pisib != null && (pisib.ToString() == "Steps"))
{
if (!sibnode.ChildrenLoaded) sibnode.LoadChildren();
while (sibnode.Nodes.Count > 0)
{
VETreeNode tmp = sibnode.Nodes[0] as VETreeNode;
tmp.Remove();
grndparnode.Nodes.Add(tmp);
}
sibnode.Remove();
}
}
if (sibnode.VEObject is PartInfo pisib && (pisib.ToString() == "Steps"))
{
if (!sibnode.ChildrenLoaded) sibnode.LoadChildren();
while (sibnode.Nodes.Count > 0)
{
VETreeNode tmp = sibnode.Nodes[0] as VETreeNode;
tmp.Remove();
grndparnode.Nodes.Add(tmp);
}
sibnode.Remove();
}
}
}
}
//public IVEReadOnlyItem GetCsla()
//{
// return _VEObject;
//}
#endregion
#region Factory Methods
// Constructors
@@ -383,25 +284,24 @@ namespace VEPROMS.CSLA.Library
_allParts = allParts;
_VEObject = o;// Save the BusinessObject
ResetNode("Dummy VETreeNode(IVEDrillDownReadOnly o)");
ItemInfo myItemInfo = o as ItemInfo;
if (myItemInfo != null)
{
myItemInfo.Deleted -= new ItemInfoEvent(myItemInfo_Deleted);
myItemInfo.Deleted += new ItemInfoEvent(myItemInfo_Deleted);
myItemInfo.ChildrenDeleted -= new ItemInfoEvent(myItemInfo_ChildrenDeleted);
myItemInfo.ChildrenDeleted += new ItemInfoEvent(myItemInfo_ChildrenDeleted);
myItemInfo.MyContent.Changed -= new ContentInfoEvent(NodeText_Changed);
myItemInfo.MyContent.Changed += new ContentInfoEvent(NodeText_Changed);
myItemInfo.OrdinalChanged -= new ItemInfoEvent(NodeText_Changed);
myItemInfo.OrdinalChanged += new ItemInfoEvent(NodeText_Changed);
myItemInfo.NewSiblingAfter -= new ItemInfoInsertEvent(myItemInfo_NewSiblingAfter);
myItemInfo.NewSiblingAfter += new ItemInfoInsertEvent(myItemInfo_NewSiblingAfter);
myItemInfo.NewSiblingBefore -= new ItemInfoInsertEvent(myItemInfo_NewSiblingBefore);
myItemInfo.NewSiblingBefore += new ItemInfoInsertEvent(myItemInfo_NewSiblingBefore);
myItemInfo.NewChild -= new ItemInfoInsertEvent(myItemInfo_NewChild);
myItemInfo.NewChild += new ItemInfoInsertEvent(myItemInfo_NewChild);
}
}
if (o is ItemInfo myItemInfo)
{
myItemInfo.Deleted -= new ItemInfoEvent(myItemInfo_Deleted);
myItemInfo.Deleted += new ItemInfoEvent(myItemInfo_Deleted);
myItemInfo.ChildrenDeleted -= new ItemInfoEvent(myItemInfo_ChildrenDeleted);
myItemInfo.ChildrenDeleted += new ItemInfoEvent(myItemInfo_ChildrenDeleted);
myItemInfo.MyContent.Changed -= new ContentInfoEvent(NodeText_Changed);
myItemInfo.MyContent.Changed += new ContentInfoEvent(NodeText_Changed);
myItemInfo.OrdinalChanged -= new ItemInfoEvent(NodeText_Changed);
myItemInfo.OrdinalChanged += new ItemInfoEvent(NodeText_Changed);
myItemInfo.NewSiblingAfter -= new ItemInfoInsertEvent(myItemInfo_NewSiblingAfter);
myItemInfo.NewSiblingAfter += new ItemInfoInsertEvent(myItemInfo_NewSiblingAfter);
myItemInfo.NewSiblingBefore -= new ItemInfoInsertEvent(myItemInfo_NewSiblingBefore);
myItemInfo.NewSiblingBefore += new ItemInfoInsertEvent(myItemInfo_NewSiblingBefore);
myItemInfo.NewChild -= new ItemInfoInsertEvent(myItemInfo_NewChild);
myItemInfo.NewChild += new ItemInfoInsertEvent(myItemInfo_NewChild);
}
}
void NodeText_Changed(object sender)
{
Text = _VEObject.ToString();
@@ -422,7 +322,7 @@ namespace VEPROMS.CSLA.Library
if (myItemInfo.Sections != null && myItemInfo.Sections.Count > 0 && myItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.UseMetaSections)
{
// see if change in children tree nodes.
this.Nodes.Clear();
Nodes.Clear();
_ChildrenLoaded = false;
LoadChildren(true);
}
@@ -433,25 +333,24 @@ namespace VEPROMS.CSLA.Library
{
_VEObject = o;// Save the BusinessObject
ResetNode("Dummy VETreeNode(IVEDrillDownReadOnly o)");
ItemInfo myItemInfo = o as ItemInfo;
if (myItemInfo != null)
{
myItemInfo.Deleted -= new ItemInfoEvent(myItemInfo_Deleted);
myItemInfo.Deleted += new ItemInfoEvent(myItemInfo_Deleted);
myItemInfo.ChildrenDeleted -= new ItemInfoEvent(myItemInfo_ChildrenDeleted);
myItemInfo.ChildrenDeleted += new ItemInfoEvent(myItemInfo_ChildrenDeleted);
myItemInfo.MyContent.Changed -= new ContentInfoEvent(NodeText_Changed);
myItemInfo.MyContent.Changed += new ContentInfoEvent(NodeText_Changed);
myItemInfo.OrdinalChanged -= new ItemInfoEvent(NodeText_Changed);
myItemInfo.OrdinalChanged += new ItemInfoEvent(NodeText_Changed);
myItemInfo.NewSiblingAfter -= new ItemInfoInsertEvent(myItemInfo_NewSiblingAfter);
myItemInfo.NewSiblingAfter += new ItemInfoInsertEvent(myItemInfo_NewSiblingAfter);
myItemInfo.NewSiblingBefore -= new ItemInfoInsertEvent(myItemInfo_NewSiblingBefore);
myItemInfo.NewSiblingBefore += new ItemInfoInsertEvent(myItemInfo_NewSiblingBefore);
myItemInfo.NewChild -= new ItemInfoInsertEvent(myItemInfo_NewChild);
myItemInfo.NewChild += new ItemInfoInsertEvent(myItemInfo_NewChild);
}
}
if (o is ItemInfo myItemInfo)
{
myItemInfo.Deleted -= new ItemInfoEvent(myItemInfo_Deleted);
myItemInfo.Deleted += new ItemInfoEvent(myItemInfo_Deleted);
myItemInfo.ChildrenDeleted -= new ItemInfoEvent(myItemInfo_ChildrenDeleted);
myItemInfo.ChildrenDeleted += new ItemInfoEvent(myItemInfo_ChildrenDeleted);
myItemInfo.MyContent.Changed -= new ContentInfoEvent(NodeText_Changed);
myItemInfo.MyContent.Changed += new ContentInfoEvent(NodeText_Changed);
myItemInfo.OrdinalChanged -= new ItemInfoEvent(NodeText_Changed);
myItemInfo.OrdinalChanged += new ItemInfoEvent(NodeText_Changed);
myItemInfo.NewSiblingAfter -= new ItemInfoInsertEvent(myItemInfo_NewSiblingAfter);
myItemInfo.NewSiblingAfter += new ItemInfoInsertEvent(myItemInfo_NewSiblingAfter);
myItemInfo.NewSiblingBefore -= new ItemInfoInsertEvent(myItemInfo_NewSiblingBefore);
myItemInfo.NewSiblingBefore += new ItemInfoInsertEvent(myItemInfo_NewSiblingBefore);
myItemInfo.NewChild -= new ItemInfoInsertEvent(myItemInfo_NewChild);
myItemInfo.NewChild += new ItemInfoInsertEvent(myItemInfo_NewChild);
}
}
void myItemInfo_ChildrenDeleted(object sender)
{
@@ -469,8 +368,7 @@ namespace VEPROMS.CSLA.Library
{
int nextItemID = args.ItemInserted.NextItem.ItemID;
VETreeNode nextNode = FindChildOrGrandChild(nextItemID);
if(nextNode != null)
nextNode.myItemInfo_NewSiblingBefore(sender, args);
nextNode?.myItemInfo_NewSiblingBefore(sender, args);
return;
}
if (args.ItemInserted.MyPrevious != null) // insert after
@@ -486,317 +384,65 @@ namespace VEPROMS.CSLA.Library
Nodes.Clear();
_ChildrenLoaded = false;
ResetNode("Dummy myItemInfo_NewChild");
ItemInfo item = VEObject as ItemInfo;
if (isExpanded && item != null && item.MyContent.ContentPartCount > 1) // || args.ItemInserted.NextItem != null || args.ItemInserted.MyPrevious != null))
Expand();
else
Collapse();
}
if (isExpanded && VEObject is ItemInfo item && item.MyContent.ContentPartCount > 1) // || args.ItemInserted.NextItem != null || args.ItemInserted.MyPrevious != null))
Expand();
else
Collapse();
}
private VETreeNode FindChildOrGrandChild(int itemID)
{
foreach (TreeNode childNode in Nodes)
{
VETreeNode child = childNode as VETreeNode;
if (child != null)
{
ItemInfo item = child.VEObject as ItemInfo;
if (item != null && item.ItemID == itemID)
return child;
}
}
if (childNode is VETreeNode child)
{
if (child.VEObject is ItemInfo item && item.ItemID == itemID)
return child;
}
}
foreach (TreeNode childNode in Nodes)
{
VETreeNode child = childNode as VETreeNode;
if (child != null && child.VEObject is PartInfo)
foreach (VETreeNode grandchild in child.Nodes)
{
ItemInfo item = grandchild.VEObject as ItemInfo;
if (item != null && item.ItemID == itemID)
return grandchild;
}
}
if (childNode is VETreeNode child && child.VEObject is PartInfo)
foreach (VETreeNode grandchild in child.Nodes)
{
if (grandchild.VEObject is ItemInfo item && item.ItemID == itemID)
return grandchild;
}
}
return null;
}
void myItemInfo_NewSiblingBefore(object sender, ItemInfoInsertEventArgs args)
{
if (this.Parent != null) // Only do this if the node has a parent - RHM 20100106
if (Parent != null) // Only do this if the node has a parent - RHM 20100106
{
ItemInfo ii = args.ItemInserted as ItemInfo;
if (ii == null)
this.Parent.Nodes.Insert(Index, (new VETreeNode(args.ItemInserted)));
else // B2020-142: Can't get properties of restored item (no treeview context menu would be correct after restore)
{
if (ii.IsProcedure) this.Parent.Nodes.Insert(Index, (new VETreeNode(ProcedureInfo.Get(ii.ItemID))));
if (ii.IsSection) this.Parent.Nodes.Insert(Index, (new VETreeNode(SectionInfo.Get(ii.ItemID))));
if (ii.IsStep) this.Parent.Nodes.Insert(Index, (new VETreeNode(StepInfo.Get(ii.ItemID))));
}
}
if (!(args.ItemInserted is ItemInfo ii))
Parent.Nodes.Insert(Index, (new VETreeNode(args.ItemInserted)));
else // B2020-142: Can't get properties of restored item (no treeview context menu would be correct after restore)
{
if (ii.IsProcedure) Parent.Nodes.Insert(Index, (new VETreeNode(ProcedureInfo.Get(ii.ItemID))));
if (ii.IsSection) Parent.Nodes.Insert(Index, (new VETreeNode(SectionInfo.Get(ii.ItemID))));
if (ii.IsStep) Parent.Nodes.Insert(Index, (new VETreeNode(StepInfo.Get(ii.ItemID))));
}
}
}
void myItemInfo_NewSiblingAfter(object sender, ItemInfoInsertEventArgs args)
{
if (this.Parent != null) // Only do this if the node has a parent - RHM 20100106
if (Parent != null) // Only do this if the node has a parent - RHM 20100106
{
ItemInfo ii = args.ItemInserted as ItemInfo;
if (ii == null)
this.Parent.Nodes.Insert(Index + 1, (new VETreeNode(args.ItemInserted)));
else // B2020-142: Can't get properties of restored item (no treeview context menu would be correct after restore)
{
if (ii.IsProcedure) this.Parent.Nodes.Insert(Index + 1, (new VETreeNode(ProcedureInfo.Get(ii.ItemID))));
if (ii.IsSection) this.Parent.Nodes.Insert(Index + 1, (new VETreeNode(SectionInfo.Get(ii.ItemID))));
if (ii.IsStep) this.Parent.Nodes.Insert(Index + 1, (new VETreeNode(StepInfo.Get(ii.ItemID))));
}
}
if (!(args.ItemInserted is ItemInfo ii))
Parent.Nodes.Insert(Index + 1, (new VETreeNode(args.ItemInserted)));
else // B2020-142: Can't get properties of restored item (no treeview context menu would be correct after restore)
{
if (ii.IsProcedure) Parent.Nodes.Insert(Index + 1, (new VETreeNode(ProcedureInfo.Get(ii.ItemID))));
if (ii.IsSection) Parent.Nodes.Insert(Index + 1, (new VETreeNode(SectionInfo.Get(ii.ItemID))));
if (ii.IsStep) Parent.Nodes.Insert(Index + 1, (new VETreeNode(StepInfo.Get(ii.ItemID))));
}
}
}
public VETreeNode(string s)
: base(s)
{
_VEObject = null;// Save the BusinessObject
//ResetNode();
}
#endregion
}
//public class VETreeNodeBase<T> : VETreeNode
//where T : VETreeNode, new()
//{
// #region Factory Methods
// private static int _ICount = 0;
// public VETreeNodeBase(string s) : base(s) { ;}
// public VETreeNodeBase(IVEReadOnlyItem o) : base(o) { ;}
// protected VETreeNodeBase() : base() {
// }
// private DateTime tNext(DateTime tStart, string msg)
// {
// DateTime tEnd = DateTime.Now;
// TimeSpan ts = new TimeSpan(tEnd.Ticks-tStart.Ticks);
// Console.WriteLine("{0} - {1}", ts.TotalMilliseconds, msg);
// return tEnd;
// }
// public override void LoadChildren()
// {
// if (!_ChildrenLoaded)
// {
// this.Nodes.Clear();
// "".TrimEnd("\r\n".ToCharArray());
// IList ol = _VEObject.GetChildren();
// if (ol != null)
// {
// this.TreeView.BeginUpdate();
// DateTime tStart = DateTime.Now;
// T[] tmpa = new T[ol.Count];
// tStart = tNext(tStart, "Allocate Array");
// for (int i = 0; i < ol.Count; i++) tmpa[i] = new T();
// tStart = tNext(tStart, "Allocate Nodes");
// int ii = 0;
// foreach (IVEReadOnlyItem o in ol)
// {
// try
// {
// tmpa[ii++].VEObject = o;
// }
// catch (Exception ex)
// {
// Console.WriteLine("{0}\r\n{1}", ex.Message, ex.InnerException);
// }
// }
// tStart = tNext(tStart, "Set Nodes");
// for (int i = 0; i < ol.Count; i++) tmpa[i].ResetNode();
// tStart = tNext(tStart, "Reset Nodes");
// this.Nodes.AddRange(tmpa);
// tStart = tNext(tStart, "Add Range");
// //foreach (IVEReadOnlyItem o in ol)
// //{
// // try
// // {
// // T tmp = new T();
// // tmp.VEObject = o;
// // this.Nodes.Add(tmp);
// // }
// // catch (Exception ex)
// // {
// // Console.WriteLine("{0}\r\n{1}", ex.Message, ex.InnerException);
// // }
// //}
// this.TreeView.EndUpdate();
// }
// _ChildrenLoaded = true;
// }
// }
//#endregion
//}
/*
public class VEFolder : VETreeNodeBase<VEVersion>
{
public static VEFolder GetFolder(int folderID)
{
return new VEFolder(FolderInfo.Get(folderID));
}
//public static VEFolder LoadTree()
//{
// VEFolder root = null;
// FolderInfoList fil = FolderInfoList.Get();
// Dictionary<int, VEFolder> dicMissing = new Dictionary<int, VEFolder>();
// Dictionary<int, VEFolder> dicExists = new Dictionary<int, VEFolder>();
// foreach (FolderInfo fi in fil)
// {
// VEFolder ftp = null;
// if (dicExists.ContainsKey(fi.ParentID))
// {
// ftp = dicExists[fi.ParentID];
// }
// else
// {
// if (fi.ParentID != fi.FolderID)
// {
// ftp = new VEFolder(fi.ParentID.ToString());
// dicMissing.Add(fi.ParentID, ftp);
// dicExists.Add(fi.ParentID, ftp);
// }
// }
// VEFolder ft = null;
// if (dicMissing.ContainsKey(fi.FolderID))
// {
// ft = dicMissing[fi.FolderID];
// ft.VEObject = fi;
// dicMissing.Remove(fi.FolderID);
// }
// else
// {
// ft = new VEFolder(fi);
// dicExists.Add(fi.FolderID, ft);
// }
// if (fi.ParentID == fi.FolderID)
// root = ft;
// else
// ftp.Nodes.Add(ft);
// }
// //root.FindTree = dicExists;
// return root;
//}
private VEFolder(string s) : base(s) { ;}
public VEFolder(IVEReadOnlyItem o) : base(o) { ;}
}
public class VEVersion : VETreeNodeBase<VEProcedure> { }
public class VEProcedure : VETreeNodeBase<VESection>
{
//public override void LoadChildren()
//{
// if (!_ChildrenLoaded)
// {
// this.Nodes.Clear();
// Dictionary<string, VESection> dicSect = new Dictionary<string, VESection>();
// SectionInfoList ol = (SectionInfoList)_VEObject.GetChildren();
// if (ol != null)
// {
// foreach (SectionInfo o in ol)
// {
// try
// {
// VESection tmp = new VESection();
// tmp.VEObject = o;
// if (dicSect.ContainsKey(o.PPath))
// dicSect[o.PPath].Nodes.Add(tmp);
// else
// this.Nodes.Add(tmp);
// dicSect[o.Path] = tmp;
// }
// catch (Exception ex)
// {
// Console.WriteLine("{0}\r\n{1}", ex.Message, ex.InnerException);
// }
// }
// }
// _ChildrenLoaded = true;
// }
//}
}
public class VESection : VETreeNodeBase<VEStep> { }
public class VEStep : VETreeNodeBase<VEStep> { }
*/
//public class VETree : VETreeNodeBase<VETree>
//{
// public VETree() { ;}
// public static VETree GetFolder(int folderID)
// {
// return new VETree(FolderInfo.Get(folderID));
// }
// //private VEFolder(string s) : base(s) { ;}
// public VETree(IVEReadOnlyItem o) : base(o) { ;}
//}
//public class VETree : VETreeNode
//{
// public VETree() { ;}
// public static VETree GetFolder(int folderID)
// {
// VETree tn = new VETree(FolderInfo.Get(folderID));
// tn.ResetNode();
// return tn;
// }
// //private VEFolder(string s) : base(s) { ;}
// public VETree(IVEReadOnlyItem o) : base(o) { ;}
// private DateTime tNext(DateTime tStart, string msg)
// {
// DateTime tEnd = DateTime.Now;
// TimeSpan ts = new TimeSpan(tEnd.Ticks - tStart.Ticks);
// Console.WriteLine("{0} - {1}", ts.TotalMilliseconds, msg);
// return tEnd;
// }
// public override void LoadChildren()
// {
// if (!_ChildrenLoaded)
// {
// this.Nodes.Clear();
// "".TrimEnd("\r\n".ToCharArray());
// IList ol = _VEObject.GetChildren();
// if (ol != null)
// {
// this.TreeView.BeginUpdate();
// DateTime tStart = DateTime.Now;
// //VETree[] tmpa = new VETree[ol.Count];
// //tStart = tNext(tStart, "Allocate Array");
// ////for (int i = 0; i < ol.Count; i++) tmpa[i] = new VETree();
// ////tStart = tNext(tStart, "Allocate Nodes");
// //int ii = 0;
// //foreach (IVEReadOnlyItem o in ol)
// //{
// // try
// // {
// // tmpa[ii++] = new VETree(o);
// // //tmpa[ii++].VEObject = o;
// // }
// // catch (Exception ex)
// // {
// // Console.WriteLine("{0}\r\n{1}", ex.Message, ex.InnerException);
// // }
// //}
// //tStart = tNext(tStart, "Set Nodes");
// //for (int i = 0; i < ol.Count; i++) tmpa[i].ResetNode();
// //tStart = tNext(tStart, "Reset Nodes");
// //this.Nodes.AddRange(tmpa);
// //tStart = tNext(tStart, "Add Range");
// this.TreeView.DrawMode = TreeViewDrawMode.OwnerDrawAll;
// foreach (IVEReadOnlyItem o in ol)
// {
// try
// {
// VETree tmp = new VETree(o);
// //tmp.VEObject = o;
// this.Nodes.Add(tmp);
// }
// catch (Exception ex)
// {
// Console.WriteLine("{0}\r\n{1}", ex.Message, ex.InnerException);
// }
// }
// tStart = tNext(tStart, "Set Nodes");
// this.TreeView.DrawMode = TreeViewDrawMode.Normal;
// tStart = tNext(tStart, "DrawMode");
// this.TreeView.EndUpdate();
// tStart = tNext(tStart, "End Update");
// this.TreeView.Refresh();
// tStart = tNext(tStart, "Refresh");
// }
// _ChildrenLoaded = true;
// }
// }
//}
}