This commit is contained in:
Jsj
2007-11-20 20:12:45 +00:00
parent d0793524be
commit 6e00716c47
149 changed files with 71953 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,89 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
namespace VEPROMS.CSLA.Library
{
public class DynamicPropertyDescriptor : PropertyDescriptor
{
private PropertyDescriptor _BasePropertyDescriptor;
private DynamicTypeDescriptor _Instance;
public DynamicPropertyDescriptor(DynamicTypeDescriptor instance, PropertyDescriptor basePropertyDescriptor)
: base(basePropertyDescriptor)
{
_Instance = instance;
_BasePropertyDescriptor = basePropertyDescriptor;
}
public override bool CanResetValue(object component)
{ return _BasePropertyDescriptor.CanResetValue(component); }
public override Type ComponentType
{ get { return _BasePropertyDescriptor.ComponentType; } }
public override object GetValue(object component)
{ return _BasePropertyDescriptor.GetValue(component); }
public override bool IsReadOnly
{ get { return _Instance.IsReadOnly; } }
public override Type PropertyType
{ get { return _BasePropertyDescriptor.PropertyType; } }
public override void ResetValue(object component)
{ _BasePropertyDescriptor.ResetValue(component); }
public override bool ShouldSerializeValue(object component)
{ return _BasePropertyDescriptor.ShouldSerializeValue(component); }
public override void SetValue(object component, object value)
{ _BasePropertyDescriptor.SetValue(component, value); }
}
[Serializable()]
public class DynamicTypeDescriptor //: ICustomTypeDescriptor//, ISupportInitialize
{
[NonSerialized]
private PropertyDescriptorCollection dynamicProps;
private bool _IsReadOnly = false;
internal virtual bool IsReadOnly
{
get { return _IsReadOnly; }
set { _IsReadOnly = value; }
}
public DynamicTypeDescriptor() { }
#region "TypeDescriptor Implementation"
public String GetClassName()
{ return TypeDescriptor.GetClassName(this, true); }
public AttributeCollection GetAttributes()
{ return TypeDescriptor.GetAttributes(this, true); }
public String GetComponentName()
{ return TypeDescriptor.GetComponentName(this, true); }
public TypeConverter GetConverter()
{ return TypeDescriptor.GetConverter(this, true); }
public EventDescriptor GetDefaultEvent()
{ return TypeDescriptor.GetDefaultEvent(this, true); }
public PropertyDescriptor GetDefaultProperty()
{ return TypeDescriptor.GetDefaultProperty(this, true); }
public object GetEditor(Type editorBaseType)
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
public EventDescriptorCollection GetEvents(Attribute[] attributes)
{ return TypeDescriptor.GetEvents(this, attributes, true); }
public EventDescriptorCollection GetEvents()
{ return TypeDescriptor.GetEvents(this, true); }
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{
return GetProperties();
}
public PropertyDescriptorCollection GetProperties()
{
if (dynamicProps == null)
{
PropertyDescriptorCollection baseProps = TypeDescriptor.GetProperties(this, true);
dynamicProps = new PropertyDescriptorCollection(null);
foreach (PropertyDescriptor oProp in baseProps)
{
dynamicProps.Add(new DynamicPropertyDescriptor(this, oProp));
}
}
return dynamicProps;
}
public object GetPropertyOwner(PropertyDescriptor pd)
{ return this; }
#endregion
}
}

View File

