using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; namespace CLIP.eForm.Consent.UI { /// /// 이미지 뷰어 관련 컨트롤 클래스 /// /// ///

[설계자]

///

클립소프트 연구소 홍지철 (jchong@clipsoft.co.kr)

///

[원본 작성자]

///

클립소프트 연구소 홍지철 (jchong@clipsoft.co.kr)

///

[수정 작성자]

///

///

----------------------------------------------------------------------------------------

///

[HISTORY]

///

2016-07-01 : 최초작성

///

----------------------------------------------------------------------------------------

///
public partial class ThumbnailCtrl : UserControl { public ThumbnailCtrl() { InitializeComponent(); } Dictionary pics = new Dictionary(); public void UpdateThumbnailImages(List images) { this.currentImageIndex = 0; pics.Clear(); List removeTarget = new List(); foreach (Control ctrl in this.Controls) { if (ctrl is PictureBox) { removeTarget.Add(ctrl); } } this.Controls.Clear(); foreach (Control ctrl in removeTarget) { ctrl.Dispose(); } this.Size = new Size(50 * images.Count + 20 * images.Count + 5, 80); int index = 0; foreach (Image img in images) { PictureBox pic = new PictureBox(); pic.Size = new Size(50, 70); pic.Location = new Point(index * 70 + 3, 3); pic.SizeMode = PictureBoxSizeMode.StretchImage; this.Controls.Add(pic); pics.Add(index, pic); pic.Image = img; pic.Tag = index; pic.Click += Pic_Click; index++; } this.Invalidate(); } /// /// 썸네일 이미지 클릭 이벤트 /// /// The source of the event. /// The instance containing the event data. private void Pic_Click(object sender, EventArgs e) { PictureBox picBox = sender as PictureBox; if (picBox == null) { return; } if (picBox.Tag == null) { return; } int index = (int)picBox.Tag; if (SelectImageChanged != null) { EventArgs eventArgs = new EventArgs(); SelectImageChanged.Invoke(index); } } public delegate void IndexChangeHandler(int index); public event IndexChangeHandler SelectImageChanged = null; public int currentImageIndex = 0; internal void SetCurrentImageIndex(int currentImageIndex) { this.currentImageIndex = currentImageIndex; this.Invalidate(); } private bool IsInDesignMode { get { return DesignMode || LicenseManager.UsageMode == LicenseUsageMode.Designtime; } } protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); if(IsInDesignMode) { return; } if (pics.Count < 1) { return; } using (Pen pen = new Pen(Color.Blue, 2.0f)) { Rectangle rect = new Rectangle(pics[this.currentImageIndex].Location, pics[this.currentImageIndex].Size); rect.Inflate(2, 2); e.Graphics.DrawRectangle(pen, rect); } } } }