using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;


using CategoryTheory;

namespace DiagramUI
{
    /// <summary>
    /// The factory of objects arrows and controls
    /// </summary>
    public interface IUIFactory
    {
        /// <summary>
        /// Creates object the corresponds to button
        /// </summary>
        /// <param name="button">The button</param>
        /// <returns>Created object</returns>
        ICategoryObject CreateObject(PaletteButton button);

        /// <summary>
        /// Creates an arrow the corresponds to button
        /// </summary>
        /// <param name="button">The button</param>
        /// <returns>Created arrow</returns>
        ICategoryArrow CreateArrow(PaletteButton button);

        /// <summary>
        /// Creates a form for component properties editor
        /// </summary>
        /// <param name="comp">The component</param>
        /// <returns>The result form</returns>
        Form CreateForm(INamedComponent comp);

        /// <summary>
        /// Shows error
        /// </summary>
        /// <param name="e">The exception of the error</param>
        void ShowError(Exception e);

        /// <summary>
        /// Creates arrow label
        /// </summary>
        /// <param name="button">Corresponding button</param>
        /// <param name="arrow">Corresponding arrow</param>
        /// <param name="source">Soource label</param>
        /// <param name="target">Target label</param>
        /// <returns>The arrow label</returns>
        ArrowLabel CreateArrowLabel(PaletteButton button, ICategoryArrow arrow, IObjectLabel source, IObjectLabel target);

        /// <summary>
        /// Creates object label
        /// </summary>
        /// <param name="button">Corresponding button</param>
        /// <returns>The object label</returns>
        ObjectLabel CreateObjectLabel(PaletteButton button);


        /// <summary>
        /// Gets button from category
        /// </summary>
        /// <param name="category">The category</param>
        /// <returns>The button</returns>
        PaletteButton GetObjectButton(ICategory category);

        /// <summary>
        /// Gets button from category
        /// </summary>
        /// <param name="category">The category</param>
        /// <returns>The button</returns>
        PaletteButton GetArrowButton(ICategory category);


        /// <summary>
        /// Tools
        /// </summary>
        ToolsDiagram Tools
        {
            set;
        }

        /// <summary>
        /// Gets button from object
        /// </summary>
        /// <param name="obj">The object</param>
        /// <returns>The button</returns>
        PaletteButton GetObjectButton(ICategoryObject obj);

        /// <summary>
        /// Gets button from arrow
        /// </summary>
        /// <param name="arrow">The arrow</param>
        /// <returns>The arrow</returns>
        PaletteButton GetArrowButton(ICategoryArrow arrow);

        /// <summary>
        /// Checks order of desktop and throws exception if order is illegal
        /// </summary>
        /// <param name="desktop">The desktop</param>
        void CheckOrder(PanelDesktop desktop);


        /// <summary>
        /// Creates object label from object
        /// </summary>
        /// <param name="obj">The object</param>
        /// <returns>The label</returns>
        ObjectLabel CreateLabel(ICategoryObject obj);

        /// <summary>
        /// Crerates arrow label from arrow
        /// </summary>
        /// <param name="arr">The arrow</param>
        /// <returns>The label</returns>
        ArrowLabel CreateLabel(ICategoryArrow arr);
    }
}
