diff --git a/PROMS/VEPROMS.CSLA.Library/Config/AnnotationConfig.cs b/PROMS/VEPROMS.CSLA.Library/Config/AnnotationConfig.cs index feb430cd..834a7233 100644 --- a/PROMS/VEPROMS.CSLA.Library/Config/AnnotationConfig.cs +++ b/PROMS/VEPROMS.CSLA.Library/Config/AnnotationConfig.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using System.ComponentModel; namespace VEPROMS.CSLA.Library @@ -11,35 +9,23 @@ namespace VEPROMS.CSLA.Library [TypeConverter(typeof(ExpandableObjectConverter))] public class AnnotationConfig : ConfigDynamicTypeDescriptor, INotifyPropertyChanged { - private XMLProperties _Xp; - private XMLProperties Xp - { - get { return _Xp; } - } + private readonly XMLProperties _Xp; + public AnnotationConfig(string xml) { if (xml == string.Empty) xml = ""; _Xp = new XMLProperties(xml); } - public AnnotationConfig() - { - _Xp = new XMLProperties(); - } - public override string ToString() + public AnnotationConfig() => _Xp = new XMLProperties(); + public override string ToString() { string s = _Xp.ToString(); if (s == "" || s == "") return string.Empty; return s; } - 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 string GetValue(string group, string item) => _Xp[group, item]; + public void SetValue(string group, string item, string newvalue) => _Xp[group, item] = newvalue; - } + } } diff --git a/PROMS/VEPROMS.CSLA.Library/Config/AnnotationTypeConfig.cs b/PROMS/VEPROMS.CSLA.Library/Config/AnnotationTypeConfig.cs index 83511c5a..8ac17f65 100644 --- a/PROMS/VEPROMS.CSLA.Library/Config/AnnotationTypeConfig.cs +++ b/PROMS/VEPROMS.CSLA.Library/Config/AnnotationTypeConfig.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using System.ComponentModel; namespace VEPROMS.CSLA.Library @@ -9,12 +7,9 @@ namespace VEPROMS.CSLA.Library [TypeConverter(typeof(ExpandableObjectConverter))] public class AnnotationTypeConfig : ConfigDynamicTypeDescriptor, INotifyPropertyChanged { - private XMLProperties _Xp; - private XMLProperties Xp - { - get { return _Xp; } - } - public AnnotationTypeConfig(string xml) + private readonly XMLProperties _Xp; + + public AnnotationTypeConfig(string xml) { if (xml == string.Empty) xml = ""; _Xp = new XMLProperties(xml); @@ -48,16 +43,16 @@ namespace VEPROMS.CSLA.Library { string s = _Xp["PrintableText", "XLocation"]; if (s == string.Empty) return 0; - int tst = 0; + int tst; try { tst = int.Parse(s); } - catch (Exception ex) - { + catch (Exception) + { return 0; } - return int.Parse(s); + return tst; } set { diff --git a/PROMS/VEPROMS.CSLA.Library/Config/AssocConfig.cs b/PROMS/VEPROMS.CSLA.Library/Config/AssocConfig.cs index 97f03639..520ce3bf 100644 --- a/PROMS/VEPROMS.CSLA.Library/Config/AssocConfig.cs +++ b/PROMS/VEPROMS.CSLA.Library/Config/AssocConfig.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using System.ComponentModel; namespace VEPROMS.CSLA.Library @@ -9,21 +7,14 @@ namespace VEPROMS.CSLA.Library [TypeConverter(typeof(ExpandableObjectConverter))] public class AssociationConfig : ConfigDynamicTypeDescriptor, INotifyPropertyChanged { - #region DynamicTypeDescriptor - internal override bool IsReadOnly - { - get { return _Association == null; } - } - #endregion - #region XML - private XMLProperties _Xp; - private XMLProperties Xp - { - get { return _Xp; } - } + #region DynamicTypeDescriptor + internal override bool IsReadOnly => _Association == null; + #endregion + #region XML + private readonly XMLProperties _Xp; #endregion #region Constructors - private Association _Association; + private readonly Association _Association; public AssociationConfig(Association association) { _Association = association; @@ -31,7 +22,7 @@ namespace VEPROMS.CSLA.Library if (xml == string.Empty) xml = ""; _Xp = new XMLProperties(xml); } - private AssociationInfo _AssociationInfo; + private readonly AssociationInfo _AssociationInfo; public AssociationConfig(AssociationInfo association) { _AssociationInfo = association; @@ -39,24 +30,17 @@ namespace VEPROMS.CSLA.Library if (xml == string.Empty) xml = ""; _Xp = new XMLProperties(xml); } - public AssociationConfig(string xml) - { - _Xp = new XMLProperties(xml); - } - public AssociationConfig() + public AssociationConfig(string xml) => _Xp = new XMLProperties(xml); + public AssociationConfig() { string xml = ""; _Xp = new XMLProperties(xml); } - internal string GetValue(string group, string item) - { - return _Xp[group, item]; - } - #endregion - public Association MyAssociation - { get { return _Association; } } - #region RODefaults // From proc.ini - [Category("Referenced Objects")] + internal string GetValue(string group, string item) => _Xp[group, item]; + #endregion + public Association MyAssociation => _Association; + #region RODefaults // From proc.ini + [Category("Referenced Objects")] [DisplayName("Default RO Prefix")] [RefreshProperties(RefreshProperties.All)] [Description("Setpoint Prefix")] @@ -146,9 +130,8 @@ namespace VEPROMS.CSLA.Library public override string ToString() { string s = _Xp.ToString(); - if (s == "" || s == "") return string.Empty; - return s; - } - #endregion - } + return s == "" || s == "" ? string.Empty : s; + } + #endregion + } } diff --git a/PROMS/VEPROMS.CSLA.Library/Config/ColorConfig.cs b/PROMS/VEPROMS.CSLA.Library/Config/ColorConfig.cs index 347e5ccc..a40dbdb6 100644 --- a/PROMS/VEPROMS.CSLA.Library/Config/ColorConfig.cs +++ b/PROMS/VEPROMS.CSLA.Library/Config/ColorConfig.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Text; using System.Text.RegularExpressions; using System.Drawing; @@ -8,9 +7,9 @@ namespace VEPROMS.CSLA.Library { public static class ColorConfig { - private static Regex byARGB = new Regex(@"Color \[A=([0-9]*), R=([0-9]*), G=([0-9]*), B=([0-9]*)\]"); - private static Regex byName = new Regex(@"Color \[(.*)\]"); - private static Regex byRGB = new Regex(@"[0-9]*,[0-9]*,[0-9]*"); + private static readonly Regex byARGB = new Regex(@"Color \[A=([0-9]*), R=([0-9]*), G=([0-9]*), B=([0-9]*)\]"); + private static readonly Regex byName = new Regex(@"Color \[(.*)\]"); + private static readonly Regex byRGB = new Regex(@"[0-9]*,[0-9]*,[0-9]*"); public static Color ColorFromString(string sColor) { if (sColor == string.Empty) return Color.Empty; @@ -59,12 +58,7 @@ namespace VEPROMS.CSLA.Library return ConvertRGBToName[tmp.Name]; return tmp; } - public static Color FindKnownColor(Color tmp) - { - if (ConvertRGBToName.ContainsKey(tmp.Name)) - return ConvertRGBToName[tmp.Name]; - return tmp; - } + public static Color FindKnownColor(Color tmp) => ConvertRGBToName.ContainsKey(tmp.Name) ? ConvertRGBToName[tmp.Name] : tmp; - } + } } diff --git a/PROMS/VEPROMS.CSLA.Library/Config/ConfigEnum.cs b/PROMS/VEPROMS.CSLA.Library/Config/ConfigEnum.cs index 15dcad8e..9750c022 100644 --- a/PROMS/VEPROMS.CSLA.Library/Config/ConfigEnum.cs +++ b/PROMS/VEPROMS.CSLA.Library/Config/ConfigEnum.cs @@ -1,13 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Text; using System.ComponentModel; using DescriptiveEnum; namespace VEPROMS.CSLA.Library { - //class ConfigEnum - //{ //C2022-004 Added option for Unit Specific Watermark [TypeConverter(typeof(EnumDescConverter))] public enum PrintWatermark : int diff --git a/PROMS/VEPROMS.CSLA.Library/Config/DocVersionConfig.cs b/PROMS/VEPROMS.CSLA.Library/Config/DocVersionConfig.cs index 876f711c..aaa6089d 100644 --- a/PROMS/VEPROMS.CSLA.Library/Config/DocVersionConfig.cs +++ b/PROMS/VEPROMS.CSLA.Library/Config/DocVersionConfig.cs @@ -1,20 +1,14 @@ using System; using System.Collections.Generic; -using System.Text; using System.ComponentModel; -using System.Drawing; -using DescriptiveEnum; using System.Xml; namespace VEPROMS.CSLA.Library { public partial class DVEnhancedDocuments : List { - 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) + 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")) @@ -37,7 +31,7 @@ namespace VEPROMS.CSLA.Library { // 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(string.Format("//Enhanced[@VersionID='{0}']", dvid)); + XmlNode xnx = _Xp.XmlContents.SelectSingleNode($"//Enhanced[@VersionID='{dvid}']"); xnx.ParentNode.RemoveChild(xnx); } } @@ -71,37 +65,12 @@ namespace VEPROMS.CSLA.Library public partial class DVEnhancedDocument { - private string _Name; - public string Name - { - get { return _Name; } - set { _Name = value; } - } - private int _Type; - public int Type - { - get { return _Type; } - set { _Type = value; } - } - private int _VersionID; - public int VersionID - { - get { return _VersionID; } - set { _VersionID = value; } - } - private int _PdfX; - public int PdfX - { - get { return _PdfX; } - set { _PdfX = value; } - } - private string _PdfToken; - public string PdfToken - { - get { return _PdfToken; } - set { _PdfToken = value; } - } - public 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; @@ -110,23 +79,17 @@ namespace VEPROMS.CSLA.Library PdfX = pdfX; PdfToken = pdfToken; } - public override string ToString() - { - return string.Format("{0}.ItemID={1}", Name,VersionID); - } - } + 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; - } + // 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) + 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)); @@ -198,19 +161,12 @@ namespace VEPROMS.CSLA.Library } } - #region DynamicTypeDescriptor - internal override bool IsReadOnly - { - get { return _DocVersion == null; } - } - #endregion + #region DynamicTypeDescriptor + internal override bool IsReadOnly => _DocVersion == null; + #endregion - #region XML - private XMLProperties _Xp; - private XMLProperties Xp - { - get { return _Xp; } - } + #region XML + private readonly XMLProperties _Xp; #endregion #region Constructors @@ -221,15 +177,8 @@ namespace VEPROMS.CSLA.Library get { return _Xp.ParentLookup; } set { _Xp.ParentLookup = value; } } - //private bool _AncestorLookup; - ////PROPGRID: Hide AncestorLookup - //[Browsable(false)] - //public bool AncestorLookup - //{ - // get { return _AncestorLookup; } - // set { _AncestorLookup = value; } - //} - private DocVersion _DocVersion; + + private readonly DocVersion _DocVersion; public DocVersionConfig(DocVersion docVersion) { _DocVersion = docVersion; @@ -251,20 +200,7 @@ namespace VEPROMS.CSLA.Library } return string.Empty; } - - //private string Xp_LookInAncestorFolderInfo(object sender, XMLPropertiesArgs args) - //{ - // if (args.AncestorLookup || ParentLookup) - // { - // for (FolderInfo folder = _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 DocVersionInfo _DocVersionInfo; + private readonly DocVersionInfo _DocVersionInfo; public DocVersionConfig(DocVersionInfo docVersionInfo) { _DocVersionInfo = docVersionInfo; @@ -283,18 +219,12 @@ namespace VEPROMS.CSLA.Library string xml = ""; _Xp = new XMLProperties(xml); } - public string GetValue(string group, string item) - { - return _Xp[group, item]; - } - public void SetValue(string group, string item, string newvalue) - { - _Xp[group, item] = newvalue; - } - #endregion + 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")] + #region Local Properties + [Category("General")] [DisplayName("Name")] [Description("Name")] public string Name @@ -376,15 +306,14 @@ namespace VEPROMS.CSLA.Library public override string ToString() { string s = _Xp.ToString(); - if (s == "" || s == "") return string.Empty; - return s; - } - #endregion + return s == "" || s == "" ? string.Empty : s; + } + #endregion - // + // - #region RODefaults // From proc.ini - [Category("Referenced Objects")] + #region RODefaults // From proc.ini + [Category("Referenced Objects")] [DisplayName("Default RO Prefix")] [RefreshProperties(RefreshProperties.All)] [Description("Setpoint Prefix")] @@ -500,13 +429,6 @@ namespace VEPROMS.CSLA.Library OnPropertyChanged("Print_Printer"); } } - //[TypeConverter(typeof(EnumDescConverter))] - //public enum PrintWatermark : int - //{ - // None = 0, Reference, Draft, Master, Sample, - // [Description("Information Only")] - // InformationOnly - //} [Category("Print Settings")] [DisplayName("Watermark")] @@ -584,23 +506,6 @@ namespace VEPROMS.CSLA.Library OnPropertyChanged("Print_DuplexBlankPageText"); } } - //// 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("No Default, 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 Bars")] @@ -642,23 +547,7 @@ namespace VEPROMS.CSLA.Library } } } - //// 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)] @@ -700,26 +589,6 @@ namespace VEPROMS.CSLA.Library } } - //// 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")] [Description("Change Bar Text")] @@ -1053,8 +922,6 @@ namespace VEPROMS.CSLA.Library { if (_SaveChangesToDocVersionConfig) { - string parval = _Xp.ParentValue("PrintSettings", "AlwaysOverwritePDF"); - _Xp["PrintSettings", "AlwaysOverwritePDF"] = value.ToString(); OnPropertyChanged("Print_AlwaysOverwritePDF"); @@ -1081,8 +948,6 @@ namespace VEPROMS.CSLA.Library { if (_SaveChangesToDocVersionConfig) { - string parval = _Xp.ParentValue("PrintSettings", "AlwaysViewPDFAfterCreate"); - _Xp["PrintSettings", "AlwaysViewPDFAfterCreate"] = value.ToString(); OnPropertyChanged("Print_AlwaysViewPDFAfterCreate"); @@ -1109,7 +974,7 @@ namespace VEPROMS.CSLA.Library { if (_SaveChangesToDocVersionConfig) { - string parval = _Xp.ParentValue("PrintSettings", "AddBlankPagesWhenUsingDuplexFoldouts"); + _ = _Xp.ParentValue("PrintSettings", "AddBlankPagesWhenUsingDuplexFoldouts"); _Xp["PrintSettings", "AddBlankPagesWhenUsingDuplexFoldouts"] = value.ToString(); @@ -1135,7 +1000,7 @@ namespace VEPROMS.CSLA.Library { if (_SaveChangesToDocVersionConfig) { - string parval = _Xp.ParentValue("PrintSettings", "UnitNumberForPageList"); + _ = _Xp.ParentValue("PrintSettings", "UnitNumberForPageList"); _Xp["PrintSettings", "UnitNumberForPageList"] = value; @@ -1256,16 +1121,16 @@ namespace VEPROMS.CSLA.Library { string s = _Xp["PrintSettings", "MergedPdfsPageNumLocX"]; if (s == string.Empty) return 0.5f; - float test = 0; - try + float test; + try { test = float.Parse(s); } - catch (Exception ex) - { + catch (Exception) + { return 0.5f; } - return float.Parse(s); + return test; } set { @@ -1286,16 +1151,16 @@ namespace VEPROMS.CSLA.Library { string s = _Xp["PrintSettings", "MergedPdfsPageNumLocY"]; if (s == string.Empty) return 0.5f; - float test = 0; - try + float test; + try { test = float.Parse(s); } - catch (Exception ex) - { + catch (Exception) + { return 0.5f; } - return float.Parse(s); + return test; } set { @@ -1342,16 +1207,16 @@ namespace VEPROMS.CSLA.Library { string s = _Xp["PrintSettings", "MergedPdfsLandPageNumLocX"]; if (s == string.Empty) return Print_MergedPdfsPageNumLocX; - float test = 0; - try + float test; + try { test = float.Parse(s); } - catch (Exception ex) - { + catch (Exception) + { return 0.5f; } - return float.Parse(s); + return test; } set { @@ -1372,16 +1237,16 @@ namespace VEPROMS.CSLA.Library { string s = _Xp["PrintSettings", "MergedPdfsLandPageNumLocY"]; if (s == string.Empty) return Print_MergedPdfsPageNumLocY; - float test = 0; - try + float test; + try { test = float.Parse(s); } - catch (Exception ex) - { + catch (Exception) + { return 0.5f; } - return float.Parse(s); + return test; } set { @@ -1435,7 +1300,7 @@ namespace VEPROMS.CSLA.Library if (_SaveChangesToDocVersionConfig) { string s = _Xp["PrintSettings", "MergedPdfsViewAfter"]; // 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; // no change. _Xp["PrintSettings", "MergedPdfsViewAfter"] = ((bool)value).ToString(); // save selected value OnPropertyChanged("Print_MergedPdfsViewAfter"); @@ -1469,6 +1334,7 @@ namespace VEPROMS.CSLA.Library { if (_SelectedSlave == value) return; _SelectedSlave = value; + // For Debugging: // if(_DocVersion != null) // Volian.Base.Library.vlnStackTrace.ShowStackLocal("SelectedSlave {0} = {1}", _DocVersion.MyDocVersionUnique, _SelectedSlave.ToString()); // else @@ -1486,13 +1352,13 @@ namespace VEPROMS.CSLA.Library { string s = GetCombinedSlaveValue("Number") ?? _Xp["Unit", "Number"];// get the saved value if (SelectedSlave > 0) - s = _Xp["Slave[@index='" + SelectedSlave.ToString() + "']", "Number"]; + s = _Xp[$"Slave[@index='{SelectedSlave}']", "Number"]; return s; } set { if (SelectedSlave > 0) - _Xp["Slave[@index='" + SelectedSlave.ToString() + "']", "Number"] = value; // save selected value + _Xp[$"Slave[@index='{SelectedSlave}']", "Number"] = value; // save selected value else _Xp["Unit", "Number"] = value; OnPropertyChanged("Unit_Number"); @@ -1505,7 +1371,7 @@ namespace VEPROMS.CSLA.Library { string s = ""; if (SelectedSlave > 0) - s = _Xp["Slave[@index='" + SelectedSlave.ToString() + "']", "oldindex"]; + s = _Xp[$"Slave[@index='{SelectedSlave}']", "oldindex"]; return s; } } @@ -1520,13 +1386,13 @@ namespace VEPROMS.CSLA.Library { string s = GetCombinedSlaveValue("OtherNumber") ?? _Xp["Unit", "OtherNumber"];// get the saved value if (SelectedSlave > 0) - s = _Xp["Slave[@index='" + SelectedSlave.ToString() + "']", "OtherNumber"]; + s = _Xp[$"Slave[@index='{SelectedSlave}']", "OtherNumber"]; return s; } set { if (SelectedSlave > 0) - _Xp["Slave[@index='" + SelectedSlave.ToString() + "']", "OtherNumber"] = value; // save selected value + _Xp[$"Slave[@index='{SelectedSlave}']", "OtherNumber"] = value; // save selected value else _Xp["Unit", "OtherNumber"] = value; OnPropertyChanged("Other_Unit_Number"); @@ -1543,14 +1409,14 @@ namespace VEPROMS.CSLA.Library string s = GetCombinedSlaveValue("Name") ?? _Xp["Unit", "Name"];// get the saved value if (SelectedSlave > 0) - s = _Xp["Slave[@index='" + SelectedSlave.ToString() + "']", "Name"]; + s = _Xp[$"Slave[@index='{SelectedSlave}']", "Name"]; return s; } set { if (SelectedSlave > 0) - _Xp["Slave[@index='" + SelectedSlave.ToString() + "']", "Name"] = value; // save selected value + _Xp[$"Slave[@index='{SelectedSlave}']", "Name"] = value; // save selected value else _Xp["Unit", "Name"] = value; @@ -1568,13 +1434,13 @@ namespace VEPROMS.CSLA.Library { string s = GetCombinedSlaveValue("OtherName") ?? _Xp["Unit", "OtherName"];// get the saved value if (SelectedSlave > 0) - s = _Xp["Slave[@index='" + SelectedSlave.ToString() + "']", "OtherName"]; + s = _Xp[$"Slave[@index='{SelectedSlave}']", "OtherName"]; return s; } set { if (SelectedSlave > 0) - _Xp["Slave[@index='" + SelectedSlave.ToString() + "']", "OtherName"] = value; // save selected value + _Xp[$"Slave[@index='{SelectedSlave}']", "OtherName"] = value; // save selected value else _Xp["Unit", "OtherName"] = value; OnPropertyChanged("Other_Unit_Name"); @@ -1590,13 +1456,13 @@ namespace VEPROMS.CSLA.Library { string s = GetCombinedSlaveValue("Text") ?? _Xp["Unit", "Text"];// get the saved value if (SelectedSlave > 0) - s = _Xp["Slave[@index='" + SelectedSlave.ToString() + "']", "Text"]; + s = _Xp[$"Slave[@index='{SelectedSlave}']", "Text"]; return s; } set { if (SelectedSlave > 0) - _Xp["Slave[@index='" + SelectedSlave.ToString() + "']", "Text"] = value; // save selected value + _Xp[$"Slave[@index='{SelectedSlave}']", "Text"] = value; // save selected value else _Xp["Unit", "Text"] = value; OnPropertyChanged("Unit_Text"); @@ -1612,13 +1478,13 @@ namespace VEPROMS.CSLA.Library { string s = GetCombinedSlaveValue("OtherText") ?? _Xp["Unit", "OtherText"];// get the saved value if (SelectedSlave > 0) - s = _Xp["Slave[@index='" + SelectedSlave.ToString() + "']", "OtherText"]; + s = _Xp[$"Slave[@index='{SelectedSlave}']", "OtherText"]; return s; } set { if (SelectedSlave > 0) - _Xp["Slave[@index='" + SelectedSlave.ToString() + "']", "OtherText"] = value; // save selected value + _Xp[$"Slave[@index='{SelectedSlave}']", "OtherText"] = value; // save selected value else _Xp["Unit", "OtherText"] = value; OnPropertyChanged("Other_Unit_Text"); @@ -1634,13 +1500,13 @@ namespace VEPROMS.CSLA.Library { string s = GetCombinedSlaveValue("ID") ?? _Xp["Unit", "ID"];// get the saved value if (SelectedSlave > 0) - s = _Xp["Slave[@index='" + SelectedSlave.ToString() + "']", "ID"]; + s = _Xp[$"Slave[@index='{SelectedSlave}']", "ID"]; return s; } set { if (SelectedSlave > 0) - _Xp["Slave[@index='" + SelectedSlave.ToString() + "']", "ID"] = value; // save selected value + _Xp[$"Slave[@index='{SelectedSlave}']", "ID"] = value; // save selected value else _Xp["Unit", "ID"] = value; OnPropertyChanged("Unit_ID"); @@ -1656,13 +1522,13 @@ namespace VEPROMS.CSLA.Library { string s = GetCombinedSlaveValue("OtherID") ?? _Xp["Unit", "OtherID"];// get the saved value if (SelectedSlave > 0) - s = _Xp["Slave[@index='" + SelectedSlave.ToString() + "']", "OtherID"]; + s = _Xp[$"Slave[@index='{SelectedSlave}']", "OtherID"]; return s; } set { if (SelectedSlave > 0) - _Xp["Slave[@index='" + SelectedSlave.ToString() + "']", "OtherID"] = value; // save selected value + _Xp[$"Slave[@index='{SelectedSlave}']", "OtherID"] = value; // save selected value else _Xp["Unit", "OtherID"] = value; OnPropertyChanged("Other_Unit_ID"); @@ -1678,13 +1544,13 @@ namespace VEPROMS.CSLA.Library { string s = GetCombinedSlaveValue("ProcedureNumber", null) ?? _Xp["Unit", "ProcedureNumber"];// get the saved value if (SelectedSlave > 0) - s = _Xp["Slave[@index='" + SelectedSlave.ToString() + "']", "ProcedureNumber"]; + s = _Xp[$"Slave[@index='{SelectedSlave}']", "ProcedureNumber"]; return s; } set { if (SelectedSlave > 0) - _Xp["Slave[@index='" + SelectedSlave.ToString() + "']", "ProcedureNumber"] = value; // save selected value + _Xp[$"Slave[@index='{SelectedSlave}']", "ProcedureNumber"] = value; // save selected value else _Xp["Unit", "ProcedureNumber"] = value; OnPropertyChanged("Unit_ProcedureNumber"); @@ -1700,13 +1566,13 @@ namespace VEPROMS.CSLA.Library { string s = GetCombinedSlaveValue("SetName", null) ?? _Xp["ProcedureSet", "Name"];// get the saved value if (SelectedSlave > 0) - s = _Xp["Slave[@index='" + SelectedSlave.ToString() + "']", "SetName"]; + s = _Xp[$"Slave[@index='{SelectedSlave}']", "SetName"]; return s; } set { if (SelectedSlave > 0) - _Xp["Slave[@index='" + SelectedSlave.ToString() + "']", "SetName"] = value; // save selected value + _Xp[$"Slave[@index='{SelectedSlave}']", "SetName"] = value; // save selected value else _Xp["ProcedureSet", "Name"] = value; OnPropertyChanged("Unit_ProcedureSetName"); @@ -1722,557 +1588,18 @@ namespace VEPROMS.CSLA.Library { string s = GetCombinedSlaveValue("SetID", null) ?? _Xp["ProcedureSet", "ID"];// get the saved value if (SelectedSlave > 0) - s = _Xp["Slave[@index='" + SelectedSlave.ToString() + "']", "SetID"]; + s = _Xp[$"Slave[@index='{SelectedSlave}']", "SetID"]; return s; } set { if (SelectedSlave > 0) - _Xp["Slave[@index='" + SelectedSlave.ToString() + "']", "SetID"] = value; // save selected value + _Xp[$"Slave[@index='{SelectedSlave}']", "SetID"] = value; // save selected value else _Xp["ProcedureSet", "ID"] = value; OnPropertyChanged("Unit_ProcedureSetID"); } } - #endregion - #region DELETE_ME - /* - #region ColorCategory // From veproms.ini - // Note that not all possibilities from 16-bit will be added here, until - // it is determined how these will be used - [Category("Color")] - [DisplayName("ro")] - [RefreshProperties(RefreshProperties.All)] - [Description("ro")] - public string Color_ro - { - get - { - return _Xp["Color", "ro"]; - } - set - { - _Xp["Color", "ro"] = value; - OnPropertyChanged("Color_ro"); - } - } - [Category("Color")] - [DisplayName("editbackground")] - [RefreshProperties(RefreshProperties.All)] - [Description("editbackground")] - public string Color_editbackground - { - get - { - return _Xp["Color", "editbackground"]; - } - set - { - _Xp["Color", "editbackground"] = value; - OnPropertyChanged("Color_editbackground"); - } - } - [Category("Color")] - [DisplayName("black")] - [RefreshProperties(RefreshProperties.All)] - [Description("black")] - public string Color_black - { - get - { - return _Xp["Color", "black"]; - } - set - { - _Xp["Color", "black"] = value; - OnPropertyChanged("Color_black"); - } - } - [Category("Color")] - [DisplayName("blue")] - [RefreshProperties(RefreshProperties.All)] - [Description("blue")] - public string Color_blue - { - get - { - return _Xp["Color", "blue"]; - } - set - { - _Xp["Color", "blue"] = value; - OnPropertyChanged("Color_blue"); - } - } - #endregion // From veproms.ini - #region SystemPrintCategory // From veproms.ini - [Category("System Print")] - [DisplayName("Underline Width")] - [RefreshProperties(RefreshProperties.All)] - [Description("Underline Width")] - public int SysPrint_UWidth - { - get - { - string s = _Xp["SystemPrint", "UnderlineWidth"]; - if (s == string.Empty) return 10; - return int.Parse(_Xp["SystemPrint", "UnderlineWidth"]); - } - set - { - _Xp["SystemPrint", "UnderlineWidth"] = value.ToString(); - OnPropertyChanged("SysPrint_UWidth"); - } - } - [Category("System Print")] - [DisplayName("Vertical Offset")] - [RefreshProperties(RefreshProperties.All)] - [Description("Vertical Offset")] - public int SysPrint_VOffset - { - get - { - string s = _Xp["SystemPrint", "VerticalOffset"]; - if (s == string.Empty) return 0; - return int.Parse(_Xp["SystemPrint", "VerticalOffset"]); - } - set - { - _Xp["SystemPrint", "VerticalOffset"] = value.ToString(); - OnPropertyChanged("SysPrint_VOffset"); - } - } - [Category("System Print")] - [DisplayName("Stroke Width")] - [RefreshProperties(RefreshProperties.All)] - [Description("Stroke Width")] - public int SysPrint_StrokeWidth - { - get - { - string s = _Xp["SystemPrint", "StrokeWidth"]; - if (s == string.Empty) return 0; - return int.Parse(_Xp["SystemPrint", "StrokeWidth"]); - } - set - { - _Xp["SystemPrint", "StrokeWidth"] = value.ToString(); - OnPropertyChanged("SysPrint_StrokeWidth"); - } - } - [Category("System Print")] - [DisplayName("Stroke Width Bold")] - [RefreshProperties(RefreshProperties.All)] - [Description("Stroke Width Bold")] - public int SysPrint_StrokeWidthBold - { - get - { - string s = _Xp["SystemPrint", "StrokeWidthBold"]; - if (s == string.Empty) return 0; - return int.Parse(_Xp["SystemPrint", "StrokeWidthBold"]); - } - set - { - _Xp["SystemPrint", "StrokeWidthBold"] = value.ToString(); - OnPropertyChanged("SysPrint_StrokeWidthBold"); - } - } - #endregion - #region StartupCategory // From veproms.ini - [Category("Startup")] - [DisplayName("Startup MessageBox Title")] - [RefreshProperties(RefreshProperties.All)] - [Description("Startup MessageBox Title")] - public string Startup_MsgTitle - { - get - { - return _Xp["Startup", "MessageBoxTitle"]; - } - set - { - _Xp["Startup", "MessageBoxTitle"] = value; - OnPropertyChanged("Startup_MsgTitle"); - } - } - [Category("Startup")] - [DisplayName("Startup Message File")] - [RefreshProperties(RefreshProperties.All)] - [Description("Startup Message File")] - public string Startup_MsgFile - { - get - { - return _Xp["Startup", "MessageFile"]; - } - set - { - _Xp["Startup", "MessageFile"] = value; - OnPropertyChanged("Startup_MsgFile"); - } - } - #endregion - #region ProcedureListTabStopsCategory // From veproms.ini - [Category("ProcedureListTabStops")] - [DisplayName("Procedure Number Tab")] - [RefreshProperties(RefreshProperties.All)] - [Description("Procedure Number Tab")] - public int ProcListTab_Number - { - get - { - string s = _Xp["ProcedureListTabStops", "ProcedureNumberTab"]; - if (s == string.Empty) return 75; - return int.Parse(_Xp["ProcedureListTabStops", "ProcedureNumberTab"]); - } - set - { - _Xp["ProcedureListTabStops", "ProcedureNumberTab"] = value.ToString(); - OnPropertyChanged("ProcListTab_Number"); - } - } - [Category("ProcedureListTabStops")] - [DisplayName("Procedure Title Tab")] - [RefreshProperties(RefreshProperties.All)] - [Description("Procedure Title Tab")] - public int ProcListTab_Title - { - get - { - string s = _Xp["ProcedureListTabStops", "ProcedureTitleTab"]; - if (s == string.Empty) return 175; - return int.Parse(_Xp["ProcedureListTabStops", "ProcedureTitleTab"]); - } - set - { - _Xp["ProcedureListTabStops", "ProcedureTitleTab"] = value.ToString(); - OnPropertyChanged("ProcListTab_Title"); - } - } - #endregion - #region FormatCategory - public enum FormatColumns : int - { - Default=0,OneColumn,TwoColumn,ThreeColumn,FourColumns - } - [Category("Format")] - [DisplayName("Column Layout")] - [RefreshProperties(RefreshProperties.All)] - [Description("Column Layout")] - public FormatColumns Format_Columns - { - get - { - string s = _Xp["format", "columns"]; - if (s == string.Empty) return (FormatColumns)0; - return (FormatColumns)int.Parse(_Xp["format", "columns"]); - //return Enum.Parse(typeof(FormatColumns),_Xp["format", "columns"]); - } - set - { - if (value == 0) _Xp["format", "columns"] = string.Empty; - else _Xp["format", "columns"] = ((int)value).ToString(); - OnPropertyChanged("Format_Columns"); - } - } - [Category("Format")] - [DisplayName("Plant Format Name")] - [RefreshProperties(RefreshProperties.All)] - [Description("Default Plant Format")] - public string Format_Plant - { - get - { return _Xp["format", "plant"]; - } - set - { - _Xp["format", "plant"] = value; - OnPropertyChanged("Format_Plant"); - } - } - #endregion - #region DefaultsCategory // from proc.ini - [Category("Defaults")] - [DisplayName("Default Setpoint Prefix")] - [RefreshProperties(RefreshProperties.All)] - [Description("Default Setpoint Prefix")] - public string Default_SPPrefix - { - get { return _Xp["default", "spprefix"]; } - set - { - _Xp["default", "spprefix"] = value; - OnPropertyChanged("Default_SPPrefix"); - } - } - [Category("Defaults")] - [DisplayName("Default Image Prefix")] - [RefreshProperties(RefreshProperties.All)] - [Description("Default Image Prefix")] - public string Default_IMPrefix - { - get { return _Xp["default", "imprefix"]; } - set - { - _Xp["default", "imprefix"] = value; - OnPropertyChanged("RO_IMPrefix"); - } - } - #endregion - #region PrintSettingsCategory // From curset.dat - [Category("Print Settings")] - [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"); - } - } - 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 (s == string.Empty) return PrintPagination.Auto; - return (PrintPagination)int.Parse(_Xp["PrintSettings", "Pagination"]); - } - set - { - if (value == PrintPagination.Auto) _Xp["PrintSettings", "Pagination"] = string.Empty; - else _Xp["PrintSettings", "Pagination"] = ((int)value).ToString(); - OnPropertyChanged("Print_Pagination"); - } - } - public enum PrintWatermark : int - { - None = 0, Reference, Draft, Master, Sample, InformationOnly - } - [Category("Print Settings")] - [DisplayName("Watermark")] - [RefreshProperties(RefreshProperties.All)] - [Description("Watermark")] - public PrintWatermark Print_Watermark - { - get - { - string s = _Xp["PrintSettings", "Watermark"]; - if (s == string.Empty) return PrintWatermark.Draft; - return (PrintWatermark)int.Parse(_Xp["PrintSettings", "Watermark"]); - } - set - { - if (value == PrintWatermark.Draft) _Xp["PrintSettings", "Watermark"] = string.Empty; - else _Xp["PrintSettings", "Watermark"] = ((int)value).ToString(); - OnPropertyChanged("Print_Watermark"); - } - } - [Category("Print Settings")] - [DisplayName("Disable Duplex Printing")] - [RefreshProperties(RefreshProperties.All)] - [Description("Disable Duplex Printing")] - public bool Print_DisableDuplex - { - get - { - string s = _Xp["PrintSettings", "disableduplex"]; - if (s == string.Empty) return false; - return bool.Parse(_Xp["PrintSettings", "disableduplex"]); - } - set - { - _Xp["PrintSettings", "disableduplex"] = value.ToString(); - OnPropertyChanged("Print_DisableDuplex"); - } - } - // Change Bar Use from 16-bit code: - // No Default - // Without Change Bars - // With Default Change Bars - // With User Specified Change Bars - public enum PrintChangeBar : int - { - NoDefault=0, Without, WithDefault, WithUserSpecified - } - [Category("Print Settings")] - [DisplayName("Change Bar")] - [RefreshProperties(RefreshProperties.All)] - [Description("Change Bar Use")] - public PrintChangeBar Print_ChangeBar - { - get - { - string s = _Xp["PrintSettings", "ChangeBar"]; - if (s == string.Empty) return PrintChangeBar.NoDefault; - return (PrintChangeBar)int.Parse(_Xp["PrintSettings", "ChangeBar"]); - } - set - { - if (value == PrintChangeBar.NoDefault) _Xp["PrintSettings", "ChangeBar"] = string.Empty; - else _Xp["PrintSettings", "ChangeBar"] = ((int)value).ToString(); - 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 - public enum PrintChangeBarLoc : int - { - WithText = 0, OutsideBox, AERleftRNOright, LeftOfText - } - [Category("Print Settings")] - [DisplayName("Change Bar Location")] - [RefreshProperties(RefreshProperties.All)] - [Description("User Specified Change Bar Location")] - public PrintChangeBarLoc Print_ChangeBarLoc - { - get - { - string s = _Xp["PrintSettings", "ChangeBarLoc"]; - if (s == string.Empty) return PrintChangeBarLoc.WithText; - return (PrintChangeBarLoc)int.Parse(_Xp["PrintSettings", "ChangeBarLoc"]); - } - set - { - if (value == PrintChangeBarLoc.WithText) _Xp["PrintSettings", "ChangeBarLoc"] = string.Empty; - else _Xp["PrintSettings", "ChangeBarLoc"] = ((int)value).ToString(); - OnPropertyChanged("Print_ChangeBarLoc"); - } - } - - // Change Bar Text from16-bit code: - // Date and Change ID - // Revision Number - // Change ID - // No Change Bar Message - // User Defined Message - public enum PrintChangeBarText : int - { - DateChgID = 0, RevNum, ChgID, None, UserDef - } - [Category("Print Settings")] - [DisplayName("Change Bar Text")] - [RefreshProperties(RefreshProperties.All)] - [Description("Change Bar Text")] - public PrintChangeBarText Print_ChangeBarText - { - get - { - string s = _Xp["PrintSettings", "ChangeBarText"]; - if (s == string.Empty) return PrintChangeBarText.DateChgID; - return (PrintChangeBarText)int.Parse(_Xp["PrintSettings", "ChangeBarText"]); - } - set - { - if (value == PrintChangeBarText.DateChgID) _Xp["PrintSettings", "ChangeBarText"] = string.Empty; - else _Xp["PrintSettings", "ChangeBarText"] = ((int)value).ToString(); - OnPropertyChanged("Print_ChangeBarText"); - } - } - - [Category("Print Settings")] - [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"); - } - } - - [Category("Print Settings")] - [DisplayName("User Change Bar Message1")] - [RefreshProperties(RefreshProperties.All)] - [Description("User Change Bar Message1")] - public string Print_UserCBMess1 - { - get - { - return _Xp["PrintSettings", "usercbmess1"]; - } - set - { - _Xp["PrintSettings", "usercbmess1"] = value; - OnPropertyChanged("Print_UserCBMess1"); - } - } - - [Category("Print Settings")] - [DisplayName("User Change Bar Message2")] - [RefreshProperties(RefreshProperties.All)] - [Description("User Change Bar Message2")] - public string Print_UserCBMess2 - { - get - { - return _Xp["PrintSettings", "usercbmess2"]; - } - set - { - _Xp["PrintSettings", "usercbmess2"] = value; - OnPropertyChanged("Print_UserCBMess2"); - } - } - #endregion -[Category("Defaults")] -[DisplayName("Default BackColor")] -[RefreshProperties(RefreshProperties.All)] -[Description("Default Background Color")] -public Color Default_BkColor -{ -get -{ -//return _Xp["default", "BkColor"]; -string sColor = _Xp["default", "BkColor"]; -if (sColor == string.Empty) sColor = "White"; -if (sColor[0] == '[') -{ -string[] parts = sColor.Substring(1, sColor.Length - 2).Split(",".ToCharArray()); -return Color.FromArgb(Int32.Parse(parts[0]), Int32.Parse(parts[1]), Int32.Parse(parts[2])); -} -else return Color.FromName(sColor); -} -set -{ -if (value.IsNamedColor) _Xp["default", "BkColor"] = value.Name; -else -{ -_Xp["default", "BkColor"] = string.Format("[{0},{1},{2}]", value.R, value.G, value.B); -} -OnPropertyChanged("Default_BkColor"); - -} -} -} -} -*/ #endregion #region Slave public void AddSlave(string xml) @@ -2281,16 +1608,16 @@ OnPropertyChanged("Default_BkColor"); 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); - } + 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.ToString() + "']"); + XmlNode dd = _Xp.XmlContents.SelectSingleNode($"//Slave[@index='{index}']"); dd?.ParentNode?.RemoveChild(dd); } public int MaxSlaveIndex @@ -2315,22 +1642,19 @@ OnPropertyChanged("Default_BkColor"); foreach (XmlNode nd in nl) { string ss = nd.Attributes.GetNamedItem("index").InnerText; - s += sep + _Xp["Slave[@index='" + ss + "']", item]; + s += $"{sep}{_Xp[$"Slave[@index='{ss}']", item]}"; sep = ","; } return s; } return defaultValue; } - private string GetCombinedSlaveValue(string item) - { - return 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")] + 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)] diff --git a/PROMS/VEPROMS.CSLA.Library/Config/DocumentConfig.cs b/PROMS/VEPROMS.CSLA.Library/Config/DocumentConfig.cs index 49a88a0e..b6cab99f 100644 --- a/PROMS/VEPROMS.CSLA.Library/Config/DocumentConfig.cs +++ b/PROMS/VEPROMS.CSLA.Library/Config/DocumentConfig.cs @@ -1,9 +1,5 @@ using System; -using System.Collections.Generic; -using System.Text; using System.ComponentModel; -using System.Drawing; -using System.Text.RegularExpressions; namespace VEPROMS.CSLA.Library { @@ -12,15 +8,11 @@ namespace VEPROMS.CSLA.Library public class DocumentConfig : ConfigDynamicTypeDescriptor, INotifyPropertyChanged { #region XML - private XMLProperties _Xp; - private XMLProperties Xp - { - get { return _Xp; } - } + private readonly XMLProperties _Xp; #endregion #region Constructors public Document _Document; - private DocumentInfo _DocumentInfo; + private readonly DocumentInfo _DocumentInfo; public DocumentConfig(Document document) { _Document = document; @@ -35,13 +27,10 @@ namespace VEPROMS.CSLA.Library if (xml == string.Empty) xml = ""; _Xp = new XMLProperties(xml); } - internal string GetValue(string group, string item) - { - return _Xp[group, item]; - } - #endregion - #region Properties - [Category("General")] + internal string GetValue(string group, string item) => _Xp[group, item]; + #endregion + #region Properties + [Category("General")] [DisplayName("Name")] [Description("Name")] public string Name @@ -100,48 +89,13 @@ namespace VEPROMS.CSLA.Library OnPropertyChanged("History_OriginalFileName"); } } - // RHM 20110415 - These are now stored in the PDF table. - //[Category("Printing")] - //[DisplayName("Length")] - //[Description("Length of Document in Full and Partial Pages")] - //public float Printing_Length - //{ - // get - // { - // string s = _Xp["Printing", "Length"];// get the saved value - - // return float.Parse(s); - // } - // set - // { - // _Xp["Printing", "Length"] = string.Format("{0:0.0000}", value); - // OnPropertyChanged("Printing_Length"); - // } - //} - //[Category("Printing")] - //[DisplayName("Color")] - //[Description("Color of Document Text")] - //public Color Printing_Color - //{ - // get - // { - // string sColor = _Xp["Printing", "Color"]; - // return ColorConfig.ColorFromString(sColor); - // } - // set - // { - // _Xp["Printing", "Color"] = value.ToString(); - // OnPropertyChanged("Printing_Color"); - // } - //} #endregion #region ToString public override string ToString() { string s = _Xp.ToString(); - if (s == "" || s == "") return string.Empty; - return s; - } - #endregion - } + return s == "" || s == "" ? string.Empty : s; + } + #endregion + } } diff --git a/PROMS/VEPROMS.CSLA.Library/Config/DynamicProperties.cs b/PROMS/VEPROMS.CSLA.Library/Config/DynamicProperties.cs index 61bc8b2c..c755a75d 100644 --- a/PROMS/VEPROMS.CSLA.Library/Config/DynamicProperties.cs +++ b/PROMS/VEPROMS.CSLA.Library/Config/DynamicProperties.cs @@ -1,17 +1,13 @@ using System; -using System.Collections.Generic; -using System.Text; using System.ComponentModel; -using System.Xml; using System.Xml.Serialization; -using System.Xml.Schema; namespace VEPROMS.CSLA.Library { public class DynamicPropertyDescriptor : PropertyDescriptor { - private PropertyDescriptor _BasePropertyDescriptor; - private ConfigDynamicTypeDescriptor _Instance; + private readonly PropertyDescriptor _BasePropertyDescriptor; + private readonly ConfigDynamicTypeDescriptor _Instance; public DynamicPropertyDescriptor(ConfigDynamicTypeDescriptor instance, PropertyDescriptor basePropertyDescriptor) : base(basePropertyDescriptor) @@ -37,16 +33,15 @@ namespace VEPROMS.CSLA.Library { _BasePropertyDescriptor.SetValue(component, value); } } [Serializable()] - public class ConfigDynamicTypeDescriptor //: ICustomTypeDescriptor//, ISupportInitialize + public class ConfigDynamicTypeDescriptor { #region Events public event PropertyChangedEventHandler PropertyChanged; protected void OnPropertyChanged(String info) { _IsDirty = true; - if (PropertyChanged != null) - PropertyChanged(this, new PropertyChangedEventArgs(info)); - } + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(info)); + } [NonSerialized] private bool _IsDirty = false; [XmlIgnore] @@ -57,54 +52,11 @@ namespace VEPROMS.CSLA.Library set { _IsDirty = value; } } #endregion - [NonSerialized] - private PropertyDescriptorCollection dynamicProps; private bool _IsReadOnly = false; internal virtual bool IsReadOnly { get { return _IsReadOnly; } set { _IsReadOnly = value; } } - public ConfigDynamicTypeDescriptor() { } - #region "TypeDescriptor Implementation" - 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 PropertyDescriptorCollection GetProperties(Attribute[] attributes) - { - return GetProperties(); - } - public PropertyDescriptorCollection GetProperties() - { - if (dynamicProps == null) - { - PropertyDescriptorCollection baseProps = TypeDescriptor.GetProperties(this, true); - dynamicProps = new PropertyDescriptorCollection(null); - - foreach (PropertyDescriptor oProp in baseProps) - { - dynamicProps.Add(new DynamicPropertyDescriptor(this, oProp)); - } - } - return dynamicProps; - } - public object GetPropertyOwner(PropertyDescriptor pd) - { return this; } - #endregion } } diff --git a/PROMS/VEPROMS.CSLA.Library/Config/EnumDescConverter.cs b/PROMS/VEPROMS.CSLA.Library/Config/EnumDescConverter.cs index cd05d4a7..ec3a5715 100644 --- a/PROMS/VEPROMS.CSLA.Library/Config/EnumDescConverter.cs +++ b/PROMS/VEPROMS.CSLA.Library/Config/EnumDescConverter.cs @@ -13,8 +13,6 @@ using System; using System.ComponentModel; -using System.Drawing; -using System.Drawing.Design; using System.Reflection; using System.Collections; using System.Data; @@ -97,26 +95,26 @@ namespace DescriptiveEnum public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) { - if(value is Enum && destinationType == typeof(string)) + if(value is Enum myenum && destinationType == typeof(string)) { - return EnumDescConverter.GetEnumDescription((Enum)value); + return EnumDescConverter.GetEnumDescription(myenum); } - if(value is string && destinationType == typeof(string)) + if(value is string mystr && destinationType == typeof(string)) { - return EnumDescConverter.GetEnumDescription(myVal, (string)value); + return EnumDescConverter.GetEnumDescription(myVal, mystr); } return base.ConvertTo (context, culture, value, destinationType); } public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { - if(value is string) + if(value is string mystr) { - return EnumDescConverter.GetEnumValue(myVal, (string)value); + return EnumDescConverter.GetEnumValue(myVal, mystr); } - if(value is Enum) + if(value is Enum myenum) { - return EnumDescConverter.GetEnumDescription((Enum)value); + return EnumDescConverter.GetEnumDescription(myenum); } return base.ConvertFrom (context, culture, value); } @@ -125,7 +123,8 @@ namespace DescriptiveEnum return true; } - public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0059:Unnecessary assignment of a value", Justification = "Keeping attributes for future extensions")] + public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { ArrayList values = new ArrayList(); FieldInfo[] fis = myVal.GetFields(); @@ -133,7 +132,6 @@ namespace DescriptiveEnum { DescriptionAttribute[] attributes =(DescriptionAttribute[])fi.GetCustomAttributes( typeof(DescriptionAttribute), false); - //if (attributes.Length > 0) if (fi.Name != "value__") values.Add(fi.GetValue(fi.Name)); } diff --git a/PROMS/VEPROMS.CSLA.Library/Config/EnumDetail.cs b/PROMS/VEPROMS.CSLA.Library/Config/EnumDetail.cs index d983be55..4e31f1ca 100644 --- a/PROMS/VEPROMS.CSLA.Library/Config/EnumDetail.cs +++ b/PROMS/VEPROMS.CSLA.Library/Config/EnumDetail.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using System.Reflection; using System.ComponentModel; @@ -8,23 +6,13 @@ namespace VEPROMS.CSLA.Library { public class EnumDetail { - private T _EValue; - public T EValue - { - get { return _EValue; } - set { _EValue = value; } - } - private string _Name; + public T EValue { get; set; } - public string Name + public string Name { get; set; } + public EnumDetail(string name, T eValue) { - get { return _Name; } - set { _Name = value; } - } - public EnumDetail(string name, T eValue) - { - _Name = name; - _EValue = eValue; + Name = name; + EValue = eValue; } public static EnumDetail[] Details() { diff --git a/PROMS/VEPROMS.CSLA.Library/Config/FolderConfig.cs b/PROMS/VEPROMS.CSLA.Library/Config/FolderConfig.cs index 940b84d4..270ce63b 100644 --- a/PROMS/VEPROMS.CSLA.Library/Config/FolderConfig.cs +++ b/PROMS/VEPROMS.CSLA.Library/Config/FolderConfig.cs @@ -1,29 +1,18 @@ using System; -using System.Collections.Generic; -using System.Text; using System.ComponentModel; using System.Drawing; -using DescriptiveEnum; namespace VEPROMS.CSLA.Library { [Serializable] [TypeConverter(typeof(ExpandableObjectConverter))] - //public class FolderConfig : INotifyPropertyChanged public class FolderConfig : ConfigDynamicTypeDescriptor, INotifyPropertyChanged { - #region DynamicTypeDescriptor - internal override bool IsReadOnly - { - get { return _Folder == null; } - } - #endregion - #region XML - private XMLProperties _Xp; - private XMLProperties Xp - { - get { return _Xp; } - } + #region DynamicTypeDescriptor + internal override bool IsReadOnly => _Folder == null; + #endregion + #region XML + private readonly XMLProperties _Xp; #endregion #region Constructors //PROPGRID: Hide ParentLookup @@ -33,19 +22,8 @@ namespace VEPROMS.CSLA.Library get { return _Xp.ParentLookup; } set { _Xp.ParentLookup = value; } } - //PROPGRID: Hide AncestorLookup - //PROPGRID: Needed to comment out [NonSerialized] in order to hide this field from the property grid - //[NonSerialized] - //[Browsable(false)] - //private bool _AncestorLookup; - //[Browsable(false)] - //public bool AncestorLookup - //{ - // get { return _AncestorLookup; } - // set { _AncestorLookup = value; } - //} - private Folder _Folder; - private FolderInfo _FolderInfo; + private readonly Folder _Folder; + private readonly FolderInfo _FolderInfo; public FolderConfig(Folder folder) { _Folder = folder; @@ -75,18 +53,6 @@ namespace VEPROMS.CSLA.Library return false; } } - //private string Xp_LookInAncestorFolderInfo(object sender, XMLPropertiesArgs args) - //{ - // if (args.AncestorLookup || ParentLookup) - // { - // for (FolderInfo folder = _FolderInfo.MyParent; folder != null; folder = folder.MyParent) - // { - // string retval = folder.FolderConfig.GetValue(args.Group, args.Item); - // if (retval != string.Empty) return retval; - // } - // } - // return string.Empty; - //} public FolderConfig(FolderInfo folderInfo) { _FolderInfo = folderInfo; @@ -100,21 +66,12 @@ namespace VEPROMS.CSLA.Library if (xml == string.Empty) xml = ""; _Xp = new XMLProperties(xml); } - public FolderConfig() - { - _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; - } - #endregion - #region Local Properties - [Category("General")] + public FolderConfig() => _Xp = new XMLProperties(""); + 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 @@ -189,7 +146,6 @@ namespace VEPROMS.CSLA.Library if (_Folder != null) { _Folder.MyFormat = FormatList.ToFormat(value); - //_Folder.ActiveFormat = null; } } } @@ -206,24 +162,17 @@ namespace VEPROMS.CSLA.Library return null; } } - public Folder MyFolder - { get { return _Folder; } } - public FolderInfo MyFolderInfo - { get { return _FolderInfo; } } - #endregion - #region ToString - public override string ToString() + public Folder MyFolder => _Folder; + public FolderInfo MyFolderInfo => _FolderInfo; + #endregion + #region ToString + public override string ToString() { string s = _Xp.ToString(); - if (s == "" || s == "") return string.Empty; - return s; - } - #endregion - #region GraphicsCategory // From veproms.ini - public bool CanWrite(string str) - { - return true; - } + return s == "" || s == "" ? string.Empty : s; + } + #endregion + #region GraphicsCategory // From veproms.ini [Category("Referenced Objects")] [DisplayName("Graphic File Extension")] [RefreshProperties(RefreshProperties.All)] @@ -304,103 +253,6 @@ namespace VEPROMS.CSLA.Library } } #endregion - //#region ColorCategory // From veproms.ini - //// ** Note that not all possibilities from 16-bit will be added here, until - //// ** it is determined how these will be used - //// ** If this is used (unhidden), then we need to add logic to blank setting if the value - //// ** we are saving is the same as the parent's value. - - ////PROPGRID: Hide Editor Color for ROs - //[Category("Editor Settings")] - //[Browsable(false)] - //[DisplayName("Step Editor Colors - Referenced Objects")] - //[RefreshProperties(RefreshProperties.All)] - //[Description("Color used to highlight an RO in procedure text")] - //public string Color_ro - //{ - // get - // { - // return _Xp["Color", "ro"]; - // } - // set - // { - // _Xp["Color", "ro"] = value; - // OnPropertyChanged("Color_ro"); - // } - //} - ////PROPGRID: Hide Editor Color for Transitions - //[Category("Editor Settings")] - //[Browsable(false)] - //[DisplayName("Step Editor Colors - Transitions")] - //[RefreshProperties(RefreshProperties.All)] - //[Description("Color used to highlight a Transition in procedure text")] - //public string Color_transition - //{ - // get - // { - // return _Xp["Color", "transition"]; - // } - // set - // { - // _Xp["Color", "transition"] = value; - // OnPropertyChanged("Color_transition"); - // } - //} - ////PROPGRID: Hide Active Text Background Color - //[Category("Editor Settings")] - //[Browsable(false)] - //[DisplayName("Step Editor Colors - Active Background")] - //[RefreshProperties(RefreshProperties.All)] - //[Description("editbackground")] - //public string Color_editbackground - //{ - // get - // { - // return _Xp["Color", "editbackground"]; - // } - // set - // { - // _Xp["Color", "editbackground"] = value; - // OnPropertyChanged("Color_editbackground"); - // } - //} - ////PROPGRID: Hide color setting for Black - //[Category("Color")] - //[Browsable(false)] - //[DisplayName("black")] - //[RefreshProperties(RefreshProperties.All)] - //[Description("black")] - //public string Color_black - //{ - // get - // { - // return _Xp["Color", "black"]; - // } - // set - // { - // _Xp["Color", "black"] = value; - // OnPropertyChanged("Color_black"); - // } - //} - ////PROPGRID: Hide Color Setting for Blue - //[Category("Color")] - //[Browsable(false)] - //[DisplayName("blue")] - //[RefreshProperties(RefreshProperties.All)] - //[Description("blue")] - //public string Color_blue - //{ - // get - // { - // return _Xp["Color", "blue"]; - // } - // set - // { - // _Xp["Color", "blue"] = value; - // OnPropertyChanged("Color_blue"); - // } - //} - //#endregion // From veproms.ini #region SystemPrintCategory // From veproms.ini [Category("Print Settings")] [DisplayName("Override Underline Thickness (dots)")] @@ -635,20 +487,6 @@ namespace VEPROMS.CSLA.Library } #endregion #region FormatCategory - //[TypeConverter(typeof(EnumDescConverter))] - //public enum FormatColumns : int - //{ - // [Description("Format Default")] - // Default = 0, - // [Description("Single Column")] - // OneColumn, - // [Description("Dual Column")] - // TwoColumn, - // [Description("Triple Column")] - // ThreeColumn, - // [Description("Quad Column")] - // FourColumns - //} [Category("Editor Settings")] [DisplayName("Step Editor Columns")] [RefreshProperties(RefreshProperties.All)] @@ -726,10 +564,6 @@ namespace VEPROMS.CSLA.Library OnPropertyChanged("Print_NumCopies"); } } - //public enum PrintPagination : int - //{ - // Free = 0, Fixed, Auto - //} [Category("Print Settings")] [DisplayName("Pagination")] [RefreshProperties(RefreshProperties.All)] @@ -767,13 +601,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")] @@ -812,23 +639,6 @@ namespace VEPROMS.CSLA.Library OnPropertyChanged("Print_Watermark"); } } - // 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)] @@ -866,24 +676,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)] @@ -922,26 +714,6 @@ namespace VEPROMS.CSLA.Library } } - // 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)] diff --git a/PROMS/VEPROMS.CSLA.Library/Config/FormatConfig.cs b/PROMS/VEPROMS.CSLA.Library/Config/FormatConfig.cs index d5617806..30707a17 100644 --- a/PROMS/VEPROMS.CSLA.Library/Config/FormatConfig.cs +++ b/PROMS/VEPROMS.CSLA.Library/Config/FormatConfig.cs @@ -1,15 +1,10 @@ using System; using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Text; using System.ComponentModel; -using DescriptiveEnum; using System.Xml; using System.Xml.Serialization; using System.Xml.Schema; -using System.Windows.Forms; using Volian.Base.Library; -using System.Drawing; namespace VEPROMS.CSLA.Library { @@ -28,13 +23,6 @@ namespace VEPROMS.CSLA.Library get { return false; } } #endregion - #region XML - private XMLProperties _Xp; - private XMLProperties Xp - { - get { return _Xp; } - } - #endregion #region Attributes [XmlAttribute("Name")] private string _Name; @@ -69,27 +57,14 @@ namespace VEPROMS.CSLA.Library } #endregion Elements #region Constructors - private Format _Format; - private FormatInfo _FormatInfo; - public FormatConfig(string xml) - { - if (xml == string.Empty) xml = ""; - } - public FormatConfig(FormatInfo fi) - { - _FormatInfo = fi; - } - public FormatConfig(Format f) - { - _Format = f; - } - public FormatConfig() - { - PlantFormat = new PlantFormatx(); - } - #endregion Constructors - #region Serialize - public string ConvertToString() + private readonly Format _Format; + private readonly FormatInfo _FormatInfo; + public FormatConfig(FormatInfo fi) => _FormatInfo = fi; + public FormatConfig(Format f) => _Format = f; + public FormatConfig() => PlantFormat = new PlantFormatx(); + #endregion Constructors + #region Serialize + public string ConvertToString() { return GenericSerializer.StringSerialize(this); } @@ -131,11 +106,8 @@ namespace VEPROMS.CSLA.Library { } - public override string ToString() - { - return "Plant Format"; - } - } + public override string ToString() => "Plant Format"; + } #endregion PlantFormat #region FormatData // FormatData maps to the PlantFormat/Format data and contains properties & data objects that are implemented for the user to @@ -202,11 +174,8 @@ namespace VEPROMS.CSLA.Library { ReplaceStrData = new ReplaceStrData(); } - public override string ToString() - { - return "Format Data"; - } - } + public override string ToString() => "Format Data"; + } #endregion FormatData #region Flags [Serializable] @@ -242,27 +211,15 @@ namespace VEPROMS.CSLA.Library [Editor(typeof(PropGridCollEditor), typeof(System.Drawing.Design.UITypeEditor))] public class ReplaceStrData : List { - [Browsable(false)] - public int Capacity { get { return base.Capacity; } } - [Browsable(false)] - public int Count { get { return base.Count; } } - public ReplaceStr this[int index] - { - get { return (ReplaceStr)base[index]; } - } - public string ConvertToString() - { - return GenericSerializer.StringSerialize(this); - } - public override string ToString() - { - return "Replace Words List Count = " + base.Count.ToString(); - } - public static ReplaceStrData Get(string xml) - { - return GenericSerializer.StringDeserialize(xml); - } - } + [Browsable(false)] + public new int Capacity => base.Capacity; + [Browsable(false)] + public new int Count => base.Count; + public new ReplaceStr this[int index] => (ReplaceStr)base[index]; + public string ConvertToString() => GenericSerializer.StringSerialize(this); + public override string ToString() => $"Replace Words List Count = {base.Count}"; + public static ReplaceStrData Get(string xml) => GenericSerializer.StringDeserialize(xml); + } #endregion ReplaceStrData #region ReplaceStr @@ -303,19 +260,10 @@ namespace VEPROMS.CSLA.Library public ReplaceStr() { } - public string ConvertToString() - { - return GenericSerializer.StringSerialize(this); - } - public override string ToString() - { - return ReplaceWord; - } - public static ReplaceStr Get(string xml) - { - return GenericSerializer.StringDeserialize(xml); - } - } + public string ConvertToString() => GenericSerializer.StringSerialize(this); + public override string ToString() => ReplaceWord; + public static ReplaceStr Get(string xml) => GenericSerializer.StringDeserialize(xml); + } #endregion ReplaceStr #region CheckOffHeaders (list) [Serializable] @@ -323,23 +271,14 @@ namespace VEPROMS.CSLA.Library [Editor(typeof(PropGridCollEditor), typeof(System.Drawing.Design.UITypeEditor))] public class CheckOffHeaderList : List { - [Browsable(false)] - public int Capacity { get { return base.Capacity; } } - [Browsable(false)] - public int Count { get { return base.Count; } } - public CheckOffHeader this[int index] - { - get { return (CheckOffHeader)base[index]; } - } - public string ConvertToString() - { - return GenericSerializer.StringSerialize(this); - } - public override string ToString() - { - return "CheckOffHeader Count = " + base.Count.ToString(); - } - } + [Browsable(false)] + public new int Capacity => base.Capacity; + [Browsable(false)] + public new int Count { get { return base.Count; } } + public new CheckOffHeader this[int index] => (CheckOffHeader)base[index]; + public string ConvertToString() => GenericSerializer.StringSerialize(this); + public override string ToString() => $"CheckOffHeader Count = {base.Count}"; + } #endregion CheckOffHeaders #region CheckOffHeader [Serializable] @@ -382,15 +321,9 @@ namespace VEPROMS.CSLA.Library public CheckOffHeader() { } - public string ConvertToString() - { - return GenericSerializer.StringSerialize(this); - } - public override string ToString() - { - return CheckOffHeading; - } - } + public string ConvertToString() => GenericSerializer.StringSerialize(this); + public override string ToString() => CheckOffHeading; + } #endregion CheckOffHeader #region CheckOffs (list) [Serializable] @@ -399,22 +332,13 @@ namespace VEPROMS.CSLA.Library public class CheckOffList : List { [Browsable(false)] - public int Capacity { get { return base.Capacity; } } + public new int Capacity { get { return base.Capacity; } } [Browsable(false)] - public int Count { get { return base.Count; } } - public CheckOff this[int index] - { - get { return (CheckOff)base[index]; } - } - public string ConvertToString() - { - return GenericSerializer.StringSerialize(this); - } - public override string ToString() - { - return "CheckOff Count = " + base.Count.ToString(); - } - } + public new int Count { get { return base.Count; } } + public new CheckOff this[int index] => (CheckOff)base[index]; + public string ConvertToString() => GenericSerializer.StringSerialize(this); + public override string ToString() => $"CheckOff Count = {base.Count}"; + } #endregion CheckOffs #region CheckOff [Serializable] @@ -457,15 +381,9 @@ namespace VEPROMS.CSLA.Library public CheckOff() { } - public string ConvertToString() - { - return GenericSerializer.StringSerialize(this); - } - public override string ToString() - { - return MenuItem; - } - } + public string ConvertToString() => GenericSerializer.StringSerialize(this); + public override string ToString() => MenuItem; + } #endregion CheckOff #region ShwRplWds [Serializable] @@ -508,15 +426,9 @@ namespace VEPROMS.CSLA.Library public ShwRplWds() { } - public string ConvertToString() - { - return GenericSerializer.StringSerialize(this); - } - public override string ToString() - { - return MenuItem; - } - } + public string ConvertToString() => GenericSerializer.StringSerialize(this); + public override string ToString() => MenuItem; + } #endregion ShwRplWds #region StepData (list) [Serializable] @@ -525,26 +437,14 @@ namespace VEPROMS.CSLA.Library public class StepData : List { [Browsable(false)] - public int Capacity { get { return base.Capacity; } } + public new int Capacity { get { return base.Capacity; } } [Browsable(false)] - public int Count { get { return base.Count; } } - public Step this[int index] - { - get { return (Step)base[index]; } - } - public string ConvertToString() - { - return GenericSerializer.StringSerialize(this); - } - public override string ToString() - { - return "Step Count = " + base.Count.ToString(); - } - public static StepData Get(string xml) - { - return GenericSerializer.StringDeserialize(xml); - } - } + public new int Count { get { return base.Count; } } + public new Step this[int index] => (Step)base[index]; + public string ConvertToString() => GenericSerializer.StringSerialize(this); + public override string ToString() => $"Step Count = {base.Count}"; + public static StepData Get(string xml) => GenericSerializer.StringDeserialize(xml); + } #endregion StepData #region Step [Serializable] @@ -577,28 +477,16 @@ namespace VEPROMS.CSLA.Library public Step() { } - public string ConvertToString() - { - return GenericSerializer.StringSerialize(this); - } - public override string ToString() - { - return Type; - } - public static Step Get(string xml) - { - return GenericSerializer.StringDeserialize(xml); - } - } + public string ConvertToString() => GenericSerializer.StringSerialize(this); + public override string ToString() => Type; + public static Step Get(string xml) => GenericSerializer.StringDeserialize(xml); + } #endregion Step #region FontDesc [Serializable] [TypeConverter(typeof(ExpandableObjectConverter))] public class FontDesc { - // The Font object allows the conversion from a windows font back/forth from a string. This is how the - // data is stored in the database, i.e. a string representing the font. - private Font _Font; [XmlAttribute("Font")] [Browsable(false)] public string Font @@ -633,19 +521,10 @@ namespace VEPROMS.CSLA.Library public FontDesc() { } - public string ConvertToString() - { - return GenericSerializer.StringSerialize(this); - } - public override string ToString() - { - return "FontDescription"; - } - public static FontDesc Get(string xml) - { - return GenericSerializer.StringDeserialize(xml); - } - } + public string ConvertToString() => GenericSerializer.StringSerialize(this); + public override string ToString() => "FontDescription"; + public static FontDesc Get(string xml) => GenericSerializer.StringDeserialize(xml); + } #endregion Font #region DocStyles [Serializable] @@ -654,22 +533,13 @@ namespace VEPROMS.CSLA.Library public class DocStyles : List { [Browsable(false)] - public int Capacity { get { return base.Capacity; } } + public new int Capacity { get { return base.Capacity; } } [Browsable(false)] - public int Count { get { return base.Count; } } - public DocStyle this[int index] - { - get { return (DocStyle)base[index]; } - } - public string ConvertToString() - { - return GenericSerializer.StringSerialize(this); - } - public override string ToString() - { - return "Section Type Count = " + base.Count.ToString(); - } - } + public new int Count { get { return base.Count; } } + public new DocStyle this[int index] => (DocStyle)base[index]; + public string ConvertToString() => GenericSerializer.StringSerialize(this); + public override string ToString() => $"Section Type Count = {base.Count}"; + } #endregion DocStyles #region DocStyle [Serializable] @@ -702,15 +572,9 @@ namespace VEPROMS.CSLA.Library public DocStyle() { } - public string ConvertToString() - { - return GenericSerializer.StringSerialize(this); - } - public override string ToString() - { - return Name; - } - } + public string ConvertToString() => GenericSerializer.StringSerialize(this); + public override string ToString() => Name; + } #endregion DocStyle #region Layout [Serializable] @@ -752,18 +616,12 @@ namespace VEPROMS.CSLA.Library public Layout() { } - public string ConvertToString() - { - return GenericSerializer.StringSerialize(this); - } - public override string ToString() - { - return "Layout"; - } - #region IXmlSerializable members - // The read & write for these is necessary since they are within same xml element, and one may be empty, so - // no attribute should be listed in the xml. - public void WriteXml(XmlWriter writer) + public string ConvertToString() => GenericSerializer.StringSerialize(this); + public override string ToString() => "Layout"; + #region IXmlSerializable members + // The read & write for these is necessary since they are within same xml element, and one may be empty, so + // no attribute should be listed in the xml. + public void WriteXml(XmlWriter writer) { if (LeftMargin != null) writer.WriteAttributeString("LeftMargin", LeftMargin.ToString()); if (PageLength != null) writer.WriteAttributeString("PageLength", PageLength.ToString()); @@ -780,12 +638,9 @@ namespace VEPROMS.CSLA.Library } } - public XmlSchema GetSchema() - { - return (null); - } - #endregion - } + public XmlSchema GetSchema() => (null); + #endregion + } #endregion Layout } } diff --git a/PROMS/VEPROMS.CSLA.Library/Config/ImageConfig.cs b/PROMS/VEPROMS.CSLA.Library/Config/ImageConfig.cs index ae9eb0cd..e06a0db1 100644 --- a/PROMS/VEPROMS.CSLA.Library/Config/ImageConfig.cs +++ b/PROMS/VEPROMS.CSLA.Library/Config/ImageConfig.cs @@ -7,21 +7,14 @@ namespace VEPROMS.CSLA.Library [TypeConverter(typeof(ExpandableObjectConverter))] public class ImageConfig : ConfigDynamicTypeDescriptor, INotifyPropertyChanged { - #region DynamicTypeDescriptor - internal override bool IsReadOnly - { - get { return _ImageInfo == null; } - } - #endregion - #region XML - private XMLProperties _Xp; - private XMLProperties Xp - { - get { return _Xp; } - } + #region DynamicTypeDescriptor + internal override bool IsReadOnly => _ImageInfo == null; + #endregion + #region XML + private readonly XMLProperties _Xp; #endregion #region Constructors - private ImageInfo _ImageInfo; + private readonly ImageInfo _ImageInfo; public ImageConfig(ImageInfo imageInfo) { if (imageInfo == null) @@ -40,13 +33,10 @@ namespace VEPROMS.CSLA.Library string xml = ""; _Xp = new XMLProperties(xml); } - internal string GetValue(string group, string item) - { - return _Xp[group, item]; - } - #endregion - #region Local Properties - [Category("Image")] + internal string GetValue(string group, string item) => _Xp[group, item]; + #endregion + #region Local Properties + [Category("Image")] [Browsable(false)] [DisplayName("DataSize")] [RefreshProperties(RefreshProperties.All)] @@ -57,16 +47,16 @@ namespace VEPROMS.CSLA.Library { string s = _Xp["Image", "DataSize"]; if (s == string.Empty) return 0; - int tst = 0; + int tst; try { tst = int.Parse(s); } - catch (Exception ex) + catch (Exception) { return 0; } - return int.Parse(s); + return tst; } set { @@ -87,16 +77,16 @@ namespace VEPROMS.CSLA.Library { string s = _Xp["Image", "Width"]; if (s == string.Empty) return 0; - int tst = 0; + int tst; try { tst = int.Parse(s); } - catch (Exception ex) + catch (Exception) { return 0; } - return int.Parse(s); + return tst; } set { @@ -117,16 +107,16 @@ namespace VEPROMS.CSLA.Library { string s = _Xp["Image", "Height"]; if (s == string.Empty) return 0; - int tst = 0; + int tst; try { tst = int.Parse(s); } - catch (Exception ex) + catch (Exception) { return 0; } - return int.Parse(s); + return tst; } set { @@ -141,9 +131,8 @@ namespace VEPROMS.CSLA.Library public override string ToString() { string s = _Xp.ToString(); - if (s == "" || s == "") return string.Empty; - return s; - } - #endregion - } + return s == "" || s == "" ? string.Empty : s; + } + #endregion + } } diff --git a/PROMS/VEPROMS.CSLA.Library/Config/ProcConfig.cs b/PROMS/VEPROMS.CSLA.Library/Config/ProcConfig.cs index d3a5468f..4c2efe56 100644 --- a/PROMS/VEPROMS.CSLA.Library/Config/ProcConfig.cs +++ b/PROMS/VEPROMS.CSLA.Library/Config/ProcConfig.cs @@ -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 = ""; + if (xml == string.Empty) + xml = ""; _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 = ""; - _Xp = new XMLProperties(xml); + if (xml == string.Empty) + xml = ""; + _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 = ""; _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 == "" || s == "") return string.Empty; - return s; - } - #endregion - #region DelProcReason - [Category("General")] + return s == "" || s == "" ? 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)] diff --git a/PROMS/VEPROMS.CSLA.Library/Config/RODbConfig.cs b/PROMS/VEPROMS.CSLA.Library/Config/RODbConfig.cs index 1a57e980..7439ad9b 100644 --- a/PROMS/VEPROMS.CSLA.Library/Config/RODbConfig.cs +++ b/PROMS/VEPROMS.CSLA.Library/Config/RODbConfig.cs @@ -1,10 +1,6 @@ using System; -using System.Collections.Generic; -using System.Text; using System.ComponentModel; -using System.Drawing; using System.IO; -using DescriptiveEnum; namespace VEPROMS.CSLA.Library { @@ -12,21 +8,14 @@ namespace VEPROMS.CSLA.Library [TypeConverter(typeof(ExpandableObjectConverter))] public class RODbConfig : ConfigDynamicTypeDescriptor, INotifyPropertyChanged { - #region DynamicTypeDescriptor - internal override bool IsReadOnly - { - get { return _RODb == null; } - } - #endregion - #region XML - private XMLProperties _Xp; - private XMLProperties Xp - { - get { return _Xp; } - } + #region DynamicTypeDescriptor + internal override bool IsReadOnly => _RODb == null; + #endregion + #region XML + private readonly XMLProperties _Xp; #endregion #region Constructors - private RODb _RODb; + private readonly RODb _RODb; public RODbConfig(RODb roDb) { _RODb = roDb; @@ -34,7 +23,7 @@ namespace VEPROMS.CSLA.Library if (xml == string.Empty) xml = ""; _Xp = new XMLProperties(xml); } - private RODbInfo _RODbInfo; + private readonly RODbInfo _RODbInfo; public RODbConfig(RODbInfo roDbInfo) { _RODbInfo = roDbInfo; @@ -52,13 +41,10 @@ namespace VEPROMS.CSLA.Library string xml = ""; _Xp = new XMLProperties(xml); } - internal string GetValue(string group, string item) - { - return _Xp[group, item]; - } - #endregion - #region Local Properties - [Category("General")] + internal string GetValue(string group, string item) => _Xp[group, item]; + #endregion + #region Local Properties + [Category("General")] [DisplayName("ROName")] [Description("ROName")] public string ROName @@ -71,22 +57,20 @@ namespace VEPROMS.CSLA.Library [Description("FolderPath")] public string FolderPath { - get { return (_RODb != null ? _RODb.FolderPath : _RODbInfo != null?_RODbInfo.FolderPath:null); } + get { return (_RODb != null ? _RODb.FolderPath : _RODbInfo?.FolderPath); } set { if (_RODb != null) _RODb.FolderPath = value; } } - public RODb MyRODb - { get { return _RODb; } } - #endregion - #region ToString - public override string ToString() + public RODb MyRODb => _RODb; + #endregion + #region ToString + public override string ToString() { string s = _Xp.ToString(); - if (s == "" || s == "") return string.Empty; - return s; - } - #endregion - #region RODefaults - [Category("Referenced Objects")] + return s == "" || s == "" ? string.Empty : s; + } + #endregion + #region RODefaults + [Category("Referenced Objects")] [DisplayName("Graphic File Extension")] [RefreshProperties(RefreshProperties.All)] [Description("Default File Extension")] @@ -98,38 +82,41 @@ namespace VEPROMS.CSLA.Library // look in roapp.ini in the FolderPath directory; // look in top folder's config // set to Volian default, i.e. "TIF". - string s = GetRoAppIniValue("ROAPP", "Extention"); + string s = GetRoAppIniValue("Extention"); if (s == null || s == string.Empty) - s = TopFolderConfigValue("Graphics", "defaultext"); + s = TopFolderConfigValue(); if (s == null || s == string.Empty) return s = "TIF"; return s; } } - private string GetRoAppIniValue(string p, string p_2) - { - if (FolderPath == null) return null; - string inipath = FolderPath + @"\roapp.ini"; - if (!File.Exists(inipath)) return null; - StreamReader myReader = new StreamReader(inipath); - string sLine; - int indx = -1; - while ((sLine = myReader.ReadLine()) != null) - { - if (sLine.Length > 0 && sLine.Substring(0, 1) != ";") - { - if ((indx = sLine.ToLower().IndexOf(p_2.ToLower())) >= 0) - { - indx = sLine.IndexOf("=", indx + 9); - return sLine.Substring(indx + 1, sLine.Length - indx - 1).Trim(); - } - } - } - myReader.Close(); - return null; - } - private string TopFolderConfigValue(string p, string p_2) + private string GetRoAppIniValue(string p_2) + { + if (FolderPath == null) return null; + string inipath = FolderPath + @"\roapp.ini"; + if (!File.Exists(inipath)) return null; + using (StreamReader myReader = new StreamReader(inipath)) + { + string sLine; + int indx = -1; + while ((sLine = myReader.ReadLine()) != null) + { + if (sLine.Length > 0 && sLine.Substring(0, 1) != ";") + { + if ((indx = sLine.ToLower().IndexOf(p_2.ToLower())) >= 0) + { + indx = sLine.IndexOf("=", indx + 9); + return sLine.Substring(indx + 1, sLine.Length - indx - 1).Trim(); + } + } + } + myReader.Close(); + } + + return null; + } + private string TopFolderConfigValue() { FolderInfo fi = FolderInfo.GetTop(); return fi.FolderConfig.Graphics_defaultext; @@ -145,9 +132,9 @@ namespace VEPROMS.CSLA.Library } public string GetDefaultGraphicExtensionLocation() { - string s = GetRoAppIniValue("ROAPP", "Extention"); + string s = GetRoAppIniValue("Extention"); if (s != null && s != string.Empty) return "Default Extension found in roapp.ini"; - s = TopFolderConfigValue("Graphics", "defaultext"); + s = TopFolderConfigValue(); if (s != null && s != string.Empty) return "Default Extension defined in veproms properties"; return "Used program default"; } diff --git a/PROMS/VEPROMS.CSLA.Library/Config/ROFSTLookup.cs b/PROMS/VEPROMS.CSLA.Library/Config/ROFSTLookup.cs index fe72f0f8..663c84f3 100644 --- a/PROMS/VEPROMS.CSLA.Library/Config/ROFSTLookup.cs +++ b/PROMS/VEPROMS.CSLA.Library/Config/ROFSTLookup.cs @@ -159,16 +159,13 @@ namespace VEPROMS.CSLA.Library private int _totalRoCnt = 0; private double _pctComplete = 0; - #endregion + #endregion - #region Properties + #region Properties - public int RofstID - { - get { return _rofstID; } - } + public int RofstID => _rofstID; - public DocVersionInfo MyDocVersionInfo + public DocVersionInfo MyDocVersionInfo { get { return _myDocVersionInfo; } set @@ -178,14 +175,11 @@ namespace VEPROMS.CSLA.Library } } - // C2021-065 see if we need to get the RO information for the "Other" Child applicability value - public int SelectedSlave - { - get { return (!string.IsNullOrEmpty(_otherChild)) ? Convert.ToInt32(_otherChild) : _selectedSlave; } - } + // C2021-065 see if we need to get the RO information for the "Other" Child applicability value + public int SelectedSlave => (!string.IsNullOrEmpty(_otherChild)) ? Convert.ToInt32(_otherChild) : _selectedSlave; - //C2021-065 used by Barakah Alarms so that we get ROLookUp for the Other applicability - public string OtherChild + //C2021-065 used by Barakah Alarms so that we get ROLookUp for the Other applicability + public string OtherChild { get { return _otherChild; } set { _otherChild = value; } @@ -237,16 +231,13 @@ namespace VEPROMS.CSLA.Library set { _autoCombineSingleRetValues = value; } } - public bool ShowLoadingStatus - { - get { return _showLoadingStatus; } - } + public bool ShowLoadingStatus => _showLoadingStatus; - #endregion + #endregion - #region Constructors + #region Constructors - public ROFSTLookup(int rofstID, DocVersionInfo dvi, string otherChild, bool showLoadingStatus = true) + public ROFSTLookup(int rofstID, DocVersionInfo dvi, string otherChild, bool showLoadingStatus = true) { // Set Fields/Properties _rofstID = rofstID; @@ -321,31 +312,19 @@ namespace VEPROMS.CSLA.Library return RofstDataSearch(_rofstID, value, searchTypeID, onlyRoid16, maxNumRecords); } - public ROFSTLookup.rochild[] GetRoChildrenByID(int id, int dbiID, bool loadChildren = false, bool loadAllChildren = false) - { - return RofstDataGetChildrenByID(_rofstID, dbiID, id, loadChildren, loadAllChildren); - } + public ROFSTLookup.rochild[] GetRoChildrenByID(int id, int dbiID, bool loadChildren = false, bool loadAllChildren = false) => RofstDataGetChildrenByID(_rofstID, dbiID, id, loadChildren, loadAllChildren); - public ROFSTLookup.rochild[] GetRoChildrenByRoid(string roid, bool loadChildren = false, bool loadAllChildren = false) - { - return RofstDataGetChildrenByRoid(_rofstID, roid, loadChildren, loadAllChildren); - } + public ROFSTLookup.rochild[] GetRoChildrenByRoid(string roid, bool loadChildren = false, bool loadAllChildren = false) => RofstDataGetChildrenByRoid(_rofstID, roid, loadChildren, loadAllChildren); - public ROFSTLookup.rochild[] GetRoChildrenByType(E_ROValueType valueTypes, bool loadChildren = false, bool loadAllChildren = false) - { - return RofstDataGetRoChildrenByType(_rofstID, valueTypes, loadChildren, loadAllChildren); - } + public ROFSTLookup.rochild[] GetRoChildrenByType(E_ROValueType valueTypes, bool loadChildren = false, bool loadAllChildren = false) => RofstDataGetRoChildrenByType(_rofstID, valueTypes, loadChildren, loadAllChildren); - #endregion + #endregion - #region (RO Database Info) + #region (RO Database Info) - public int GetRODatabaseTitleIndex(string roid) - { - return Convert.ToInt32("0x" + roid.Substring(0, 4), 16); - } + public int GetRODatabaseTitleIndex(string roid) => Convert.ToInt32("0x" + roid.Substring(0, 4), 16); - public string GetRODatabaseTitle(int idx) + public string GetRODatabaseTitle(int idx) { ROFSTLookup.rodbi rd = RofstDataGetDatabaseByID(_rofstID, idx); return (!string.IsNullOrEmpty(rd.dbiTitle) ? rd.dbiTitle : "RO Database Title Not Found"); @@ -358,16 +337,13 @@ namespace VEPROMS.CSLA.Library return (rd.dbiID > 0) ? rd : RofstDataGetDatabaseByID(_rofstID, 1, loadChildren, loadAllChildren); } - public ROFSTLookup.rodbi[] GetRODatabaseList(bool loadChildren = false, bool loadAllChildren = false) - { - return RofstDataGetDatabases(_rofstID, loadChildren, loadAllChildren); - } + public ROFSTLookup.rodbi[] GetRODatabaseList(bool loadChildren = false, bool loadAllChildren = false) => RofstDataGetDatabases(_rofstID, loadChildren, loadAllChildren); - #endregion + #endregion - #region (RO Info By AccPageID) + #region (RO Info By AccPageID) - public string FormatAccPageKey(string accPageID) + public string FormatAccPageKey(string accPageID) { string accPageBase = string.Empty; string accPageExt = string.Empty; @@ -527,12 +503,9 @@ namespace VEPROMS.CSLA.Library return (!string.IsNullOrEmpty(retval)) ? retval.Replace("\r\n", @"\par ") : retval; } - public List GetValueDifferences(int originalRofstID, ref List delList) - { - return RofstDataGetValueDifferences(originalRofstID, _rofstID, ref delList); - } + public List GetValueDifferences(int originalRofstID, ref List delList) => RofstDataGetValueDifferences(originalRofstID, _rofstID, ref delList); - public List GetROTitleAndGroupPath(string roid, bool reportMissingROs, bool convertCaretToDelta) + public List GetROTitleAndGroupPath(string roid, bool reportMissingROs, bool convertCaretToDelta) { // Return the RO Title in a list of strings. The last item in the list is the actual RO title, // the items preceding it are the titles of the groups and sub-groups containing the RO @@ -616,26 +589,17 @@ namespace VEPROMS.CSLA.Library return sb.ToString(); } - #endregion + #endregion - #region (RO Info Helper Methods) + #region (RO Info Helper Methods) - public static byte[] GetRofstLookupBytes(int rofstID) - { - return RofstDataGetRofstLookupBytes(rofstID); - } + public static byte[] GetRofstLookupBytes(int rofstID) => RofstDataGetRofstLookupBytes(rofstID); - public static DateTime GetRoFSTdts(int rofstID) - { - return GetRofstDtsByID(rofstID); - } + public static DateTime GetRoFSTdts(int rofstID) => GetRofstDtsByID(rofstID); - public DateTime GetRoFSTdts() - { - return GetRoFSTdts(_rofstID); - } + public DateTime GetRoFSTdts() => GetRoFSTdts(_rofstID); - public bool HasChildren(ref ROFSTLookup.rochild child) + public bool HasChildren(ref ROFSTLookup.rochild child) { LoadChildren(ref child); return child.children.Any(); @@ -666,12 +630,9 @@ namespace VEPROMS.CSLA.Library db.children = GetRoChildrenByID(db.ID, db.dbiID, false); } - public static ROFSTLookup.rochild GetEmptyRoChild() - { - return new ROFSTLookup.rochild() { ID = -1, type = 0 }; - } + public static ROFSTLookup.rochild GetEmptyRoChild() => new ROFSTLookup.rochild() { ID = -1, type = 0 }; - public static string CalculateDuration(DateTime dtStart) + public static string CalculateDuration(DateTime dtStart) { string duration = string.Empty; @@ -1736,31 +1697,6 @@ namespace VEPROMS.CSLA.Library #region (Convert To Objects) - private ROFSTLookup.roHdr ConvertToRoHdrObject(SafeDataReader dr, bool loadChildren) - { - ROFSTLookup.roHdr rh = new ROFSTLookup.roHdr - { - hSize = (int)dr.GetValue("hSize"), - hYear = (int)dr.GetValue("hYear"), - hMonth = (byte)dr.GetValue("hMonth"), - hDay = (byte)dr.GetValue("hDay"), - hcYear = (int)dr.GetValue("hcYear"), - hcMonth = (byte)dr.GetValue("hcMonth"), - hcDay = (byte)dr.GetValue("hcDay"), - hcHour = (byte)dr.GetValue("hcHour"), - hcMin = (byte)dr.GetValue("hcMin"), - hcSec = (byte)dr.GetValue("hcSec"), - hcHund = (byte)dr.GetValue("hcHund") - }; - - if (loadChildren) - { - rh.myDbs = RofstDataGetDatabases(_rofstID); - } - - return rh; - } - private ROFSTLookup.rodbi ConvertToRodbiObject(SafeDataReader dr, bool loadChildren, bool loadAllChildren) { ROFSTLookup.rodbi rd = new ROFSTLookup.rodbi @@ -2202,12 +2138,9 @@ namespace VEPROMS.CSLA.Library return i; } - private int NextDelimiter(string delim, string str) - { - return (!string.IsNullOrEmpty(str)) ? str.IndexOfAny(delim.ToCharArray()) : -1; - } + private int NextDelimiter(string delim, string str) => (!string.IsNullOrEmpty(str)) ? str.IndexOfAny(delim.ToCharArray()) : -1; - private int MatchingBrace(string str) + private int MatchingBrace(string str) { int level = 1; int idx = 0; // the while will skip the first position (the first brace) @@ -2426,7 +2359,7 @@ namespace VEPROMS.CSLA.Library { if (match.Groups[2].Value != "1") // Other than "1", multiply it times 10 raised to a power { - sb.Append(match.Groups[2].Value + "x10"); + sb.Append($"{match.Groups[2].Value}x10"); } else // The number is simply 1 so it can be ignored and 10 can be raised to a power { @@ -2435,11 +2368,11 @@ namespace VEPROMS.CSLA.Library } else // A number with a decimal point { - sb.Append(match.Groups[2].Value + "." + match.Groups[3].Value + "x10"); + sb.Append($"{match.Groups[2].Value}.{match.Groups[3].Value}x10"); } // Add the exponent as superscript - return sb.ToString() + "\\up2 " + match.Groups[4].Value.Replace("-", @"\u8209?") + match.Groups[5].Value + "\\up0 "; + return $"{sb}\\up2 {match.Groups[4].Value.Replace("-", @"\u8209?")}{match.Groups[5].Value}\\up0 "; } #endregion diff --git a/PROMS/VEPROMS.CSLA.Library/Config/ROImageConfig.cs b/PROMS/VEPROMS.CSLA.Library/Config/ROImageConfig.cs index d55e0c8d..feef6ac3 100644 --- a/PROMS/VEPROMS.CSLA.Library/Config/ROImageConfig.cs +++ b/PROMS/VEPROMS.CSLA.Library/Config/ROImageConfig.cs @@ -7,21 +7,14 @@ namespace VEPROMS.CSLA.Library [TypeConverter(typeof(ExpandableObjectConverter))] public class ROImageConfig : ConfigDynamicTypeDescriptor, INotifyPropertyChanged { - #region DynamicTypeDescriptor - internal override bool IsReadOnly - { - get { return _ROImageInfo == null; } - } - #endregion - #region XML - private XMLProperties _Xp; - private XMLProperties Xp - { - get { return _Xp; } - } + #region DynamicTypeDescriptor + internal override bool IsReadOnly => _ROImageInfo == null; + #endregion + #region XML + private readonly XMLProperties _Xp; #endregion #region Constructors - private ROImageInfo _ROImageInfo; + private readonly ROImageInfo _ROImageInfo; public ROImageConfig(ROImageInfo rOImageInfo) { _ROImageInfo = rOImageInfo; @@ -34,13 +27,10 @@ namespace VEPROMS.CSLA.Library string xml = ""; _Xp = new XMLProperties(xml); } - internal string GetValue(string group, string item) - { - return _Xp[group, item]; - } - #endregion - #region Local Properties - [Category("Image")] + internal string GetValue(string group, string item) => _Xp[group, item]; + #endregion + #region Local Properties + [Category("Image")] [Browsable(false)] [DisplayName("Size")] [RefreshProperties(RefreshProperties.All)] @@ -62,9 +52,8 @@ namespace VEPROMS.CSLA.Library public override string ToString() { string s = _Xp.ToString(); - if (s == "" || s == "") return string.Empty; - return s; - } - #endregion - } + return s == "" || s == "" ? string.Empty : s; + } + #endregion + } } diff --git a/PROMS/VEPROMS.CSLA.Library/Config/RevisionConfig.cs b/PROMS/VEPROMS.CSLA.Library/Config/RevisionConfig.cs index 990a6ace..6b727a0b 100644 --- a/PROMS/VEPROMS.CSLA.Library/Config/RevisionConfig.cs +++ b/PROMS/VEPROMS.CSLA.Library/Config/RevisionConfig.cs @@ -1,9 +1,5 @@ using System; -using System.Collections.Generic; -using System.Text; using System.ComponentModel; -using System.Drawing; -using DescriptiveEnum; namespace VEPROMS.CSLA.Library { @@ -11,22 +7,15 @@ namespace VEPROMS.CSLA.Library [TypeConverter(typeof(ExpandableObjectConverter))] public class RevisionConfig : ConfigDynamicTypeDescriptor, INotifyPropertyChanged { - #region DynamicTypeDescriptor - internal override bool IsReadOnly - { - get { return false; }//_Section == null; } - } - #endregion - #region XML - private XMLProperties _Xp; - private XMLProperties Xp - { - get { return _Xp; } - } + #region DynamicTypeDescriptor + internal override bool IsReadOnly => false; + #endregion + #region XML + private readonly XMLProperties _Xp; #endregion #region Constructors - private Revision _Revision; - private RevisionInfo _RevisionInfo; + private readonly Revision _Revision; + private readonly RevisionInfo _RevisionInfo; [Browsable(false)] public bool ParentLookup { @@ -52,18 +41,12 @@ namespace VEPROMS.CSLA.Library if (xml == string.Empty) xml = ""; _Xp = new XMLProperties(xml); } - public RevisionConfig() - { - _Xp = new XMLProperties(); - } - internal string GetValue(string group, string item) - { - return _Xp[group, item]; - } - #endregion - #region Properties and Methods - // This is needed for the Data Loader - [Category("History")] + public RevisionConfig() => _Xp = new XMLProperties(); + internal string GetValue(string group, string item) => _Xp[group, item]; + #endregion + #region Properties and Methods + // This is needed for the Data Loader + [Category("History")] [Browsable(false)] [DisplayName("Start Date")] [RefreshProperties(RefreshProperties.All)] @@ -115,9 +98,8 @@ namespace VEPROMS.CSLA.Library public override string ToString() { string s = _Xp.ToString(); - if (s == "" || s == "") return string.Empty; - return s; - } - #endregion - } + return s == "" || s == "" ? string.Empty : s; + } + #endregion + } } diff --git a/PROMS/VEPROMS.CSLA.Library/Config/SectionConfig.cs b/PROMS/VEPROMS.CSLA.Library/Config/SectionConfig.cs index dc6fe4dc..d2b373af 100644 --- a/PROMS/VEPROMS.CSLA.Library/Config/SectionConfig.cs +++ b/PROMS/VEPROMS.CSLA.Library/Config/SectionConfig.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Text; using System.ComponentModel; using DescriptiveEnum; using System.Xml; @@ -11,18 +10,11 @@ namespace VEPROMS.CSLA.Library [TypeConverter(typeof(ExpandableObjectConverter))] public class SectionConfig : ConfigDynamicTypeDescriptor, INotifyPropertyChanged, IItemConfig { - #region DynamicTypeDescriptor - internal override bool IsReadOnly - { - get { return false; }//_Section == null; } - } - #endregion - #region XML - private XMLProperties _Xp; - private XMLProperties Xp - { - get { return _Xp; } - } + #region DynamicTypeDescriptor + internal override bool IsReadOnly => false; + #endregion + #region XML + private readonly XMLProperties _Xp; #endregion #region Constructors //PROPGRID: Hide ParentLookup @@ -32,26 +24,13 @@ namespace VEPROMS.CSLA.Library get { return _Xp.ParentLookup; } set { _Xp.ParentLookup = value; } } - //PROPGRID: Had to comment out NonSerialized 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 Section _Section; - private SectionInfo _SectionInfo; + private readonly Section _Section; + private readonly SectionInfo _SectionInfo; private static int _SectionConfigUnique = 0; - private static int SectionConfigUnique - { get { return ++_SectionConfigUnique; } } - private int _MySectionConfigUnique = SectionConfigUnique; - public int MySectionConfigUnique // Absolutely Unique ID - Info - { get { return _MySectionConfigUnique; } } + private static int SectionConfigUnique => ++_SectionConfigUnique; + private readonly int _MySectionConfigUnique = SectionConfigUnique; - public SectionConfig(Section section) + public SectionConfig(Section section) { _Section = section; string xml = section.MyContent.Config; @@ -82,9 +61,8 @@ namespace VEPROMS.CSLA.Library if (retval != string.Empty) return retval; proc = (ProcedureInfo)proc.ActiveParent; } - 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) { @@ -102,23 +80,11 @@ namespace VEPROMS.CSLA.Library _Xp = new XMLProperties(xml); if (_SectionInfo.ActiveParent != null) _Xp.LookInAncestor += new XMLPropertiesEvent(Xp_LookInAncestorFolder); } - //public SectionConfig(string xml) - //{ - // if (xml == string.Empty) xml = ""; - // _Xp = new XMLProperties(xml); - //} - public SectionConfig() - { - _Xp = new XMLProperties(); - } - internal string GetValue(string group, string item) - { - return _Xp[group, item]; - } - #endregion - #region Local Properties - //[Category("Identification")] - [Category("General")] + public SectionConfig() => _Xp = new XMLProperties(); + internal string GetValue(string group, string item) => _Xp[group, item]; + #endregion + #region Local Properties + [Category("General")] [DisplayName("Number")] [Description("Number")] public string Number @@ -126,7 +92,6 @@ namespace VEPROMS.CSLA.Library get { return (_Section != null ? _Section.MyContent.Number : _SectionInfo.MyContent.Number); } set { if (_Section != null) _Section.MyContent.Number = value; } } - //[Category("Identification")] [Category("General")] [DisplayName("Title")] [Description("Title")] @@ -142,7 +107,7 @@ namespace VEPROMS.CSLA.Library [Description("Old Sequence")] public string OldSequence { - get { return (_Section != null ? _Section.MyContent.MyZContent.OldStepSequence : (_SectionInfo.MyContent.MyZContent == null ? null : _SectionInfo.MyContent.MyZContent.OldStepSequence)); } + get { return (_Section != null ? _Section.MyContent.MyZContent.OldStepSequence : (_SectionInfo.MyContent.MyZContent?.OldStepSequence)); } set { if (_Section != null) _Section.MyContent.MyZContent.OldStepSequence = value; } } [Category("Identification")] @@ -152,7 +117,7 @@ namespace VEPROMS.CSLA.Library [Description("Dirty")] public bool Dirty { - get { return (_Section != null ? _Section.IsDirty : false); } + get { return (_Section != null && _Section.IsDirty); } } [Category("Format")] [DisplayName("Format")] @@ -171,7 +136,6 @@ namespace VEPROMS.CSLA.Library if (_Section != null) { _Section.MyContent.MyFormat = FormatList.ToFormat(value); // Can only be set if _DocVersion is set - //_Section.ActiveFormat = null; DocStyleListConverter.MySection = _Section; } } @@ -192,7 +156,7 @@ namespace VEPROMS.CSLA.Library set { if (_Section != null) - _Section.MyContent.MyFormat = value == null ? null : value.GetJustFormat(); + _Section.MyContent.MyFormat = value?.GetJustFormat(); } } [Category("Format")] @@ -304,15 +268,13 @@ namespace VEPROMS.CSLA.Library public override string ToString() { string s = _Xp.ToString(); - if (s == "" || s == "") return string.Empty; - return s; - } - #endregion - #region SectionCategory // from sequence number in 16-bit database. - [TypeConverter(typeof(EnumDescConverter))] + return s == "" || s == "" ? string.Empty : s; + } + #endregion + #region SectionCategory // from sequence number in 16-bit database. + [TypeConverter(typeof(EnumDescConverter))] public enum SectionPagination : int { - //Default = 0, Continuous, Separate Continuous = 1, Separate = 2 } [Category("Format")] @@ -415,7 +377,7 @@ namespace VEPROMS.CSLA.Library get { string tmp = _Xp["Section", "TOC_Group_Title"]; - return (tmp == null)? "" : tmp; + return tmp ?? ""; } set { @@ -476,23 +438,6 @@ namespace VEPROMS.CSLA.Library OnPropertyChanged("Section_DontIncludeDuplexFoldout"); } } - //[Category("Section")] - ////PROPGRID: Hide AutoGen - //[DisplayName("Section AutoGen")] - //[RefreshProperties(RefreshProperties.All)] - //[Description("Section AutoGen")] - //public string Section_AutoGen - //{ - // get - // { - // return _Xp["Section", "AutoGen"]; - // } - // set - // { - // _Xp["Section", "AutoGen"] = value; - // OnPropertyChanged("Section_AutoGen"); - // } - //} [Category("Section")] //PROPGRID: Hide Subsection PH [DisplayName("Section PrintHdr")] @@ -536,7 +481,6 @@ namespace VEPROMS.CSLA.Library { get { - //return _Xp["Section", "ShwRplWords"]; string tmp = _Xp["Section", "ShwRplWords"]; return tmp == null || tmp == "" ? "Y" : tmp; } @@ -568,8 +512,6 @@ namespace VEPROMS.CSLA.Library // C2020-046 change wording for the column modes to One, Two, Three, and Four public enum SectionColumnMode : int { - //[Description("Format Default")] - //Default = 0, [Description("One Column")] One = 1, [Description("Two Columns")] @@ -595,7 +537,7 @@ namespace VEPROMS.CSLA.Library // If there is no parent value, then use the volian default if (s == string.Empty) { - SectionInfo si = _SectionInfo != null ? _SectionInfo : SectionInfo.Get(_Section.ItemID); + SectionInfo si = _SectionInfo ?? SectionInfo.Get(_Section.ItemID); if (si != null) { E_PurchaseOptions po = (E_PurchaseOptions)(MyFormat ?? MyDefaultFormat).PlantFormat.FormatData.PurchaseOptions; @@ -607,34 +549,23 @@ namespace VEPROMS.CSLA.Library { case FormatColumns.OneColumn: return SectionColumnMode.One; - break; case FormatColumns.TwoColumn: return SectionColumnMode.Two; - break; case FormatColumns.ThreeColumn: return SectionColumnMode.Three; - break; case FormatColumns.FourColumns: return SectionColumnMode.Four; - break; - //default: - // return SectionColumnMode.One; - // break; } } } - int rval = 0; - if (MyFormat != null) + int rval; + if (MyFormat != null) { rval = (int)MyFormat.MyStepSectionLayoutData.PMode; - //int rval = (int)MyFormat.MyStepSectionLayoutData.PMode; - //return (SectionColumnMode)rval;//SectionColumnMode.Two; //SectionColumnMode.Default;// default to volian default } else { - //int rval = (int)MyDefaultFormat.MyStepSectionLayoutData.PMode; rval = (int)MyDefaultFormat.MyStepSectionLayoutData.PMode; - //return (SectionColumnMode)rval; } // if no pmode is defined, i.e. rval = 0, then go up to the procedure level & get // it's format column. @@ -646,11 +577,6 @@ namespace VEPROMS.CSLA.Library } else return (SectionColumnMode)int.Parse(s); - - //if (s == string.Empty) - // return SectionColumnMode.Default; - - //return (SectionColumnMode)int.Parse(s); } set { @@ -670,13 +596,12 @@ namespace VEPROMS.CSLA.Library } else rval =(int)MyFormat.MyStepSectionLayoutData.PMode; - //parval = ((rval > 0)?((SectionColumnMode)rval).ToString() : "2"); // if PMode is zero default to 2 column mode } // if still no value found in inheritance, check if the procedure has a default. if so and value matches, clear out any config item. if (rval == 0) { - SectionInfo si = _SectionInfo != null ? _SectionInfo : SectionInfo.Get(_Section.ItemID); + SectionInfo si = _SectionInfo ?? SectionInfo.Get(_Section.ItemID); if (si != null) { switch (si.MyProcedure.ProcedureConfig.Format_Columns) @@ -708,103 +633,6 @@ namespace VEPROMS.CSLA.Library OnPropertyChanged("Section_ColumnMode"); } } -//char * far printtypes[] = { -// "Compressed, 8 lines per inch", -// "Elite, 6 lines per inch", -// "Pica, 6 lines per inch", -// "Default font, 4 Lines Per Inch", -// "Default font, 6 Lines Per Inch", -// "Compressed 6 LPI", -// "Default font, 7 Lines Per Inch", -// "Special Landscape, Elite, 6 lines per inch" -//}; - //[TypeConverter(typeof(EnumDescConverter))] - //public enum AttPrintSize : int - //{ - // [Description("Compressed, 8 lines per inch")] - // Cmp8lpi = 0, - // [Description("Elite, 6 lines per inch")] - // Elite6lpi = 1, - // [Description("Pica, 6 lines per inch")] - // Pica6lpi = 2, - // [Description("Default font, 4 Lines Per Inch")] - // Def4lpi = 3, - // [Description("Default font, 6 Lines Per Inch")] - // Def6lpi = 4, - // [Description("Compressed 6 LPI")] - // Cmp6lpi = 5, - // [Description("Default font, 7 Lines Per Inch")] - // Def7lpi = 6, - // [Description("Landscape, Elite, 6 lines per inch")] - // landElite6lpi = 7 - //} - - //[Category("Format")] - //[DisplayName("Attachment PrintSize")] - //[RefreshProperties(RefreshProperties.All)] - //[Description("Attachment Print Size")] - //public AttPrintSize Section_AttachmentPrintSize - //{ - // get - // { - // string lpiSettings = "*pP46f7L"; - // string s = _Xp["Section", "OldType"]; - // int idx = -1; - - // //If there is no value to get, then get the parent value (a.k.a. default value). - // if (s == string.Empty) - // s = _Xp.ParentValue("Section", "OldType"); // get the parent value - // // If there is no parent value, then use the volian default - // if (s == string.Empty) - // return AttPrintSize.Def6lpi;// default to volian default - - // idx = lpiSettings.IndexOf(s[1]); - // if (idx == -1) idx = 4; - // return (AttPrintSize)idx; - // //return (AttPrintSize)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 lpiSettings = "*pP46f7L"; - // string parval = _Xp.ParentValue("Section", "OldType"); // get the parent value - // StringBuilder sb = new StringBuilder(); - // string curval = parval[1].ToString(); - - // sb.Append(parval[0]); // save first part of OldType - - // if (parval.Equals(string.Empty)) // if the parent value is empty, then use the volian default - // { - // //parval = ((int)(AttPrintSize.Def6lpi)).ToString(); - // //sb.Append(((int)(AttPrintSize.Def6lpi)).ToString()); - // sb.Append(lpiSettings[(int)(AttPrintSize.Def6lpi)]); - // } - - // if (curval.Equals(((int)value).ToString())) - // _Xp["Section", "OldType"] = string.Empty; // reset to parent value - // else - // { - // //sb.Append(((int)value).ToString()); - // sb.Append(lpiSettings[(int)value]); - // _Xp["Section", "OldType"] = sb.ToString(); // save selected value - // } - - // OnPropertyChanged("Section_AttachmentPrintSize"); - // } - //} - /* - int chkOffType = (rid[0] & 0x007F) - '0'; - if (chkOffType > 0) - ci.AddItem("Section", "CheckoffSelection", chkOffType.ToString()); - - if (stype.Length > 1) - { - int chkOffHeading = (stype[1] & 0x007F) - '0'; - if (chkOffHeading > 0) - ci.AddItem("Section", "CheckoffHeading", chkOffHeading.ToString()); - */ [Category("Format")] [DisplayName("Checkoff List Selection")] [Description("Checkoff List Selection")] @@ -874,13 +702,10 @@ namespace VEPROMS.CSLA.Library { get { - //if (_SectionInfo != null && _SectionInfo.Sections != null && _SectionInfo.Sections.Count > 0 && _SectionInfo.Steps != null && _SectionInfo.Steps.Count > 0) if (_SectionInfo != null && _SectionInfo.Sections != null && _SectionInfo.Sections.Count > 0) return "N"; if (_Section != null && HasSubsections) return "N"; - //if (_Section != null && _Section.MyContent.cont .Sections.Count > 0 && _Section.Steps.Count > 0) - // return "N"; return "Y"; } } @@ -1013,8 +838,6 @@ namespace VEPROMS.CSLA.Library { if (MyEnhancedDocuments == null || MyEnhancedDocuments.Count == 0) // clear out the xml node { - //XmlNode dd = _Xp.XmlContents.SelectSingleNode("//Slave[@index='" + index.ToString() + "']"); - //dd.ParentNode.RemoveChild(dd); List nodesToDel = new List(); foreach (XmlNode xnr in _Xp.XmlContents.SelectNodes("//Enhanced")) nodesToDel.Add(xnr); if (nodesToDel != null) diff --git a/PROMS/VEPROMS.CSLA.Library/Config/StepConfig.cs b/PROMS/VEPROMS.CSLA.Library/Config/StepConfig.cs index 692a8db3..42463e89 100644 --- a/PROMS/VEPROMS.CSLA.Library/Config/StepConfig.cs +++ b/PROMS/VEPROMS.CSLA.Library/Config/StepConfig.cs @@ -1,19 +1,14 @@ using System; using System.Collections.Generic; -using System.Text; using System.ComponentModel; -using DescriptiveEnum; using System.Xml; namespace VEPROMS.CSLA.Library { public partial class EnhancedDocuments : List { - public void Add(int type, int itemID) - { - Add(new EnhancedDocument(type, itemID)); - } - public static EnhancedDocuments Load(XMLProperties _Xp) + public void Add(int type, int itemID) => Add(new EnhancedDocument(type, itemID)); + public static EnhancedDocuments Load(XMLProperties _Xp) { EnhancedDocuments ed = new EnhancedDocuments(); foreach (XmlNode xn in _Xp.XmlContents.SelectNodes("//Enhanced")) @@ -31,45 +26,25 @@ namespace VEPROMS.CSLA.Library } public partial class EnhancedDocument { - private int _Type; - public int Type - { - get { return _Type; } - set { _Type = value; } - } - private int _ItemID; - public int ItemID - { - get { return _ItemID; } - set { _ItemID = value; } - } - public EnhancedDocument() { ;} + public int Type { get; set; } + public int ItemID { get; set; } + public EnhancedDocument() { ;} public EnhancedDocument(int type, int itemID) { Type = type; ItemID = itemID; } - public override string ToString() - { - return string.Format("{0}.ItemID={1}", Type, ItemID); - } - } + public override string ToString() => $"{Type}.ItemID={ItemID}"; + } [Serializable] [TypeConverter(typeof(ExpandableObjectConverter))] public class StepConfig : ConfigDynamicTypeDescriptor, INotifyPropertyChanged, IItemConfig { - #region DynamicTypeDescriptor - internal override bool IsReadOnly - { - get { return false; }//_Section == null; } - } - #endregion - #region XML - private XMLProperties _Xp; - private XMLProperties Xp - { - get { return _Xp; } - } + #region DynamicTypeDescriptor + internal override bool IsReadOnly => false; + #endregion + #region XML + private readonly XMLProperties _Xp; #endregion #region Constructors //PROPGRID: Hide ParentLookup @@ -79,18 +54,8 @@ namespace VEPROMS.CSLA.Library get { return _Xp.ParentLookup; } set { _Xp.ParentLookup = value; } } - //PROPGRID: Had to comment out NonSerialized 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 Step _Step; - private StepInfo _StepInfo; + private readonly Step _Step; + private readonly StepInfo _StepInfo; public StepConfig(Step step) { _Step = step; @@ -111,47 +76,36 @@ namespace VEPROMS.CSLA.Library _Xp = new XMLProperties(xml); } - public StepConfig() - { - _Xp = new XMLProperties(); - } - internal string GetValue(string group, string item) - { - return _Xp[group, item]; - } - #endregion - #region Local Properties - - #endregion - #region ToString - public override string ToString() + public StepConfig() => _Xp = new XMLProperties(); + internal string GetValue(string group, string item) => _Xp[group, item]; + #endregion + #region Local Properties + + #endregion + #region ToString + public override string ToString() { string s = _Xp.ToString(); - if (s == "" || s == "") return string.Empty; - return s; - } - #endregion - #region StepAttr - //[Category("Step Attributes")] - //[DisplayName("Step Floating Foldout Association")] - //[RefreshProperties(RefreshProperties.All)] - //[Description("Step Floating Foldout Association")] - public int Step_FloatingFoldout + return s == "" || s == "" ? string.Empty : s; + } + #endregion + #region StepAttr + public int Step_FloatingFoldout { get { string s = _Xp["Step", "FloatingFoldout"]; if (s == string.Empty) return 0; - int tst = 0; - try + int tst; + try { tst = int.Parse(s); } - catch (Exception ex) - { + catch (Exception) + { return 0; } - return int.Parse(s); + return tst; } set { @@ -196,28 +150,6 @@ namespace VEPROMS.CSLA.Library OnPropertyChanged("Step_TCAS"); } } - //// Alternate text to use on the Continuous Action Summary - //public string Step_AlternateContActSumText - //{ - // get - // { - // string s = _Xp["Step", "AlternateContActSumText"]; - // //If there is no value to get, then we use the actual step text - // if (s == string.Empty) return null; - // return s; - // } - // set - // { - // string s = _Xp["Step", "AlternateContActSumText"]; - // if (value == s) return; - // _Xp["Step", "AlternateContActSumText"] = value; - // OnPropertyChanged("Step_AlternateContActSumText"); - // } - //} - //[Category("Step Attributes")] - //[DisplayName("Step Placekeeper")] - //[RefreshProperties(RefreshProperties.All)] - //[Description("Step Placekeeper")] public string Step_Placekeeper { get @@ -236,10 +168,6 @@ namespace VEPROMS.CSLA.Library OnPropertyChanged("Step_Placekeeper"); } } - //[Category("Step Attributes")] - //[DisplayName("Step Check Off Index")] - //[RefreshProperties(RefreshProperties.All)] - //[Description("Step Check Off Index")] public int Step_CheckOffIndex { get @@ -248,24 +176,14 @@ namespace VEPROMS.CSLA.Library if (s == string.Empty) return 0; - // there was an invalid character for Wolf Creek's index. just return - // a 0 if found. The dataloader was fixed (6/8/12) to not migrate the - // bad character, but this was added, in case there are some other conditions. - int tst = 0; - if(int.TryParse(s,out tst)) - return tst; - tst = (int) s[0]; + // there was an invalid character for Wolf Creek's index. just return + // a 0 if found. The dataloader was fixed (6/8/12) to not migrate the + // bad character, but this was added, in case there are some other conditions. + if (int.TryParse(s, out int tst)) + return tst; + tst = (int) s[0]; tst -= '0'; return tst; - //try - //{ - // tst = int.Parse(s); - //} - //catch (Exception ex) - //{ - // return 0; - //} - //return int.Parse(s); } set { @@ -275,10 +193,6 @@ namespace VEPROMS.CSLA.Library OnPropertyChanged("Step_CheckOffIndex"); } } - //[Category("Step Attributes")] - //[DisplayName("Step Manual Pagebreak")] - //[RefreshProperties(RefreshProperties.All)] - //[Description("Step Manual Pagebreak")] public bool Step_ManualPagebreak { get @@ -352,10 +266,6 @@ namespace VEPROMS.CSLA.Library OnPropertyChanged("Step_SubStepPagebreak"); } } - //[Category("Step Attributes")] - //[DisplayName("Step Change Bar Override")] - //[RefreshProperties(RefreshProperties.All)] - //[Description("Step Change Bar Override")] public string Step_CBOverride { get @@ -440,10 +350,6 @@ namespace VEPROMS.CSLA.Library OnPropertyChanged("Step_Responsibility"); } } - //[Category("Step Attributes")] - //[DisplayName("Step Change By Spell Checker")] - //[RefreshProperties(RefreshProperties.All)] - //[Description("Step Change By Spell Checker")] // When the spell checker changes text do not assign a change bar but keep existing change bar if it is there public string Step_SpellCheckerChangedText { @@ -557,16 +463,16 @@ namespace VEPROMS.CSLA.Library { string s = _Xp["Step", "ImageWidth"]; if (s == string.Empty) return 0; - int tst = 0; - try + int tst; + try { tst = int.Parse(s); } - catch (Exception ex) - { + catch (Exception) + { return 0; } - return int.Parse(s); + return tst; } set { @@ -582,16 +488,16 @@ namespace VEPROMS.CSLA.Library { string s = _Xp["Step", "ImageHeight"]; if (s == string.Empty) return 0; - int tst = 0; - try + int tst; + try { tst = int.Parse(s); } - catch (Exception ex) - { + catch (Exception) + { return 0; } - return int.Parse(s); + return tst; } set { @@ -617,7 +523,6 @@ namespace VEPROMS.CSLA.Library set { _MyEnhancedDocuments = value; - //OnPropertyChanged("EnhancedDocuments"); } } public void AddEnhancedDocument(int type, int itemid) @@ -637,7 +542,6 @@ namespace VEPROMS.CSLA.Library // 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")) { - //EnhancedDocument tmp = edsToAdd[int.Parse(xn.Attributes["Type"].Value)]; EnhancedDocument tmp = edsToAdd.GetByType(int.Parse(xn.Attributes["Type"].Value)); if (tmp != null) { @@ -659,74 +563,6 @@ namespace VEPROMS.CSLA.Library xa.Value = edadd.ItemID.ToString(); } } - //public string Step_SourceToBackground - //{ - // get - // { - // string s = _Xp["Step", "SourceToBackground"]; - // if (s == string.Empty) return null; - // return s; - // } - // set - // { - // string s = _Xp["Step", "SourceToBackground"]; - // if (value != null && value.ToString() == s) return; - // if (value == null && s != null) _Xp["Step", "SourceToBackground"] = null; - // else _Xp["Step", "SourceToBackground"] = value.ToString(); - // OnPropertyChanged("Step_SourceToBackground"); - // } - //} - //public string Step_BackgroundToSource - //{ - // get - // { - // string s = _Xp["Step", "BackgroundToSource"]; - // if (s == string.Empty) return null; - // return s; - // } - // set - // { - // string s = _Xp["Step", "BackgroundToSource"]; - // if (value != null && value.ToString() == s) return; - // if (value == null && s != null) _Xp["Step", "BackgroundToSource"] = null; - // else _Xp["Step", "BackgroundToSource"] = value.ToString(); - // OnPropertyChanged("Step_BackgroundToSource"); - // } - //} - //public string Step_SourceToDeviation - //{ - // get - // { - // string s = _Xp["Step", "SourceToDeviation"]; - // if (s == string.Empty) return null; - // return s; - // } - // set - // { - // string s = _Xp["Step", "SourceToDeviation"]; - // if (value != null && value.ToString() == s) return; - // if (value == null && s != null) _Xp["Step", "SourceToDeviation"] = null; - // else _Xp["Step", "SourceToDeviation"] = value.ToString(); - // OnPropertyChanged("Step_SourceToDeviation"); - // } - //} - //public string Step_DeviationToSource - //{ - // get - // { - // string s = _Xp["Step", "DeviationToSource"]; - // if (s == string.Empty) return null; - // return s; - // } - // set - // { - // string s = _Xp["Step", "DeviationToSource"]; - // if (value != null && value.ToString() == s) return; - // if (value == null && s != null) _Xp["Step", "DeviationToSource"] = null; - // else _Xp["Step", "DeviationToSource"] = value.ToString(); - // OnPropertyChanged("Step_DeviationToSource"); - // } - //} #endregion #region IItemConfig Members diff --git a/PROMS/VEPROMS.CSLA.Library/Config/TransitionConfig.cs b/PROMS/VEPROMS.CSLA.Library/Config/TransitionConfig.cs index 21ca181d..311e3aed 100644 --- a/PROMS/VEPROMS.CSLA.Library/Config/TransitionConfig.cs +++ b/PROMS/VEPROMS.CSLA.Library/Config/TransitionConfig.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using System.ComponentModel; namespace VEPROMS.CSLA.Library @@ -9,11 +7,7 @@ namespace VEPROMS.CSLA.Library [TypeConverter(typeof(ExpandableObjectConverter))] public class TransitionConfig : ConfigDynamicTypeDescriptor, INotifyPropertyChanged { - private XMLProperties _Xp; - private XMLProperties Xp - { - get { return _Xp; } - } + private readonly XMLProperties _Xp; public TransitionConfig(string xml) { if (xml == string.Empty) xml = ""; @@ -38,8 +32,7 @@ namespace VEPROMS.CSLA.Library public override string ToString() { string s = _Xp.ToString(); - if (s == "" || s == "") return string.Empty; - return s; + return s == "" || s == "" ? string.Empty : s; } #region GeneralTransitionProperties [Category("Formatted")] // format transition, i.e. include page number diff --git a/PROMS/VEPROMS.CSLA.Library/Config/UserConfig.cs b/PROMS/VEPROMS.CSLA.Library/Config/UserConfig.cs index fe26018d..a5f3a198 100644 --- a/PROMS/VEPROMS.CSLA.Library/Config/UserConfig.cs +++ b/PROMS/VEPROMS.CSLA.Library/Config/UserConfig.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using System.ComponentModel; namespace VEPROMS.CSLA.Library @@ -9,11 +7,7 @@ namespace VEPROMS.CSLA.Library [TypeConverter(typeof(ExpandableObjectConverter))] public class UserConfig : ConfigDynamicTypeDescriptor, INotifyPropertyChanged { - private XMLProperties _Xp; - private XMLProperties Xp - { - get { return _Xp; } - } + private readonly XMLProperties _Xp; public UserConfig(string xml) { if (xml == string.Empty) xml = ""; @@ -26,8 +20,7 @@ namespace VEPROMS.CSLA.Library public override string ToString() { string s = _Xp.ToString(); - if (s == "" || s == "") return string.Empty; - return s; + return s == "" || s == "" ? string.Empty : s; } #region UserCategory // from user.cfg [Category("User")] diff --git a/PROMS/VEPROMS.CSLA.Library/Config/XMLProperties.cs b/PROMS/VEPROMS.CSLA.Library/Config/XMLProperties.cs index 20107c58..5efa89d8 100644 --- a/PROMS/VEPROMS.CSLA.Library/Config/XMLProperties.cs +++ b/PROMS/VEPROMS.CSLA.Library/Config/XMLProperties.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using System.Runtime.Serialization; using System.Xml; @@ -47,12 +45,9 @@ namespace VEPROMS.CSLA.Library set { _ParentLookup = value; } } [NonSerialized] - XmlDocument _XmlContents; - public XmlDocument XmlContents - { - get { return _XmlContents; } - } - private XmlNode GetGroup(string group) + readonly XmlDocument _XmlContents; + public XmlDocument XmlContents => _XmlContents; + private XmlNode GetGroup(string group) { XmlNodeList xl = _XmlContents.DocumentElement.SelectNodes(string.Format("//{0}", group)); if(xl.Count == 0 && System.Text.RegularExpressions.Regex.IsMatch(group,"^[A-Za-z0-9]+$")) @@ -72,7 +67,6 @@ namespace VEPROMS.CSLA.Library } private XmlAttribute GetItem(XmlNode xx, string item) { - //XmlNodeList xl = xx.SelectNodes(string.Format("@{0}", item)); XmlNodeList xl = xx.SelectNodes( string.Format("@*[translate(local-name(), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')='{0}']", item.ToLower())); switch (xl.Count) @@ -87,11 +81,8 @@ namespace VEPROMS.CSLA.Library throw new XmlPropertiesException("Found more than one node @{0}", item); } } - public string ParentValue(string group, string item) - { - return OnLookInAncestor(this, new XMLPropertiesArgs(group, item, true)); - } - public string this[string group, string item] + public string ParentValue(string group, string item) => OnLookInAncestor(this, new XMLPropertiesArgs(group, item, true)); + public string this[string group, string item] { get { @@ -162,41 +153,26 @@ namespace VEPROMS.CSLA.Library } public partial class XMLPropertiesArgs { - #region Business Methods - private string _Group; - public string Group - { - get { return _Group; } - set { _Group = value; } - } - private string _Item; - public string Item - { - get { return _Item; } - set { _Item = value; } - } - private bool _AncestorLookup; + #region Business Methods + public string Group { get; set; } + public string Item { get; set; } - public bool AncestorLookup - { - get { return _AncestorLookup; } - set { _AncestorLookup = value; } - } + public bool AncestorLookup { get; set; } - #endregion - #region Factory Methods - private XMLPropertiesArgs() { ;} + #endregion + #region Factory Methods + private XMLPropertiesArgs() { ;} public XMLPropertiesArgs(string group, string item) { - _Group=group; - _Item=item; - _AncestorLookup = false; + Group=group; + Item=item; + AncestorLookup = false; } public XMLPropertiesArgs(string group, string item, bool ancestorLookup) { - _Group = group; - _Item = item; - _AncestorLookup = ancestorLookup; + Group = group; + Item = item; + AncestorLookup = ancestorLookup; } #endregion } diff --git a/PROMS/VEPROMS.CSLA.Library/EnumExtensions.cs b/PROMS/VEPROMS.CSLA.Library/EnumExtensions.cs index 3a1cb378..dfcbeaa7 100644 --- a/PROMS/VEPROMS.CSLA.Library/EnumExtensions.cs +++ b/PROMS/VEPROMS.CSLA.Library/EnumExtensions.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace VEPROMS.CSLA.Library { diff --git a/PROMS/VEPROMS.CSLA.Library/GlobalSuppressions.cs b/PROMS/VEPROMS.CSLA.Library/GlobalSuppressions.cs new file mode 100644 index 00000000..046248af --- /dev/null +++ b/PROMS/VEPROMS.CSLA.Library/GlobalSuppressions.cs @@ -0,0 +1,8 @@ +// This file is used by Code Analysis to maintain SuppressMessage +// attributes that are applied to this project. +// Project-level suppressions either have no target or are given +// a specific target and scoped to a namespace, type, member, etc. + +using System.Diagnostics.CodeAnalysis; + +[assembly: SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Not modifying Naming Styles")] diff --git a/PROMS/VEPROMS.CSLA.Library/VEPROMS.CSLA.Library.csproj b/PROMS/VEPROMS.CSLA.Library/VEPROMS.CSLA.Library.csproj index db431669..39afc380 100644 --- a/PROMS/VEPROMS.CSLA.Library/VEPROMS.CSLA.Library.csproj +++ b/PROMS/VEPROMS.CSLA.Library/VEPROMS.CSLA.Library.csproj @@ -148,7 +148,6 @@ - @@ -388,6 +387,7 @@ + diff --git a/PROMS/VEPROMS.CSLA.Library/frmRofstLoadStatus.cs b/PROMS/VEPROMS.CSLA.Library/frmRofstLoadStatus.cs index cc9b1e41..89631aac 100644 --- a/PROMS/VEPROMS.CSLA.Library/frmRofstLoadStatus.cs +++ b/PROMS/VEPROMS.CSLA.Library/frmRofstLoadStatus.cs @@ -1,41 +1,26 @@ using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Text; using System.Windows.Forms; - -using VEPROMS.CSLA.Library; -using Volian.Base.Library; -using JR.Utils.GUI.Forms; using System.Threading; namespace VEPROMS.CSLA.Library { public partial class frmRofstLoadStatus : Form { - #region Fields + #region Fields - #endregion + #endregion - #region Properties + #region Properties - public string Title - { - get { return lblTitle.Text; } - } + public string Title => lblTitle.Text; - public string DisplayText - { - get { return statusProgressBar.Text; } - } + public string DisplayText => statusProgressBar.Text; - #endregion + #endregion - #region Constructor + #region Constructor - public frmRofstLoadStatus() + public frmRofstLoadStatus() { // B2022-107: Display Progress Bar Messages/Statuses when a new ROFST binary file is loaded into the database // Initialize Base Component @@ -64,14 +49,14 @@ namespace VEPROMS.CSLA.Library lblTitle.Text = title; - this.Refresh(); + Refresh(); Application.DoEvents(); // Check if Finalizing Status/Progress Bar if (curVal >= 100) { Thread.Sleep(3000); - this.Close(); + Close(); } }