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
|
||||
|
@@ -1771,6 +1771,28 @@ namespace VEPROMS.CSLA.Library
|
||||
|
||||
public partial class ContentInfo
|
||||
{
|
||||
public static ContentInfo RestoreImage(ImageAuditInfo iai)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (Content ctmp = Content.Get(iai.ContentID))
|
||||
{
|
||||
ctmp.MyImage.FileName = iai.FileName;
|
||||
ctmp.MyImage.Data = iai.Data;
|
||||
ctmp.MyImage.Config = iai.Config;
|
||||
ctmp.MyImage.DTS = DateTime.Now;
|
||||
ctmp.MyImage.UserID = Volian.Base.Library.VlnSettings.UserID;
|
||||
ctmp.DTS = DateTime.Now;
|
||||
ImageInfo.Refresh(ctmp.MyImage);
|
||||
ctmp.Save();
|
||||
return ContentInfo.Get(iai.ContentID);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new DbCslaException("Error on ContentInfo.RestoreImage", ex);
|
||||
}
|
||||
}
|
||||
public static ContentInfo RestoreContent(ContentAuditInfo cai,ROFstInfo myRoFst)
|
||||
{
|
||||
try
|
||||
|
@@ -2219,6 +2219,11 @@ namespace VEPROMS.CSLA.Library
|
||||
//string number = cont.Number;
|
||||
string number = DisplayNumber;
|
||||
//if (cont.Type >= 20000) number = Ordinal.ToString() + ".";
|
||||
if ((cont.Type == 20036 || cont.Type == 20037 || cont.Type == 20038 || cont.Type == 20039))// && !RO
|
||||
{
|
||||
if (MyContent.ContentRoUsages == null || MyContent.ContentRoUsages.Count == 0)
|
||||
return "Embedded Image";
|
||||
}
|
||||
if (cont.Type >= 20000) number = MyTab == null ? "" : MyTab.CleanText;
|
||||
return string.Format("{0} {1}", number, DisplayText).Trim(); // Need TrimEnd(); for IP3
|
||||
//return string.Format("{0} {1}", number, cont.Text).Trim();
|
||||
|
@@ -102,7 +102,11 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
foreach (Item tmp in _RefreshItems)
|
||||
{
|
||||
if (tmp._MyContent != null) ContentInfo.Refresh(tmp._MyContent);
|
||||
if (tmp._MyContent != null)
|
||||
{
|
||||
ContentInfo.Refresh(tmp._MyContent);
|
||||
if (tmp._MyContent.MyImage != null) ImageInfo.Refresh(tmp._MyContent.MyImage);
|
||||
}
|
||||
ItemInfo.Refresh(tmp);
|
||||
}
|
||||
foreach (ItemAnnotation tmp in _RefreshItemAnnotations)
|
||||
|
Reference in New Issue
Block a user