@@ -0,0 +1,164 @@
/*****************************************************************
* Module: EnumDescConverter.cs
* Type: C# Source Code
* Version: 1.0
* Description: Enum Converter using Description Attributes
*
* Revisions
* ------------------------------------------------
* [F] 24/02/2004, Jcl - Shaping up
* [B] 25/02/2004, Jcl - Made it much easier :-)
*
*****************************************************************/
using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Design;
using System.Reflection;
using System.Collections;
using System.Data;
namespace DescriptiveEnum
{
/// <summary>
/// EnumConverter supporting System.ComponentModel.DescriptionAttribute
/// </summary>
public class EnumDescConverter : System.ComponentModel.EnumConverter
{
protected System.Type myVal;
/// <summary>
/// Gets Enum Value's Description Attribute
/// </summary>
/// <param name="value">The value you want the description attribute for</param>
/// <returns>The description, if any, else it's .ToString()</returns>
public static string GetEnumDescription(Enum value)
{
Console.WriteLine("{0}", value);
FieldInfo fi = value.GetType().GetField(value.ToString());
DescriptionAttribute[] attributes =
(DescriptionAttribute[])fi.GetCustomAttributes(
typeof(DescriptionAttribute), false);
//Console.WriteLine("{0},{1},{2}", value.ToString(), attributes.Length, (attributes.Length > 0) ? attributes[0].Description : value.ToString());
return (attributes.Length>0)?attributes[0].Description:value.ToString();
}
/// <summary>
/// Gets the description for certaing named value in an Enumeration
/// </summary>
/// <param name="value">The type of the Enumeration</param>
/// <param name="name">The name of the Enumeration value</param>
/// <returns>The description, if any, else the passed name</returns>
public static string GetEnumDescription(System.Type value, string name)
{
FieldInfo fi= value.GetField(name);
DescriptionAttribute[] attributes =
(DescriptionAttribute[])fi.GetCustomAttributes(
typeof(DescriptionAttribute), false);
return (attributes.Length>0)?attributes[0].Description:name;
}
/// <summary>
/// Gets the value of an Enum, based on it's Description Attribute or named value
/// </summary>
/// <param name="value">The Enum type</param>
/// <param name="description">The description or name of the element</param>
/// <returns>The value, or the passed in description, if it was not found</returns>
public static object GetEnumValue(System.Type value, string description)
{
FieldInfo [] fis = value.GetFields();
foreach(FieldInfo fi in fis)
{
DescriptionAttribute[] attributes =
(DescriptionAttribute[])fi.GetCustomAttributes(
typeof(DescriptionAttribute), false);
if(attributes.Length>0)
{
if(attributes[0].Description == description)
{
return fi.GetValue(fi.Name);
}
}
if(fi.Name == description)
{
return fi.GetValue(fi.Name);
}
}
return description;
}
public EnumDescConverter(System.Type type) : base(type.GetType())
{
myVal = type;
}
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
{
if(value is Enum && destinationType == typeof(string))
{
return EnumDescConverter.GetEnumDescription((Enum)value);
}
if(value is string && destinationType == typeof(string))
{
return EnumDescConverter.GetEnumDescription(myVal, (string)value);
}
return base.ConvertTo (context, culture, value, destinationType);
}
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
{
if(value is string)
{
return EnumDescConverter.GetEnumValue(myVal, (string)value);
}
if(value is Enum)
{
return EnumDescConverter.GetEnumDescription((Enum)value);
}
return base.ConvertFrom (context, culture, value);
}
public override bool GetPropertiesSupported(ITypeDescriptorContext context)
{
return true;
}
public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
{
ArrayList values = new ArrayList();
FieldInfo[] fis = myVal.GetFields();
foreach (FieldInfo fi in fis)
{
DescriptionAttribute[] attributes =(DescriptionAttribute[])fi.GetCustomAttributes(
typeof(DescriptionAttribute), false);
//if (attributes.Length > 0)
if (fi.Name != "value__")
values.Add(fi.GetValue(fi.Name));
}
return new TypeConverter.StandardValuesCollection(values);
}
public static string GetEnumKeyDescription(Enum value)
{
FieldInfo fi = value.GetType().GetField(value.ToString());
DescriptionAttribute[] attributes =
(DescriptionAttribute[])fi.GetCustomAttributes(
typeof(DescriptionAttribute), false);
return (attributes.Length > 0) ? attributes[0].Description : value.ToString();
}
public static DataTable GetEnumAsDataTable(System.Type EnumType)
{
DataTable DTEnum = new DataTable();
DTEnum.Columns.Add(new DataColumn("EnumID", typeof(Int32)));
DTEnum.Columns.Add(new DataColumn("Enum", typeof(string)));
DTEnum.Columns.Add(new DataColumn("Description", typeof(string)));
foreach (int i in Enum.GetValues(EnumType))
{
System.Enum fooItem = (System.Enum)Enum.ToObject(EnumType, i);
DTEnum.Rows.Add(new object[] { i, fooItem.ToString(), GetEnumKeyDescription(fooItem) });
}
return DTEnum;
}
}
}

View File

