Embedded images
This commit is contained in:
149
PROMS/VEPROMS.CSLA.Library/Config/ImageConfig.cs
Normal file
149
PROMS/VEPROMS.CSLA.Library/Config/ImageConfig.cs
Normal file
@@ -0,0 +1,149 @@
|
||||
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 = "<Config/>";
|
||||
_Xp = new XMLProperties(xmlx);
|
||||
return;
|
||||
}
|
||||
_ImageInfo = imageInfo;
|
||||
string xml = imageInfo.Config;
|
||||
if (xml == string.Empty) xml = "<Config/>";
|
||||
_Xp = new XMLProperties(xml);
|
||||
}
|
||||
public ImageConfig()
|
||||
{
|
||||
string xml = "<Config/>";
|
||||
_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 == "<Config/>" || s == "<Config></Config>") return string.Empty;
|
||||
return s;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -358,6 +358,60 @@ namespace VEPROMS.CSLA.Library
|
||||
OnPropertyChanged("Step_Responsibility");
|
||||
}
|
||||
}
|
||||
#region RO image sizing
|
||||
// if the RO image (figure) is resized, save it in the step config, not in the ROImageConfig. If stored in ROImageConfig
|
||||
// the size is set for ALL uses.
|
||||
public int Step_ImageWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
string s = _Xp["Step", "ImageWidth"];
|
||||
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["Step", "ImageWidth"];
|
||||
if (value.ToString() == s) return;
|
||||
_Xp["Step", "ImageWidth"] = value.ToString();
|
||||
OnPropertyChanged("Step_ImageWidth");
|
||||
}
|
||||
}
|
||||
public int Step_ImageHeight
|
||||
{
|
||||
get
|
||||
{
|
||||
string s = _Xp["Step", "ImageHeight"];
|
||||
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["Step", "ImageHeight"];
|
||||
if (value.ToString() == s) return;
|
||||
_Xp["Step", "ImageHeight"] = value.ToString();
|
||||
OnPropertyChanged("Step_ImageHeight");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
// Enhanced Documents
|
||||
private EnhancedDocuments _MyEnhancedDocuments = null;
|
||||
public EnhancedDocuments MyEnhancedDocuments
|
||||
|
Reference in New Issue
Block a user