using System; using System.Collections.Generic; using System.Text; using System.ComponentModel; using DescriptiveEnum; namespace VEPROMS.CSLA.Library { [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; } } #endregion #region Constructors //PROPGRID: Hide ParentLookup [Browsable(false)] public bool ParentLookup { 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; public StepConfig(Step step) { _Step = step; string xml = step.MyContent.Config; if (xml == string.Empty) xml = ""; _Xp = new XMLProperties(xml); } public StepConfig(StepInfo stepInfo) { _StepInfo = stepInfo; string xml = stepInfo.MyContent.Config; if (xml == string.Empty) xml = ""; _Xp = new XMLProperties(xml); } public StepConfig(string xml) { if (xml == string.Empty) xml = ""; _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() { 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 { get { string s = _Xp["Step", "FloatingFoldout"]; if (s == string.Empty) return 0; int tst = 0; try { tst = int.Parse(s); } catch (Exception ex) { return 0; } return int.Parse(s); } set { string s = _Xp["Step", "FloatingFoldout"]; if (value.ToString() == s) return; _Xp["Step", "FloatingFoldout"] = value.ToString(); OnPropertyChanged("Step_FloatingFoldout"); } } public string Step_CAS { get { string s = _Xp["Step", "ContActSum"]; //If there is no value in the config, then return null. This will tell us to check the step type and format flag (ExcludeFromContActSum). if (s == string.Empty) return null; return s; } set { string s = _Xp["Step", "ContActSum"]; if (value == s) return; _Xp["Step", "ContActSum"] = value; OnPropertyChanged("Step_CAS"); } } //// 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 { string s = _Xp["Step", "Placekeeper"]; //If there is no value to get, then get the parent value (a.k.a. default value). if (s == string.Empty) return "N"; return s; } set { string s = _Xp["Step", "Placekeeper"]; if (value == s) return; _Xp["Step", "Placekeeper"] = value; OnPropertyChanged("Step_Placekeeper"); } } //[Category("Step Attributes")] //[DisplayName("Step Check Off Index")] //[RefreshProperties(RefreshProperties.All)] //[Description("Step Check Off Index")] public int Step_CheckOffIndex { get { string s = _Xp["Step", "CheckOffIndex"]; 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]; tst -= '0'; return tst; //try //{ // tst = int.Parse(s); //} //catch (Exception ex) //{ // return 0; //} //return int.Parse(s); } set { string s = _Xp["Step", "CheckOffIndex"]; if (value.ToString() == s) return; _Xp["Step", "CheckOffIndex"] = value.ToString(); OnPropertyChanged("Step_CheckOffIndex"); } } //[Category("Step Attributes")] //[DisplayName("Step Manual Pagebreak")] //[RefreshProperties(RefreshProperties.All)] //[Description("Step Manual Pagebreak")] public bool Step_ManualPagebreak { get { string s = _Xp["Step", "ManualPagebreak"]; if (s == string.Empty) return false; if (s == "True") return true; return false; } set { string s = _Xp["Step", "ManualPagebreak"]; if (value.ToString() == s) return; _Xp["Step", "ManualPagebreak"] = value.ToString(); OnPropertyChanged("Step_ManualPagebreak"); } } public bool Step_NewManualPagebreak { get { string s = _Xp["Step", "NewManualPagebreak"]; if (s == string.Empty) return false; if (s == "True") return true; return false; } set { string s = _Xp["Step", "NewManualPagebreak"]; if (value.ToString() == s) return; _Xp["Step", "NewManualPagebreak"] = value.ToString(); OnPropertyChanged("Step_NewManualPagebreak"); } } //[Category("Step Attributes")] //[DisplayName("Step Change Bar Override")] //[RefreshProperties(RefreshProperties.All)] //[Description("Step Change Bar Override")] public string Step_CBOverride { get { string s = _Xp["Step", "CBOverride"]; if (s == string.Empty) return null; return s; } set { string s = _Xp["Step", "CBOverride"]; if (value != null && value.ToString() == s) return; if (value == null && s != null) _Xp["Step", "CBOverride"] = null; else _Xp["Step", "CBOverride"] = value.ToString(); OnPropertyChanged("Step_CBOverride"); } } public string Step_ChangeID { get { string s = _Xp["Step", "ChangeID"]; if (s == string.Empty) return null; return s; } set { string s = _Xp["Step", "ChangeID"]; if (value != null && value.ToString() == s) return; if (value == null && s != null) _Xp["Step", "ChangeID"] = null; else _Xp["Step", "ChangeID"] = value.ToString(); OnPropertyChanged("Step_ChangeID"); } } public string Step_Responsibility { get { string s = _Xp["Step", "Responsibility"]; if (s == string.Empty) return null; return s; } set { string s = _Xp["Step", "Responsibility"]; if (value != null && value.ToString() == s) return; if (value == null && s != null) _Xp["Step", "Responsibility"] = null; else _Xp["Step", "Responsibility"] = value.ToString(); OnPropertyChanged("Step_Responsibility"); } } 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 [Category("Master/Slave Settings")] [DisplayName("Applicability")] [RefreshProperties(RefreshProperties.All)] [Description("Scope Applicability")] public Volian.Base.Library.BigNum MasterSlave_Applicability { get { string s = _Xp["MasterSlave", "Applicability"]; return new Volian.Base.Library.BigNum(s); } set { if (value != null) _Xp["MasterSlave", "Applicability"] = value.FlagList; else _Xp["MasterSlave", "Applicability"] = null; OnPropertyChanged("MasterSlave_Applicability"); } } #endregion } }