using System; using System.ComponentModel; namespace VEPROMS.CSLA.Library { [Serializable] [TypeConverter(typeof(ExpandableObjectConverter))] public class ImageConfig : ConfigDynamicTypeDescriptor, INotifyPropertyChanged { #region DynamicTypeDescriptor internal override bool IsReadOnly { get { return _ImageInfo == null; } } #endregion #region XML private XMLProperties _Xp; private XMLProperties Xp { get { return _Xp; } } #endregion #region Constructors private ImageInfo _ImageInfo; public ImageConfig(ImageInfo imageInfo) { if (imageInfo == null) { string xmlx = ""; _Xp = new XMLProperties(xmlx); return; } _ImageInfo = imageInfo; string xml = imageInfo.Config; if (xml == string.Empty) xml = ""; _Xp = new XMLProperties(xml); } public ImageConfig() { string xml = ""; _Xp = new XMLProperties(xml); } internal string GetValue(string group, string item) { return _Xp[group, item]; } #endregion #region Local Properties [Category("Image")] [Browsable(false)] [DisplayName("DataSize")] [RefreshProperties(RefreshProperties.All)] [Description("DataSize")] public int Image_DataSize // original size of image data, if it is compressed { get { string s = _Xp["Image", "DataSize"]; if (s == string.Empty) return 0; int tst = 0; try { tst = int.Parse(s); } catch (Exception ex) { return 0; } return int.Parse(s); } set { string s = _Xp["Image", "DataSize"]; if (value.ToString() == s) return; _Xp["Image", "DataSize"] = value.ToString(); OnPropertyChanged("Image_DataSize"); } } [Category("Image")] [Browsable(false)] [DisplayName("Width")] [RefreshProperties(RefreshProperties.All)] [Description("Width")] public int Image_Width // resized image's resized width { get { string s = _Xp["Image", "Width"]; if (s == string.Empty) return 0; int tst = 0; try { tst = int.Parse(s); } catch (Exception ex) { return 0; } return int.Parse(s); } set { string s = _Xp["Image", "Width"]; if (value.ToString() == s) return; _Xp["Image", "Width"] = value.ToString(); OnPropertyChanged("Image_Width"); } } [Category("Image")] [Browsable(false)] [DisplayName("Height")] [RefreshProperties(RefreshProperties.All)] [Description("Height")] public int Image_Height // resized image's resized height { get { string s = _Xp["Image", "Height"]; if (s == string.Empty) return 0; int tst = 0; try { tst = int.Parse(s); } catch (Exception ex) { return 0; } return int.Parse(s); } set { string s = _Xp["Image", "Height"]; if (value.ToString() == s) return; _Xp["Image", "Height"] = value.ToString(); OnPropertyChanged("Image_Height"); } } #endregion #region ToString public override string ToString() { string s = _Xp.ToString(); if (s == "" || s == "") return string.Empty; return s; } #endregion } }