using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace DataProcessing
{
    public partial class FormSemantic : Form
    {
        public FormMain mainForm = null;
        
        public FormSemantic()
        {
            InitializeComponent();
        }       

        public void Enable()
        {
            panelFloorCeiling.Enabled = true;
            panelSemantic.Enabled = true;
        }

        public void Disable()
        {
            panelFloorCeiling.Enabled = false;
            panelSemantic.Enabled = false;
        }

        private void btnSemantic_Click(object sender, EventArgs e)
        {
            if(mainForm.SelectedMesh.Segments.Count < 1)
                MessageBox.Show("There are no segments for semantic.");
            
            int ceilingTop = (int)numBoxCeilingTop.Value;
            int ceilingBottom = (int)numBoxCeilingBottom.Value;
            int floorTop = (int)numBoxFloorTop.Value;
            int floorBottom = (int)numBoxFloorBottom.Value;
            string action = comboBoxAction.Text;
            string feature = comboBoxFeature.Text;

            if (ceilingTop <= ceilingBottom)
            {
                MessageBox.Show("Ceiling Top must be higher then Ceiling Bottom.");
                return;
            }

            if (floorTop <= floorBottom)
            {
                MessageBox.Show("Floor Top must be higher then Floor Bottom.");
                return;
            }

            mainForm.SaveState();
            mainForm.SelectedMesh.Semantic(ceilingTop, ceilingBottom, floorTop, floorBottom, action, feature);
            mainForm.UpdateValues();
            mainForm.ReDraw();
        }

        private void btnDecolorize_Click(object sender, EventArgs e)
        {
            if (mainForm.SelectedMesh.Segments.Count < 1)
                MessageBox.Show("There are no segments for this action.");

            mainForm.SaveState();
            mainForm.SelectedMesh.Semantic(0, 0, 0, 0, "Decolorize", "");
            mainForm.ReDraw();
        }

        private void FormSemantic_FormClosed(object sender, FormClosedEventArgs e)
        {
            mainForm.SemanticForm = null;
        }

        ToolTip toolTipSemantic = new ToolTip();

        private void FormSemantic_Load(object sender, EventArgs e)
        {
            toolTipSemantic.SetToolTip(this.labelCeilingTop, "Vzdálenost horní hranice stropu od počátku(skeneru).");
            toolTipSemantic.SetToolTip(this.labelCeilingBottom, "Vzdálenost dolní hranice stropu od počátku(skeneru).");
            toolTipSemantic.SetToolTip(this.labelFloorTop, "Vzdálenost horní hranice podlahy od počátku(skeneru).");
            toolTipSemantic.SetToolTip(this.labelFloorBottom, "Vzdálenost dolní hranice podlahy od počátku(skeneru).");
            toolTipSemantic.SetToolTip(this.labelAction, "Výběr akce.\r\nColorize - obarvení segmentů\r\nRemove - odstranění segmentů.");
            toolTipSemantic.SetToolTip(this.labelFeature, "Výběr prvku pro provedení akce.");
            toolTipSemantic.SetToolTip(this.btnSemantic, "Provede zvolenou akci.");
            toolTipSemantic.SetToolTip(this.btnDecolorize, "Odbarví všechny segmenty.");

            toolTipSemantic.ShowAlways = true;
            toolTipSemantic.AutomaticDelay = 6000;
            toolTipSemantic.InitialDelay = 500;
        }

        //nutne kvuli bugu na winXP kdy se tooltip objevi pouze 1x
        private void labelCeilingTop_MouseEnter(object sender, EventArgs e)
        {
            toolTipSemantic.Active = false;
            toolTipSemantic.Active = true;
        }

        private void labelCeilingBottom_MouseEnter(object sender, EventArgs e)
        {
            toolTipSemantic.Active = false;
            toolTipSemantic.Active = true;
        }

        private void labelFloorTop_MouseEnter(object sender, EventArgs e)
        {
            toolTipSemantic.Active = false;
            toolTipSemantic.Active = true;
        }

        private void labelFloorBottom_MouseEnter(object sender, EventArgs e)
        {
            toolTipSemantic.Active = false;
            toolTipSemantic.Active = true;
        }

        private void labelAction_MouseEnter(object sender, EventArgs e)
        {
            toolTipSemantic.Active = false;
            toolTipSemantic.Active = true;
        }

        private void labelFeature_MouseEnter(object sender, EventArgs e)
        {
            toolTipSemantic.Active = false;
            toolTipSemantic.Active = true;
        }

        private void btnSemantic_MouseEnter(object sender, EventArgs e)
        {
            toolTipSemantic.Active = false;
            toolTipSemantic.Active = true;
        }

        private void btnDecolorize_MouseEnter(object sender, EventArgs e)
        {
            toolTipSemantic.Active = false;
            toolTipSemantic.Active = true;
        }
    }
}