@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.ComponentModel;
namespace VEPROMS.CSLA.Library
{
public class EnumDetail<T>
{
private T _EValue;
public T EValue
{
get { return _EValue; }
set { _EValue = value; }
}
private string _Name;
public string Name
{
get { return _Name; }
set { _Name = value; }
}
public EnumDetail(string name, T eValue)
{
_Name = name;
_EValue = eValue;
}
public static EnumDetail<T>[] Details()
{
string[] names = Enum.GetNames(typeof(T));
Array values = Enum.GetValues(typeof(T));
EnumDetail<T>[] retval = new EnumDetail<T>[values.Length];
for (int i = 0; i < values.Length; i++)
{
T val = (T)values.GetValue(i);
FieldInfo fi = val.GetType().GetField(val.ToString());
DescriptionAttribute[] attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false);
retval[i] = new EnumDetail<T>(((attributes.Length > 0) ? attributes[0].Description : names[i]), (T)values.GetValue(i));
}
return retval;
}
}
}

View File

@@ -0,0 +1,804 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Drawing;
using DescriptiveEnum;
namespace VEPROMS.CSLA.Library
{
[Serializable]
[TypeConverter(typeof(ExpandableObjectConverter))]
//public class FolderConfig : INotifyPropertyChanged
public class FolderConfig : DynamicTypeDescriptor, INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(String info)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(info));
}
internal override bool IsReadOnly
{
get { return _Folder == null; }
}
private XMLProperties _Xp;
private XMLProperties Xp
{
get { return _Xp; }
}
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 Folder _Folder;
private FolderInfo _FolderInfo;
public FolderConfig(Folder folder)
{
_Folder = folder;
string xml = _Folder.Config;
if (xml == string.Empty) xml = "<config/>";
_Xp = new XMLProperties(xml);
if(folder.MyParent != null) _Xp.LookInAncestor += new XMLPropertiesEvent(Xp_LookInAncestorFolder);
}
private string Xp_LookInAncestorFolder(object sender, XMLPropertiesArgs args)
{
if (_AncestorLookup || ParentLookup)
{
for (Folder folder = _Folder.MyParent; folder != null; folder = folder.MyParent)
{
string 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)
{
for (FolderInfo folder = _FolderInfo.MyParent; folder != null; folder = folder.MyParent)
{
string retval = folder.FolderConfig.GetValue(args.Group, args.Item);
if (retval != string.Empty) return retval;
}
}
return string.Empty;
}
public FolderConfig(FolderInfo folderInfo)
{
_FolderInfo = folderInfo;
string xml = _FolderInfo.Config;
if (xml == string.Empty) xml = "<config/>";
_Xp = new XMLProperties(xml);
}
public FolderConfig(string xml)
{
if (xml == string.Empty) xml = "<config/>";
_Xp = new XMLProperties(xml);
}
public FolderConfig()
{
_Xp = new XMLProperties("<config/>");
}
internal string GetValue(string group, string item)
{
return _Xp[group, item];
}
//[Category("Identification")]
[Category("General")]
[DisplayName("Name")]
[Description("Name")]
public string Name
{
get { return (_Folder != null ? _Folder.Name : _FolderInfo.Name); }
set { if (_Folder != null)_Folder.Name = value; }
}
//[Category("Identification")]
[Category("General")]
[DisplayName("Title")]
[Description("Title")]
public string Title
{
get { return (_Folder != null ? _Folder.Title : _FolderInfo.Title); }
set { _Folder.Title = value; }
}
//[Category("Identification")]
[Category("General")]
[DisplayName("Short Name")]
[Description("Short Name")]
public string ShortName
{
get { return (_Folder != null ? _Folder.ShortName : _FolderInfo.ShortName); }
set { if (_Folder != null)_Folder.ShortName = value; }
}
//[Category("Format")]
[Category("Format Settings")]
[DisplayName("Format")]
[Description("Format")]
[TypeConverter(typeof(FormatList))]
public string FormatSelection
{
get
{
//if (_Folder != null) return FormatList.ToString(_Folder.FormatID);
//if (_FolderInfo != null) return FormatList.ToString(_FolderInfo.FormatID);
if (_Folder != null && _Folder.MyFormat != null) return _Folder.MyFormat.PlantFormat.FormatData.Name;
if (_FolderInfo != null && _FolderInfo.MyFormat != null) return _FolderInfo.MyFormat.PlantFormat.FormatData.Name;
return null;
}
set
{
if (_Folder != null)_Folder.MyFormat = FormatList.ToFormat(value);
}
}
//[Category("Format")]
[Category("Format Settings")]
[DisplayName("Default Format")]
//[DisplayName("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 (_Folder != null && _Folder.MyParent!= null && _Folder.MyParent.ActiveFormat != null) return _Folder.MyParent.ActiveFormat.PlantFormat.FormatData.Name;
if (_FolderInfo != null && _FolderInfo.MyParent != null && _FolderInfo.MyParent.ActiveFormat != null) return _FolderInfo.MyParent.ActiveFormat.PlantFormat.FormatData.Name;
return null;
}
}
public override string ToString()
{
string s = _Xp.ToString();
if (s == "<config/>" || s == "<config></config>") return string.Empty;
return s;
}
#region GraphicsCategory // From veproms.ini
public bool CanWrite(string str)
{
return true;
}
//[Category("Graphics")]
[Category("Referenced Objects")]
[DisplayName("Graphic File Extension")]
//[DisplayName("Default File Extension")]
[RefreshProperties(RefreshProperties.All)]
[Description("Default File Extension")]
public string Graphics_defaultext
{
get
{
return _Xp["Graphics", "defaultext"];
}
set
{
_Xp["Graphics", "defaultext"] = value;
OnPropertyChanged("Graphics_defaultext");
}
}
#endregion
#region ColorCategory // From veproms.ini
// Note that not all possibilities from 16-bit will be added here, until
// it is determined how these will be used
//[Category("Color")]
[Category("Editor Settings")]
//[DisplayName("Referenced Object Highlight")]
[DisplayName("Step Editor Colors - Referenced Objects")]
[RefreshProperties(RefreshProperties.All)]
[Description("Color used to highlight an RO in procedure text")]
public string Color_ro
{
get
{
return _Xp["Color", "ro"];
}
set
{
_Xp["Color", "ro"] = value;
OnPropertyChanged("Color_ro");
}
}
//[Category("Color")]
[Category("Editor Settings")]
//[DisplayName("Transition Highlight")]
[DisplayName("Step Editor Colors - Transitions")]
[RefreshProperties(RefreshProperties.All)]
[Description("Color used to highlight a Transition in procedure text")]
public string Color_transition
{
get
{
return _Xp["Color", "transition"];
}
set
{
_Xp["Color", "transition"] = value;
OnPropertyChanged("Color_transition");
}
}
//[Category("Color")]
[Category("Editor Settings")]
//[DisplayName("editbackground")]
[DisplayName("Step Editor Colors - Active Background")]
[RefreshProperties(RefreshProperties.All)]
[Description("editbackground")]
public string Color_editbackground
{
get
{
return _Xp["Color", "editbackground"];
}
set
{
_Xp["Color", "editbackground"] = value;
OnPropertyChanged("Color_editbackground");
}
}
[Category("Color")]
[DisplayName("black")]
[RefreshProperties(RefreshProperties.All)]
[Description("black")]
public string Color_black
{
get
{
return _Xp["Color", "black"];
}
set
{
_Xp["Color", "black"] = value;
OnPropertyChanged("Color_black");
}
}
[Category("Color")]
[DisplayName("blue")]
[RefreshProperties(RefreshProperties.All)]
[Description("blue")]
public string Color_blue
{
get
{
return _Xp["Color", "blue"];
}
set
{
_Xp["Color", "blue"] = value;
OnPropertyChanged("Color_blue");
}
}
#endregion // From veproms.ini
#region SystemPrintCategory // From veproms.ini
//[Category("System Print")]
[Category("Print Settings")]
[DisplayName("Override Underline Thickness (dots)")]
//[DisplayName("Underline Width")]
[RefreshProperties(RefreshProperties.All)]
[Description("Underline Width")]
public int SysPrint_UWidth
{
get
{
string s = _Xp["SystemPrint", "UnderlineWidth"];
if (s == string.Empty) return 10;
return int.Parse(_Xp["SystemPrint", "UnderlineWidth"]);
}
set
{
_Xp["SystemPrint", "UnderlineWidth"] = value.ToString();
OnPropertyChanged("SysPrint_UWidth");
}
}
//[Category("System Print")]
[Category("Print Settings")]
[DisplayName("Adjust Starting Print Position (dots)")]
//[DisplayName("Vertical Offset")]
[RefreshProperties(RefreshProperties.All)]
[Description("Vertical Offset")]
public int SysPrint_VOffset
{
get
{
string s = _Xp["SystemPrint", "VerticalOffset"];
if (s == string.Empty) return 0;
return int.Parse(_Xp["SystemPrint", "VerticalOffset"]);
}
set
{
_Xp["SystemPrint", "VerticalOffset"] = value.ToString();
OnPropertyChanged("SysPrint_VOffset");
}
}
//[Category("System Print")]
[Category("Print Settings")]
[DisplayName("Override Normal Pen Width (dots)")]
//[DisplayName("Stroke Width")]
[RefreshProperties(RefreshProperties.All)]
[Description("Stroke Width")]
public int SysPrint_StrokeWidth
{
get
{
string s = _Xp["SystemPrint", "StrokeWidth"];
if (s == string.Empty) return 0;
return int.Parse(_Xp["SystemPrint", "StrokeWidth"]);
}
set
{
_Xp["SystemPrint", "StrokeWidth"] = value.ToString();
OnPropertyChanged("SysPrint_StrokeWidth");
}
}
//[Category("System Print")]
[Category("Print Settings")]
[DisplayName("Override Bold Pen Width (dots)")]
//[DisplayName("Stroke Width Bold")]
[RefreshProperties(RefreshProperties.All)]
[Description("Stroke Width Bold")]
public int SysPrint_StrokeWidthBold
{
get
{
string s = _Xp["SystemPrint", "StrokeWidthBold"];
if (s == string.Empty) return 0;
return int.Parse(_Xp["SystemPrint", "StrokeWidthBold"]);
}
set
{
_Xp["SystemPrint", "StrokeWidthBold"] = value.ToString();
OnPropertyChanged("SysPrint_StrokeWidthBold");
}
}
#endregion
#region StartupCategory // From veproms.ini
//[Category("Startup")]
[Category("Startup Message")]
[DisplayName("Startup MessageBox Title")]
[RefreshProperties(RefreshProperties.All)]
[Description("Startup MessageBox Title")]
public string Startup_MsgTitle
{
get
{
return _Xp["Startup", "MessageBoxTitle"];
}
set
{
_Xp["Startup", "MessageBoxTitle"] = value;
OnPropertyChanged("Startup_MsgTitle");
}
}
//[Category("Startup")]
[Category("Startup Message")]
[DisplayName("Startup Message File")]
[RefreshProperties(RefreshProperties.All)]
[Description("Startup Message File")]
public string Startup_MsgFile
{
get
{
return _Xp["Startup", "MessageFile"];
}
set
{
_Xp["Startup", "MessageFile"] = value;
OnPropertyChanged("Startup_MsgFile");
}
}
#endregion
#region ProcedureListTabStopsCategory // From veproms.ini
[Category("ProcedureListTabStops")]
[DisplayName("Procedure Number Tab")]
[RefreshProperties(RefreshProperties.All)]
[Description("Procedure Number Tab")]
public int ProcListTab_Number
{
get
{
string s = _Xp["ProcedureListTabStops", "ProcedureNumberTab"];
if (s == string.Empty) return 75;
return int.Parse(_Xp["ProcedureListTabStops", "ProcedureNumberTab"]);
}
set
{
_Xp["ProcedureListTabStops", "ProcedureNumberTab"] = value.ToString();
OnPropertyChanged("ProcListTab_Number");
}
}
[Category("ProcedureListTabStops")]
[DisplayName("Procedure Title Tab")]
[RefreshProperties(RefreshProperties.All)]
[Description("Procedure Title Tab")]
public int ProcListTab_Title
{
get
{
string s = _Xp["ProcedureListTabStops", "ProcedureTitleTab"];
if (s == string.Empty) return 175;
return int.Parse(_Xp["ProcedureListTabStops", "ProcedureTitleTab"]);
}
set
{
_Xp["ProcedureListTabStops", "ProcedureTitleTab"] = value.ToString();
OnPropertyChanged("ProcListTab_Title");
}
}
#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")]
//[DisplayName("Column Layout")]
[Category("Editor Settings")]
[DisplayName("Step Editor Columns")]
[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;//return (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")]
[Category("Format Settings")]
[DisplayName("Format")]
[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 DefaultsCategory // from proc.ini
//[Category("Defaults")]
[Category("Referenced Objects")]
//[DisplayName("Default Setpoint Prefix")]
[DisplayName("Default RO Prefix")]
[RefreshProperties(RefreshProperties.All)]
[Description("Default Setpoint Prefix")]
public string Default_SPPrefix
{
get { return _Xp["default", "spprefix"]; }
set
{
_Xp["default", "spprefix"] = value;
OnPropertyChanged("Default_SPPrefix");
}
}
//[Category("Defaults")]
[Category("Referenced Objects")]
[DisplayName("Default Image Prefix")]
[RefreshProperties(RefreshProperties.All)]
[Description("Default Image Prefix")]
public string Default_IMPrefix
{
get { return _Xp["default", "imprefix"]; }
set
{
_Xp["default", "imprefix"] = value;
OnPropertyChanged("RO_IMPrefix");
}
}
#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, 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 Automatic Duplexing")]
//[DisplayName("Disable Duplex Printing")]
[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
//[Category("Defaults")]
[Category("Editor Settings")]
//[DisplayName("Default BackColor")]
[DisplayName("Step Editor Colors - Non Active Background")]
[RefreshProperties(RefreshProperties.All)]
[Description("Default Background Color")]
public Color Default_BkColor
{
get
{
//return _Xp["default", "BkColor"];
string sColor = _Xp["default", "BkColor"];
if (sColor == string.Empty) sColor = "White";
if (sColor[0] == '[')
{
string[] parts = sColor.Substring(1, sColor.Length - 2).Split(",".ToCharArray());
return Color.FromArgb(Int32.Parse(parts[0]), Int32.Parse(parts[1]), Int32.Parse(parts[2]));
}
else return Color.FromName(sColor);
}
set
{
if (value.IsNamedColor) _Xp["default", "BkColor"] = value.Name;
else
{
_Xp["default", "BkColor"] = string.Format("[{0},{1},{2}]", value.R, value.G, value.B);
}
OnPropertyChanged("Default_BkColor");
}
}
}
}

View 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
}
}

