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