public void ModifySchedule(string CourseName) { PrintSchedule(CourseName); Prompt._Prompt("輸入格式:加入or刪除(I or D) 星期幾(1-7) 第幾節課(1-10)"); Prompt._Prompt("註:第5節為中午12:00"); Prompt._Prompt("註:格式錯誤將自動退出設定"); while (true) { string input = Prompt.Input("請輸入:"); Match mh = Regex.Match(input, "([ID]) ([1-7]) ([0-9]{1,2})"); if (mh.Success) { int week = int.Parse(mh.Groups[2].Value); int courseTime = int.Parse(mh.Groups[3].Value); string mode = mh.Groups[1].Value; if (mode == "I") { schedule[week - 1, courseTime - 1] = CourseName; Prompt.Success($"{CourseName}上課時間 => 星期{_week[week - 1]} 第{courseTime}節({courseTime + 7}:00~{courseTime + 8}:00)"); } else if (mode == "D") { schedule[week - 1, courseTime - 1] = ""; Prompt.Success($"刪除 {CourseName}的星期{_week[week - 1]} 第{courseTime}節({courseTime + 7}:00~{courseTime + 8}:00)"); } } else { Prompt.Error("格式錯誤 退出設定!"); break; } } }
public void ModifyLocation(string CourseName) { while (true) { Prompt._Prompt("輸入格式:經度,緯度"); string input = Prompt.Input("請輸入:"); Match mh = Regex.Match(input, "[0-9]+.[0-9]*,[0-9]+.[0-9]*"); if (mh.Success) { Location[CourseName] = mh.Groups[0].Value; Prompt.Success($"{CourseName}定位地點 => {input}"); break; } else { Prompt.Error(Prompt.FormatError); } } }
public Zuvio() { if (!File.Exists("Setting.json")) { account = Prompt.Input("請輸入帳號:"); password = Prompt.Input("請輸入密碼:"); Login(); for (int i = 0; i < schedule.GetLength(0); i++) { for (int j = 0; j < schedule.GetLength(1); j++) { schedule[i, j] = string.Empty; } } Location = new Dictionary <string, string>(); Prompt.Success("登入成功"); } else { JObject json = JObject.Parse(File.ReadAllText("Setting.json")); account = json["account"].ToString(); password = json["password"].ToString(); Login(); //AccessToken = json["AccessToken"].ToString(); //UserID = json["UserID"].ToString(); //Session = json["Session"].ToString(); int.TryParse(json["DelayTime"].ToString(), out DelayTime); Location = JsonConvert.DeserializeObject <Dictionary <string, string> >(json["Location"].ToString()); for (int i = 0; i < schedule.GetLength(0); i++) { for (int j = 0; j < schedule.GetLength(1); j++) { schedule[i, j] = json["schedule"][i][j].ToString(); } } Prompt.Success("設定讀取成功"); } }