View File

@@ -0,0 +1,441 @@
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
}
}

View File

@@ -0,0 +1,105 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
namespace VEPROMS.CSLA.Library
{
[Serializable]
[TypeConverter(typeof(ExpandableObjectConverter))]
public class UserConfig:INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(String info)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(info));
}
private XMLProperties _Xp;
private XMLProperties Xp
{
get { return _Xp; }
}
public UserConfig(string xml)
{
if (xml == string.Empty) xml = "<config/>";
_Xp = new XMLProperties(xml);
}
public UserConfig()
{
_Xp = new XMLProperties();
}
public override string ToString()
{
string s = _Xp.ToString();
if (s == "<config/>" || s == "<config></config>") return string.Empty;
return s;
}
#region UserCategory // from user.cfg
[Category("User")]
[DisplayName("User Location1")]
[RefreshProperties(RefreshProperties.All)]
[Description("User Location1")]
public string User_UserLoc1
{
get
{
return _Xp["user", "UserLoc1"];
}
set
{
_Xp["user", "UserLoc1"] = value;
OnPropertyChanged("User_UserLoc1");
}
}
[Category("User")]
[DisplayName("User Location2")]
[RefreshProperties(RefreshProperties.All)]
[Description("User Location2")]
public string User_UserLoc2
{
get
{
return _Xp["user", "UserLoc2"];
}
set
{
_Xp["user", "UserLoc2"] = value;
OnPropertyChanged("User_UserLoc2");
}
}
[Category("User")]
[DisplayName("User Phone1")]
[RefreshProperties(RefreshProperties.All)]
[Description("User Phone1")]
public string User_UserPhone1
{
get
{
return _Xp["user", "UserPhone1"];
}
set
{
_Xp["user", "UserPhone1"] = value;
OnPropertyChanged("User_UserPhone1");
}
}
[Category("User")]
[DisplayName("User Phone2")]
[RefreshProperties(RefreshProperties.All)]
[Description("User Phone2")]
public string User_UserPhone2
{
get
{
return _Xp["user", "UserPhone2"];
}
set
{
_Xp["user", "UserPhone2"] = value;
OnPropertyChanged("User_UserPhone2");
}
}
#endregion
}
}

