using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.ConstrainedExecution;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Windows;

public enum Enable
{
    Getoutofline1,
    Getoutofline2,
    Getoutofline3,
    Getoutofline4,
}
public class Thethirdsteppanl : MonoBehaviour
{
    /// <summary>
    /// 工单初始页面显示
    /// </summary>
    public RectTransform thirdoperationpanl1;
    /// <summary>
    /// 复制输入框文本
    /// </summary>
    public InputField inputFieldname;
    /// <summary>
    /// 发送工资的按钮
    /// </summary>
    public Button workorderviewbutton;
    /// <summary>
    /// 显示查询页面
    /// </summary>
    public RectTransform thirdoperationpanl2;
    /// <summary>
    /// 输入工单编号框
    /// </summary>
    public InputField inputmbuer;
    /// <summary>
    /// 查询按钮
    /// </summary>
    public Button viewbuton;
    /// <summary>
    /// 人员选择界面
    /// </summary>
    public RectTransform thirdoperationpanl3;
    /// <summary>
    /// 人员高亮显示
    /// </summary>
    public Toggle toggleiamge1;
    /// <summary>
    /// 人员图片显示
    /// </summary>
    public Image imagelxs;
    /// <summary>
    /// 合同违约按钮
    /// </summary>
    public Button breachofcontractbutton;
    /// <summary>
    /// 签收按钮
    /// </summary>
    public Button signforbutton;
    /// <summary>
    /// 有无违约页面
    /// </summary>
    public RectTransform thirdoperationpanl4;
    /// <summary>
    /// 传递参数的文本
    /// </summary>
    public Text receivetext1, receivetext2, receivetext3;
    /// <summary>
    /// 高亮显示
    /// </summary>
    public Toggle togglepromise;
    /// <summary>
    /// 显示的图片
    /// </summary>
    public Image weiyue;
    /// <summary>
    /// 页面五信息页面
    /// </summary>
    public RectTransform thirdoperationpanl5;
    /// <summary>
    /// 信息页面按钮
    /// </summary>
    public Button messagebutton;
    /// <summary>
    /// 页面六工程编号填写
    /// </summary>
    public RectTransform thirdoperationpanl6;
    /// <summary>
    /// 输入工单编号框
    /// </summary>
    public InputField inputid;
    /// <summary>
    /// 查询按钮
    /// </summary>
    public Button inquirebutton2;
    /// <summary>
    /// 页面7查询信息页面
    /// </summary>
    public RectTransform thirdoperationpanl7;
    /// <summary>
    /// 点击信息按钮
    /// </summary>
    public Button tapbutton;
    /// <summary>
    /// 页面8确认按钮页面
    /// </summary>
    public RectTransform thirdoperationpanl8;
    /// <summary>
    /// 确认按钮
    /// </summary>
    public Button verifybutton;
    /// <summary>
    /// 页面9违约类型
    /// </summary>
    public RectTransform thirdoperationpanl9;
    /// <summary>
    /// 违约按钮
    /// </summary>
    public Button verifybutton3;
    /// <summary>
    /// 页面10违约内容显示
    /// </summary>
    public RectTransform thirdoperationpanl10;
    /// <summary>
    /// 违约确认按钮
    /// </summary>
    public Button verifybutton4;
    /// <summary>
    /// 页面11
    /// </summary>
    public RectTransform thirdoperationpanl11;
    /// <summary>
    /// 是否违约下拉框
    /// </summary>
    public Dropdown glideinput1, glideinput2, glideinput3, glideinput4;
    /// <summary>
    /// 输入违约内容
    /// </summary>
    public InputField textinput1, textinput2;
    /// <summary>
    /// 用枚举判断选那个下拉框
    /// </summary>
    Enable enable = Enable.Getoutofline1;
    /// <summary>
    /// 输入日期按钮
    /// </summary>
    public InputField inputdata;
    /// <summary>
    /// 保存按钮的
    /// </summary>
    public Button savebutton;
    /// <summary>
    /// 发送按钮
    /// </summary>
    public Button cancelbutton;
    /// <summary>
    /// 提示文本
    /// </summary>
    public Text tipstext2;
    // 定义日期格式，可以根据需要添加更多格式
    private string[] dateFormats = new string[] { "yyyy-MM-dd", "dd/MM/yyyy", "MM/dd/yyyy" };
    /// <summary>
    /// 页面12
    /// </summary>
    public RectTransform thirdoperationpanl12;
    /// <summary>
    /// 收集按钮
    /// </summary>
    public Button collectbutton;
    /// <summary>
    /// 资料上传按钮
    /// </summary>
    public Button profilebutton;
    /// <summary>
    /// 页面13
    /// </summary>
    public RectTransform thirdoperationpanl13;
    /// <summary>
    /// 确认资料按钮
    /// </summary>
    public Button verifybutton5;
    /// <summary>
    /// 页面14
    /// </summary>
    public RectTransform thirdoperationpanl14;
    /// <summary>
    /// 保存按钮
    /// </summary>
    public Button savebutton2;
    /// <summary>
    /// 页面15
    /// </summary>
    public RectTransform thirdoperationpanl15;
    /// <summary>
    /// 发送按钮
    /// </summary>
    public Button sendbutton;
    void Start()
    {
        workorderviewbutton.onClick.AddListener(() =>
        {
            thirdoperationpanl1.gameObject.SetActive(false);
            thirdoperationpanl2.gameObject.SetActive(true);
        });
        viewbuton.onClick.AddListener(() =>
        {
            thirdoperationpanl2.gameObject.SetActive(false);
            thirdoperationpanl3.gameObject.SetActive(true);
        });
        toggleiamge1.onValueChanged.AddListener((ison) =>
        {
            if (ison)
            {
                imagelxs.gameObject.SetActive(true);
            }
        });
        breachofcontractbutton.onClick.AddListener(() =>
        {
            thirdoperationpanl3.gameObject.SetActive(false);
            thirdoperationpanl4.gameObject.SetActive(true);
        });
        togglepromise.onValueChanged.AddListener(delegate
        {
            ToggleValueChanged(togglepromise);
        });
        messagebutton.onClick.AddListener(() =>
        {
            thirdoperationpanl5.gameObject.SetActive(false);
            thirdoperationpanl6.gameObject.SetActive(true);
        });
        inquirebutton2.onClick.AddListener(() =>
        {
            thirdoperationpanl6.gameObject.SetActive(false);
            thirdoperationpanl7.gameObject.SetActive(true);
        });
        tapbutton.onClick.AddListener(() =>
        {
            thirdoperationpanl7.gameObject.SetActive(false);
            thirdoperationpanl8.gameObject.SetActive(true);
        });
        verifybutton.onClick.AddListener(() =>
        {
            thirdoperationpanl8.gameObject.SetActive(false);
            thirdoperationpanl9.gameObject.SetActive(true);
        });
        verifybutton3.onClick.AddListener(() =>
        {
            thirdoperationpanl9.gameObject.SetActive(false);
            thirdoperationpanl10.gameObject.SetActive(true);
        });
        verifybutton4.onClick.AddListener(() =>
        {
            thirdoperationpanl10.gameObject.SetActive(false);
            thirdoperationpanl11.gameObject.SetActive(true);
        });
        glideinput1.onValueChanged.AddListener(delegate
        {
            Status(Enable.Getoutofline1);
        });
        glideinput2.onValueChanged.AddListener(delegate
        {
            Status(Enable.Getoutofline2);
        });
        glideinput3.onValueChanged.AddListener(delegate
        {
            Status(Enable.Getoutofline3);
        });
        glideinput4.onValueChanged.AddListener(delegate
        {
            Status(Enable.Getoutofline4);
        });
        savebutton.onClick.AddListener(Getsave);
        cancelbutton.onClick.AddListener(() =>
        {
            thirdoperationpanl11.gameObject.SetActive(false);
            thirdoperationpanl12.gameObject.SetActive(true);
        });
        profilebutton.onClick.AddListener(() =>
        {
            thirdoperationpanl12.gameObject.SetActive(false);
            thirdoperationpanl13.gameObject.SetActive(true);
        });
        verifybutton5.onClick.AddListener(() =>
        {
            thirdoperationpanl13.gameObject.SetActive(false);
            thirdoperationpanl14.gameObject.SetActive(true);    
        });
        savebutton2.onClick.AddListener(() =>
        {
            thirdoperationpanl14.gameObject.SetActive(false);
            thirdoperationpanl15.gameObject.SetActive(true);    
        });
        sendbutton.onClick.AddListener(() =>
        {
            thirdoperationpanl15.gameObject.SetActive(false);
        });
    }
    /// <summary>
    /// 判断是否符合保存条件
    /// </summary>
    private void Getsave()
    {
        DateTime dateValue;
        if (DateTime.TryParseExact(inputdata.text, dateFormats, null, System.Globalization.DateTimeStyles.None, out dateValue))
        {
            tipstext2.text = "保存成功";
            Invoke("Cleartext", 1.5f);
        }
        else
        {
            tipstext2.text = "输入正确日期格式";
            Invoke("Cleartext", 1.5f);
        }
    }

