diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/PropertyDescriptors.cs b/PROMS/VEPROMS.CSLA.Library/Extension/PropertyDescriptors.cs index c92d4210..a815e7a9 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/PropertyDescriptors.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/PropertyDescriptors.cs @@ -41,23 +41,32 @@ namespace VEPROMS.CSLA.Library } public class FormatList : System.ComponentModel.StringConverter { - private static SortedList _FormatInfoList; + private static SortedList _MyFormatInfoList; + public static SortedList MyFormatInfoList + { + get + { + if (_MyFormatInfoList == null) + LoadSortedList(); + return FormatList._MyFormatInfoList; + } + } private static void LoadSortedList() { - if (_FormatInfoList == null) + if (_MyFormatInfoList == null) { - _FormatInfoList = new SortedList(); + _MyFormatInfoList = new SortedList(); foreach (FormatInfo formatInfo in FormatInfoList.Get()) { - _FormatInfoList.Add(formatInfo.Name, formatInfo); + //_FormatInfoList.Add(formatInfo.Name, formatInfo); + _MyFormatInfoList.Add(formatInfo.FullName, formatInfo); } - _FormatInfoList.Add("", null); + _MyFormatInfoList.Add("", null); } } public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { - LoadSortedList(); - return new StandardValuesCollection((ICollection)_FormatInfoList.Values); + return new StandardValuesCollection((ICollection)MyFormatInfoList.Values); } public override bool GetStandardValuesSupported(ITypeDescriptorContext context) { @@ -70,26 +79,84 @@ namespace VEPROMS.CSLA.Library public static int? ToInt(string formatName) { if (formatName == null || formatName == string.Empty) return null; - LoadSortedList(); - foreach (FormatInfo formatInfo in _FormatInfoList.Values) - if (formatInfo != null && formatInfo.Name == formatName) return formatInfo.FormatID; + foreach (FormatInfo formatInfo in MyFormatInfoList.Values) + if (formatInfo != null && formatInfo.FullName == formatName) return formatInfo.FormatID; return null; } public static string ToString(int? formatID) { if (formatID == null) return null; - LoadSortedList(); - foreach (FormatInfo formatInfo in _FormatInfoList.Values) + foreach (FormatInfo formatInfo in MyFormatInfoList.Values) if (formatInfo != null && formatInfo.FormatID == formatID) return formatInfo.ToString(); return null; } public static Format ToFormat(string formatName) { if (formatName == null || formatName == string.Empty) return null; - LoadSortedList(); - foreach (FormatInfo formatInfo in _FormatInfoList.Values) + foreach (FormatInfo formatInfo in MyFormatInfoList.Values) if (formatInfo != null && formatInfo.ToString() == formatName) return formatInfo.Get(); return null; } } + public class DocStyleListConverter : System.ComponentModel.StringConverter + { + private static SortedList _MyDocStyleList; + private static SortedList MyDocStyleList + { + get + { + if (_MyDocStyleList == null) + LoadSortedList(); + return _MyDocStyleList; + } + set { _MyDocStyleList = value; } + } + private static Section _MySection; + public static Section MySection + { + get { return _MySection; } + set + { + _MySection = value; + _MyDocStyleList = null; + } + } + private static void LoadSortedList() + { + if (_MyDocStyleList == null) + { + _MyDocStyleList = new SortedList(); + foreach(DocStyle ds in _MySection.ActiveFormat.PlantFormat.DocStyles.DocStyleList) + { + _MyDocStyleList.Add(ds.Name,10000 + (int) ds.Index); + } + } + } + public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) + { + return new StandardValuesCollection((ICollection)MyDocStyleList.Keys); + } + public override bool GetStandardValuesSupported(ITypeDescriptorContext context) + { + return true; + } + public override bool GetStandardValuesExclusive(ITypeDescriptorContext context) + { + return true; + } + public static int? ToInt(string docStyleName) + { + return MyDocStyleList[docStyleName]; + } + public static string ToString(int? sectionType) + { + if (sectionType == null) return null; + return MyDocStyleList.Keys[MyDocStyleList.IndexOfValue((int)sectionType)]; + } + public static int ToSectionType(string docStyleName) + { + return MyDocStyleList[docStyleName]; + } + } + }