better handling of parent values for Get and Set

This commit is contained in:
Jsj 2008-03-26 18:26:45 +00:00
parent 1108280311
commit c7c678f6ed

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: 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; }
@ -66,7 +71,7 @@ namespace VEPROMS.CSLA.Library
if (retval != string.Empty) return retval;
sect = (Section)sect.ActiveParent;
}
Procedure proc = (Procedure) sect.ActiveParent;
Procedure proc = (Procedure)sect.ActiveParent;
while (proc.ActiveParent.GetType() == typeof(Procedure))
{
retval = proc.ProcedureConfig.GetValue(args.Group, args.Item);
@ -97,7 +102,7 @@ namespace VEPROMS.CSLA.Library
sect = (Section)sect.ActiveParent;
}
Procedure proc = (Procedure)sect.ActiveParent;
DocVersionInfo docVersion = (DocVersionInfo) proc.ActiveParent;
DocVersionInfo docVersion = (DocVersionInfo)proc.ActiveParent;
retval = docVersion.DocVersionConfig.GetValue(args.Group, args.Item);
if (retval != string.Empty) return retval;
for (FolderInfo folder = docVersion.MyFolder; folder != null; folder = folder.MyParent)
@ -149,6 +154,8 @@ namespace VEPROMS.CSLA.Library
set { if (_Section != null) _Section.MyContent.Text = value; }
}
[Category("Identification")]
//PROPGRID: Hide Old Sequence
[Browsable(false)]
[DisplayName("Old Sequence")]
[Description("Old Sequence")]
public string OldSequence
@ -157,6 +164,8 @@ namespace VEPROMS.CSLA.Library
set { if (_Section != null) _Section.MyContent.MyZContent.OldStepSequence = value; }
}
[Category("Identification")]
//PROPGRID: Hide Dirty
[Browsable(false)]
[DisplayName("Dirty")]
[Description("Dirty")]
public bool Dirty
@ -171,8 +180,6 @@ namespace VEPROMS.CSLA.Library
{
get
{
//if (_DocVersion != null) return FormatList.ToString(_DocVersion.FormatID);
//if (_DocVersionInfo != null) return FormatList.ToString(_DocVersionInfo.FormatID);
if (_Section != null && _Section.MyContent.MyFormat != null) return _Section.MyContent.MyFormat.PlantFormat.FormatData.Name;
if (_SectionInfo != null && _SectionInfo.MyContent.MyFormat != null) return _SectionInfo.MyContent.MyFormat.PlantFormat.FormatData.Name;
return null;
@ -183,16 +190,13 @@ namespace VEPROMS.CSLA.Library
}
}
[Category("Format")]
//[DisplayName("DefFormat")]
[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 (_Section != null && _Section.ActiveParent != null && _Section.ActiveParent.ActiveFormat != null) return _Section.ActiveParent.ActiveFormat.PlantFormat.FormatData.Name;
if (_SectionInfo != null && _SectionInfo.MyParent != null && _SectionInfo.MyParent.ActiveFormat != null) return _SectionInfo.MyParent.ActiveFormat.PlantFormat.FormatData.Name;
return null;
@ -208,12 +212,10 @@ namespace VEPROMS.CSLA.Library
}
#endregion
#region SectionCategory // from sequence number in 16-bit database.
// jsj ...
public enum SectionPagination : int
{
Default = 0, Continuous, Separate
}
//[Category("Section")]
[Category("Format")]
[DisplayName("Section Pagination")]
[RefreshProperties(RefreshProperties.All)]
@ -223,37 +225,37 @@ namespace VEPROMS.CSLA.Library
get
{
string s = _Xp["Section", "Pagination"];
if (s == string.Empty || s.Equals("-1")) return SectionPagination.Default;
return (SectionPagination)int.Parse(_Xp["Section", "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("Section", "Pagination"); // get the parent value
// If there is no parent value, then use the volian default
if (s == string.Empty)
return SectionPagination.Default;// default to volian default
return (SectionPagination)int.Parse(s);
}
set
{
if (value == SectionPagination.Default) _Xp["Section", "Pagination"] = string.Empty;
else _Xp["Section", "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("Section", "Pagination"); // get the parent value
if (parval.Equals(string.Empty)) // if the parent value is empty, then use the volian default
parval = ((int)(SectionPagination.Default)).ToString();
if (parval.Equals(((int)value).ToString()))
_Xp["Section", "Pagination"] = string.Empty; // reset to parent value
else
_Xp["Section", "Pagination"] = ((int)value).ToString(); // save selected value
OnPropertyChanged("Section_Pagination");
}
}
// ... jsj
//[Category("Section")]
//[DisplayName("Section Pagination")]
//[RefreshProperties(RefreshProperties.All)]
//[Description("Section Pagination")]
//public string Section_Pagination
//{
// get
// {
// return _Xp["Section", "Pagination"];
// }
// set
// {
// _Xp["Section", "Pagination"] = value;
// OnPropertyChanged("Section_Pagination");
// }
//}
//[Category("Section")]
[Category("View Settings")]
//[DisplayName("Section LinkEnhanced")]
//PROPGRID: Hide Include in Background/Deviation
[Browsable(false)]
[DisplayName("Include in Background/Deviation")]
[RefreshProperties(RefreshProperties.All)]
[Description("Section LinkEnhanced")]
@ -269,9 +271,9 @@ namespace VEPROMS.CSLA.Library
OnPropertyChanged("Section_LnkEnh");
}
}
//[Category("Section")]
[Category("General")]
//[DisplayName("Section TOC")]
//PROPGRID: Hide Include On Table Of Contents
[Browsable(false)]
[DisplayName("Include On Table Of Contents")]
[RefreshProperties(RefreshProperties.All)]
[Description("Section TOC")]
@ -288,6 +290,8 @@ namespace VEPROMS.CSLA.Library
}
}
[Category("Section")]
//PROPGRID: Hide AutoGen
[Browsable(false)]
[DisplayName("Section AutoGen")]
[RefreshProperties(RefreshProperties.All)]
[Description("Section AutoGen")]
@ -304,6 +308,8 @@ namespace VEPROMS.CSLA.Library
}
}
[Category("Section")]
//PROPGRID: Hide Section NumPages
[Browsable(false)]
[DisplayName("Section NumPages")]
[RefreshProperties(RefreshProperties.All)]
[Description("Section NumPages")]
@ -319,19 +325,20 @@ namespace VEPROMS.CSLA.Library
OnPropertyChanged("Section_NumPages");
}
}
// jsj ...
[TypeConverter(typeof(EnumDescConverter))]
public enum SectionColumnMode : int
{
Default = 0,
[Description("Single Column")]One,
[Description("Duel Column")]Two,
[Description("Triple Column")]Three,
[Description("Quad Column")]Four
[Description("Single Column")]
One,
[Description("Duel Column")]
Two,
[Description("Triple Column")]
Three,
[Description("Quad Column")]
Four
}
//[Category("Section")]
[Category("Format")]
//[DisplayName("Section ColumnMode")]
[DisplayName("Columns")]
[RefreshProperties(RefreshProperties.All)]
[Description("Section ColumnMode")]
@ -340,37 +347,39 @@ namespace VEPROMS.CSLA.Library
get
{
string s = _Xp["Section", "ColumnMode"];
if (s == string.Empty || s.Equals("-1")) return SectionColumnMode.Default;
return (SectionColumnMode)int.Parse(_Xp["Section", "ColumnMode"]);
//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", "ColumnMode"); // get the parent value
// If there is no parent value, then use the volian default
if (s == string.Empty)
return SectionColumnMode.Default;// default to volian default
return (SectionColumnMode)int.Parse(s);
}
set
{
if (value == SectionColumnMode.Default) _Xp["Section", "ColumnMode"] = string.Empty;
else _Xp["Section", "ColumnMode"] = ((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("Section", "ColumnMode"); // get the parent value
if (parval.Equals(string.Empty)) // if the parent value is empty, then use the volian default
parval = ((int)(SectionColumnMode.Default)).ToString();
if (parval.Equals(((int)value).ToString()))
_Xp["Section", "ColumnMode"] = string.Empty; // reset to parent value
else
_Xp["Section", "ColumnMode"] = ((int)value).ToString(); // save selected value
OnPropertyChanged("Section_ColumnMode");
}
}
// ... jsj
//[Category("Section")]
//[DisplayName("Section ColumnMode")]
//[RefreshProperties(RefreshProperties.All)]
//[Description("Section ColumnMode")]
//public string Section_ColumnMode
//{
// get
// {
// return _Xp["Section", "ColumnMode"];
// }
// set
// {
// _Xp["Section", "ColumnMode"] = value;
// OnPropertyChanged("Section_ColumnMode");
// }
//}
#endregion
#region SubSectionCategory // from sequence number in 16-bit database.
[Category("SubSection")]
//PROPGRID: Hide SubSection Edit
[Browsable(false)]
[DisplayName("SubSection Edit")]
[RefreshProperties(RefreshProperties.All)]
[Description("SubSection Edit")]
@ -387,6 +396,8 @@ namespace VEPROMS.CSLA.Library
}
}
[Category("SubSection")]
//PROPGRID: Hide Subsection PH
[Browsable(false)]
[DisplayName("SubSection PH")]
[RefreshProperties(RefreshProperties.All)]
[Description("SubSection PH")]
@ -403,6 +414,8 @@ namespace VEPROMS.CSLA.Library
}
}
[Category("SubSection")]
//PROPGRID: Hide Subsection AutoIndent
[Browsable(false)]
[DisplayName("SubSection AutoIndent")]
[RefreshProperties(RefreshProperties.All)]
[Description("SubSection AutoIndent")]
@ -421,6 +434,8 @@ namespace VEPROMS.CSLA.Library
#endregion
#region LibDocCategory // from library document file during migration
[Category("LibraryDocument")]
//PROPGRID: Hide Libary Document Comment
[Browsable(false)]
[DisplayName("LibraryDocument Comment")]
[RefreshProperties(RefreshProperties.All)]
[Description("LibraryDocument Comment")]