    private void Cleartext()
    {
        tipstext2.text = "";
    }

    /// <summary>
    /// 初始化页面
    /// </summary>
    /// <param name="str"></param>
    /// <param name="str1"></param>
    /// <param name="str2"></param>
    public void Getvalue(string str,string str1,string str2)
    {
        receivetext1.text = str;
        receivetext2.text = str1;
        receivetext3.text = str2;
    }
    /// <summary>
    /// 图片显示高亮
    /// </summary>
    public void ToggleValueChanged(Toggle toggle)
    {
        if (toggle.isOn)
        {
            weiyue.gameObject.SetActive(true);
            thirdoperationpanl4.gameObject.SetActive(false);
            thirdoperationpanl5.gameObject.SetActive(true);
        }
        else
        {
            weiyue.gameObject.SetActive(false);
            thirdoperationpanl4.gameObject.SetActive(true);
            thirdoperationpanl5.gameObject.SetActive(false);
        }
    }
    /// <summary>
    /// 用枚举判断选择了那个选项框
    /// </summary>
    public void Status(Enable enable)
    {
        switch (enable)
        {
            case Enable.Getoutofline1:
                Debug.Log("1");
                glideinput1.captionText.text = glideinput1.options[glideinput1.value].text;
                break;
            case Enable.Getoutofline2:
                Debug.Log("2");
                glideinput2.captionText.text = glideinput2.options[glideinput2.value].text;
                break;
            case Enable.Getoutofline3:
                Debug.Log("3");
                glideinput3.captionText.text = glideinput3.options[glideinput3.value].text;
                break;
            case Enable.Getoutofline4:
                Debug.Log("4");
                glideinput4.captionText.text = glideinput4.options[glideinput4.value].text;
                break;
            default:
                break;
        }
    }
    void Update()
    {

    }
}
