public void ConfirmDelHospital()
 {
     if (HospitalCellMap.ContainsKey(hotHospitalCell))
     {
         PollsConfig.DelHospital(HospitalCellMap[hotHospitalCell].name);
         DestroyImmediate(hotHospitalCell.gameObject);
         hotHospitalCell        = null;
         textSelected.text      = "未选择医院";
         btnDelete.interactable = false;
         btnNext.interactable   = false;
         PollsConfig.SerializeData();
         Invoke("_refreshList", 0.1f);
     }
 }
    void OnEnable()
    {
        btnNew.gameObject.SetActive(PollsConfig.isOfflineMode);
        btnLoad.gameObject.SetActive(!PollsConfig.isOfflineMode);
        btnDelete.gameObject.SetActive(PollsConfig.isOfflineMode);
        if (gridOriginHeight == 0)
        {
            gridOriginHeight = grid.GetComponent <RectTransform>().sizeDelta.y;
        }
        for (int i = 0; i < grid.transform.childCount; i++)
        {
            Destroy(grid.transform.GetChild(i).gameObject);
        }
        UpdateList();

        /*if (PollsConfig.selectedHospital != null)
         * {
         *  if (PollsConfig.Hospitals.ContainsKey(PollsConfig.selectedHospital.name))
         *  {
         *      foreach(KeyValuePair<HospitalCell, PollsConfig.HospitalCellInfo> pair in HospitalCellMap)
         *      {
         *          if (pair.Key.textName.text == PollsConfig.selectedHospital.name)
         *          {
         *              OnClickCell(pair.Key);
         *          }
         *      }
         *  }
         * }
         * else*/
        {
            if (hotHospitalCell != null)
            {
                hotHospitalCell.imgSelected.enabled = false;
            }
            PollsConfig.selectedHospital   = null;
            PollsConfig.selectedDepartment = null;
            hotHospitalCell        = null;
            textSelected.text      = "未选择医院";
            btnDelete.interactable = false;
            btnNext.interactable   = false;
        }
    }
 public void OnClickCell(HospitalCell cell)
 {
     if (HospitalCellMap.ContainsKey(cell))
     {
         PollsConfig.HospitalCellInfo hci = HospitalCellMap[cell];
         textSelected.text = "已选择 :" + hci.name;
         if (hotHospitalCell == null)
         {
             hotHospitalCell          = cell;
             cell.imgSelected.enabled = true;
         }
         else
         {
             hotHospitalCell.imgSelected.enabled = false;
             hotHospitalCell          = cell;
             cell.imgSelected.enabled = true;
         }
         btnDelete.interactable = true;
         btnNext.interactable   = true;
     }
 }
    void AddNewCell(string name, bool load = false)
    {
        GameObject newone = Instantiate(Resources.Load("ui/HospitalCell") as GameObject);

        if (newone != null)
        {
            newone.transform.SetParent(grid.transform);
            newone.transform.localScale = Vector3.one;
            newone.transform.position   = Vector3.zero;
            RectTransform rti = newone.GetComponent <RectTransform>();
            rti.anchoredPosition3D = new Vector3(rti.anchoredPosition3D.x, rti.anchoredPosition3D.y, 0);

            PollsConfig.HospitalCellInfo hci = PollsConfig.GetHospitalCellInfoByName(name);
            if (hci != null)
            {
                HospitalCell hc = newone.GetComponent <HospitalCell>();
                hc.controller          = this;
                hc.textName.text       = hci.name;
                hc.textTime.text       = "创建时间 : " + hci.createTime.ToShortDateString() + " " + hci.createTime.ToShortTimeString();
                hc.imgSelected.enabled = false;
                HospitalCellMap.Add(hc, hci);
                if (!load)
                {
                    PollsConfig.SerializeData();
                }
                Invoke("_refreshList", 0.1f);
            }
        }
        else
        {
            Debug.Log("Instantiate HospitalCell failed.");
#if UNITY_ANDROID
            Toast.ShowToast("未知错误,请退出后重试");
#endif
        }
    }