#region Copyright and GPL
/*************************************************************************
 * dataMagus - The open source database learning software
 * Copyright (C) 2007 by all authors
 * Authors: Monika Schwitter (monsy@gmx.ch)
 *          Jürg Zgraggen (j.zgraggen@ejaz.net)
 *          HSLU (Hochschule Luzern - Technik+Architektur)
 * 
 *     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 3 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, see <http://www.gnu.org/licenses/>.
 *************************************************************************/
#endregion
#region Using
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using dataMagus.Common;
using dataMagus.Common.PlugIn;
using dataMagus.Common.PlugIn.Notation;
using dataMagus.Common.Logical;
#endregion

namespace dataMagus.PlugIns.Notations.ModifiedChen
{
	/// <summary>
	/// This class is used to draw the Modified Chen notation.
	/// </summary>
    public class ModifiedChenNotation : ILogicalNotation
    {
        #region Members
        /// <summary>
        /// Name of the notation.
        /// </summary>
        private string _name = "Modified Chen";
        #endregion

        #region Properties
        /// <summary>
        /// Name of the notation.
        /// </summary>
        public string Name
        {
            get { return this._name; }
        }
		#endregion

        #region Methodes
        /// <summary>
        /// Tells the notation that the drawing of the relationships will begin.
        /// </summary>
        public void BeginDrawingRelationships()
        {
        	RelationshipDrawer.BeginDrawingRelationships();
        }

        /// <summary>
        /// Gets the control for an entity.
        /// </summary>
        /// <param name="entity">Logical entity.</param>
        /// <returns>ElementControl if successfull, null to ignore.</returns>
        public ElementControl GetEntityControl(LogicalEntity entity)
        {
        	EntityControl ctrl = new EntityControl(entity);
        	ctrl.AutoSize = true;
			return ctrl;
        }

        /// <summary>
        /// Tells the notation to draw a relationship.
        /// </summary>
        /// <param name="relationship">Logical relationship to draw.</param>
        /// <param name="element1">Control of the first element between the relationship.</param>
        /// <param name="element2">Control of the second element between the relationship.</param>
        /// <param name="showRelationshipName">Indicator if the name of the relationship should show up.</param>
        /// <param name="showRolenames">Indicator if the name of the roles should show up.</param>
        /// <param name="showCardinalities">Indicator if the cardinalities should show up.</param>
        /// <param name="context">Graphics context</param>
        public void DrawRelationship(LogicalRelationship relationship, ElementControl element1, ElementControl element2, 
			bool showRelationshipName, bool showRolenames, bool showCardinalities, Graphics context)
        {
        	RelationshipDrawer drawer = new RelationshipDrawer(relationship, element1, element2);
        	drawer.ShowCardinalities = showCardinalities;
        	drawer.DrawRelationship(context);
        }

        /// <summary>
        /// Tells the notation that a MouseDown event has happend on the schema control.
        /// </summary>
        /// <param name="e">MouseEventArgs</param>
        public void OnMouseDown(MouseEventArgs e)
        {
        	RelationshipDrawer.OnMouseDown(e);
        }
        #endregion
    }
}
