|
@@ -2,6 +2,7 @@
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
using System.Drawing;
|
|
using System.Drawing;
|
|
using System.Drawing.Imaging;
|
|
using System.Drawing.Imaging;
|
|
|
|
+using NTERA.Interop;
|
|
|
|
|
|
namespace NTERA.Console
|
|
namespace NTERA.Console
|
|
{
|
|
{
|
|
@@ -9,29 +10,46 @@ namespace NTERA.Console
|
|
{
|
|
{
|
|
public Bitmap Image { get; set; }
|
|
public Bitmap Image { get; set; }
|
|
|
|
|
|
- public ImageRenderItem(Bitmap bitmap)
|
|
|
|
- {
|
|
|
|
- Image = bitmap;
|
|
|
|
- }
|
|
|
|
|
|
+ public DisplayLineAlignment Alignment;
|
|
|
|
|
|
- public ImageRenderItem(Bitmap original, Rectangle cropRectangle)
|
|
|
|
|
|
+ public ImageRenderItem(Bitmap bitmap, Rectangle? cropRectangle = null, DisplayLineAlignment alignment = DisplayLineAlignment.LEFT)
|
|
{
|
|
{
|
|
- Image = new Bitmap(original.Width, cropRectangle.Height, PixelFormat.Format32bppArgb);
|
|
|
|
|
|
+ if (cropRectangle != null)
|
|
|
|
+ {
|
|
|
|
+ Image = new Bitmap(bitmap.Width, cropRectangle.Value.Height, PixelFormat.Format32bppArgb);
|
|
|
|
|
|
- using (Graphics g = Graphics.FromImage(Image))
|
|
|
|
|
|
+ using (Graphics g = Graphics.FromImage(Image))
|
|
|
|
+ {
|
|
|
|
+ g.DrawImage(bitmap, new Rectangle(0, 0, bitmap.Width, cropRectangle.Value.Height), cropRectangle.Value, GraphicsUnit.Pixel);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
{
|
|
{
|
|
- g.DrawImage(original, new Rectangle(0, 0, original.Width, cropRectangle.Height), cropRectangle, GraphicsUnit.Pixel);
|
|
|
|
|
|
+ Image = bitmap;
|
|
}
|
|
}
|
|
- }
|
|
|
|
-
|
|
|
|
- public ImageRenderItem(string imagePath)
|
|
|
|
- {
|
|
|
|
- Image = new Bitmap(imagePath);
|
|
|
|
|
|
+
|
|
|
|
+ Alignment = alignment;
|
|
}
|
|
}
|
|
|
|
|
|
public override void Render(Graphics graphics, Rectangle renderArea, Point mousePointer)
|
|
public override void Render(Graphics graphics, Rectangle renderArea, Point mousePointer)
|
|
{
|
|
{
|
|
- graphics.DrawImage(Image, new Rectangle(0, renderArea.Y, Image.Width, renderArea.Height));
|
|
|
|
|
|
+ int x;
|
|
|
|
+
|
|
|
|
+ switch (Alignment)
|
|
|
|
+ {
|
|
|
|
+ default:
|
|
|
|
+ case DisplayLineAlignment.LEFT:
|
|
|
|
+ x = 0;
|
|
|
|
+ break;
|
|
|
|
+ case DisplayLineAlignment.CENTER:
|
|
|
|
+ x = (renderArea.Width - Image.Width) / 2;
|
|
|
|
+ break;
|
|
|
|
+ case DisplayLineAlignment.RIGHT:
|
|
|
|
+ x = renderArea.Width - Image.Width;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ graphics.DrawImage(Image, new Rectangle(x, renderArea.Y, Image.Width, renderArea.Height));
|
|
}
|
|
}
|
|
|
|
|
|
public static List<ImageRenderItem> CreateFromLargeBitmap(Bitmap original, int lineHeight)
|
|
public static List<ImageRenderItem> CreateFromLargeBitmap(Bitmap original, int lineHeight)
|