private static void Testing() { cn test = new cn(); test.Manga.AddMangaRow(2, "test", "test", "test"); test.Manga.FindById(0); Console.WriteLine(test.Manga.FindById(0)); }
private void btnConvertPolRec_Click(object sender, EventArgs e) { double polar = Convert.ToDouble(txtPolarPolRec.Text); int angle = Convert.ToInt16(txtAnglePolRec.Text); cn polToRec = new cn(polar, angle); txtRealPolRec.Text = polToRec.getReal(); txtImagPolRec.Text = polToRec.getImaginary(); }
//All calculations are handled by the button presses (+ - * /) on the screen. They are all bellow. private void btnConvertRecPol_Click(object sender, EventArgs e) { double real, imaginary; real = Convert.ToDouble(txtRealRecPol.Text); imaginary = Convert.ToDouble(txtImagRecPol.Text); cn recToPol = new cn(real, imaginary); txtPolarRecPol.Text = recToPol.getPolar(); txtAngleRecPol.Text = recToPol.getAngle(); }
private void btnDiv_Click(object sender, EventArgs e) { double polar = Convert.ToDouble(txtMDPol1.Text); int angle = Convert.ToInt16(txtMDPolAngel1.Text); cn one = new cn(polar, angle); polar = Convert.ToDouble(txtMDPol2.Text); angle = Convert.ToInt16(txtMDPolAngle2.Text); cn two = new cn(polar, angle); txtMDPolTotal.Text = Convert.ToString(one.getPolarDouble() / two.getPolarDouble()); txtMDPolAngleTotal.Text = Convert.ToString(one.getAngleInt() - two.getAngleInt()); }
private void btnMinus_Click(object sender, EventArgs e) { double real = Convert.ToDouble(txtAddRecReal1.Text); double imaginary = Convert.ToDouble(txtAddRecImag1.Text); cn one = new cn(real, imaginary); real = Convert.ToDouble(txtAddRecReal2.Text); imaginary = Convert.ToDouble(txtAddRecImag2.Text); cn two = new cn(real, imaginary); txtAddRecRealTotal.Text = Convert.ToString(one.getRealDouble() - two.getRealDouble()); txtAddRecImagTotal.Text = Convert.ToString(one.getImaginaryDouble() - two.getImaginaryDouble()); }
static void Main(string[] args) { cn x = new cn(1, 2); //this is a complex number 1+2i cn y = new cn(3, 4); //3+4i cn somecom = new cn(1, 2) + new cn(3, 4); somecom.Print(); cn a = x - y; //(1+2i) - (3+4i) a.Print(); a = new cn(1, 2) * new cn(3, 4); //(1 + 2i) *(3 + 4i) a.Print(); a = x / y; //(1+2i) / (3+4i) a.Print(); Console.Read(); }
public JournalItemDescriptor(cn instance) { _internal = instance; }
private async void DownloadData_Async(cn l) { if (l.name != "藏身處裝飾" && l.name != "保險箱") { try { HttpClient client = new HttpClient(); HttpResponseMessage response = await client.GetAsync(String.Format("http://poedb.tw/{0}", l.url)); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); Regex r; if (l.url.ToLower().Contains("gem")) { r = new Regex(reg_gem, RegexOptions.IgnoreCase); } else if (l.url.ToLower().Contains("flask")) { r = new Regex(reg_Flask, RegexOptions.IgnoreCase); } else if (l.url.ToLower().Contains("currency")) { r = new Regex(reg_Currency, RegexOptions.IgnoreCase); } else if (l.url.ToLower().EndsWith("map")) { r = new Regex(reg_Map, RegexOptions.IgnoreCase); } else if (l.url.ToLower().EndsWith("microtransaction")) { r = new Regex(reg_Microtransaction, RegexOptions.IgnoreCase); } else if (l.url.ToLower().EndsWith("prophecy")) { r = new Regex(reg_Prophecy, RegexOptions.IgnoreCase); } else { r = new Regex(reg1, RegexOptions.IgnoreCase | RegexOptions.Singleline); } MatchCollection mm = r.Matches(responseBody); //從網址解析出物品大小 Regex r_url = new Regex(@"&w=(\d)&h=(\d)", RegexOptions.IgnoreCase); Regex r_GemColor = new Regex(@"class='gem_(.)", RegexOptions.IgnoreCase); List <RootObject> roots = new List <RootObject>(); if (mm.Count > 0) { //一般的順序 int o1 = 1, o2 = 2, o3 = 3, o4 = 4; //由於藥水、地圖、通貨的排版特別,因此要另外處理 bool 順序不同 = (l.url.ToLower().Contains("flask")) || l.url.ToLower().EndsWith("prophecy"); bool 沒有顯示大小 = (l.url.ToLower().Contains("currency")); bool 技能寶石 = (l.url.ToLower().Contains("gem")); if (順序不同) { o1 = 3; o2 = 1; o3 = 2; } if (技能寶石) { o1 = 1; o2 = 3; o3 = 4; o4 = 2; } foreach (Match m in mm) { string Icon_url = m.Groups[o1].ToString(); if (l.url.ToLower().EndsWith("prophecy")) { Icon_url = "http://web.poecdn.com/image/Art/2DItems/Currency/ProphecyOrbRed.png?scale=1&w=1&h=1"; } //地圖的大小沒有在圖片的網址寫出來,但都固定是1x1 Match m_url = 沒有顯示大小 ? null : r_url.Match(Icon_url); var GemColor = r_GemColor.Match(m.Groups[o4].ToString()).Groups; roots.Add(new RootObject { c = m.Groups[o2].ToString().Trim(), e = m.Groups[o3].ToString().Trim(), url = Icon_url, GC = 技能寶石 ? char.Parse(GemColor.Count == 1 ? "w" : GemColor[1].ToString()) : 'n', w = 沒有顯示大小 ? 1 : int.Parse(m_url.Groups[1].ToString()), h = 沒有顯示大小 ? 1 : int.Parse(m_url.Groups[2].ToString()), type = l.name_eng }); } } lock (thislock) { running--; Data.AddRange(roots); /* * 依照類型寫入各個檔案 * using (StreamWriter w = new StreamWriter(Application.StartupPath + "/" + l.name + ".txt", false, Encoding.UTF8)) * { * w.WriteAsync(JsonConvert.SerializeObject(roots, Formatting.Indented)); * w.FlushAsync(); * }*/ } } catch (Exception e) { Debug.Print(l.name + "," + e.Message); } } }
public AgentsDataFile(cn instance) : base(instance) { _internal = instance; }
private async Task DownloadData_Async(cn l) { switch (l.name_eng) { case "Microtransaction": return; case "HideoutDoodad": return; case "Chest": return; } try { DateTime Now = DateTime.Now; bool 技能寶石 = (l.url.ToLower().Contains("gem")); HttpResponseMessage response = await client.GetAsync(String.Format("http://poedb.tw/json.php/item_class?cn={0}", l.name_eng)); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); var gg = poedbJson.FromJson(responseBody); Regex r_Name = new Regex(reg_Name, RegexOptions.IgnoreCase | RegexOptions.Singleline); Regex r_Name2 = new Regex(reg_Name2, RegexOptions.IgnoreCase | RegexOptions.Singleline); Regex r_imgURL = new Regex(reg_imgURL, RegexOptions.IgnoreCase); Regex r_GemColor = new Regex(@".Gems/(.*?)'.*?>(.*)", RegexOptions.IgnoreCase); //有時nameC會變成<img .....,因此需要再處理一次 Regex r_realName = new Regex(@"<img\s.*/>(.*)", RegexOptions.IgnoreCase); List <Data> roots = new List <Data>(); foreach (var tt in gg.Data) { GroupCollection NameGroup = tt[1].StartsWith("<a") ? r_Name.Match(tt[1]).Groups : r_Name2.Match(tt[1]).Groups; var url = r_imgURL.Match(tt[0]).Groups[1].ToString(); string nameC = NameGroup[1].ToString().Trim(), nameE = NameGroup[2].ToString().Trim(); char colorGem = 'n'; if (技能寶石) { var temp = r_GemColor.Match(nameC).Groups; nameC = temp[2].ToString().Trim(); switch (temp[1].ToString()) { case "IntelligenceGem.png": colorGem = 'b'; break; case "DexterityGem.png": colorGem = 'g'; break; case "StrengthGem.png": colorGem = 'r'; break; } } if (nameC.StartsWith("<img")) { nameC = r_realName.Match(nameC).Groups[1].ToString().Trim(); } System.Net.WebClient WC = new System.Net.WebClient(); if (!Directory.Exists(Path.Combine(Application.StartupPath, "Image"))) { Directory.CreateDirectory(Path.Combine(Application.StartupPath, "Image")); } string filepath = Path.Combine(Path.Combine(Application.StartupPath, "Image"), nameE + ".png"); try { if (!nameE.EndsWith("</del>")) { if (!File.Exists(filepath) || (File.Exists(filepath) && new FileInfo(filepath).Length == 0)) { await WC.DownloadFileTaskAsync(new Uri(url), filepath); } } } catch (Exception e) { Debug.Print(e.Message + "," + nameE); } Size size = new Size(); try { size = ImageUtilities.GetDimensions(filepath); } catch (Exception e) { size = new Size(47, 47); url = "question-mark.png"; Debug.Print(e.Message + "," + filepath); } roots.Add(new Data { Name_Chinese = nameC, Name_English = NameGroup[2].ToString(), Rarity = 0, ImageURL = url, GemColor = colorGem.ToString(), Width = size.Width / 47, Height = size.Height / 47, Type = l.name_eng, UpdateDate = Now }); } lock (thislock) { Data.AddRange(roots); } } catch (Exception e) { Debug.Print(l.name + "," + e.Message); } }
private async Task DownloadData_Async(cn l) { switch (l.name_eng) { case "Microtransaction": return; case "HideoutDoodad": return; case "Chest": return; } try { DateTime Now = DateTime.Now; bool 技能寶石 = (l.url.ToLower().Contains("gem")); HttpResponseMessage response = await client.GetAsync(String.Format("http://poedb.tw/json.php/item_class?cn={0}", l.name_eng)); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); var gg = poedbJson.FromJson(responseBody); Regex r_Name = new Regex(reg_Name, RegexOptions.IgnoreCase | RegexOptions.Singleline); Regex r_Name2 = new Regex(reg_Name2, RegexOptions.IgnoreCase | RegexOptions.Singleline); Regex r_imgURL = new Regex(reg_imgURL, RegexOptions.IgnoreCase); Regex r_GemColor = new Regex(@".Gems/(.*?)'.*?>(.*)", RegexOptions.IgnoreCase); //有時nameC會變成<img .....,因此需要再處理一次 Regex r_realName = new Regex(@"<img\s.*/>(.*)", RegexOptions.IgnoreCase); List <Data> roots = new List <Data>(); foreach (var tt in gg.Data) { GroupCollection NameGroup = tt[1].StartsWith("<a") ? r_Name.Match(tt[1]).Groups : r_Name2.Match(tt[1]).Groups; var url = r_imgURL.Match(tt[0]).Groups[1].ToString(); string nameC = NameGroup[1].ToString().Trim(), nameE = NameGroup[2].ToString().Trim(); char colorGem = 'n'; if (技能寶石) { var temp = r_GemColor.Match(nameC).Groups; nameC = temp[2].ToString().Trim(); switch (temp[1].ToString()) { case "IntelligenceGem.png": colorGem = 'b'; break; case "DexterityGem.png": colorGem = 'g'; break; case "StrengthGem.png": colorGem = 'r'; break; } } if (nameC.StartsWith("<img")) { nameC = r_realName.Match(nameC).Groups[1].ToString().Trim(); } if (!nameE.EndsWith("</del>")) { if (!File.Exists(Path.Combine(ImageDirPath, $"{nameE}.png"))) { lock (lock_imagedownload) ImageDownloadList.Add(new Struct_Image() { DataType = 1, FileName = Path.Combine(ImageDirPath, $"{nameE}.png"), URL = url, GetSizeNeed = true, EngName = nameE }); } } Size size = new Size(47, 47); roots.Add(new Data { Name_Chinese = nameC, Name_English = NameGroup[2].ToString(), Rarity = 0, ImageURL = url, GemColor = colorGem.ToString(), Width = size.Width / 47, Height = size.Height / 47, Type = l.name_eng, UpdateDate = Now }); } lock (thislock) { Data.AddRange(roots); } } catch (Exception e) { Debug.Print(l.name + "," + e.Message); } }