|
|
@ -58,8 +58,8 @@ namespace ICSharpCode.Reports.Addin |
|
|
|
throw new ArgumentNullException("graphics"); |
|
|
|
throw new ArgumentNullException("graphics"); |
|
|
|
} |
|
|
|
} |
|
|
|
Rectangle rect = new Rectangle(this.ClientRectangle.Left,this.ClientRectangle.Top, |
|
|
|
Rectangle rect = new Rectangle(this.ClientRectangle.Left,this.ClientRectangle.Top, |
|
|
|
this.ClientRectangle.Right -1, |
|
|
|
this.ClientRectangle.Right -1, |
|
|
|
this.ClientRectangle.Bottom -1); |
|
|
|
this.ClientRectangle.Bottom -1); |
|
|
|
|
|
|
|
|
|
|
|
base.DrawControl(graphics); |
|
|
|
base.DrawControl(graphics); |
|
|
|
if (this.Image != null) { |
|
|
|
if (this.Image != null) { |
|
|
@ -77,7 +77,9 @@ namespace ICSharpCode.Reports.Addin |
|
|
|
[EditorAttribute ( typeof(FileNameEditor), typeof(UITypeEditor) ) ] |
|
|
|
[EditorAttribute ( typeof(FileNameEditor), typeof(UITypeEditor) ) ] |
|
|
|
public string ImageFileName { |
|
|
|
public string ImageFileName { |
|
|
|
get { return imageFileName; } |
|
|
|
get { return imageFileName; } |
|
|
|
set { imageFileName = value; } |
|
|
|
set { imageFileName = value; |
|
|
|
|
|
|
|
System.Diagnostics.Trace.WriteLine(String.Format("<ADDIN.BaseImage > {0}",this.ImageFileName)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -87,20 +89,68 @@ namespace ICSharpCode.Reports.Addin |
|
|
|
using (Graphics g = Graphics.FromImage (b)){ |
|
|
|
using (Graphics g = Graphics.FromImage (b)){ |
|
|
|
g.DrawRectangle (new Pen(Color.Black, 1), |
|
|
|
g.DrawRectangle (new Pen(Color.Black, 1), |
|
|
|
1,1,size.Width -2,size.Height -2); |
|
|
|
1,1,size.Width -2,size.Height -2); |
|
|
|
g.DrawString("Image",new Font("Microsoft Sans Serif", 8), |
|
|
|
g.DrawString("Image",new Font("Microsoft Sans Serif", 8), |
|
|
|
new SolidBrush(Color.Gray), |
|
|
|
new SolidBrush(Color.Gray), |
|
|
|
new RectangleF(1,1,size.Width,size.Height) ); |
|
|
|
new RectangleF(1,1,size.Width,size.Height) ); |
|
|
|
} |
|
|
|
} |
|
|
|
return b; |
|
|
|
return b; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Image LoadImage () |
|
|
|
private Image LoadImage () |
|
|
|
{ |
|
|
|
{ |
|
|
|
try { |
|
|
|
try { |
|
|
|
Image im; |
|
|
|
Image im = null; |
|
|
|
|
|
|
|
// string absFileName = this.AbsoluteFileName;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.relativeFileName = FileUtility.GetRelativePath(this.ReportFileName,this.ImageFileName); |
|
|
|
|
|
|
|
// absFileName = FileUtility.GetAbsolutePath (this.relativeFileName,this.ImageFileName);
|
|
|
|
|
|
|
|
// System.Diagnostics.Trace.WriteLine("-----");
|
|
|
|
|
|
|
|
// System.Diagnostics.Trace.WriteLine(String.Format("<ADDIN.LoadImage ReportFN > {0}",this.reportFileName));
|
|
|
|
|
|
|
|
// System.Diagnostics.Trace.WriteLine(String.Format("<ADDIN.LoadImage IamgeFN > {0}",this.ImageFileName));
|
|
|
|
|
|
|
|
// System.Diagnostics.Trace.WriteLine(String.Format("<ADDIN.LoadImage rel neu s3 > {0}",this.relativeFileName));
|
|
|
|
|
|
|
|
// System.Diagnostics.Trace.WriteLine(String.Format("<ADDIN.LoadImage from absolute > {0}",this.AbsoluteFileName));
|
|
|
|
|
|
|
|
// System.Diagnostics.Trace.WriteLine("-----");
|
|
|
|
|
|
|
|
string absFileName = this.AbsoluteFileName; |
|
|
|
|
|
|
|
if (!String.IsNullOrEmpty(absFileName) && File.Exists(absFileName)){ |
|
|
|
|
|
|
|
im = Image.FromFile (absFileName); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
im = BaseImageItem.ErrorBitmap(base.Size); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (im == null) { |
|
|
|
|
|
|
|
string str = String.Format(CultureInfo.InvariantCulture, |
|
|
|
|
|
|
|
"Unable to Load {0}",imageFileName); |
|
|
|
|
|
|
|
throw new ReportException(str); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return im; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (System.OutOfMemoryException) { |
|
|
|
|
|
|
|
throw; |
|
|
|
|
|
|
|
} catch (System.IO.FileNotFoundException) { |
|
|
|
|
|
|
|
throw; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Image old_LoadImage () |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
Image im = null; |
|
|
|
string absFileName = this.AbsoluteFileName; |
|
|
|
string absFileName = this.AbsoluteFileName; |
|
|
|
if (!String.IsNullOrEmpty(absFileName) && File.Exists(absFileName)) { |
|
|
|
System.Diagnostics.Trace.WriteLine("-----"); |
|
|
|
|
|
|
|
System.Diagnostics.Trace.WriteLine(String.Format("<ADDIN.LoadImage > {0}",absFileName)); |
|
|
|
|
|
|
|
System.Diagnostics.Trace.WriteLine(String.Format("<ADDIN.LoadImage ReportFN > {0}",this.reportFileName)); |
|
|
|
|
|
|
|
System.Diagnostics.Trace.WriteLine(String.Format("<ADDIN.LoadImage IamgeFN > {0}",this.ImageFileName)); |
|
|
|
|
|
|
|
System.Diagnostics.Trace.WriteLine(String.Format("<ADDIN.LoadImage IamgeFN > {0}",this.RelativeFileName)); |
|
|
|
|
|
|
|
// string s1 = FileUtility.GetRelativePath(this.reportFileName,this.ImageFileName);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string s2 = FileUtility.GetRelativePath(this.ImageFileName,this.ReportFileName); |
|
|
|
|
|
|
|
string s3 = FileUtility.GetAbsolutePath (s2,this.ImageFileName); |
|
|
|
|
|
|
|
// System.Diagnostics.Trace.WriteLine(String.Format("<ADDIN.LoadImage s1 > {0}",s1));
|
|
|
|
|
|
|
|
//System.Diagnostics.Trace.WriteLine(String.Format("<ADDIN.LoadImage s2 > {0}",s2));
|
|
|
|
|
|
|
|
System.Diagnostics.Trace.WriteLine(String.Format("<ADDIN.LoadImage from absolute s3 > {0}",s3)); |
|
|
|
|
|
|
|
System.Diagnostics.Trace.WriteLine("-----"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!String.IsNullOrEmpty(absFileName) && File.Exists(absFileName)){ |
|
|
|
im = Image.FromFile (this.AbsoluteFileName); |
|
|
|
im = Image.FromFile (this.AbsoluteFileName); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
im = BaseImageItem.ErrorBitmap(base.Size); |
|
|
|
im = BaseImageItem.ErrorBitmap(base.Size); |
|
|
@ -111,6 +161,7 @@ namespace ICSharpCode.Reports.Addin |
|
|
|
throw new ReportException(str); |
|
|
|
throw new ReportException(str); |
|
|
|
} |
|
|
|
} |
|
|
|
return im; |
|
|
|
return im; |
|
|
|
|
|
|
|
|
|
|
|
} catch (System.OutOfMemoryException) { |
|
|
|
} catch (System.OutOfMemoryException) { |
|
|
|
throw; |
|
|
|
throw; |
|
|
|
} catch (System.IO.FileNotFoundException) { |
|
|
|
} catch (System.IO.FileNotFoundException) { |
|
|
@ -166,7 +217,7 @@ namespace ICSharpCode.Reports.Addin |
|
|
|
[Category("Image from Database")] |
|
|
|
[Category("Image from Database")] |
|
|
|
public string BaseTableName { |
|
|
|
public string BaseTableName { |
|
|
|
get { return baseTableName; } |
|
|
|
get { return baseTableName; } |
|
|
|
set { |
|
|
|
set { |
|
|
|
baseTableName = value; |
|
|
|
baseTableName = value; |
|
|
|
this.imageSource = GlobalEnums.ImageSource.Database; |
|
|
|
this.imageSource = GlobalEnums.ImageSource.Database; |
|
|
|
} |
|
|
|
} |
|
|
@ -175,10 +226,12 @@ namespace ICSharpCode.Reports.Addin |
|
|
|
|
|
|
|
|
|
|
|
[XmlIgnoreAttribute] |
|
|
|
[XmlIgnoreAttribute] |
|
|
|
[Category("Image")] |
|
|
|
[Category("Image")] |
|
|
|
[Browsable(false)] |
|
|
|
// [Browsable(false)]
|
|
|
|
public string ReportFileName { |
|
|
|
public string ReportFileName { |
|
|
|
get { return reportFileName; } |
|
|
|
get { return Path.GetFullPath(reportFileName); } |
|
|
|
set { reportFileName = value; } |
|
|
|
set { reportFileName = value; |
|
|
|
|
|
|
|
System.Diagnostics.Trace.WriteLine(""); |
|
|
|
|
|
|
|
System.Diagnostics.Trace.WriteLine(String.Format("<ADDIN.ImageItem> Filename {0}",Path.GetFullPath(this.reportFileName)));} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -186,19 +239,25 @@ namespace ICSharpCode.Reports.Addin |
|
|
|
// [Browsable(false)]
|
|
|
|
// [Browsable(false)]
|
|
|
|
public string RelativeFileName { |
|
|
|
public string RelativeFileName { |
|
|
|
get { return relativeFileName; } |
|
|
|
get { return relativeFileName; } |
|
|
|
set { relativeFileName = value; } |
|
|
|
set { relativeFileName = value; |
|
|
|
|
|
|
|
System.Diagnostics.Trace.WriteLine(""); |
|
|
|
|
|
|
|
System.Diagnostics.Trace.WriteLine(String.Format("<ADDIN.RelativeFilenamee > {0}",this.relativeFileName)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// [XmlIgnoreAttribute]
|
|
|
|
// [XmlIgnoreAttribute]
|
|
|
|
[Category("Image")] |
|
|
|
// [Category("Image")]
|
|
|
|
[Browsable(false)] |
|
|
|
// [Browsable(false)]
|
|
|
|
public string AbsoluteFileName |
|
|
|
public string AbsoluteFileName |
|
|
|
{ |
|
|
|
{ |
|
|
|
get { |
|
|
|
get { |
|
|
|
string p1 = Path.GetDirectoryName(this.reportFileName); |
|
|
|
|
|
|
|
string p2 = Path.GetFullPath(relativeFileName); |
|
|
|
string absolute = FileUtility.GetAbsolutePath(reportFileName,imageFileName); |
|
|
|
string s = FileUtility.GetRelativePath(p1,p2); |
|
|
|
|
|
|
|
|
|
|
|
if (File.Exists(absolute)){ |
|
|
|
|
|
|
|
return absolute; |
|
|
|
|
|
|
|
} |
|
|
|
if (!string.IsNullOrEmpty(relativeFileName)) { |
|
|
|
if (!string.IsNullOrEmpty(relativeFileName)) { |
|
|
|
string testFileName = FileUtility.NormalizePath(Path.Combine(Path.GetDirectoryName(this.reportFileName),this.relativeFileName)); |
|
|
|
string testFileName = FileUtility.NormalizePath(Path.Combine(Path.GetDirectoryName(this.reportFileName),this.relativeFileName)); |
|
|
|
if (File.Exists(testFileName)){ |
|
|
|
if (File.Exists(testFileName)){ |
|
|
@ -221,10 +280,10 @@ namespace ICSharpCode.Reports.Addin |
|
|
|
|
|
|
|
|
|
|
|
// public ImageItemTypeProvider(TypeDescriptionProvider parent): base(parent)
|
|
|
|
// public ImageItemTypeProvider(TypeDescriptionProvider parent): base(parent)
|
|
|
|
// {
|
|
|
|
// {
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override ICustomTypeDescriptor GetTypeDescriptor(Type objectType, object instance) |
|
|
|
public override ICustomTypeDescriptor GetTypeDescriptor(Type objectType, object instance) |
|
|
|
{ |
|
|
|
{ |
|
|
|
ICustomTypeDescriptor td = base.GetTypeDescriptor(objectType,instance); |
|
|
|
ICustomTypeDescriptor td = base.GetTypeDescriptor(objectType,instance); |
|
|
@ -253,13 +312,13 @@ namespace ICSharpCode.Reports.Addin |
|
|
|
{ |
|
|
|
{ |
|
|
|
PropertyDescriptorCollection props = base.GetProperties(attributes); |
|
|
|
PropertyDescriptorCollection props = base.GetProperties(attributes); |
|
|
|
List<PropertyDescriptor> allProperties = new List<PropertyDescriptor>(); |
|
|
|
List<PropertyDescriptor> allProperties = new List<PropertyDescriptor>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DesignerHelper.AddDefaultProperties(allProperties,props); |
|
|
|
DesignerHelper.AddDefaultProperties(allProperties,props); |
|
|
|
|
|
|
|
|
|
|
|
PropertyDescriptor prop = prop = props.Find("imageFileName",true); |
|
|
|
PropertyDescriptor prop = prop = props.Find("imageFileName",true); |
|
|
|
allProperties.Add(prop); |
|
|
|
allProperties.Add(prop); |
|
|
|
|
|
|
|
|
|
|
|
prop = props.Find("Image",true); |
|
|
|
prop = props.Find("Image",true); |
|
|
|
allProperties.Add(prop); |
|
|
|
allProperties.Add(prop); |
|
|
|
|
|
|
|
|
|
|
@ -275,6 +334,9 @@ namespace ICSharpCode.Reports.Addin |
|
|
|
prop = props.Find("RelativeFileName",true); |
|
|
|
prop = props.Find("RelativeFileName",true); |
|
|
|
allProperties.Add(prop); |
|
|
|
allProperties.Add(prop); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
prop = props.Find("AbsoluteFileName",true); |
|
|
|
|
|
|
|
allProperties.Add(prop); |
|
|
|
|
|
|
|
|
|
|
|
prop = props.Find("ColumnName",true); |
|
|
|
prop = props.Find("ColumnName",true); |
|
|
|
allProperties.Add(prop); |
|
|
|
allProperties.Add(prop); |
|
|
|
|
|
|
|
|
|
|
|