View File

@@ -0,0 +1,171 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Serialization;
using System.Xml;
namespace VEPROMS.CSLA.Library
{
public delegate string XMLPropertiesEvent(object sender, XMLPropertiesArgs args);
[Serializable()]
public class XMLProperties
{
#region Events
public event XMLPropertiesEvent LookInAncestor;
private string OnLookInAncestor(object sender, XMLPropertiesArgs args)
{
if (LookInAncestor != null) return LookInAncestor(sender, args);
return string.Empty;
}
#endregion
#region Constructors
public XMLProperties()
{
_XmlContents = new XmlDocument();
_XmlContents.LoadXml("<config/>");
}
public XMLProperties(string xml)
{
_XmlContents = new XmlDocument();
_XmlContents.LoadXml(xml);
}
#endregion
#region BusinessMethods
[NonSerialized]
private bool _ParentLookup=false;
public bool ParentLookup
{
get { return _ParentLookup; }
set { _ParentLookup = value; }
}
[NonSerialized]
XmlDocument _XmlContents;
public XmlDocument XmlContents
{
get { return _XmlContents; }
}
private XmlNode GetGroup(string group)
{
XmlNodeList xl = _XmlContents.DocumentElement.SelectNodes(string.Format("//{0}", group));
switch (xl.Count)
{
case 0: // No nodes found
return null;
case 1: // Found the node
XmlNode xn = xl[0];
if (xn.GetType() == typeof(XmlElement)) return xn;
throw new XmlPropertiesException("Retrieved {0} while looking for XmlElement //{1}", xn.GetType().ToString(), group);
default: // Found more than 1 node
throw new XmlPropertiesException("Found more than one node //{0}", group);
}
}
private XmlAttribute GetItem(XmlNode xx, string item)
{
XmlNodeList xl = xx.SelectNodes(string.Format("@{0}", item));
switch (xl.Count)
{
case 0: // No nodes found
return null;
case 1: // Found the node
XmlNode xn = xl[0];
if (xn.GetType() == typeof(XmlAttribute)) return (XmlAttribute)xn;
throw new XmlPropertiesException("Retrieved {0} while looking for XmlAttribute @{1}", xn.GetType().ToString(), item);
default: // Found more than 1 node
throw new XmlPropertiesException("Found more than one node @{0}", item);
}
}
public string this[string group, string item]
{
get
{
if (_ParentLookup)
return OnLookInAncestor(this, new XMLPropertiesArgs(group, item));
XmlNode xn = GetGroup(group);
if (xn == null) return OnLookInAncestor(this,new XMLPropertiesArgs(group,item));
XmlNode xa = GetItem(xn, item);
if (xa == null) return OnLookInAncestor(this, new XMLPropertiesArgs(group, item));
return xa.InnerText;
}
set
{
if (value == null) value = string.Empty;
XmlNode xn = GetGroup(group);
if (xn == null)
{
if (value != string.Empty)// Add Group and Item
{
xn = _XmlContents.DocumentElement.AppendChild(_XmlContents.CreateElement(group));
XmlAttribute xa = xn.Attributes.Append(_XmlContents.CreateAttribute(item));
xa.Value = value;
}
}
else
{
XmlAttribute xa = GetItem(xn, item);
if (xa == null)
{
if (value != string.Empty) // Add Item
{
xa = xn.Attributes.Append(_XmlContents.CreateAttribute(item));
xa.Value = value;
}
}
else
{
if (value != string.Empty) // Add Item
{
xa.Value = value;
}
else
{
xn.Attributes.Remove(xa);
if (xn.Attributes.Count == 0)
_XmlContents.DocumentElement.RemoveChild(xn);
}
}
}
}
}
public override string ToString()
{
if (XmlContents == null) return null;
return XmlContents.OuterXml;
}
#endregion
#region XmlPropertiesException
public class XmlPropertiesException : Exception
{
public XmlPropertiesException() : base() { ;}
public XmlPropertiesException(string message) : base(message) { ;}
public XmlPropertiesException(string messageFormat,params object [] args) : base(string.Format(messageFormat,args)) { ;}
public XmlPropertiesException(SerializationInfo info, StreamingContext context) : base(info, context) { ;}
public XmlPropertiesException(string message,Exception innerException) : base(message, innerException) { ;}
}
#endregion
}
public partial class XMLPropertiesArgs
{
#region Business Methods
private string _Group;
public string Group
{
get { return _Group; }
set { _Group = value; }
}
private string _Item;
public string Item
{
get { return _Item; }
set { _Item = value; }
}
#endregion
#region Factory Methods
private XMLPropertiesArgs() { ;}
public XMLPropertiesArgs(string group, string item)
{
_Group=group;
_Item=item;
}
#endregion
}
}