public void LoadTextButtonClicked() { fileChooser.setup(FileChooser.OPENSAVE.OPEN, "txt"); fileChooser.callbackYes = delegate(string filename) { fileChooser.gameObject.SetActive(false); if (File.Exists(filename)) { //load text file try { using (StreamReader sr = new StreamReader(filename)) { string text = sr.ReadToEnd(); textfield.text = text; } } catch (Exception e) { Debug.Log("The file could not be read: " + e.Message); } } else { Debug.Log("The file does not exist: " + filename); } }; fileChooser.callbackNo = delegate() { fileChooser.gameObject.SetActive(false); }; }
public void LoadCombiResultsCSV() { fileChooser.setup(FileChooser.OPENSAVE.OPEN, "csv"); fileChooser.callbackYes = delegate(string filename) { fileChooser.gameObject.SetActive(false); if (File.Exists(filename)) { CombiResultsFilename = filename; CombiResultsShortFilename = Path.GetFileNameWithoutExtension(filename); CombiResultsText.text = CombiResultsShortFilename; //ExtractAndLoadCSV(filename, isAssay); if (!StringIsNull(AssayTestingFilename)) { Debug.Log("AssayTestingFilename = " + AssayTestingFilename); LoadCSVsButton.interactable = true; } } else { Debug.Log("The file does not exist: " + filename); } }; fileChooser.callbackNo = delegate() { fileChooser.gameObject.SetActive(false); }; }
//From filechooser asset public void OpenFileDialog(string format) { fileChooser.setup(FileChooser.OPENSAVE.SAVE, format); fileChooser.callbackYes = delegate(string filename) { fileChooser.gameObject.SetActive(false); if (format == "txt") { ExportDataToTXTCombi(filename); } else if (format == "csv") { ExportDataToCSVCombi(filename); } }; fileChooser.callbackNo = delegate() { fileChooser.gameObject.SetActive(false); }; }
public void OnLoadQuestion() { // EditorUtility.OpenFilePanel("sss", "\\", ".json"); fileChooser.setup(FileChooser.OPENSAVE.OPEN, "json"); fileChooser.openSaveButton.GetComponentInChildren <Text>().text = "打开"; fileChooser.TextTopic.text = "请选择需要打开的题目文件"; fileChooser.callbackYes = delegate(string filename, string fullname) { //first hide the filechooser fileChooser.gameObject.SetActive(false); Debug.Log("select " + fullname); /* * if (PollsConfig.QuestionMap.ContainsKey(fullname)) * { * if (hotDepartmentCell != null) * { * PollsConfig.DepartmentCellInfo hdci = DepartmentCellMap[hotDepartmentCell]; * if (hdci != null) * { * hdci.qusetionLoaded = true; * hdci.questionPath = fullname; * } * PollsConfig.selectedDepartment = hdci; * btnPreview.interactable = true; * btnStart.interactable = true; * PollsConfig.SerializeData(); * } * } * else * { * //jsonPath = fullname; * //jsonName = filename; * //StartCoroutine(LoadWWW()); * }*/ if (hotDepartmentCell != null) { PollsConfig.DepartmentCellInfo hdci = DepartmentCellMap[hotDepartmentCell]; if (hdci != null) { hdci.qusetionLoaded = true; hdci.questionID = fullname; } PollsConfig.selectedDepartment = hdci; btnPreview.interactable = selectMode ? false : true; btnStart.interactable = true; btnLoad.interactable = false; PollsConfig.SerializeData(); } }; fileChooser.callbackNo = delegate() { fileChooser.gameObject.SetActive(false); }; }
public void OpenFileDialog(bool isAssay) { fileChooser.setup(FileChooser.OPENSAVE.OPEN, "csv"); fileChooser.callbackYes = delegate(string filename) { fileChooser.gameObject.SetActive(false); if (File.Exists(filename)) { ExtractAndLoadCSV(filename, isAssay); } else { Debug.Log("The file does not exist: " + filename); } }; fileChooser.callbackNo = delegate() { fileChooser.gameObject.SetActive(false); }; }
void SetupPwd(string pwd) { HoldInputPanel.SetActive(false); if (pwd == null || pwd == "") { return; } TopicText.text = ""; string pattern = @"^[^ ]{6,6}$"; Regex regex = new Regex(pattern); if (!regex.IsMatch(pwd)) { #if UNITY_ANDROID Toast.ShowToast("密码为6位字符,且不能存在空格"); #endif Debug.LogWarning("密码为6位字符,且不能存在空格"); return; } if (pwd.Length != 6) { #if UNITY_ANDROID Toast.ShowToast("密码长度为6位"); #endif return; } if (pwdStage == PWD_STAGE.NEW_PWD) { TmpPwd = PollsConfig.GetMD5(pwd); TopicText.text = "请再次输入管理员密码"; Invoke("InputNewPwd", 0.5f); pwdStage = PWD_STAGE.CONFIRM_PWD; } else if (pwdStage == PWD_STAGE.CONFIRM_PWD) // { if (TmpPwd == PollsConfig.GetMD5(pwd)) { #if UNITY_ANDROID Toast.ShowToast("管理员密码设置成功"); #endif TmpPwd = ""; PollsConfig.Password = pwd; PwdText.text = "Pwd is : " + PollsConfig.Password; TextPwd.text = "管理密码"; BtnExport.interactable = true; BtnQuestionMgr.interactable = true; TopicText.text = ""; } else { #if UNITY_ANDROID Toast.ShowToast("密码输入不一致,请重新再试"); #endif TmpPwd = ""; } } else if (pwdStage == PWD_STAGE.VERIFY_PWD) { if (PollsConfig.GetMD5(pwd) == PollsConfig.Password) { TopicText.text = "请输入新的管理员密码"; Invoke("InputNewPwd", 0.5f); pwdStage = PWD_STAGE.NEW_PWD; } else { #if UNITY_ANDROID Toast.ShowToast("请输入正确的管理员密码"); #endif TopicText.text = ""; } } else if (pwdStage == PWD_STAGE.VERIFY_QUESTION_PWD) { if (PollsConfig.GetMD5(pwd) == PollsConfig.Password) { this.gameObject.SetActive(false); hospitalPage.gameObject.SetActive(true); } else { #if UNITY_ANDROID Toast.ShowToast("请输入正确的管理员密码"); #endif TopicText.text = ""; } } else if (pwdStage == PWD_STAGE.VERIFY_EXPORT_PWD) { if (PollsConfig.GetMD5(pwd) == PollsConfig.Password) { if (PollsConfig.Answers.Count == 0) { #if UNITY_ANDROID Toast.ShowToast("目前无可导出数据"); #endif } else { fileChooser.setup(FileChooser.OPENSAVE.OPEN, ""); fileChooser.openSaveButton.GetComponentInChildren <Text>().text = "选择"; fileChooser.TextTopic.text = "请选择需要导出至的位置"; fileChooser.callbackYes = delegate(string filename, string fullname) { //first hide the filechooser fileChooser.gameObject.SetActive(false); Debug.Log("select " + fullname); pollsConfig.ExportData(fullname); }; fileChooser.callbackNo = delegate() { fileChooser.gameObject.SetActive(false); }; } } else { #if UNITY_ANDROID Toast.ShowToast("请输入正确的管理员密码"); #endif TopicText.text = ""; } } }