This commit is contained in:
520
PROMS/VEPROMS.CSLA.Library/Config/ProcConfig.cs
Normal file
520
PROMS/VEPROMS.CSLA.Library/Config/ProcConfig.cs
Normal file
@@ -0,0 +1,520 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
using DescriptiveEnum;
|
||||
|
||||
namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
[Serializable]
|
||||
[TypeConverter(typeof(ExpandableObjectConverter))]
|
||||
public class ProcedureConfig : 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 _Procedure == 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 Procedure _Procedure;
|
||||
private ProcedureInfo _ProcedureInfo;
|
||||
public ProcedureConfig(Procedure procedure)
|
||||
{
|
||||
_Procedure = procedure;
|
||||
string xml = procedure.MyContent.Config;
|
||||
if (xml == string.Empty) xml = "<config/>";
|
||||
_Xp = new XMLProperties(xml);
|
||||
if (procedure.ActiveParent != null) _Xp.LookInAncestor += new XMLPropertiesEvent(Xp_LookInAncestorFolder);
|
||||
}
|
||||
private string Xp_LookInAncestorFolder(object sender, XMLPropertiesArgs args)
|
||||
{
|
||||
if (_AncestorLookup || ParentLookup)
|
||||
{
|
||||
string retval;
|
||||
Procedure proc = _Procedure;
|
||||
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)
|
||||
{
|
||||
|
||||
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 = "<config/>";
|
||||
_Xp = new XMLProperties(xml);
|
||||
}
|
||||
public ProcedureConfig(string xml)
|
||||
{
|
||||
if (xml == string.Empty) xml = "<config/>";
|
||||
_Xp = new XMLProperties(xml);
|
||||
}
|
||||
//public ProcedureConfig()
|
||||
//{
|
||||
// _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 (_Procedure != null ? _Procedure.MyContent.Number : _ProcedureInfo.MyContent.Number); }
|
||||
set { if (_Procedure != null) _Procedure.MyContent.Number = value; }
|
||||
}
|
||||
//[Category("Identification")]
|
||||
[Category("General")]
|
||||
[DisplayName("Title")]
|
||||
[Description("Title")]
|
||||
public string Title
|
||||
{
|
||||
get { return (_Procedure != null ? _Procedure.MyContent.Text : _ProcedureInfo.MyContent.Text); }
|
||||
set { if (_Procedure != null) _Procedure.MyContent.Text = value; }
|
||||
}
|
||||
[Category("Identification")]
|
||||
[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)); }
|
||||
set { if (_Procedure != null) _Procedure.MyContent.MyZContent.OldStepSequence = value; }
|
||||
}
|
||||
[Category("Identification")]
|
||||
[DisplayName("Dirty")]
|
||||
[Description("Dirty")]
|
||||
public bool Dirty
|
||||
{
|
||||
get { return (_Procedure != null ? _Procedure.IsDirty : false ); }
|
||||
}
|
||||
//[Category("Format")]
|
||||
[Category("Format Settings")]
|
||||
[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 (_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;
|
||||
}
|
||||
set
|
||||
{
|
||||
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")]
|
||||
[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;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region ToString
|
||||
public override string ToString()
|
||||
{
|
||||
string s = _Xp.ToString();
|
||||
if (s == "<config/>" || s == "<config></config>") return string.Empty;
|
||||
return s;
|
||||
}
|
||||
#endregion
|
||||
#region FormatCategory
|
||||
[TypeConverter(typeof(EnumDescConverter))]
|
||||
public enum FormatColumns : int
|
||||
{
|
||||
Default = 0,
|
||||
[Description("Single Column")]
|
||||
OneColumn,
|
||||
[Description("Duel Column")]
|
||||
TwoColumn,
|
||||
[Description("Triple Column")]
|
||||
ThreeColumn,
|
||||
[Description("Quad Column")]
|
||||
FourColumns
|
||||
}
|
||||
//[Category("Format")]
|
||||
[Category("General")]
|
||||
//[DisplayName("Column Layout")]
|
||||
[DisplayName("Default Column Mode")]
|
||||
[RefreshProperties(RefreshProperties.All)]
|
||||
[Description("Column Layout")]
|
||||
public FormatColumns Format_Columns
|
||||
{
|
||||
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"]);
|
||||
}
|
||||
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 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,
|
||||
[Description("Automatic")]
|
||||
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 || s.Equals("-1")) 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");
|
||||
}
|
||||
}
|
||||
[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)]
|
||||
[Description("Watermark")]
|
||||
public PrintWatermark Print_Watermark
|
||||
{
|
||||
get
|
||||
{
|
||||
string s = _Xp["PrintSettings", "Watermark"];
|
||||
if (s == string.Empty || s.Equals("-1")) 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")]
|
||||
[DisplayName("Disable Automatic Duplexing")]
|
||||
[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
|
||||
[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
|
||||
}
|
||||
//{
|
||||
// [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)]
|
||||
[Description("Change Bar Use")]
|
||||
public PrintChangeBar Print_ChangeBar
|
||||
{
|
||||
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"]);
|
||||
}
|
||||
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();
|
||||
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("Print Settings")]
|
||||
[Category("Format Settings")]
|
||||
//[DisplayName("Change Bar Location")]
|
||||
[DisplayName("Change Bar Position")]
|
||||
[RefreshProperties(RefreshProperties.All)]
|
||||
[Description("User Specified Change Bar Location")]
|
||||
public PrintChangeBarLoc Print_ChangeBarLoc
|
||||
{
|
||||
get
|
||||
{
|
||||
string s = _Xp["PrintSettings", "ChangeBarLoc"];
|
||||
if (s == string.Empty || s.Equals("-1")) 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
|
||||
[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("Print Settings")]
|
||||
[Category("Format Settings")]
|
||||
//[DisplayName("Change Bar Text")]
|
||||
[DisplayName("Change Bar Text Type")]
|
||||
[RefreshProperties(RefreshProperties.All)]
|
||||
[Description("Change Bar Text")]
|
||||
public PrintChangeBarText Print_ChangeBarText
|
||||
{
|
||||
get
|
||||
{
|
||||
string s = _Xp["PrintSettings", "ChangeBarText"];
|
||||
if (s == string.Empty || s.Equals("-1")) 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")]
|
||||
[Category("Format Settings")]
|
||||
//[DisplayName("User Change Bar Message1")]
|
||||
[DisplayName("Custom Change Bar Message Line One")]
|
||||
[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")]
|
||||
[Category("Format Settings")]
|
||||
//[DisplayName("User Change Bar Message2")]
|
||||
[DisplayName("Custom Change Bar Message Line Two")]
|
||||
[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
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user