728x90
반응형
728x170
▶ CustomTileGenerator.cs
using System;
using System.Drawing;
using DevExpress.XtraMap;
namespace TestProject
{
/// <summary>
/// 커스텀 타일 생성기
/// </summary>
public class CustomTileGenerator : IImageTileSource
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Field
////////////////////////////////////////////////////////////////////////////////////////// Private
#region Field
/// <summary>
/// 폰트
/// </summary>
private readonly Font font = new Font("Arial", 10);
/// <summary>
/// 난수기
/// </summary>
private Random random = new Random();
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Property
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 소스 이미지 리소스 해제 가능 여부 - CanDisposeSourceImage
/// <summary>
/// 소스 이미지 리소스 해제 가능 여부
/// </summary>
public bool CanDisposeSourceImage
{
get
{
return true;
}
}
#endregion
#region 명칭 - Name
/// <summary>
/// 명칭
/// </summary>
public string Name
{
get
{
return nameof(CustomTileGenerator);
}
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 이미지 구하기 - GetImage(x, y, level, size)
/// <summary>
/// 이미지 구하기
/// </summary>
/// <param name="x">X 좌표</param>
/// <param name="y">Y 좌표</param>
/// <param name="level">레벨</param>
/// <param name="size">크기</param>
/// <returns>이미지</returns>
public Image GetImage(int x, int y, int level, Size size)
{
Bitmap bitmap = new Bitmap(size.Width, size.Height);
using(Graphics graphics = Graphics.FromImage(bitmap))
{
graphics.Clear(Color.FromArgb(128, random.Next(255), random.Next(255), random.Next(255)));
graphics.DrawString
(
string.Format("X : {0}, Y : {1}, Level : {2}", x, y, level),
font,
Brushes.Black,
new PointF(5, 5)
);
}
return bitmap;
}
#endregion
}
}
728x90
▶ MainForm.cs
using System;
using DevExpress.XtraEditors;
using DevExpress.XtraMap;
namespace TestProject
{
/// <summary>
/// 메인 폼
/// </summary>
public partial class MainForm : XtraForm
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - MainForm()
/// <summary>
/// 생성자
/// </summary>
public MainForm()
{
InitializeComponent();
Load += Form_Load;
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Private
#region 폼 로드시 처리하기 - Form_Load(sender, e)
/// <summary>
/// 폼 로드시 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void Form_Load(object sender, EventArgs e)
{
ImageTileDataProvider imageTileDataProvider = new ImageTileDataProvider();
imageTileDataProvider.TileSource = new CustomTileGenerator();
this.imageLayer.DataProvider = imageTileDataProvider;
}
#endregion
}
}
728x90
반응형
그리드형(광고전용)
댓글을 달아 주세요