|
#region Using directives
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Drawing.Drawing2D;
#endregion
namespace SmartInstitute.Client.Automation.Controls
{
public partial class PictureViewer : UserControl
{
public PictureViewer()
{
InitializeComponent();
}
private byte[] _PictureData;
private Image _Image = null;
public Image Image
{
get
{
return this._Image;
}
set
{
this._Image = value;
}
}
public byte[] PictureData
{
get { return _PictureData; }
set
{
_PictureData = value;
if (null == this._PictureData)
{
return;
}
else if (this._PictureData.Length > 0)
{
MemoryStream stream = new MemoryStream(this._PictureData);
this._Image = Bitmap.FromStream(stream);
stream.Close();
}
}
}
private void PictureViewer_Paint(object sender, PaintEventArgs e)
{
e.Graphics.Clear(base.BackColor);
Rectangle bounds = base.ClientRectangle;
// Calculate the image rectangle
Rectangle picRect = new Rectangle(2, 2, bounds.Width - 6, bounds.Height - 6);
// Draw the image if available
if( null != this._Image )
e.Graphics.DrawImage(this._Image, picRect);
// Draw a white border
using (Pen borderPen = new Pen(Brushes.White, 2f))
{
borderPen.LineJoin = LineJoin.Round;
e.Graphics.DrawRectangle(borderPen, picRect);
}
// draw the shadows
using (Pen linePen = new Pen(Color.Gray))
{
for (int i = 0; i < 4; i++)
{
linePen.Color = Color.FromArgb(100 - (i * 20), Color.Gray);
// Horizontal shadow
e.Graphics.DrawLine(linePen,
picRect.Left + i, picRect.Bottom + 1 + i,
picRect.Right + i + 1, picRect.Bottom + 1 + i);
// Vertical shadow
e.Graphics.DrawLine(linePen,
picRect.Right + i + 1, picRect.Top + i,
picRect.Right + i + 1, picRect.Bottom + i);
}
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here