442 lines
12 KiB
C#
442 lines
12 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using System.ComponentModel;
|
|
using DescriptiveEnum;
|
|
|
|
namespace VEPROMS.CSLA.Library
|
|
{
|
|
[Serializable]
|
|
[TypeConverter(typeof(ExpandableObjectConverter))]
|
|
public class SectionConfig : DynamicTypeDescriptor, INotifyPropertyChanged
|
|
{
|
|
#region Events
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
private void OnPropertyChanged(String info)
|
|
{
|
|
if (PropertyChanged != null)
|
|
PropertyChanged(this, new PropertyChangedEventArgs(info));
|
|
}
|
|
#endregion
|
|
#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
|
|
public bool ParentLookup
|
|
{
|
|
get { return _Xp.ParentLookup; }
|
|
set { _Xp.ParentLookup = value; }
|
|
}
|
|
[NonSerialized]
|
|
private bool _AncestorLookup;
|
|
public bool AncestorLookup
|
|
{
|
|
get { return _AncestorLookup; }
|
|
set { _AncestorLookup = value; }
|
|
}
|
|
private Section _Section;
|
|
private SectionInfo _SectionInfo;
|
|
public SectionConfig(Section section)
|
|
{
|
|
_Section = section;
|
|
string xml = section.MyContent.Config;
|
|
if (xml == string.Empty) xml = "<config/>";
|
|
_Xp = new XMLProperties(xml);
|
|
if (section.ActiveParent != null) _Xp.LookInAncestor += new XMLPropertiesEvent(Xp_LookInAncestorFolder);
|
|
}
|
|
private string Xp_LookInAncestorFolder(object sender, XMLPropertiesArgs args)
|
|
{
|
|
if (_AncestorLookup || ParentLookup)
|
|
{
|
|
string retval;
|
|
Section sect = _Section;
|
|
while (sect.ActiveParent.GetType() == typeof(Section))
|
|
{
|
|
retval = sect.SectionConfig.GetValue(args.Group, args.Item);
|
|
if (retval != string.Empty) return retval;
|
|
sect = (Section)sect.ActiveParent;
|
|
}
|
|
Procedure proc = (Procedure) sect.ActiveParent;
|
|
while (proc.ActiveParent.GetType() == typeof(Procedure))
|
|
{
|
|
retval = proc.ProcedureConfig.GetValue(args.Group, args.Item);
|
|
if (retval != string.Empty) return retval;
|
|
proc = (Procedure)proc.ActiveParent;
|
|
}
|
|
DocVersion docVersion = (DocVersion)proc.ActiveParent;
|
|
retval = docVersion.DocVersionConfig.GetValue(args.Group, args.Item);
|
|
if (retval != string.Empty) return retval;
|
|
for (Folder 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;
|
|
}
|
|
private string Xp_LookInAncestorFolderInfo(object sender, XMLPropertiesArgs args)
|
|
{
|
|
if (_AncestorLookup || ParentLookup)
|
|
{
|
|
string retval;
|
|
Section sect = _Section;
|
|
while (sect.ActiveParent.GetType() == typeof(Section))
|
|
{
|
|
//retval = sect.SectionConfig.GetValue(args.Group, args.Item);
|
|
//if (retval != string.Empty) return retval;
|
|
sect = (Section)sect.ActiveParent;
|
|
}
|
|
Procedure proc = (Procedure)sect.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)
|
|
{
|
|
retval = folder.FolderConfig.GetValue(args.Group, args.Item);
|
|
if (retval != string.Empty) return retval;
|
|
}
|
|
}
|
|
return string.Empty;
|
|
}
|
|
public SectionConfig(SectionInfo sectionInfo)
|
|
{
|
|
_SectionInfo = sectionInfo;
|
|
string xml = sectionInfo.MyContent.Config;
|
|
if (xml == string.Empty) xml = "<config/>";
|
|
_Xp = new XMLProperties(xml);
|
|
}
|
|
public SectionConfig(string xml)
|
|
{
|
|
if (xml == string.Empty) xml = "<config/>";
|
|
_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")]
|
|
[DisplayName("Number")]
|
|
[Description("Number")]
|
|
public string Number
|
|
{
|
|
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")]
|
|
public string Title
|
|
{
|
|
get { return (_Section != null ? _Section.MyContent.Text : _SectionInfo.MyContent.Text); }
|
|
set { if (_Section != null) _Section.MyContent.Text = value; }
|
|
}
|
|
[Category("Identification")]
|
|
[DisplayName("Old Sequence")]
|
|
[Description("Old Sequence")]
|
|
public string OldSequence
|
|
{
|
|
get { return (_Section != null ? _Section.MyContent.MyZContent.OldStepSequence : (_SectionInfo.MyContent.MyZContent == null ? null : _SectionInfo.MyContent.MyZContent.OldStepSequence)); }
|
|
set { if (_Section != null) _Section.MyContent.MyZContent.OldStepSequence = value; }
|
|
}
|
|
[Category("Identification")]
|
|
[DisplayName("Dirty")]
|
|
[Description("Dirty")]
|
|
public bool Dirty
|
|
{
|
|
get { return (_Section != null ? _Section.IsDirty : false); }
|
|
}
|
|
[Category("Format")]
|
|
[DisplayName("Format")]
|
|
[Description("Format")]
|
|
[TypeConverter(typeof(FormatList))]
|
|
public string FormatSelection
|
|
{
|
|
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;
|
|
}
|
|
set
|
|
{
|
|
if (_Section != null) _Section.MyContent.MyFormat = FormatList.ToFormat(value); // Can only be set if _DocVersion is set
|
|
}
|
|
}
|
|
[Category("Format")]
|
|
//[DisplayName("DefFormat")]
|
|
[DisplayName("Default Format")]
|
|
[Description("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;
|
|
}
|
|
}
|
|
#endregion
|
|
#region ToString
|
|
public override string ToString()
|
|
{
|
|
string s = _Xp.ToString();
|
|
if (s == "<config/>" || s == "<config></config>") return string.Empty;
|
|
return s;
|
|
}
|
|
#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)]
|
|
[Description("Section Pagination")]
|
|
public SectionPagination Section_Pagination
|
|
{
|
|
get
|
|
{
|
|
string s = _Xp["Section", "Pagination"];
|
|
if (s == string.Empty || s.Equals("-1")) return SectionPagination.Default;
|
|
return (SectionPagination)int.Parse(_Xp["Section", "Pagination"]);
|
|
}
|
|
set
|
|
{
|
|
if (value == SectionPagination.Default) _Xp["Section", "Pagination"] = string.Empty;
|
|
else _Xp["Section", "Pagination"] = ((int)value).ToString();
|
|
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")]
|
|
[DisplayName("Include in Background/Deviation")]
|
|
[RefreshProperties(RefreshProperties.All)]
|
|
[Description("Section LinkEnhanced")]
|
|
public string Section_LnkEnh
|
|
{
|
|
get
|
|
{
|
|
return _Xp["Section", "LnkEnh"];
|
|
}
|
|
set
|
|
{
|
|
_Xp["Section", "LnkEnh"] = value;
|
|
OnPropertyChanged("Section_LnkEnh");
|
|
}
|
|
}
|
|
//[Category("Section")]
|
|
[Category("General")]
|
|
//[DisplayName("Section TOC")]
|
|
[DisplayName("Include On Table Of Contents")]
|
|
[RefreshProperties(RefreshProperties.All)]
|
|
[Description("Section TOC")]
|
|
public string Section_TOC
|
|
{
|
|
get
|
|
{
|
|
return _Xp["Section", "TOC"];
|
|
}
|
|
set
|
|
{
|
|
_Xp["Section", "TOC"] = value;
|
|
OnPropertyChanged("Section_TOC");
|
|
}
|
|
}
|
|
[Category("Section")]
|
|
[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")]
|
|
[DisplayName("Section NumPages")]
|
|
[RefreshProperties(RefreshProperties.All)]
|
|
[Description("Section NumPages")]
|
|
public string Section_NumPages
|
|
{
|
|
get
|
|
{
|
|
return _Xp["Section", "NumPages"];
|
|
}
|
|
set
|
|
{
|
|
_Xp["Section", "NumPages"] = value;
|
|
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
|
|
}
|
|
//[Category("Section")]
|
|
[Category("Format")]
|
|
//[DisplayName("Section ColumnMode")]
|
|
[DisplayName("Columns")]
|
|
[RefreshProperties(RefreshProperties.All)]
|
|
[Description("Section ColumnMode")]
|
|
public SectionColumnMode Section_ColumnMode
|
|
{
|
|
get
|
|
{
|
|
string s = _Xp["Section", "ColumnMode"];
|
|
if (s == string.Empty || s.Equals("-1")) return SectionColumnMode.Default;
|
|
return (SectionColumnMode)int.Parse(_Xp["Section", "ColumnMode"]);
|
|
}
|
|
set
|
|
{
|
|
if (value == SectionColumnMode.Default) _Xp["Section", "ColumnMode"] = string.Empty;
|
|
else _Xp["Section", "ColumnMode"] = ((int)value).ToString();
|
|
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")]
|
|
[DisplayName("SubSection Edit")]
|
|
[RefreshProperties(RefreshProperties.All)]
|
|
[Description("SubSection Edit")]
|
|
public string SubSection_Edit
|
|
{
|
|
get
|
|
{
|
|
return _Xp["SubSection", "Edit"];
|
|
}
|
|
set
|
|
{
|
|
_Xp["SubSection", "Edit"] = value;
|
|
OnPropertyChanged("SubSection_Edit");
|
|
}
|
|
}
|
|
[Category("SubSection")]
|
|
[DisplayName("SubSection PH")]
|
|
[RefreshProperties(RefreshProperties.All)]
|
|
[Description("SubSection PH")]
|
|
public string SubSection_PH
|
|
{
|
|
get
|
|
{
|
|
return _Xp["SubSection", "PH"];
|
|
}
|
|
set
|
|
{
|
|
_Xp["SubSection", "PH"] = value;
|
|
OnPropertyChanged("SubSection_PH");
|
|
}
|
|
}
|
|
[Category("SubSection")]
|
|
[DisplayName("SubSection AutoIndent")]
|
|
[RefreshProperties(RefreshProperties.All)]
|
|
[Description("SubSection AutoIndent")]
|
|
public string SubSection_AutoIndent
|
|
{
|
|
get
|
|
{
|
|
return _Xp["SubSection", "AutoIndent"];
|
|
}
|
|
set
|
|
{
|
|
_Xp["SubSection", "AutoIndent"] = value;
|
|
OnPropertyChanged("SubSection_AutoIndent");
|
|
}
|
|
}
|
|
#endregion
|
|
#region LibDocCategory // from library document file during migration
|
|
[Category("LibraryDocument")]
|
|
[DisplayName("LibraryDocument Comment")]
|
|
[RefreshProperties(RefreshProperties.All)]
|
|
[Description("LibraryDocument Comment")]
|
|
public string LibDoc_Comment
|
|
{
|
|
get
|
|
{
|
|
return _Xp["LibraryDocument", "Comment"];
|
|
}
|
|
set
|
|
{
|
|
_Xp["LibraryDocument", "Comment"] = value;
|
|
OnPropertyChanged("LibDoc_Comment");
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
}
|