Files
SourceCode/PROMS/VEPROMS.CSLA.Library/Config/DocVersionConfig.cs
T
2026-08-28 11:15:35 -04:00

1682 lines
51 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Xml;
namespace VEPROMS.CSLA.Library
{
public partial class DVEnhancedDocuments : List<DVEnhancedDocument>
{
public void Add(string name, int type, int versionID, int pdfX, string pdfToken) => Add(new DVEnhancedDocument(name, type, versionID, pdfX, pdfToken));
public static DVEnhancedDocuments Load(XMLProperties _Xp)
{
DVEnhancedDocuments eds = new DVEnhancedDocuments(); // B2020-060: don't return null, caused null reference later
foreach (XmlNode xn in _Xp.XmlContents.SelectNodes("//Enhanced"))
{
XmlAttribute xa = xn.Attributes["VersionID"];
if (xa == null) return null; // B2020-004: if an enhanced node exists but has no version data, return null.
if (eds == null) eds = new DVEnhancedDocuments();
int dvid = int.Parse(xn.Attributes["VersionID"].Value);
DocVersionInfo dvi = DocVersionInfo.Get(dvid);
if (dvi != null)
{
eds.Add(xn.Attributes["Name"].Value,
int.Parse(xn.Attributes["Type"].Value),
int.Parse(xn.Attributes["VersionID"].Value),
int.Parse(xn.Attributes["PdfX"].Value),
xn.Attributes["PdfToken"].Value
);
}
else
{
// B2018-025: If there is config data in the source pointing to a non-existent enhanced, remove
// this from the internal data structure so no errors will occur:
XmlNode xnx = _Xp.XmlContents.SelectSingleNode($"//Enhanced[@VersionID='{dvid}']");
xnx.ParentNode.RemoveChild(xnx);
}
}
return eds;
}
public DVEnhancedDocument GetByType(int type)
{
foreach (DVEnhancedDocument ed in this)
if (ed.Type == type) return ed;
return null;
}
public DVEnhancedDocument this[string name]
{
get
{
foreach (DVEnhancedDocument ed in this)
if (ed.Name == name) return ed;
return null;
}
}
public bool HasSourcePointer
{
get
{
foreach (DVEnhancedDocument ed in this)
if (ed.Type == 0) return true;
return false;
}
}
}
public partial class DVEnhancedDocument
{
public string Name { get; set; }
public int Type { get; set; }
public int VersionID { get; set; }
public int PdfX { get; set; }
public string PdfToken { get; set; }
public DVEnhancedDocument() { ;}
public DVEnhancedDocument(string name,int type, int versionID, int pdfX, string pdfToken)
{
Name = name;
Type = type;
VersionID = versionID;
PdfX = pdfX;
PdfToken = pdfToken;
}
public override string ToString() => $"{Name}.ItemID={VersionID}";
}
[Serializable]
[TypeConverter(typeof(ExpandableObjectConverter))]
public class DocVersionConfig : ConfigDynamicTypeDescriptor, INotifyPropertyChanged
{
// B2018-025: Allow refresh of enhanced document data structure, RefreshMyEnhancedDocuments, and remove link data, RemoveEnhancedLink.
public void RefreshMyEnhancedDocuments() => _MyEnhancedDocuments = null;
public void RemoveEnhancedLink(int dvid)
{
// from this config, remove the link to the input dvid (DocVersionId:
XmlNode xnx = _Xp.XmlContents.SelectSingleNode(string.Format("//Enhanced[@VersionID='{0}']", dvid));
if (xnx == null) return; // B2020-069: check for null reference before accessing xnx.
xnx.ParentNode.RemoveChild(xnx);
}
private DVEnhancedDocuments _MyEnhancedDocuments = null;
public DVEnhancedDocuments MyEnhancedDocuments
{
get
{
if (_MyEnhancedDocuments == null)
{
_MyEnhancedDocuments = DVEnhancedDocuments.Load(_Xp);
}
return _MyEnhancedDocuments;
}
set { _MyEnhancedDocuments = value; }
}
public void SaveDVEnhancedDocuments()
{
// get all of the current enhanced links from data structure in code. This list may have been
// modified by adding items during code execution by associating source <--> background etc.
DVEnhancedDocuments edsToAdd = new DVEnhancedDocuments();
foreach (DVEnhancedDocument ed in MyEnhancedDocuments)
edsToAdd.Add(ed);
// from the existing list in xml, remove any that are in the 'edited (edsToAdd) list
// so that what remains are those that need added to xml that will then be written to database
foreach (XmlNode xn in _Xp.XmlContents.SelectNodes("//Enhanced"))
{
DVEnhancedDocument tmp = edsToAdd.GetByType(int.Parse(xn.Attributes["Type"].Value));
if (tmp != null)
{
if (xn.Attributes["Name"].Value != tmp.Name)
xn.Attributes["Name"].Value = tmp.Name;
if (int.Parse(xn.Attributes["Type"].Value) != tmp.Type)
xn.Attributes["Type"].Value = tmp.Type.ToString();
if (int.Parse(xn.Attributes["VersionID"].Value) != tmp.VersionID)
xn.Attributes["VersionID"].Value = tmp.VersionID.ToString();
if (int.Parse(xn.Attributes["PdfX"].Value) != tmp.PdfX)
xn.Attributes["PdfX"].Value = tmp.PdfX.ToString();
if (xn.Attributes["PdfToken"].Value != tmp.PdfToken)
xn.Attributes["PdfToken"].Value = tmp.PdfToken;
edsToAdd.Remove(tmp);
}
}
// Add any remaining doc versions to the xml node //Enhanced
foreach (DVEnhancedDocument edadd in edsToAdd)
{
// Add (example): <Enhanced Type="Background" ItemID="43138" /><Enhanced Type="Deviation" ItemID="67165" />
// First add 'Enhanced' element:
XmlNode newEnhNode = _Xp.XmlContents.CreateNode(XmlNodeType.Element, "Enhanced", _Xp.XmlContents.NamespaceURI);
XmlNode xnEnh = _Xp.XmlContents.DocumentElement.AppendChild(newEnhNode);
// Now add the 'Type' and 'ItemID' attributes:
XmlAttribute xa = xnEnh.Attributes.Append(_Xp.XmlContents.CreateAttribute("Type"));
xa.Value = edadd.Type.ToString();
xa = xnEnh.Attributes.Append(_Xp.XmlContents.CreateAttribute("Name"));
xa.Value = edadd.Name;
xa = xnEnh.Attributes.Append(_Xp.XmlContents.CreateAttribute("VersionID"));
xa.Value = edadd.VersionID.ToString();
xa = xnEnh.Attributes.Append(_Xp.XmlContents.CreateAttribute("PdfX"));
xa.Value = edadd.PdfX.ToString();
xa = xnEnh.Attributes.Append(_Xp.XmlContents.CreateAttribute("PdfToken"));
xa.Value = edadd.PdfToken;
}
}
#region DynamicTypeDescriptor
internal override bool IsReadOnly => _DocVersion == null;
#endregion
#region XML
private readonly XMLProperties _Xp;
#endregion
#region Constructors
//PROPGRID: Hide ParentLookup
[Browsable(false)]
public bool ParentLookup
{
get { return _Xp.ParentLookup; }
set { _Xp.ParentLookup = value; }
}
private readonly DocVersion _DocVersion;
public DocVersionConfig(DocVersion docVersion)
{
_DocVersion = docVersion;
string xml = docVersion.Config;
if (xml == string.Empty) xml = "<Config/>";
_Xp = new XMLProperties(xml);
if (docVersion.MyDocVersionInfo.MyFolder != null) _Xp.LookInAncestor += new XMLPropertiesEvent(Xp_LookInAncestorFolder);
}
private string Xp_LookInAncestorFolder(object sender, XMLPropertiesArgs args)
{
if (args.AncestorLookup || ParentLookup)
{
for (FolderInfo folder = _DocVersion != null ? _DocVersion.MyDocVersionInfo.MyFolder : _DocVersionInfo.MyFolder; folder != null; folder = folder.MyParent)
{
string retval = folder.FolderConfig.GetValue(args.Group, args.Item);
if (retval != string.Empty) return retval;
}
}
return string.Empty;
}
private readonly DocVersionInfo _DocVersionInfo;
public DocVersionConfig(DocVersionInfo docVersionInfo)
{
_DocVersionInfo = docVersionInfo;
string xml = docVersionInfo.Config;
if (xml == string.Empty) xml = "<Config/>";
_Xp = new XMLProperties(xml);
if (docVersionInfo.MyFolder != null) _Xp.LookInAncestor += new XMLPropertiesEvent(Xp_LookInAncestorFolder);
}
public DocVersionConfig(string xml)
{
if (xml == string.Empty) xml = "<Config/>";
_Xp = new XMLProperties(xml);
}
public DocVersionConfig()
{
string xml = "<Config/>";
_Xp = new XMLProperties(xml);
}
public string GetValue(string group, string item) => _Xp[group, item];
public void SetValue(string group, string item, string newvalue) => _Xp[group, item] = newvalue;
#endregion
#region Local Properties
[Category("General")]
[DisplayName("Name")]
[Description("Name")]
public string Name
{
get { return (_DocVersion != null ? _DocVersion.Name : _DocVersionInfo.Name); }
set { if (_DocVersion != null) _DocVersion.Name = value; }
}
[Category("General")]
[DisplayName("Procedure Set Revision")]
[Description("Westinghouse Owners Group Revision")]
public string ProcedureSetRev
{
get
{
return _Xp["ProcedureSet", "Revision"];
}
set
{
_Xp["ProcedureSet", "Revision"] = value;
OnPropertyChanged("ProcedureSet_Revision");
}
}
[Category("General")]
//PROPGRID: Hide Title
[Browsable(false)]
[DisplayName("Title")]
[Description("Title")]
public string Title
{
get { return (_DocVersion != null ? _DocVersion.Title : _DocVersionInfo.Title); }
set { if (_DocVersion != null) _DocVersion.Title = value; }
}
[Category("Format Settings")]
[DisplayName("Format")]
[Description("Format")]
[TypeConverter(typeof(FormatList))]
public string FormatSelection
{
get
{
if (_DocVersion != null && _DocVersion.MyFormat != null) return _DocVersion.MyFormat.FullName;
if (_DocVersionInfo != null && _DocVersionInfo.MyFormat != null) return _DocVersionInfo.MyFormat.FullName;
return null;
}
set
{
if (_DocVersion != null)
{
_DocVersion.MyFormat = FormatList.ToFormat(value); // Can only be set if _DocVersion is set
//_DocVersion.ActiveFormat = null;
}
}
}
[Category("Format Settings")]
[DisplayName("Default Format")]
[Description("Default Format")]
[TypeConverter(typeof(FormatList))]
public string DefaultFormatSelection
{
get
{
if (_DocVersion != null && _DocVersion.MyDocVersionInfo.MyFolder != null && _DocVersion.MyDocVersionInfo.MyFolder.ActiveFormat != null) return _DocVersion.MyDocVersionInfo.MyFolder.ActiveFormat.FullName;
if (_DocVersionInfo != null && _DocVersionInfo.MyFolder != null && _DocVersionInfo.MyFolder.ActiveFormat != null) return _DocVersionInfo.MyFolder.ActiveFormat.FullName;
return null;
}
}
public DocVersion MyDocVersion
{ get { return _DocVersion; } }
private bool _SaveChangesToDocVersionConfig = true;
public bool SaveChangesToDocVersionConfig
{
get { return _SaveChangesToDocVersionConfig; }
set { _SaveChangesToDocVersionConfig = value; }
}
#endregion
#region ToString
public override string ToString()
{
string s = _Xp.ToString();
return s == "<Config/>" || s == "<Config></Config>" ? string.Empty : s;
}
#endregion
//<Config><RODefaults Setpoint="SP1" Graphics="IG1" ROPATH="g:\ops\vehlp\ro" /><PrintSettings ChangeBar="3" ChangeBarLoc="1" ChangeBarText="3" numcopies="1" Watermark="1" userformat=" " disableduplex="False" /><format plant="OHLP" /></Config>
#region RODefaults // From proc.ini
[Category("Referenced Objects")]
[DisplayName("Default RO Prefix")]
[RefreshProperties(RefreshProperties.All)]
[Description("Setpoint Prefix")]
public string RODefaults_setpointprefix
{
get
{
string s = _Xp["RODefaults", "Setpoint"];// get the saved value
//If there is no value to get, then get the parent value (a.k.a. default value).
if (s == string.Empty)
s = _Xp.ParentValue("RODefaults", "Setpoint"); // get the parent value
// If there is no parent value, then use the volian default
if (s == string.Empty)
s = "SP1";// default to volian default
return s;
}
set
{
// if value being saved is same as the parent value, then clear the value (save blank). This will
// reset the data to use the parent value.
string parval = _Xp.ParentValue("RODefaults", "Setpoint"); // get the parent value
if (parval.Equals(string.Empty)) // if the parent value is empty, then use the volian default
parval = "SP1";
if (parval.Equals(value))
_Xp["RODefaults", "Setpoint"] = string.Empty; // reset to parent value
else
_Xp["RODefaults", "Setpoint"] = value; // save selected value
OnPropertyChanged("RODefaults_setpointprefix");
}
}
[Category("Referenced Objects")]
[DisplayName("Default Graphics Prefix")]
[RefreshProperties(RefreshProperties.All)]
[Description("Graphics Prefix")]
public string RODefaults_graphicsprefix
{
get
{
string s = _Xp["RODefaults", "Graphics"];// get the saved value
//If there is no value to get, then get the parent value (a.k.a. default value).
if (s == string.Empty)
s = _Xp.ParentValue("RODefaults", "Graphics"); // get the parent value
// If there is no parent value, then use the volian default
if (s == string.Empty)
s = "IG1";// default to volian default
return s;
}
set
{
// if value being saved is same as the parent value, then clear the value (save blank). This will
// reset the data to use the parent value.
string parval = _Xp.ParentValue("RODefaults", "Graphics"); // get the parent value
if (parval.Equals(string.Empty)) // if the parent value is empty, then use the volian default
parval = "IG1";
if (parval.Equals(value))
_Xp["RODefaults", "Graphics"] = string.Empty; // reset to parent value
else
_Xp["RODefaults", "Graphics"] = value; // save selected value
OnPropertyChanged("RODefaults_graphicsprefix");
}
}
#endregion
#region PrintSettingsCategory // From curset.dat
[Category("Print Settings")]
//PROPGRID: Hide Printer
[Browsable(false)]
[DisplayName("Number of Copies")]
[RefreshProperties(RefreshProperties.All)]
[Description("Number of Copies")]
public int Print_NumCopies
{
get
{
string s = _Xp["PrintSettings", "numcopies"];
if (s == string.Empty) return 1;
return int.Parse(_Xp["PrintSettings", "numcopies"]);
}
set
{
_Xp["PrintSettings", "numcopies"] = value.ToString();
OnPropertyChanged("Print_NumCopies");
}
}
[Category("Print Settings")]
//PROPGRID: Hide Printer
[Browsable(false)]
[DisplayName("Printer")]
[RefreshProperties(RefreshProperties.All)]
[Description("Printer")]
public string Print_Printer
{
get
{
string s = _Xp["PrintSettings", "Printer"];
return s;
}
set
{
_Xp["PrintSettings", "Printer"] = value.ToString();
OnPropertyChanged("Print_Printer");
}
}
[Category("Print Settings")]
[DisplayName("Watermark")]
[RefreshProperties(RefreshProperties.All)]
[Description("Watermark")]
public PrintWatermark Print_Watermark
{
get
{
string s = _Xp["PrintSettings", "Watermark"];
//If there is no value to get, then get the parent value (a.k.a. default value).
if (s == string.Empty)
s = _Xp.ParentValue("PrintSettings", "Watermark"); // get the parent value
// If there is no parent value, then use the volian default
if (s == string.Empty)
return PrintWatermark.Draft;// default to volian default
return (PrintWatermark)int.Parse(s);
}
set
{
// if value being saved is same as the parent value, then clear the value (save blank). This will
// reset the data to use the parent value.
string parval = _Xp.ParentValue("PrintSettings", "Watermark"); // get the parent value
if (parval.Equals(string.Empty)) // if the parent value is empty, then use the volian default
parval = ((int)(PrintWatermark.Draft)).ToString();
if (parval.Equals(((int)value).ToString()))
_Xp["PrintSettings", "Watermark"] = string.Empty; // reset to parent value
else
_Xp["PrintSettings", "Watermark"] = ((int)value).ToString(); // save selected value
OnPropertyChanged("Print_Watermark");
}
}
// C2019-004: Allow user to define duplex blank page text at the docversion level
[Category("Print Settings")]
[DisplayName("Duplex Blank Page Text")]
[RefreshProperties(RefreshProperties.All)]
[Description("Duplex Blank Page Text")]
public string Print_DuplexBlankPageText
{
get
{
string s = _Xp["PrintSettings", "duplexblnktxt"];
//If there is no value to get, then get the parent value (a.k.a. default value).
if (s == string.Empty)
s = _Xp.ParentValue("PrintSettings", "duplexblnktxt"); // get the parent value
// If there is no parent value, then use the volian default
if (s == string.Empty)
s = "";// default to volian default
return s;
}
set
{
// if value being saved is same as the parent value, then clear the value (save blank). This will
// reset the data to use the parent value.
string parval = _Xp.ParentValue("PrintSettings", "duplexblnktxt"); // get the parent value
if (parval.Equals(string.Empty)) // if the parent value is empty, then use the volian default
parval = "";
if (parval.Equals(value))
_Xp["PrintSettings", "duplexblnktxt"] = string.Empty; // reset to parent value
else
_Xp["PrintSettings", "duplexblnktxt"] = value; // save selected value
OnPropertyChanged("Print_DuplexBlankPageText");
}
}
[Category("Format Settings")]
[DisplayName("Change Bars")]
[RefreshProperties(RefreshProperties.All)]
[Description("Change Bar Use")]
public PrintChangeBar Print_ChangeBar
{
get
{
string s = _Xp["PrintSettings", "ChangeBar"];
//If there is no value to get, then get the parent value (a.k.a. default value).
if (s == string.Empty)
s = _Xp.ParentValue("PrintSettings", "ChangeBar"); // get the parent value
// If there is no parent value, then use the volian default
if (s == string.Empty)
return PrintChangeBar.SelectBeforePrinting;// default to volian default
return (PrintChangeBar)int.Parse(s);
}
set
{
if (_SaveChangesToDocVersionConfig)
{
// if value being saved is same as the parent value, then clear the value (save blank). This will
// reset the data to use the parent value.
string parval = _Xp.ParentValue("PrintSettings", "ChangeBar"); // get the parent value
if (parval.Equals(string.Empty)) // if the parent value is empty, then use the volian default
parval = ((int)(PrintChangeBar.SelectBeforePrinting)).ToString();
if (parval.Equals(((int)value).ToString()))
_Xp["PrintSettings", "ChangeBar"] = string.Empty; // reset to parent value
else
_Xp["PrintSettings", "ChangeBar"] = ((int)value).ToString(); // save selected value
OnPropertyChanged("Print_ChangeBar");
}
}
}
[Category("Format Settings")]
[DisplayName("Change Bar Position")]
[RefreshProperties(RefreshProperties.All)]
[Description("User Specified Change Bar Location")]
public PrintChangeBarLoc Print_ChangeBarLoc
{
get
{
string s = _Xp["PrintSettings", "ChangeBarLoc"];
//If there is no value to get, then get the parent value (a.k.a. default value).
if (s == string.Empty)
s = _Xp.ParentValue("PrintSettings", "ChangeBarLoc"); // get the parent value
// If there is no parent value, then use the volian default
if (s == string.Empty)
return PrintChangeBarLoc.WithText;// default to volian default
return (PrintChangeBarLoc)int.Parse(s);
}
set
{
if (_SaveChangesToDocVersionConfig)
{
// if value being saved is same as the parent value, then clear the value (save blank). This will
// reset the data to use the parent value.
string parval = _Xp.ParentValue("PrintSettings", "ChangeBarLoc"); // get the parent value
if (parval.Equals(string.Empty)) // if the parent value is empty, then use the volian default
parval = ((int)(PrintChangeBarLoc.WithText)).ToString();
if (parval.Equals(((int)value).ToString()))
_Xp["PrintSettings", "ChangeBarLoc"] = string.Empty; // reset to parent value
else
_Xp["PrintSettings", "ChangeBarLoc"] = ((int)value).ToString(); // save selected value
OnPropertyChanged("Print_ChangeBarLoc");
}
}
}
[Category("Format Settings")]
[DisplayName("Change Bar Text Type")]
[Description("Change Bar Text")]
public PrintChangeBarText Print_ChangeBarText
{
get
{
string s = _Xp["PrintSettings", "ChangeBarText"];
//If there is no value to get, then get the parent value (a.k.a. default value).
if (s == string.Empty)
s = _Xp.ParentValue("PrintSettings", "ChangeBarText"); // get the parent value
// If there is no parent value, then use the volian default
if (s == string.Empty)
return PrintChangeBarText.DateChgID;// default to volian default
return (PrintChangeBarText)int.Parse(s);
}
set
{
if (_SaveChangesToDocVersionConfig)
{
// if value being saved is same as the parent value, then clear the value (save blank). This will
// reset the data to use the parent value.
string parval = _Xp.ParentValue("PrintSettings", "ChangeBarText"); // get the parent value
if (parval.Equals(string.Empty)) // if the parent value is empty, then use the volian default
parval = ((int)(PrintChangeBarText.DateChgID)).ToString();
if (parval.Equals(((int)value).ToString()))
_Xp["PrintSettings", "ChangeBarText"] = string.Empty; // reset to parent value
else
_Xp["PrintSettings", "ChangeBarText"] = ((int)value).ToString(); // save selected value
OnPropertyChanged("Print_ChangeBarText");
}
}
}
[Category("Format Settings")]
[DisplayName("Custom Change Bar Message Line One")]
[RefreshProperties(RefreshProperties.All)]
[Description("User Change Bar Message1")]
public string Print_UserCBMess1
{
get
{
string s = _Xp["PrintSettings", "usercbmess1"];// get the saved value
//If there is no value to get, then get the parent value (a.k.a. default value).
if (s == string.Empty)
s = _Xp.ParentValue("PrintSettings", "usercbmess1"); // get the parent value
// If there is no parent value, then use the volian default
if (s == string.Empty)
return "";// default to volian default
return s;
}
set
{
if (_SaveChangesToDocVersionConfig)
{
// if value being saved is same as the parent value, then clear the value (save blank). This will
// reset the data to use the parent value.
string parval = _Xp.ParentValue("PrintSettings", "usercbmess1"); // get the parent value
if (parval.Equals(string.Empty)) // if the parent value is empty, then use the volian default
parval = "";
if (parval.Equals(value))
_Xp["PrintSettings", "usercbmess1"] = string.Empty; // reset to parent value
else
_Xp["PrintSettings", "usercbmess1"] = value; // save selected value
OnPropertyChanged("Print_UserCBMess1");
}
}
}
[Category("Format Settings")]
[DisplayName("Custom Change Bar Message Line Two")]
[RefreshProperties(RefreshProperties.All)]
[Description("User Change Bar Message2")]
public string Print_UserCBMess2
{
get
{
string s = _Xp["PrintSettings", "usercbmess2"];// get the saved value
//If there is no value to get, then get the parent value (a.k.a. default value).
if (s == string.Empty)
s = _Xp.ParentValue("PrintSettings", "usercbmess2"); // get the parent value
// If there is no parent value, then use the volian default
if (s == string.Empty)
return "";// default to volian default
return s;
}
set
{
if (_SaveChangesToDocVersionConfig)
{
// if value being saved is same as the parent value, then clear the value (save blank). This will
// reset the data to use the parent value.
string parval = _Xp.ParentValue("PrintSettings", "usercbmess2"); // get the parent value
if (parval.Equals(string.Empty)) // if the parent value is empty, then use the volian default
parval = "";
if (parval.Equals(value))
_Xp["PrintSettings", "usercbmess2"] = string.Empty; // reset to parent value
else
_Xp["PrintSettings", "usercbmess2"] = value; // save selected value
OnPropertyChanged("Print_UserCBMess2");
}
}
}
[Category("Print Settings")]
//PROPGRID: Hide User Format
[Browsable(false)]
[DisplayName("User Format")]
[RefreshProperties(RefreshProperties.All)]
[Description("User Format")]
public string Print_UserFormat
{
get
{
return _Xp["PrintSettings", "userformat"];
}
set
{
_Xp["PrintSettings", "userformat"] = value;
OnPropertyChanged("Print_UserFormat");
}
}
//public enum PrintPagination : int
//{
// Free = 0, Fixed, Auto
//}
[Category("Print Settings")]
[DisplayName("Pagination")]
[RefreshProperties(RefreshProperties.All)]
[Description("Pagination")]
public PrintPagination Print_Pagination
{
get
{
string s = _Xp["PrintSettings", "Pagination"];
//If there is no value to get, then get the parent value (a.k.a. default value).
if (s == string.Empty)
s = _Xp.ParentValue("PrintSettings", "Pagination"); // get the parent value
// If there is no parent value, then use the volian default
if (s == string.Empty)
return PrintPagination.Auto;// default to volian default
return (PrintPagination)int.Parse(s);
}
set
{
// if value being saved is same as the parent value, then clear the value (save blank). This will
// reset the data to use the parent value.
string parval = _Xp.ParentValue("PrintSettings", "Pagination"); // get the parent value
if (parval.Equals(string.Empty)) // if the parent value is empty, then use the volian default
parval = ((int)(PrintPagination.Auto)).ToString();
if (parval.Equals(((int)value).ToString()))
_Xp["PrintSettings", "Pagination"] = string.Empty; // reset to parent value
else
_Xp["PrintSettings", "Pagination"] = ((int)value).ToString(); // save selected value
OnPropertyChanged("Print_Pagination");
}
}
[Category("Print Settings")]
[DisplayName("PDFLocation")]
[RefreshProperties(RefreshProperties.All)]
[Description("PDF Location")]
public string Print_PDFLocation
{
get
{
return _Xp["PrintSettings", "PDFLocation"];
}
set
{
if (_SaveChangesToDocVersionConfig)
{
_Xp["PrintSettings", "PDFLocation"] = value; // save selected value
OnPropertyChanged("Print_PDFLocation");
}
}
}
[Category("Print Settings")]
[DisplayName("PDFFilePrefix")]
[RefreshProperties(RefreshProperties.All)]
[Description("PDF File Prefix")]
public string Print_PDFFilePrefix
{
get
{
return _Xp["PrintSettings", "PDFFilePrefix"];
}
set
{
if (_SaveChangesToDocVersionConfig)
{
_Xp["PrintSettings", "PDFFilePrefix"] = value; // save selected value
OnPropertyChanged("Print_PDFFilePrefix");
}
}
}
[Category("Print Settings")]
[DisplayName("PDFFileSuffix")]
[RefreshProperties(RefreshProperties.All)]
[Description("PDF File Suffix")]
public string Print_PDFFileSuffix
{
get
{
return _Xp["PrintSettings", "PDFFileSuffix"];
}
set
{
if (_SaveChangesToDocVersionConfig)
{
_Xp["PrintSettings", "PDFFileSuffix"] = value; // save selected value
OnPropertyChanged("Print_PDFFileSuffix");
}
}
}
// C2018-033 the Prefix date/time format is in the config
[Category("Print Settings")]
[DisplayName("PDFdtFilePrefix")]
[RefreshProperties(RefreshProperties.All)]
[Description("PDF File Date Time Prefix")]
public PDFDTPrefix Print_PDFdtFilePrefix
{
get
{
string s = _Xp["PrintSettings", "PDFdtFilePrefix"];
//If there is no value to get, then get the parent value (a.k.a. default value).
if (s == string.Empty)
s = _Xp.ParentValue("PrintSettings", "PDFdtFilePrefix"); // get the parent value
// If there is no parent value, then use the volian default
if (s == string.Empty)
return PDFDTPrefix.None;// default to volian default
return (PDFDTPrefix)int.Parse(s);
}
set
{
// if value being saved is same as the parent value, then clear the value (save blank). This will
// reset the data to use the parent value.
string parval = _Xp.ParentValue("PrintSettings", "PDFdtFilePrefix"); // get the parent value
if (parval.Equals(string.Empty)) // if the parent value is empty, then use the volian default
parval = ((int)(PDFDTPrefix.None)).ToString();
if (parval.Equals(((int)value).ToString()))
_Xp["PrintSettings", "PDFdtFilePrefix"] = string.Empty; // reset to parent value
else
_Xp["PrintSettings", "PDFdtFilePrefix"] = ((int)value).ToString(); // save selected value
OnPropertyChanged("Print_PDFdtFilePrefix");
}
}
// C2018-033 the Suffix date/time format is in the config
[Category("Print Settings")]
[DisplayName("PDFdtFileSuffix")]
[RefreshProperties(RefreshProperties.All)]
[Description("PDF File Date Time Suffix")]
public PDFDTSuffix Print_PDFdtFileSuffix
{
get
{
string s = _Xp["PrintSettings", "PDFdtFileSuffix"];
//If there is no value to get, then get the parent value (a.k.a. default value).
if (s == string.Empty)
s = _Xp.ParentValue("PrintSettings", "PDFdtFileSuffix"); // get the parent value
// If there is no parent value, then use the volian default
if (s == string.Empty)
return PDFDTSuffix.None;// default to volian default
return (PDFDTSuffix)int.Parse(s);
}
set
{
// if value being saved is same as the parent value, then clear the value (save blank). This will
// reset the data to use the parent value.
string parval = _Xp.ParentValue("PrintSettings", "PDFdtFileSuffix"); // get the parent value
if (parval.Equals(string.Empty)) // if the parent value is empty, then use the volian default
parval = ((int)(PDFDTSuffix.None)).ToString();
if (parval.Equals(((int)value).ToString()))
_Xp["PrintSettings", "PDFdtFileSuffix"] = string.Empty; // reset to parent value
else
_Xp["PrintSettings", "PDFdtFileSuffix"] = ((int)value).ToString(); // save selected value
OnPropertyChanged("Print_PDFdtFileSuffix");
}
}
[Category("Print Settings")]
[DisplayName("AlwaysOverwritePDF")]
[RefreshProperties(RefreshProperties.All)]
[Description("Always Overwrite PDF File")]
public bool Print_AlwaysOverwritePDF
{
get
{
string s = _Xp["PrintSettings", "AlwaysOverwritePDF"];
// If there is no value, then default to true
if (s == string.Empty)
s = "true"; // default
return bool.Parse(s);
}
set
{
if (_SaveChangesToDocVersionConfig)
{
_Xp["PrintSettings", "AlwaysOverwritePDF"] = value.ToString();
OnPropertyChanged("Print_AlwaysOverwritePDF");
}
}
}
[Category("Print Settings")]
[DisplayName("AlwaysViewPDFAfterCreate")]
[RefreshProperties(RefreshProperties.All)]
[Description("Always View PDF File After Create")]
public bool Print_AlwaysViewPDFAfterCreate
{
get
{
string s = _Xp["PrintSettings", "AlwaysViewPDFAfterCreate"];
// If there is no value, then default to true
if (s == string.Empty)
s = "true"; // default
return bool.Parse(s);
}
set
{
if (_SaveChangesToDocVersionConfig)
{
_Xp["PrintSettings", "AlwaysViewPDFAfterCreate"] = value.ToString();
OnPropertyChanged("Print_AlwaysViewPDFAfterCreate");
}
}
}
[Category("Print Settings")]
[DisplayName("AddBlankPagesWhenUsingDuplexFoldouts")]
[RefreshProperties(RefreshProperties.All)]
[Description("Add Blank Pages in Procedures that Print Duplex Foldouts")]
public bool Print_AddBlankPagesWhenUsingDuplexFoldouts
{
get
{
string s = _Xp["PrintSettings", "AddBlankPagesWhenUsingDuplexFoldouts"];
// If there is no value, then default to true
if (s == string.Empty)
s = "false"; // default
return bool.Parse(s);
}
set
{
if (_SaveChangesToDocVersionConfig)
{
_ = _Xp.ParentValue("PrintSettings", "AddBlankPagesWhenUsingDuplexFoldouts");
_Xp["PrintSettings", "AddBlankPagesWhenUsingDuplexFoldouts"] = value.ToString();
OnPropertyChanged("Print_AddBlankPagesWhenUsingDuplexFoldouts");
}
}
}
[Category("Print Settings")]
[DisplayName("UnitNumberForPageList")]
[RefreshProperties(RefreshProperties.All)]
[Description("For Printing of Unit 1, 2 or 1 & 2 on cover page and in header of other pages")]
public string Print_UnitNumberForPageList
{
get
{
string s = _Xp["PrintSettings", "UnitNumberForPageList"];
// If there is no value, then default to "1", i.e. Unit 1.
if (s == string.Empty) s = "1"; // default
return s;
}
set
{
if (_SaveChangesToDocVersionConfig)
{
_ = _Xp.ParentValue("PrintSettings", "UnitNumberForPageList");
_Xp["PrintSettings", "UnitNumberForPageList"] = value;
OnPropertyChanged("Print_UnitNumberForPageList");
}
}
}
[Category("Print Settings")]
[DisplayName("PhoneList")]
[RefreshProperties(RefreshProperties.All)]
[Description("Phone List")]
public string Print_PhoneList
{
get
{
return _Xp["PrintSettings", "PhoneList"];
}
set
{
if (_SaveChangesToDocVersionConfig)
{
_Xp["PrintSettings", "PhoneList"] = value; // save selected value
OnPropertyChanged("Print_PhoneList");
}
}
}
#region MergedPdfs
[Category("Print Settings")]
[DisplayName("MergedPdfPageOf")]
[RefreshProperties(RefreshProperties.All)]
[Description("Merged Pdf Page Number Format")]
public MergedPdfsPageOf Print_MergedPdfsPageOf
{
get
{
string s = _Xp["PrintSettings", "MergedPdfPageOf"];
if (s == string.Empty)
return MergedPdfsPageOf.PageOf;
return (MergedPdfsPageOf)int.Parse(s);
}
set
{
if (_SaveChangesToDocVersionConfig)
{
string s = _Xp["PrintSettings", "MergedPdfPageOf"]; // get the original value to see if a change
MergedPdfsPageOf originalpo = (s==string.Empty)?MergedPdfsPageOf.PageOf:(MergedPdfsPageOf)int.Parse(s);
if (originalpo == value) return; // no change.
_Xp["PrintSettings", "MergedPdfPageOf"] = ((int)value).ToString(); // save selected value
OnPropertyChanged("Print_MergedPdfPageOf");
}
}
}
[Category("Print Settings")]
[DisplayName("MergedPdfsPageNumFormatOther")]
[RefreshProperties(RefreshProperties.All)]
[Description("Merged Pdfs Page Num Format Other")]
public string Print_MergedPdfsPageNumFormatOther
{
get
{
string s = _Xp["PrintSettings", "MergedPdfsPageNumFormatOther"];
return s;
}
set
{
_Xp["PrintSettings", "MergedPdfsPageNumFormatOther"] = value.ToString();
OnPropertyChanged("Print_MergedPdfsPageNumFormatOther");
}
}
[Category("Print Settings")]
[DisplayName("MergedPdfsPageNumFont")]
[RefreshProperties(RefreshProperties.All)]
[Description("Merged Pdfs Page Num Format Font")]
public string Print_MergedPdfsPageNumFont
{
get
{
// if this isn't set, then it will be empty. Empty will flag for code that prints page number to use working draft's format's font
string s = _Xp["PrintSettings", "MergedPdfsPageNumFont"];
return s;
}
set
{
if (value == null) return;
string origstr = _Xp["PrintSettings", "MergedPdfsPageNumFont"]; // get the original value to see if a change
if (origstr == value) return;
_Xp["PrintSettings", "MergedPdfsPageNumFont"] = value.ToString();
OnPropertyChanged("MergedPdfsPageNumFont");
}
}
[Category("Print Settings")]
[DisplayName("MergedPdfsPageNumFontSize")]
[RefreshProperties(RefreshProperties.All)]
[Description("Merged Pdfs Page Num Format Font Size")]
public string Print_MergedPdfsPageNumFontSize
{
get
{
// if this isn't set, then it will be empty. Empty will flag for code that prints page number to use working draft's format's font
string s = _Xp["PrintSettings", "MergedPdfsPageNumFontSize"];
return s;
}
set
{
string origstr = _Xp["PrintSettings", "MergedPdfsPageNumFontSize"]; // get the original value to see if a change
if (origstr == value) return;
_Xp["PrintSettings", "MergedPdfsPageNumFontSize"] = value.ToString();
OnPropertyChanged("MergedPdfsPageNumFontSize");
}
}
[Category("Print Settings")]
[DisplayName("MergedPdfsPageNumLocX")]
[RefreshProperties(RefreshProperties.All)]
[Description("Merged Pdfs Page Num Loc X")]
public float? Print_MergedPdfsPageNumLocX
{
get
{
string s = _Xp["PrintSettings", "MergedPdfsPageNumLocX"];
if (s == string.Empty) return 0.5f;
float test;
try
{
test = float.Parse(s);
}
catch (Exception)
{
return 0.5f;
}
return test;
}
set
{
string s = _Xp["PrintSettings", "MergedPdfsPageNumLocX"];
float orig = (s == string.Empty) ? 0.5f : float.Parse(s);
if (orig == value) return;
_Xp["PrintSettings", "MergedPdfsPageNumLocX"] = value.ToString();
OnPropertyChanged("MergedPdfsPageNumLocX");
}
}
[Category("Print Settings")]
[DisplayName("MergedPdfsPageNumLocY")]
[RefreshProperties(RefreshProperties.All)]
[Description("Merged Pdfs Page Num Loc Y")]
public float? Print_MergedPdfsPageNumLocY
{
get
{
string s = _Xp["PrintSettings", "MergedPdfsPageNumLocY"];
if (s == string.Empty) return 0.5f;
float test;
try
{
test = float.Parse(s);
}
catch (Exception)
{
return 0.5f;
}
return test;
}
set
{
string s = _Xp["PrintSettings", "MergedPdfsPageNumLocY"];
float orig = (s == string.Empty) ? 0.5f : float.Parse(s);
if (orig == value) return;
_Xp["PrintSettings", "MergedPdfsPageNumLocY"] = value.ToString();
OnPropertyChanged("MergedPdfsPageNumLocY");
}
}
[Category("Print Settings")]
[DisplayName("MergedPdfsPageNumCorner")]
[RefreshProperties(RefreshProperties.All)]
[Description("Merged Pdf Page Number Corner")]
public MergedPdfsPageNumCorner Print_MergedPdfsPageNumCorner
{
get
{
string s = _Xp["PrintSettings", "MergedPdfsPageNumCorner"];
if (s == string.Empty)
return MergedPdfsPageNumCorner.TopRight;
return (MergedPdfsPageNumCorner)int.Parse(s);
}
set
{
if (_SaveChangesToDocVersionConfig)
{
string s = _Xp["PrintSettings", "MergedPdfsPageNumCorner"]; // get the original value to see if a change
MergedPdfsPageNumCorner original = (s == string.Empty) ? MergedPdfsPageNumCorner.TopRight : (MergedPdfsPageNumCorner)int.Parse(s);
if (original == value) return; // no change.
_Xp["PrintSettings", "MergedPdfsPageNumCorner"] = ((int)value).ToString(); // save selected value
OnPropertyChanged("Print_MergedPdfsPageNumCorner");
}
}
}
// C2021-047: Allow for setting of Merged Pdf Landscape Page Number Location (X, Y & corner)
[Category("Print Settings")]
[DisplayName("MergedPdfsLandPageNumLocX")]
[RefreshProperties(RefreshProperties.All)]
[Description("Merged Pdfs Landscape Page Num Loc X")]
public float? Print_MergedPdfsLandPageNumLocX
{
get
{
string s = _Xp["PrintSettings", "MergedPdfsLandPageNumLocX"];
if (s == string.Empty) return Print_MergedPdfsPageNumLocX;
float test;
try
{
test = float.Parse(s);
}
catch (Exception)
{
return 0.5f;
}
return test;
}
set
{
string s = _Xp["PrintSettings", "MergedPdfsLandPageNumLocX"];
float orig = (s == string.Empty) ? (float) Print_MergedPdfsPageNumLocX : float.Parse(s);
if (orig == value) return;
_Xp["PrintSettings", "MergedPdfsLandPageNumLocX"] = value.ToString();
OnPropertyChanged("MergedPdfsLandPageNumLocX");
}
}
[Category("Print Settings")]
[DisplayName("MergedPdfsLandPageNumLocY")]
[RefreshProperties(RefreshProperties.All)]
[Description("Merged Pdfs Landscape Page Num Loc Y")]
public float? Print_MergedPdfsLandPageNumLocY
{
get
{
string s = _Xp["PrintSettings", "MergedPdfsLandPageNumLocY"];
if (s == string.Empty) return Print_MergedPdfsPageNumLocY;
float test;
try
{
test = float.Parse(s);
}
catch (Exception)
{
return 0.5f;
}
return test;
}
set
{
string s = _Xp["PrintSettings", "MergedPdfsLandPageNumLocY"];
float orig = (s == string.Empty) ? (float)Print_MergedPdfsPageNumLocY : float.Parse(s);
if (orig == value) return;
_Xp["PrintSettings", "MergedPdfsLandPageNumLocY"] = value.ToString();
OnPropertyChanged("MergedPdfsLandPageNumLocY");
}
}
[Category("Print Settings")]
[DisplayName("MergedPdfsLandPageNumCorner")]
[RefreshProperties(RefreshProperties.All)]
[Description("Merged Pdf Landscape Page Number Corner")]
public MergedPdfsPageNumCorner Print_MergedPdfsLandPageNumCorner
{
get
{
string s = _Xp["PrintSettings", "MergedPdfsLandPageNumCorner"];
if (s == string.Empty)
return Print_MergedPdfsPageNumCorner;
return (MergedPdfsPageNumCorner)int.Parse(s);
}
set
{
if (_SaveChangesToDocVersionConfig)
{
string s = _Xp["PrintSettings", "MergedPdfsLandPageNumCorner"]; // get the original value to see if a change
MergedPdfsPageNumCorner original = (s == string.Empty) ? Print_MergedPdfsPageNumCorner : (MergedPdfsPageNumCorner)int.Parse(s);
if (original == value) return; // no change.
_Xp["PrintSettings", "MergedPdfsLandPageNumCorner"] = ((int)value).ToString(); // save selected value
OnPropertyChanged("Print_MergedPdfsLandPageNumCorner");
}
}
}
[Category("Print Settings")]
[DisplayName("MergedPdfsViewAfter")]
[RefreshProperties(RefreshProperties.All)]
[Description("Merged Pdf View After Print")]
public bool Print_MergedPdfsViewAfter
{
get
{
string s = _Xp["PrintSettings", "MergedPdfsViewAfter"];
if (s == string.Empty)
return false;
return bool.Parse(s);
}
set
{
if (_SaveChangesToDocVersionConfig)
{
string s = _Xp["PrintSettings", "MergedPdfsViewAfter"]; // get the original value to see if a change
bool original = s != string.Empty && bool.Parse(s);
if (original == value) return; // no change.
_Xp["PrintSettings", "MergedPdfsViewAfter"] = ((bool)value).ToString(); // save selected value
OnPropertyChanged("Print_MergedPdfsViewAfter");
}
}
}
#endregion
#endregion
#region Unit // From PROC.INI
//MultiUnitCount
[Category("Unit")]
[DisplayName("Unit Count")]
[RefreshProperties(RefreshProperties.All)]
[Description("Number of Units")]
public int Unit_Count
{
get
{
return _Xp.XmlContents.SelectNodes("//Slave").Count;
}
}
private int _SelectedSlave = 0;
//[Browsable(false)]
public int SelectedSlave
{
get { return _SelectedSlave; }
set
{
if (_SelectedSlave == value) return;
_SelectedSlave = value;
// For Debugging:
// if(_DocVersion != null)
// Volian.Base.Library.vlnStackTrace.ShowStackLocal("SelectedSlave {0} = {1}", _DocVersion.MyDocVersionUnique, _SelectedSlave.ToString());
// else
// Volian.Base.Library.vlnStackTrace.ShowStackLocal("SelectedSlaveInfo {0} = {1}", _DocVersionInfo.MyDocVersionInfoUnique, _SelectedSlave.ToString());
}
}
[Category("Unit")]
[DisplayName("Unit Number")]
[RefreshProperties(RefreshProperties.All)]
[Description("Assigned Unit Number")]
public string Unit_Number
{
get
{
string s = GetCombinedSlaveValue("Number") ?? _Xp["Unit", "Number"];// get the saved value
if (SelectedSlave > 0)
s = _Xp[$"Slave[@index='{SelectedSlave}']", "Number"];
return s;
}
set
{
if (SelectedSlave > 0)
_Xp[$"Slave[@index='{SelectedSlave}']", "Number"] = value; // save selected value
else
_Xp["Unit", "Number"] = value;
OnPropertyChanged("Unit_Number");
}
}
[Browsable(false)]
public string Old_Index
{
get
{
string s = "";
if (SelectedSlave > 0)
s = _Xp[$"Slave[@index='{SelectedSlave}']", "oldindex"];
return s;
}
}
[Category("Unit")]
[DisplayName("Other Unit Number")]
[RefreshProperties(RefreshProperties.All)]
[Description("Assigned Other Unit Number")]
public string Other_Unit_Number
{
get
{
string s = GetCombinedSlaveValue("OtherNumber") ?? _Xp["Unit", "OtherNumber"];// get the saved value
if (SelectedSlave > 0)
s = _Xp[$"Slave[@index='{SelectedSlave}']", "OtherNumber"];
return s;
}
set
{
if (SelectedSlave > 0)
_Xp[$"Slave[@index='{SelectedSlave}']", "OtherNumber"] = value; // save selected value
else
_Xp["Unit", "OtherNumber"] = value;
OnPropertyChanged("Other_Unit_Number");
}
}
[Category("Unit")]
[DisplayName("Unit Name")]
[RefreshProperties(RefreshProperties.All)]
[Description("Assigned Unit Name")]
public string Unit_Name
{
get
{
string s = GetCombinedSlaveValue("Name") ?? _Xp["Unit", "Name"];// get the saved value
if (SelectedSlave > 0)
s = _Xp[$"Slave[@index='{SelectedSlave}']", "Name"];
return s;
}
set
{
if (SelectedSlave > 0)
_Xp[$"Slave[@index='{SelectedSlave}']", "Name"] = value; // save selected value
else
_Xp["Unit", "Name"] = value;
OnPropertyChanged("Unit_Name");
}
}
[Category("Unit")]
[DisplayName("Other Unit Name")]
[RefreshProperties(RefreshProperties.All)]
[Description("Assigned Other Unit Name")]
public string Other_Unit_Name
{
get
{
string s = GetCombinedSlaveValue("OtherName") ?? _Xp["Unit", "OtherName"];// get the saved value
if (SelectedSlave > 0)
s = _Xp[$"Slave[@index='{SelectedSlave}']", "OtherName"];
return s;
}
set
{
if (SelectedSlave > 0)
_Xp[$"Slave[@index='{SelectedSlave}']", "OtherName"] = value; // save selected value
else
_Xp["Unit", "OtherName"] = value;
OnPropertyChanged("Other_Unit_Name");
}
}
[Category("Unit")]
[DisplayName("Unit Text")]
[RefreshProperties(RefreshProperties.All)]
[Description("Assigned Unit Text")]
public string Unit_Text
{
get
{
string s = GetCombinedSlaveValue("Text") ?? _Xp["Unit", "Text"];// get the saved value
if (SelectedSlave > 0)
s = _Xp[$"Slave[@index='{SelectedSlave}']", "Text"];
return s;
}
set
{
if (SelectedSlave > 0)
_Xp[$"Slave[@index='{SelectedSlave}']", "Text"] = value; // save selected value
else
_Xp["Unit", "Text"] = value;
OnPropertyChanged("Unit_Text");
}
}
[Category("Unit")]
[DisplayName("Other Unit Text")]
[RefreshProperties(RefreshProperties.All)]
[Description("Assigned Other Unit Text")]
public string Other_Unit_Text
{
get
{
string s = GetCombinedSlaveValue("OtherText") ?? _Xp["Unit", "OtherText"];// get the saved value
if (SelectedSlave > 0)
s = _Xp[$"Slave[@index='{SelectedSlave}']", "OtherText"];
return s;
}
set
{
if (SelectedSlave > 0)
_Xp[$"Slave[@index='{SelectedSlave}']", "OtherText"] = value; // save selected value
else
_Xp["Unit", "OtherText"] = value;
OnPropertyChanged("Other_Unit_Text");
}
}
[Category("Unit")]
[DisplayName("Unit ID")]
[RefreshProperties(RefreshProperties.All)]
[Description("Assigned Unit ID")]
public string Unit_ID
{
get
{
string s = GetCombinedSlaveValue("ID") ?? _Xp["Unit", "ID"];// get the saved value
if (SelectedSlave > 0)
s = _Xp[$"Slave[@index='{SelectedSlave}']", "ID"];
return s;
}
set
{
if (SelectedSlave > 0)
_Xp[$"Slave[@index='{SelectedSlave}']", "ID"] = value; // save selected value
else
_Xp["Unit", "ID"] = value;
OnPropertyChanged("Unit_ID");
}
}
[Category("Unit")]
[DisplayName("Other Unit ID")]
[RefreshProperties(RefreshProperties.All)]
[Description("Assigned Other Unit ID")]
public string Other_Unit_ID
{
get
{
string s = GetCombinedSlaveValue("OtherID") ?? _Xp["Unit", "OtherID"];// get the saved value
if (SelectedSlave > 0)
s = _Xp[$"Slave[@index='{SelectedSlave}']", "OtherID"];
return s;
}
set
{
if (SelectedSlave > 0)
_Xp[$"Slave[@index='{SelectedSlave}']", "OtherID"] = value; // save selected value
else
_Xp["Unit", "OtherID"] = value;
OnPropertyChanged("Other_Unit_ID");
}
}
[Category("Unit")]
[DisplayName("Unit Specific Procedure Number")]
[RefreshProperties(RefreshProperties.All)]
[Description("Assigned Unit Specific Procedure Number")]
public string Unit_ProcedureNumber
{
get
{
string s = GetCombinedSlaveValue("ProcedureNumber", null) ?? _Xp["Unit", "ProcedureNumber"];// get the saved value
if (SelectedSlave > 0)
s = _Xp[$"Slave[@index='{SelectedSlave}']", "ProcedureNumber"];
return s;
}
set
{
if (SelectedSlave > 0)
_Xp[$"Slave[@index='{SelectedSlave}']", "ProcedureNumber"] = value; // save selected value
else
_Xp["Unit", "ProcedureNumber"] = value;
OnPropertyChanged("Unit_ProcedureNumber");
}
}
[Category("Unit")]
[DisplayName("Unit Specific Procedure Set Name")]
[RefreshProperties(RefreshProperties.All)]
[Description("Assigned Unit Specific Procedure Set Name")]
public string Unit_ProcedureSetName
{
get
{
string s = GetCombinedSlaveValue("SetName", null) ?? _Xp["ProcedureSet", "Name"];// get the saved value
if (SelectedSlave > 0)
s = _Xp[$"Slave[@index='{SelectedSlave}']", "SetName"];
return s;
}
set
{
if (SelectedSlave > 0)
_Xp[$"Slave[@index='{SelectedSlave}']", "SetName"] = value; // save selected value
else
_Xp["ProcedureSet", "Name"] = value;
OnPropertyChanged("Unit_ProcedureSetName");
}
}
[Category("Unit")]
[DisplayName("Unit Specific Procedure Set ID")]
[RefreshProperties(RefreshProperties.All)]
[Description("Assigned Unit Specific Procedure Set ID")]
public string Unit_ProcedureSetID
{
get
{
string s = GetCombinedSlaveValue("SetID", null) ?? _Xp["ProcedureSet", "ID"];// get the saved value
if (SelectedSlave > 0)
s = _Xp[$"Slave[@index='{SelectedSlave}']", "SetID"];
return s;
}
set
{
if (SelectedSlave > 0)
_Xp[$"Slave[@index='{SelectedSlave}']", "SetID"] = value; // save selected value
else
_Xp["ProcedureSet", "ID"] = value;
OnPropertyChanged("Unit_ProcedureSetID");
}
}
#endregion
#region Slave
public void AddSlave(string xml)
{
XmlDocument xd = new XmlDocument();
xd.LoadXml(xml);
XmlNode pn = _Xp.XmlContents.SelectSingleNode("//Slaves");
XmlNode nn = _Xp.XmlContents.ImportNode(xd.DocumentElement, true);
if (pn == null)
{
pn = _Xp.XmlContents.CreateElement("Slaves");
_Xp.XmlContents.DocumentElement.AppendChild(pn);
}
pn.AppendChild(nn);
}
public void RemoveSlave(int index)
{
XmlNode dd = _Xp.XmlContents.SelectSingleNode($"//Slave[@index='{index}']");
dd?.ParentNode?.RemoveChild(dd);
}
public int MaxSlaveIndex
{
get
{
int k = 0;
XmlNodeList nl = _Xp.XmlContents.SelectNodes("//Slave/@index");
foreach (XmlNode n in nl)
k = Math.Max(k, int.Parse(n.InnerText));
return k;
}
}
//added by jcb to fix master issue byron/braidwood
private string GetCombinedSlaveValue(string item, string defaultValue)
{
if (MaxSlaveIndex > 0)
{
string s = "";
string sep = "";
XmlNodeList nl = _Xp.XmlContents.SelectNodes("//Slave");
foreach (XmlNode nd in nl)
{
string ss = nd.Attributes.GetNamedItem("index").InnerText;
s += $"{sep}{_Xp[$"Slave[@index='{ss}']", item]}";
sep = ",";
}
return s;
}
return defaultValue;
}
private string GetCombinedSlaveValue(string item) => GetCombinedSlaveValue(item, "0");
//end added by jcb to fix master issue byron/braidwood
#endregion
#region Enhanced
// C2019-045: For enhanced procedures, allow modifications of number & text.
[Category("Enhanced Settings")]
[Browsable(false)]
[DisplayName("AllowMods")]
[RefreshProperties(RefreshProperties.All)]
[Description("Allow Modifications of Number and Text")]
public bool Enhanced_AllowMods
{
get
{
string s = _Xp["Enhanced", "allowmods"];
if (s == string.Empty) return false; // empty is false
return bool.Parse(s);
}
set
{
if (_SaveChangesToDocVersionConfig)
{
_Xp["Enhanced", "allowmods"] = value.ToString();
OnPropertyChanged("Enhanced_AllowMods");
}
}
}
#endregion
}
}