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

namespace FPER
{
    // 현장도면 회로 창 클래스

    public partial class FormRepeater : Form
    {
        // 회로번호
        // 예시 : MI010110161
        // 설명 : MI (입력) - 01 (수신기) - 01 (통신보드) - 1 (채널계통) - 016 (중계기) - 1 (포인트)

        // 메인 폼 파라미터
        MDIParent mdi;

        //public int ioType = 0;

        // 생성자
        public FormRepeater(MDIParent ParentForm)
        {
            // 컴포넌트 초기화
            InitializeComponent();

            // 메인폼
            this.mdi = ParentForm;
        }

        // 입력 회로 내용
        public void SetInputContext1(string txt)
        {
            this.Input1.Text = txt;
            this.Input1.Select(0, 0);
        }
        public void SetInputContext2(string txt)
        {
            this.Input2.Text = txt;
            this.Input2.Select(0, 0);
        }
        public void SetInputContext3(string txt)
        {
            this.Input3.Text = txt;
            this.Input3.Select(0, 0);
        }
        public void SetInputContext4(string txt)
        {
            this.Input4.Text = txt;
            this.Input4.Select(0, 0);
        }
        // 출력회로
        public void SetOutPutText1(string txt)
        {
            this.Output1.Text = txt;
            this.Output1.Select(0, 0);
        }
        public void SetOutPutText2(string txt)
        {
            this.Output2.Text = txt;
            this.Output2.Select(0, 0);
        }

        public void SetOutPutText3(string txt)
        {
            this.Output3.Text = txt;
            this.Output3.Select(0, 0);
        }
        public void SetOutPutText4(string txt)
        {
            this.Output4.Text = txt;
            this.Output4.Select(0, 0);
        }
        // 창 사라지는 타이머
        int hideLevel = 100;
        int hideCount = 0;
        private void timerHide_Tick(object sender, EventArgs e)
        {
            //if (hideLevel < 10) {
            //  this.Visible = false;
            //}

            if (this.hideCount >= 300)
            {
                this.Visible = false;
            }
            else if (this.hideCount >= 200)
            {
                this.hideLevel = hideLevel - 5;
                this.Opacity = ((double)hideLevel) / 100.0;
            }
            else
            {
                this.hideCount++;
            }
            this.Update();
        }

        // 보임,안보임 변경 함수 
        private void FormDevice_VisibleChanged(object sender, EventArgs e)
        {
            if (this.Visible == true)
            {
                this.hideLevel = 100;
                this.Opacity = 100;
                this.hideCount = 0;
                this.timerHide.Start();
            }
            else
            {
                this.timerHide.Stop();
            }
        }

        // 창 클릭 함수
        private void FormDevice_MouseClick(object sender, MouseEventArgs e)
        {
            this.Visible = false;
        }

        private void FormDevice_Deactivate(object sender, EventArgs e)
        {

        }
    }
}