/******************************************************************************
 * MarkGroupView.cs 
 * 
 * <Copyright and License> 
 * 
 * This file is part of GODS, a package for annotating medical images. 
 * 
 * Copyright (C) 2004 
 * Xuedong Chen 
 * Heri Mariwa 
 * Kimmy (Hsiang-ling) Lin 
 * Rui Yu 
 * 
 * This program is free software; you can redistribute it and/or 
 * modify it under the terms of the GNU General Public License 
 * as published by the Free Software Foundation; either version 2 
 * of the License, or (at your option) any later version. 
 * 
 * This program is distributed in the hope that it will be useful, 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
 * GNU General Public License for more details. 
 * 
 * You should have received a copy of the GNU General Public License 
 * along with this program; if not, write to the Free Software 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
 *  
 * For further questions about this file, please send email to 
 * gods@cs.umb.edu or visit us at http://gods.sourceforge.net.  
 ******************************************************************************/

using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using GODS.MarkData;

namespace GODS.MarkGUI
{
	/// <summary>
	/// Summary description for MarkGroupView.
	/// </summary>
	public class MarkGroupView : System.Windows.Forms.UserControl
	{
		/// <summary> 
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;
		private System.Windows.Forms.Label lblGroup;
		private ArrayList markViews;

		public MarkGroupView(MarkGroup group, EventHandler handler)
		{
			// This call is required by the Windows.Forms Form Designer.
			InitializeComponent();
			composeMarkGroupView(group, handler);
		}

		public ArrayList MarkViews
		{
			get 
			{
				return this.markViews;
			}
		}

		/// <summary> 
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Component Designer generated code

		/// <summary> 

		/// Required method for Designer support - do not modify 

		/// the contents of this method with the code editor.

		/// </summary>

		private void InitializeComponent()

		{
			this.lblGroup = new System.Windows.Forms.Label();
			this.SuspendLayout();
			// 
			// lblGroup
			// 
			this.lblGroup.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.lblGroup.Location = new System.Drawing.Point(8, 8);
			this.lblGroup.Name = "lblGroup";
			this.lblGroup.Size = new System.Drawing.Size(168, 24);
			this.lblGroup.TabIndex = 0;
			this.lblGroup.Text = "groupName";
			this.lblGroup.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// MarkGroupView
			// 
			this.Controls.Add(this.lblGroup);
			this.Name = "MarkGroupView";
			this.Size = new System.Drawing.Size(200, 128);
			this.ResumeLayout(false);

		}

		#endregion

		private void composeMarkGroupView(MarkGroup group, EventHandler handler)
		{
			MarkView mView;
			this.markViews = new ArrayList();
			this.lblGroup.Text = group.GroupName;
			int count = group.Marks.Count;
			int x = 15;
			int y = 40;

			foreach (Mark mark in group.Marks)
			{
				mView = new MarkView(mark);
				if (handler != null)
					mView.setClickEvent(handler);
				mView.Location = new Point(x, y);
				y += mView.Height + 5;
				this.Controls.Add(mView);
				this.markViews.Add(mView);
			}
			this.Height = y;
		}
	}

}

