﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="EditModelEquippedForm.cs" company="">
//   
// </copyright>
// <summary>
//   The edit model equipped form.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace MineAPI.Editor.Renderer
{
    using System;
    using System.Windows.Forms;

    using EditorBase.Rendering;

    /// <summary>
    ///     The edit model equipped form.
    /// </summary>
    public partial class EditModelEquippedForm : Form
    {
        #region Constructors and Destructors

        /// <summary>
        ///     Initializes a new instance of the <see cref="EditModelEquippedForm" /> class.
        /// </summary>
        public EditModelEquippedForm()
        {
            InitializeComponent();
        }

        #endregion

        #region Public Properties

        /// <summary>
        ///     Gets or sets the item render data.
        /// </summary>
        /// <value>The item render data.</value>
        /// <returns>ItemRenderInfo.</returns>
        public ItemRenderInfo ItemRenderData { private get; set; }

        #endregion

        #region Methods

        /// <summary>
        /// The edit model equipped form_ form closed.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private void EditModelEquippedForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            EditorRenderer.EditModelEquipped(false, null);
        }

        /// <summary>
        /// The edit model equipped form_ shown.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private void EditModelEquippedForm_Shown(object sender, EventArgs e)
        {
            RefreshModelEquippedData();
        }

        /// <summary>
        ///     The refresh model equipped data.
        /// </summary>
        private void RefreshModelEquippedData()
        {
            // ModelTranslateX
            txtModelTranslateX.DataBindings.Clear();
            txtModelTranslateX.DataBindings.Add(
                "Text", 
                ItemRenderData.ModelItemEquippedPosition, 
                "ModelTranslateX", 
                false, 
                DataSourceUpdateMode.OnPropertyChanged);

            // ModelTranslateY
            txtModelTranslateY.DataBindings.Clear();
            txtModelTranslateY.DataBindings.Add(
                "Text", 
                ItemRenderData.ModelItemEquippedPosition, 
                "ModelTranslateY", 
                false, 
                DataSourceUpdateMode.OnPropertyChanged);

            // ModelTranslateZ
            txtModelTranslateZ.DataBindings.Clear();
            txtModelTranslateZ.DataBindings.Add(
                "Text", 
                ItemRenderData.ModelItemEquippedPosition, 
                "ModelTranslateZ", 
                false, 
                DataSourceUpdateMode.OnPropertyChanged);

            // ModelRotationAngle
            txtModelRotationAngle.DataBindings.Clear();
            txtModelRotationAngle.DataBindings.Add(
                "Text", 
                ItemRenderData.ModelItemEquippedRotation, 
                "ModelRotationAngle", 
                false, 
                DataSourceUpdateMode.OnPropertyChanged);

            // ModelRotationX
            txtModelRotationX.DataBindings.Clear();
            txtModelRotationX.DataBindings.Add(
                "Text", 
                ItemRenderData.ModelItemEquippedRotation, 
                "ModelRotationX", 
                false, 
                DataSourceUpdateMode.OnPropertyChanged);

            // ModelRotationY
            txtModelRotationY.DataBindings.Clear();
            txtModelRotationY.DataBindings.Add(
                "Text", 
                ItemRenderData.ModelItemEquippedRotation, 
                "ModelRotationY", 
                false, 
                DataSourceUpdateMode.OnPropertyChanged);

            // ModelRotationZ
            txtModelRotationZ.DataBindings.Clear();
            txtModelRotationZ.DataBindings.Add(
                "Text", 
                ItemRenderData.ModelItemEquippedRotation, 
                "ModelRotationZ", 
                false, 
                DataSourceUpdateMode.OnPropertyChanged);

            // ModelScaleX
            txtModelScaleX.DataBindings.Clear();
            txtModelScaleX.DataBindings.Add(
                "Text", 
                ItemRenderData.ModelItemEquippedScale, 
                "ModelScaleX", 
                false, 
                DataSourceUpdateMode.OnPropertyChanged);

            // ModelScaleY
            txtModelScaleY.DataBindings.Clear();
            txtModelScaleY.DataBindings.Add(
                "Text", 
                ItemRenderData.ModelItemEquippedScale, 
                "ModelScaleY", 
                false, 
                DataSourceUpdateMode.OnPropertyChanged);

            // ModelScaleZ
            txtModelScaleZ.DataBindings.Clear();
            txtModelScaleZ.DataBindings.Add(
                "Text", 
                ItemRenderData.ModelItemEquippedScale, 
                "ModelScaleZ", 
                false, 
                DataSourceUpdateMode.OnPropertyChanged);
        }

        /// <summary>
        /// The btn o k_ click.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private void btnOK_Click(object sender, EventArgs e)
        {
            Close();
        }

        #endregion
    }
}