Better handling of parent information in Get and Set

This commit is contained in:
Jsj 2008-03-26 18:26:01 +00:00
parent 6acc548cf3
commit 1108280311
3 changed files with 1346 additions and 705 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -32,13 +32,18 @@ namespace VEPROMS.CSLA.Library
}
#endregion
#region Constructors
//PROPGRID: Hide ParentLookup
[Browsable(false)]
public bool ParentLookup
{
get { return _Xp.ParentLookup; }
set { _Xp.ParentLookup = value; }
}
[NonSerialized]
//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; }
@ -64,7 +69,7 @@ namespace VEPROMS.CSLA.Library
{
retval = proc.ProcedureConfig.GetValue(args.Group, args.Item);
if (retval != string.Empty) return retval;
proc = (Procedure) proc.ActiveParent;
proc = (Procedure)proc.ActiveParent;
}
DocVersion docVersion = (DocVersion)proc.ActiveParent;
retval = docVersion.DocVersionConfig.GetValue(args.Group, args.Item);
@ -95,11 +100,11 @@ namespace VEPROMS.CSLA.Library
}
public ProcedureConfig(ProcedureInfo procedureInfo)
{
_ProcedureInfo = procedureInfo;
string xml = procedureInfo.MyContent.Config;
if (xml == string.Empty) xml = "<config/>";
_Xp = new XMLProperties(xml);
}
_ProcedureInfo = procedureInfo;
string xml = procedureInfo.MyContent.Config;
if (xml == string.Empty) xml = "<config/>";
_Xp = new XMLProperties(xml);
}
public ProcedureConfig(string xml)
{
if (xml == string.Empty) xml = "<config/>";
@ -115,7 +120,6 @@ namespace VEPROMS.CSLA.Library
}
#endregion
#region Local Properties
//[Category("Identification")]
[Category("General")]
[DisplayName("Number")]
[Description("Number")]
@ -124,7 +128,6 @@ namespace VEPROMS.CSLA.Library
get { return (_Procedure != null ? _Procedure.MyContent.Number : _ProcedureInfo.MyContent.Number); }
set { if (_Procedure != null) _Procedure.MyContent.Number = value; }
}
//[Category("Identification")]
[Category("General")]
[DisplayName("Title")]
[Description("Title")]
@ -134,21 +137,24 @@ namespace VEPROMS.CSLA.Library
set { if (_Procedure != null) _Procedure.MyContent.Text = value; }
}
[Category("Identification")]
//PROPGRID: Hide Old Sequence
[Browsable(false)]
[DisplayName("Old Sequence")]
[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 == null ? null : _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 ); }
get { return (_Procedure != null ? _Procedure.IsDirty : false); }
}
//[Category("Format")]
[Category("Format Settings")]
[DisplayName("Format")]
[Description("Format")]
@ -157,8 +163,6 @@ namespace VEPROMS.CSLA.Library
{
get
{
//if (_DocVersion != null) return FormatList.ToString(_DocVersion.FormatID);
//if (_DocVersionInfo != null) return FormatList.ToString(_DocVersionInfo.FormatID);
if (_Procedure != null && _Procedure.MyContent.MyFormat != null) return _Procedure.MyContent.MyFormat.PlantFormat.FormatData.Name;
if (_ProcedureInfo != null && _ProcedureInfo.MyContent.MyFormat != null) return _ProcedureInfo.MyContent.MyFormat.PlantFormat.FormatData.Name;
return null;
@ -168,18 +172,14 @@ namespace VEPROMS.CSLA.Library
if (_Procedure != null) _Procedure.MyContent.MyFormat = FormatList.ToFormat(value); // Can only be set if _DocVersion is set
}
}
//[Category("Format")]
[Category("Format Settings")]
//[DisplayName("Format")]
[DisplayName("Default Format")]
[Description("Format")]
[Description("Default Format")]
[TypeConverter(typeof(FormatList))]
public string DefaultFormatSelection
{
get
{
//if (_Folder != null) return FormatList.ToString(_Folder.FormatID);
//if (_FolderInfo != null) return FormatList.ToString(_FolderInfo.FormatID);
if (_Procedure != null && _Procedure.ActiveParent != null && _Procedure.ActiveParent.ActiveFormat != null) return _Procedure.ActiveParent.ActiveFormat.PlantFormat.FormatData.Name;
if (_ProcedureInfo != null && _ProcedureInfo.MyParent != null && _ProcedureInfo.MyParent.ActiveFormat != null) return _ProcedureInfo.MyParent.ActiveFormat.PlantFormat.FormatData.Name;
return null;
@ -208,9 +208,7 @@ namespace VEPROMS.CSLA.Library
[Description("Quad Column")]
FourColumns
}
//[Category("Format")]
[Category("General")]
//[DisplayName("Column Layout")]
[DisplayName("Default Column Mode")]
[RefreshProperties(RefreshProperties.All)]
[Description("Column Layout")]
@ -219,18 +217,37 @@ namespace VEPROMS.CSLA.Library
get
{
string s = _Xp["format", "columns"];
if (s == string.Empty || s.Equals("-1")) return FormatColumns.Default;//(FormatColumns)0;
return (FormatColumns)int.Parse(_Xp["format", "columns"]);
//return Enum.Parse(typeof(FormatColumns),_Xp["format", "columns"]);
//If there is no value to get, then get the parent value (a.k.a. default value).
if (s == string.Empty)
s = _Xp.ParentValue("format", "columns"); // get the parent value
// If there is no parent value, then use the volian default
if (s == string.Empty)
return FormatColumns.Default;// default to volian default
return (FormatColumns)int.Parse(s);
}
set
{
if (value == 0) _Xp["format", "columns"] = string.Empty;
else _Xp["format", "columns"] = ((int)value).ToString();
// if value being saved is same as the parent value, then clear the value (save blank). This will
// reset the data to use the parent value.
string parval = _Xp.ParentValue("format", "columns"); // get the parent value
if (parval.Equals(string.Empty)) // if the parent value is empty, then use the volian default
parval = ((int)(FormatColumns.Default)).ToString();
if (parval.Equals(((int)value).ToString()))
_Xp["format", "columns"] = string.Empty; // reset to parent value
else
_Xp["format", "columns"] = ((int)value).ToString(); // save selected value
OnPropertyChanged("Format_Columns");
}
}
[Category("Format")]
//PROPGRID: Hide Plant Format Name (using Format and Default Format)
[Browsable(false)]
[DisplayName("Plant Format Name")]
[RefreshProperties(RefreshProperties.All)]
[Description("Default Plant Format")]
@ -249,6 +266,8 @@ namespace VEPROMS.CSLA.Library
#endregion
#region PrintSettingsCategory // From curset.dat
[Category("Print Settings")]
//PROPGRID: Hide Number of Copies
[Browsable(false)]
[DisplayName("Number of Copies")]
[RefreshProperties(RefreshProperties.All)]
[Description("Number of Copies")]
@ -280,14 +299,32 @@ namespace VEPROMS.CSLA.Library
{
get
{
string s = _Xp["PrintSettings", "Pagination"];
if (s == string.Empty || s.Equals("-1")) return PrintPagination.Auto;
return (PrintPagination)int.Parse(_Xp["PrintSettings", "Pagination"]);
//If there is no value to get, then get the parent value (a.k.a. default value).
if (s == string.Empty)
s = _Xp.ParentValue("PrintSettings", "Pagination"); // get the parent value
// If there is no parent value, then use the volian default
if (s == string.Empty)
return PrintPagination.Auto;// default to volian default
return (PrintPagination)int.Parse(s);
}
set
{
if (value == PrintPagination.Auto) _Xp["PrintSettings", "Pagination"] = string.Empty;
else _Xp["PrintSettings", "Pagination"] = ((int)value).ToString();
// if value being saved is same as the parent value, then clear the value (save blank). This will
// reset the data to use the parent value.
string parval = _Xp.ParentValue("PrintSettings", "Pagination"); // get the parent value
if (parval.Equals(string.Empty)) // if the parent value is empty, then use the volian default
parval = ((int)(PrintPagination.Auto)).ToString();
if (parval.Equals(((int)value).ToString()))
_Xp["PrintSettings", "Pagination"] = string.Empty; // reset to parent value
else
_Xp["PrintSettings", "Pagination"] = ((int)value).ToString(); // save selected value
OnPropertyChanged("Print_Pagination");
}
}
@ -307,18 +344,35 @@ namespace VEPROMS.CSLA.Library
get
{
string s = _Xp["PrintSettings", "Watermark"];
if (s == string.Empty || s.Equals("-1")) return PrintWatermark.Draft;
return (PrintWatermark)int.Parse(_Xp["PrintSettings", "Watermark"]);
//If there is no value to get, then get the parent value (a.k.a. default value).
if (s == string.Empty)
s = _Xp.ParentValue("PrintSettings", "Watermark"); // get the parent value
// If there is no parent value, then use the volian default
if (s == string.Empty)
return PrintWatermark.Draft;// default to volian default
return (PrintWatermark)int.Parse(s);
}
set
{
if (value == PrintWatermark.Draft) _Xp["PrintSettings", "Watermark"] = string.Empty;
else _Xp["PrintSettings", "Watermark"] = ((int)value).ToString();
// if value being saved is same as the parent value, then clear the value (save blank). This will
// reset the data to use the parent value.
string parval = _Xp.ParentValue("PrintSettings", "Watermark"); // get the parent value
if (parval.Equals(string.Empty)) // if the parent value is empty, then use the volian default
parval = ((int)(PrintWatermark.Draft)).ToString();
if (parval.Equals(((int)value).ToString()))
_Xp["PrintSettings", "Watermark"] = string.Empty; // reset to parent value
else
_Xp["PrintSettings", "Watermark"] = ((int)value).ToString(); // save selected value
OnPropertyChanged("Print_Watermark");
}
}
[Category("Print Settings")]
//[DisplayName("Disable Duplex Printing")]
[DisplayName("Disable Automatic Duplexing")]
[RefreshProperties(RefreshProperties.All)]
[Description("Disable Duplex Printing")]
@ -327,12 +381,31 @@ namespace VEPROMS.CSLA.Library
get
{
string s = _Xp["PrintSettings", "disableduplex"];
if (s == string.Empty) return false;
return bool.Parse(_Xp["PrintSettings", "disableduplex"]);
//If there is no value to get, then get the parent value (a.k.a. default value).
if (s == string.Empty)
s = _Xp.ParentValue("PrintSettings", "disableduplex"); // get the parent value
// If there is no parent value, then use the volian default
if (s == string.Empty)
s = "false";// default to volian default
return bool.Parse(s);
}
set
{
_Xp["PrintSettings", "disableduplex"] = value.ToString();
// if value being saved is same as the parent value, then clear the value (save blank). This will
// reset the data to use the parent value.
string parval = _Xp.ParentValue("PrintSettings", "disableduplex"); // get the parent value
if (parval.Equals(string.Empty)) // if the parent value is empty, then use the volian default
parval = "false";
if (parval.Equals(value.ToString()))
_Xp["PrintSettings", "disableduplex"] = string.Empty; // reset to parent value
else
_Xp["PrintSettings", "disableduplex"] = value.ToString(); // save selected value
OnPropertyChanged("Print_DisableDuplex");
}
}
@ -353,13 +426,6 @@ namespace VEPROMS.CSLA.Library
[Description("Use Custom Change Bars")]
WithUserSpecified
}
//{
// [Description("Select When Printed")]NoDefault = 0,
// [Description("None")]Without,
// [Description("Default")]WithDefault,
// [Description("User Specified")]WithUserSpecified
//}
//[Category("Print Settings")]
[Category("Format Settings")]
[DisplayName("Change Bar")]
[RefreshProperties(RefreshProperties.All)]
@ -369,14 +435,31 @@ namespace VEPROMS.CSLA.Library
get
{
string s = _Xp["PrintSettings", "ChangeBar"];
if (s == string.Empty || s.Equals("-1")) return PrintChangeBar.SelectBeforePrinting;//PrintChangeBar.NoDefault;
return (PrintChangeBar)int.Parse(_Xp["PrintSettings", "ChangeBar"]);
//If there is no value to get, then get the parent value (a.k.a. default value).
if (s == string.Empty)
s = _Xp.ParentValue("PrintSettings", "ChangeBar"); // get the parent value
// If there is no parent value, then use the volian default
if (s == string.Empty)
return PrintChangeBar.SelectBeforePrinting;// default to volian default
return (PrintChangeBar)int.Parse(s);
}
set
{
//if (value == PrintChangeBar.NoDefault) _Xp["PrintSettings", "ChangeBar"] = string.Empty;
if (value == PrintChangeBar.SelectBeforePrinting) _Xp["PrintSettings", "ChangeBar"] = string.Empty;
else _Xp["PrintSettings", "ChangeBar"] = ((int)value).ToString();
// if value being saved is same as the parent value, then clear the value (save blank). This will
// reset the data to use the parent value.
string parval = _Xp.ParentValue("PrintSettings", "ChangeBar"); // get the parent value
if (parval.Equals(string.Empty)) // if the parent value is empty, then use the volian default
parval = ((int)(PrintChangeBar.SelectBeforePrinting)).ToString();
if (parval.Equals(((int)value).ToString()))
_Xp["PrintSettings", "ChangeBar"] = string.Empty; // reset to parent value
else
_Xp["PrintSettings", "ChangeBar"] = ((int)value).ToString(); // save selected value
OnPropertyChanged("Print_ChangeBar");
}
}
@ -397,9 +480,7 @@ namespace VEPROMS.CSLA.Library
[Description("To the Left of the Text")]
LeftOfText
}
//[Category("Print Settings")]
[Category("Format Settings")]
//[DisplayName("Change Bar Location")]
[DisplayName("Change Bar Position")]
[RefreshProperties(RefreshProperties.All)]
[Description("User Specified Change Bar Location")]
@ -408,13 +489,31 @@ namespace VEPROMS.CSLA.Library
get
{
string s = _Xp["PrintSettings", "ChangeBarLoc"];
if (s == string.Empty || s.Equals("-1")) return PrintChangeBarLoc.WithText;
return (PrintChangeBarLoc)int.Parse(_Xp["PrintSettings", "ChangeBarLoc"]);
//If there is no value to get, then get the parent value (a.k.a. default value).
if (s == string.Empty)
s = _Xp.ParentValue("PrintSettings", "ChangeBarLoc"); // get the parent value
// If there is no parent value, then use the volian default
if (s == string.Empty)
return PrintChangeBarLoc.WithText;// default to volian default
return (PrintChangeBarLoc)int.Parse(s);
}
set
{
if (value == PrintChangeBarLoc.WithText) _Xp["PrintSettings", "ChangeBarLoc"] = string.Empty;
else _Xp["PrintSettings", "ChangeBarLoc"] = ((int)value).ToString();
// if value being saved is same as the parent value, then clear the value (save blank). This will
// reset the data to use the parent value.
string parval = _Xp.ParentValue("PrintSettings", "ChangeBarLoc"); // get the parent value
if (parval.Equals(string.Empty)) // if the parent value is empty, then use the volian default
parval = ((int)(PrintChangeBarLoc.WithText)).ToString();
if (parval.Equals(((int)value).ToString()))
_Xp["PrintSettings", "ChangeBarLoc"] = string.Empty; // reset to parent value
else
_Xp["PrintSettings", "ChangeBarLoc"] = ((int)value).ToString(); // save selected value
OnPropertyChanged("Print_ChangeBarLoc");
}
}
@ -439,9 +538,7 @@ namespace VEPROMS.CSLA.Library
[Description("Custom Change Bar Text")]
UserDef
}
//[Category("Print Settings")]
[Category("Format Settings")]
//[DisplayName("Change Bar Text")]
[DisplayName("Change Bar Text Type")]
[RefreshProperties(RefreshProperties.All)]
[Description("Change Bar Text")]
@ -450,18 +547,38 @@ namespace VEPROMS.CSLA.Library
get
{
string s = _Xp["PrintSettings", "ChangeBarText"];
if (s == string.Empty || s.Equals("-1")) return PrintChangeBarText.DateChgID;
return (PrintChangeBarText)int.Parse(_Xp["PrintSettings", "ChangeBarText"]);
//If there is no value to get, then get the parent value (a.k.a. default value).
if (s == string.Empty)
s = _Xp.ParentValue("PrintSettings", "ChangeBarText"); // get the parent value
// If there is no parent value, then use the volian default
if (s == string.Empty)
return PrintChangeBarText.DateChgID;// default to volian default
return (PrintChangeBarText)int.Parse(s);
}
set
{
if (value == PrintChangeBarText.DateChgID) _Xp["PrintSettings", "ChangeBarText"] = string.Empty;
else _Xp["PrintSettings", "ChangeBarText"] = ((int)value).ToString();
// if value being saved is same as the parent value, then clear the value (save blank). This will
// reset the data to use the parent value.
string parval = _Xp.ParentValue("PrintSettings", "ChangeBarText"); // get the parent value
if (parval.Equals(string.Empty)) // if the parent value is empty, then use the volian default
parval = ((int)(PrintChangeBarText.DateChgID)).ToString();
if (parval.Equals(((int)value).ToString()))
_Xp["PrintSettings", "ChangeBarText"] = string.Empty; // reset to parent value
else
_Xp["PrintSettings", "ChangeBarText"] = ((int)value).ToString(); // save selected value
OnPropertyChanged("Print_ChangeBarText");
}
}
[Category("Print Settings")]
//PROPGRID: Hide User Format
[Browsable(false)]
[DisplayName("User Format")]
[RefreshProperties(RefreshProperties.All)]
[Description("User Format")]
@ -478,9 +595,7 @@ namespace VEPROMS.CSLA.Library
}
}
//[Category("Print Settings")]
[Category("Format Settings")]
//[DisplayName("User Change Bar Message1")]
[DisplayName("Custom Change Bar Message Line One")]
[RefreshProperties(RefreshProperties.All)]
[Description("User Change Bar Message1")]
@ -488,18 +603,37 @@ namespace VEPROMS.CSLA.Library
{
get
{
return _Xp["PrintSettings", "usercbmess1"];
string s = _Xp["PrintSettings", "usercbmess1"];// get the saved value
//If there is no value to get, then get the parent value (a.k.a. default value).
if (s == string.Empty)
s = _Xp.ParentValue("PrintSettings", "usercbmess1"); // get the parent value
// If there is no parent value, then use the volian default
if (s == string.Empty)
s = "";// default to volian default
return s;
}
set
{
_Xp["PrintSettings", "usercbmess1"] = value;
// if value being saved is same as the parent value, then clear the value (save blank). This will
// reset the data to use the parent value.
string parval = _Xp.ParentValue("PrintSettings", "usercbmess1"); // get the parent value
if (parval.Equals(string.Empty)) // if the parent value is empty, then use the volian default
parval = "";
if (parval.Equals(value))
_Xp["PrintSettings", "usercbmess1"] = string.Empty; // reset to parent value
else
_Xp["PrintSettings", "usercbmess1"] = value; // save selected value
OnPropertyChanged("Print_UserCBMess1");
}
}
//[Category("Print Settings")]
[Category("Format Settings")]
//[DisplayName("User Change Bar Message2")]
[DisplayName("Custom Change Bar Message Line Two")]
[RefreshProperties(RefreshProperties.All)]
[Description("User Change Bar Message2")]
@ -507,11 +641,32 @@ namespace VEPROMS.CSLA.Library
{
get
{
return _Xp["PrintSettings", "usercbmess2"];
string s = _Xp["PrintSettings", "usercbmess2"];// get the saved value
//If there is no value to get, then get the parent value (a.k.a. default value).
if (s == string.Empty)
s = _Xp.ParentValue("PrintSettings", "usercbmess2"); // get the parent value
// If there is no parent value, then use the volian default
if (s == string.Empty)
s = "";// default to volian default
return s;
}
set
{
_Xp["PrintSettings", "usercbmess2"] = value;
// if value being saved is same as the parent value, then clear the value (save blank). This will
// reset the data to use the parent value.
string parval = _Xp.ParentValue("PrintSettings", "usercbmess2"); // get the parent value
if (parval.Equals(string.Empty)) // if the parent value is empty, then use the volian default
parval = "";
if (parval.Equals(value))
_Xp["PrintSettings", "usercbmess2"] = string.Empty; // reset to parent value
else
_Xp["PrintSettings", "usercbmess2"] = value; // save selected value
OnPropertyChanged("Print_UserCBMess2");
}
}