CSLA Config cleanup

This commit is contained in:
2026-08-28 11:15:35 -04:00
parent d0587706a2
commit f88f8a1c75
27 changed files with 566 additions and 2412 deletions
+40 -174
View File
@@ -1,8 +1,5 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using DescriptiveEnum;
using System.Xml;
namespace VEPROMS.CSLA.Library
@@ -11,18 +8,11 @@ namespace VEPROMS.CSLA.Library
[TypeConverter(typeof(ExpandableObjectConverter))]
public class ProcedureConfig : ConfigDynamicTypeDescriptor, INotifyPropertyChanged, IItemConfig
{
#region DynamicTypeDescriptor
internal override bool IsReadOnly
{
get { return _Procedure == null; }
}
#endregion
#region XML
private XMLProperties _Xp;
private XMLProperties Xp
{
get { return _Xp; }
}
#region DynamicTypeDescriptor
internal override bool IsReadOnly => _Procedure == null;
#endregion
#region XML
private readonly XMLProperties _Xp;
#endregion
#region Constructors
//PROPGRID: Hide ParentLookup
@@ -32,24 +22,14 @@ namespace VEPROMS.CSLA.Library
get { return _Xp.ParentLookup; }
set { _Xp.ParentLookup = value; }
}
//PROPGRID: Needed to comment out [NonSerialized] in order to hide AncestorLookup from property grid
//[NonSerialized]
//private bool _AncestorLookup;
////PROPGRID: Hide AncestorLookup
//[Browsable(false)]
//public bool AncestorLookup
//{
// get { return _AncestorLookup; }
// set { _AncestorLookup = value; }
//}
private Procedure _Procedure;
private ProcedureInfo _ProcedureInfo;
private readonly Procedure _Procedure;
private readonly ProcedureInfo _ProcedureInfo;
public ProcedureConfig(Procedure procedure)
{
_Procedure = procedure;
string xml = procedure.MyContent.Config;
if (xml == string.Empty)
xml = "<Config/>";
if (xml == string.Empty)
xml = "<Config/>";
_Xp = new XMLProperties(xml);
// Correct Slaves nodes for Parent Child
ValidateSlaves(_Xp.XmlContents, _Procedure.MyProcedureInfo.MyDocVersion.MultiUnitCount);
@@ -74,7 +54,7 @@ namespace VEPROMS.CSLA.Library
}
for (int i = 1; i <= unitCount; i++)
{
XmlNode xnc = xn.SelectSingleNode(string.Format("Slave[@index='{0}']", i));
XmlNode xnc = xn.SelectSingleNode($"Slave[@index='{i}']");
if (xnc == null) // Missing Required Slave Node (index=i) - Add it.
{
XmlElement xec = xd.CreateElement("Slave");
@@ -98,9 +78,8 @@ namespace VEPROMS.CSLA.Library
retval = proc.ProcedureConfig.GetValue(args.Group, args.Item);
if (retval != string.Empty) return retval;
}
DocVersionInfo docVersion = proc.ActiveParent as DocVersionInfo;
if (docVersion == null) return string.Empty;
retval = docVersion.DocVersionConfig.GetValue(args.Group, args.Item);
if (!(proc.ActiveParent is DocVersionInfo docVersion)) return string.Empty;
retval = docVersion.DocVersionConfig.GetValue(args.Group, args.Item);
if (retval != string.Empty) return retval;
for (FolderInfo folder = docVersion.MyFolder; folder != null; folder = folder.MyParent)
{
@@ -110,36 +89,19 @@ namespace VEPROMS.CSLA.Library
}
return string.Empty;
}
//private string Xp_LookInAncestorFolderInfo(object sender, XMLPropertiesArgs args)
//{
// if (args.AncestorLookup || ParentLookup)
// {
// DocVersionInfo docVersion = (DocVersionInfo)_Procedure.ActiveParent;
// string retval = docVersion.DocVersionConfig.GetValue(args.Group, args.Item);
// if (retval != string.Empty) return retval;
// for (FolderInfo folder = docVersion.MyFolder; folder != null; folder = folder.MyParent)
// {
// retval = folder.FolderConfig.GetValue(args.Group, args.Item);
// if (retval != string.Empty) return retval;
// }
// }
// return string.Empty;
//}
public ProcedureConfig(ProcedureInfo procedureInfo)
{
_ProcedureInfo = procedureInfo;
string xml = procedureInfo.MyContent.Config;
if (xml == string.Empty)
xml = "<Config/>";
_Xp = new XMLProperties(xml);
if (xml == string.Empty)
xml = "<Config/>";
_Xp = new XMLProperties(xml);
// Fix Slaves nodes for Parent Child
ValidateSlaves(_Xp.XmlContents, _ProcedureInfo.MyDocVersion.MultiUnitCount);
_Xp.AncestorLookup = true;
if (procedureInfo.ActiveParent != null) _Xp.LookInAncestor += new XMLPropertiesEvent(Xp_LookInAncestorFolder);
}
private int _SelectedSlave = 0;
//[Browsable(false)]
public int SelectedSlave
{
get { return _SelectedSlave; }
@@ -150,19 +112,9 @@ namespace VEPROMS.CSLA.Library
if (xml == string.Empty) xml = "<Config/>";
_Xp = new XMLProperties(xml);
}
//public ProcedureConfig()
//{
// _Xp = new XMLProperties();
//}
public string GetValue(string group, string item)
{
return _Xp[group, item];
}
public void SetValue(string group, string item, string newvalue)
{
_Xp[group, item] = newvalue;
}
public int GetItemId()
public string GetValue(string group, string item) => _Xp[group, item];
public void SetValue(string group, string item, string newvalue) => _Xp[group, item] = newvalue;
public int GetItemId()
{
if (_Procedure != null) return _Procedure.ItemID;
if (_ProcedureInfo != null) return _ProcedureInfo.ItemID;
@@ -193,19 +145,16 @@ namespace VEPROMS.CSLA.Library
[Description("Old Sequence")]
public string OldSequence
{
get { return (_Procedure != null ? _Procedure.MyContent.MyZContent.OldStepSequence : (_ProcedureInfo.MyContent.MyZContent == null ? null : _ProcedureInfo.MyContent.MyZContent.OldStepSequence)); }
get { return (_Procedure != null ? _Procedure.MyContent.MyZContent.OldStepSequence : (_ProcedureInfo.MyContent.MyZContent?.OldStepSequence)); }
set { if (_Procedure != null) _Procedure.MyContent.MyZContent.OldStepSequence = value; }
}
[Category("Identification")]
//PROPGRID: Hide Dirty
[Browsable(false)]
[DisplayName("Dirty")]
[Description("Dirty")]
public bool Dirty
{
get { return (_Procedure != null ? _Procedure.IsDirty : false); }
}
[Category("Format Settings")]
[Category("Identification")]
//PROPGRID: Hide Dirty
[Browsable(false)]
[DisplayName("Dirty")]
[Description("Dirty")]
public bool Dirty => _Procedure != null && _Procedure.IsDirty;
[Category("Format Settings")]
[DisplayName("Format")]
[Description("Format")]
[TypeConverter(typeof(FormatList))]
@@ -222,7 +171,6 @@ namespace VEPROMS.CSLA.Library
if (_Procedure != null)
{
_Procedure.MyContent.MyFormat = FormatList.ToFormat(value); // Can only be set if _DocVersion is set
//_Procedure.ActiveFormat = null;
}
}
}
@@ -261,12 +209,11 @@ namespace VEPROMS.CSLA.Library
public override string ToString()
{
string s = _Xp.ToString();
if (s == "<Config/>" || s == "<Config></Config>") return string.Empty;
return s;
}
#endregion
#region DelProcReason
[Category("General")]
return s == "<Config/>" || s == "<Config></Config>" ? string.Empty : s;
}
#endregion
#region DelProcReason
[Category("General")]
[DisplayName("DelProcReason")]
[RefreshProperties(RefreshProperties.All)]
[Description("Delete Procedure Reason")]
@@ -283,19 +230,6 @@ namespace VEPROMS.CSLA.Library
}
#endregion
#region FormatCategory
//[TypeConverter(typeof(EnumDescConverter))]
//public enum FormatColumns : int
//{
// Default = 0,
// [Description("Single Column")]
// OneColumn,
// [Description("Dual Column")]
// TwoColumn,
// [Description("Triple Column")]
// ThreeColumn,
// [Description("Quad Column")]
// FourColumns
//}
[Category("General")]
[DisplayName("Default Column Mode")]
[RefreshProperties(RefreshProperties.All)]
@@ -375,13 +309,13 @@ namespace VEPROMS.CSLA.Library
{
string s = _Xp["Procedure", "Rev"];
if (SelectedSlave > 0)
s = _Xp["Slave[@index='" + SelectedSlave.ToString() + "']", "Rev"];
s = _Xp[$"Slave[@index='{SelectedSlave}']", "Rev"];
return s;
}
set
{
if (SelectedSlave > 0)
_Xp["Slave[@index='" + SelectedSlave.ToString() + "']", "Rev"] = value; // save selected value
_Xp[$"Slave[@index='{SelectedSlave}']", "Rev"] = value; // save selected value
else
_Xp["Procedure", "Rev"] = value;
OnPropertyChanged("Print_Rev");
@@ -399,13 +333,13 @@ namespace VEPROMS.CSLA.Library
{
string s = _Xp["Procedure", "RevDate"];
if (SelectedSlave > 0)
s = _Xp["Slave[@index='" + SelectedSlave.ToString() + "']", "RevDate"];
s = _Xp[$"Slave[@index='{SelectedSlave}']", "RevDate"];
return s;
}
set
{
if (SelectedSlave > 0)
_Xp["Slave[@index='" + SelectedSlave.ToString() + "']", "RevDate"] = value; // save selected value
_Xp[$"Slave[@index='{SelectedSlave}']", "RevDate"] = value; // save selected value
else
_Xp["Procedure", "RevDate"] = value;
OnPropertyChanged("Print_RevDate");
@@ -443,7 +377,7 @@ namespace VEPROMS.CSLA.Library
{
string s = _Xp["Procedure", "ChangeBarDate"];
if (SelectedSlave > 0)
s = _Xp["Slave[@index='" + SelectedSlave.ToString() + "']", "ChangeBarDate"];
s = _Xp[$"Slave[@index='{SelectedSlave}']", "ChangeBarDate"];
else
{
if (s != "")
@@ -470,7 +404,7 @@ namespace VEPROMS.CSLA.Library
set
{
if (SelectedSlave > 0)
_Xp["Slave[@index='" + SelectedSlave.ToString() + "']", "ChangeBarDate"] = value; // save selected value
_Xp[$"Slave[@index='{SelectedSlave}']", "ChangeBarDate"] = value; // save selected value
else
_Xp["Procedure", "ChangeBarDate"] = value;
OnPropertyChanged("Print_ChangeBarDate");
@@ -487,13 +421,13 @@ namespace VEPROMS.CSLA.Library
{
string s = _Xp["Procedure", "ReviewDate"];
if (SelectedSlave > 0)
s = _Xp["Slave[@index='" + SelectedSlave.ToString() + "']", "ReviewDate"];
s = _Xp[$"Slave[@index='{SelectedSlave}']", "ReviewDate"];
return s;
}
set
{
if (SelectedSlave > 0)
_Xp["Slave[@index='" + SelectedSlave.ToString() + "']", "ReviewDate"] = value; // save selected value
_Xp[$"Slave[@index='{SelectedSlave}']", "ReviewDate"] = value; // save selected value
else
_Xp["Procedure", "ReviewDate"] = value;
OnPropertyChanged("Print_ReviewDate");
@@ -519,12 +453,6 @@ namespace VEPROMS.CSLA.Library
OnPropertyChanged("Print_NumCopies");
}
}
//public enum PrintPagination : int
//{
// Free = 0, Fixed,
// [Description("Automatic")]
// Auto
//}
[Category("Print Settings")]
[DisplayName("Pagination")]
[RefreshProperties(RefreshProperties.All)]
@@ -562,13 +490,6 @@ namespace VEPROMS.CSLA.Library
OnPropertyChanged("Print_Pagination");
}
}
//[TypeConverter(typeof(EnumDescConverter))]
//public enum PrintWatermark : int
//{
// None = 0, Reference, Draft, Master, Sample,
// [Description("Information Only")]
// InformationOnly
//}
[Category("Print Settings")]
[DisplayName("Watermark")]
[RefreshProperties(RefreshProperties.All)]
@@ -623,29 +544,12 @@ namespace VEPROMS.CSLA.Library
set
{
string s = _Xp["PrintSettings", "NotInMergeAll"]; // get the original value to see if a change
bool original = (s==string.Empty) ? false : bool.Parse(s);
bool original = s != string.Empty && bool.Parse(s);
if (original == value) return;
_Xp["PrintSettings", "NotInMergeAll"] = ((bool)value).ToString(); // save selected value
OnPropertyChanged("Print_NotInMergeAll");
}
}
// Change Bar Use from 16-bit code:
// No Default
// Without Change Bars
// With Default Change Bars
// With User Specified Change Bars
//[TypeConverter(typeof(EnumDescConverter))]
//public enum PrintChangeBar : int
//{
// [Description("Select Before Printing")]
// SelectBeforePrinting = 0,
// [Description("Without Change Bars")]
// Without,
// [Description("With Default Change Bars")]
// WithDefault,
// [Description("Use Custom Change Bars")]
// WithUserSpecified
//}
[Category("Format Settings")]
[DisplayName("Change Bar")]
[RefreshProperties(RefreshProperties.All)]
@@ -683,23 +587,6 @@ namespace VEPROMS.CSLA.Library
OnPropertyChanged("Print_ChangeBar");
}
}
// User Specified Change Bar Location from16-bit code:
// With Text
// Outside Box
// AER on LEFT, RNO on Right
// To the Left of Text
//[TypeConverter(typeof(EnumDescConverter))]
//public enum PrintChangeBarLoc : int
//{
// [Description("With Text")]
// WithText = 0,
// [Description("Outside Box")]
// OutsideBox,
// [Description("AER on Left RNO on Right")]
// AERleftRNOright,
// [Description("To the Left of the Text")]
// LeftOfText
//}
[Category("Format Settings")]
[DisplayName("Change Bar Position")]
[RefreshProperties(RefreshProperties.All)]
@@ -737,27 +624,6 @@ namespace VEPROMS.CSLA.Library
OnPropertyChanged("Print_ChangeBarLoc");
}
}
// Change Bar Text from16-bit code:
// Date and Change ID
// Revision Number
// Change ID
// No Change Bar Message
// User Defined Message
//[TypeConverter(typeof(EnumDescConverter))]
//public enum PrintChangeBarText : int
//{
// [Description("Date and Change ID")]
// DateChgID = 0,
// [Description("Revision Number")]
// RevNum,
// [Description("Change ID")]
// ChgID,
// [Description("No Change Bar Text")]
// None,
// [Description("Custom Change Bar Text")]
// UserDef
//}
[Category("Format Settings")]
[DisplayName("Change Bar Text Type")]
[RefreshProperties(RefreshProperties.All)]