public Form2(string clip, string Name) { InitializeComponent(); ApplicationHelper.SetForegroundWindow(this.Handle); richTextBox1.Text = clip; if (PrivateFunction.IsChineseContain(Name)) { textBox1.Text = Name; } else { textBox2.Text = Name; } if (System.Threading.Thread.CurrentThread.CurrentUICulture == new CultureInfo("en")) { SpeciesDic.Add(new KeyValuePair <string, string>("Amulet", "Amulet")); SpeciesDic.Add(new KeyValuePair <string, string>("Ring", "Ring")); SpeciesDic.Add(new KeyValuePair <string, string>("Jewel", "Jewel")); SpeciesDic.Add(new KeyValuePair <string, string>("Currency", "Currency")); SpeciesDic.Add(new KeyValuePair <string, string>("Map", "Map")); SpeciesDic.Add(new KeyValuePair <string, string>("DivinationCard", "Divination Card")); SpeciesDic.Add(new KeyValuePair <string, string>("Leaguestone", "Leaguestone")); SpeciesDic.Add(new KeyValuePair <string, string>("MiscMapItem", "OtherMapItem")); SpeciesDic.Add(new KeyValuePair <string, string>("UniqueFragment", "Unique Fragment")); SpeciesDic.Add(new KeyValuePair <string, string>("Gem", "Gem")); SpeciesDic.Add(new KeyValuePair <string, string>("Other", "Other")); SpeciesDic.Add(new KeyValuePair <string, string>("Prophec", "Prophecy")); } else { SpeciesDic.Add(new KeyValuePair <string, string>("Amulet", "護身符")); SpeciesDic.Add(new KeyValuePair <string, string>("Ring", "戒指")); SpeciesDic.Add(new KeyValuePair <string, string>("Jewel", "珠寶")); SpeciesDic.Add(new KeyValuePair <string, string>("Currency", "通貨")); SpeciesDic.Add(new KeyValuePair <string, string>("Map", "地圖")); SpeciesDic.Add(new KeyValuePair <string, string>("DivinationCard", "命運卡")); SpeciesDic.Add(new KeyValuePair <string, string>("Leaguestone", "聯盟石")); SpeciesDic.Add(new KeyValuePair <string, string>("MiscMapItem", "其他地圖道具")); SpeciesDic.Add(new KeyValuePair <string, string>("UniqueFragment", "碎片")); SpeciesDic.Add(new KeyValuePair <string, string>("Gem", "技能寶石")); SpeciesDic.Add(new KeyValuePair <string, string>("Other", "其他")); SpeciesDic.Add(new KeyValuePair <string, string>("Prophec", "預言")); } comboBox1.Items.AddRange(SpeciesDic.Select(x => x.Value).ToArray()); comboBox1.SelectedIndex = 0; comboBox2.SelectedIndex = 0; comboBox3.SelectedIndex = 0; textBox3.Text = "n"; textBox4.Text = "question-mark.png"; }
private void ShowItemInfo(object sender, MouseEventArgs e) { var showwhat = ((PictureBox)sender) == pictureBox1 ? pictureBox1 : pictureBox2; var temp = ((PictureBox)sender) == pictureBox1 ? Items : resoult; Point p = new Point(((int)Math.Floor((double)e.X / 40 * (radioButton4.Checked ? 1 : 2))), ((int)Math.Floor((double)e.Y / 40 * (radioButton4.Checked ? 1 : 2)))); var item = temp.Where(x => PrivateFunction.IsWithin(p, x.point, Point.Add(x.point, new Size(x.w - 1, x.h - 1)))).FirstOrDefault(); // toolTip1.SetToolTip(showwhat, String.Format("{0},{1}", e.X, e.Y)); if (item != null) { if (System.Threading.Thread.CurrentThread.CurrentUICulture.Name == "en") { toolTip1.SetToolTip(showwhat, String.Format("Name:{0}\nItem level:{1}\nQuality:{2}\nRarity:{3}\nLevel:{4}", item.Name_eng, item.itemlevel, item.quality, item.Rarity, item.level)); } else { toolTip1.SetToolTip(showwhat, String.Format("物品名稱:{0}\n物品等級:{1}\n品質:{2}\n稀有度:{3}\n等級:{4}", item.Name, item.itemlevel, item.quality, item.Rarity, item.level)); } } else { toolTip1.SetToolTip(showwhat, ""); } }
/// <summary> /// 取得並分析POE倉庫頁面中所有物品的資訊 /// </summary> /// <param name="length">倉庫頁的大小,12或24,由於本人沒有24*24倉庫頁,因此24未完成</param> public async void GetWarehouse(int length = 12) { await Task.Delay(0); Items.Clear(); used.Clear(); resoult.Clear(); string reg_itemlevel = @"物品等級:\s(\d+)", reg_itemlevel_eng = @"Item Level:\s(\d+)"; string reg_quality = @"品質:\s\+(\d+)", reg_quality_eng = @"Quality:\s\+(\d+)"; string reg_level = @"(?<!需求:)\r\n^等級:\s(\d+)", reg_level_eng = @"(?<!Requirements:)\r\n^Level:\s(\d+)"; string reg_maplevel = @"地圖階級:\s(\d+)", reg_maplevel_eng = @"Map Tier:\s(\d+)"; Regex r_itemlevel = new Regex(reg_itemlevel, RegexOptions.IgnoreCase | RegexOptions.Multiline), r_itemlevel_eng = new Regex(reg_itemlevel_eng, RegexOptions.IgnoreCase | RegexOptions.Multiline); Regex r_quality = new Regex(reg_quality, RegexOptions.IgnoreCase | RegexOptions.Multiline), r_quality_eng = new Regex(reg_quality_eng, RegexOptions.IgnoreCase | RegexOptions.Multiline); Regex r_level = new Regex(reg_level, RegexOptions.IgnoreCase | RegexOptions.Multiline), r_level_eng = new Regex(reg_level_eng, RegexOptions.IgnoreCase | RegexOptions.Multiline); Regex r_maplevel = new Regex(reg_maplevel, RegexOptions.IgnoreCase | RegexOptions.Multiline), r_maplevel_eng = new Regex(reg_maplevel_eng, RegexOptions.IgnoreCase | RegexOptions.Multiline); Regex r = new Regex(reg, RegexOptions.IgnoreCase | RegexOptions.Singleline); Match m, m_itemlevel, m_quality, m_level, m_maplevel; int id = 0; for (int x = 0; x < length; x++) { for (int y = 0; y < length; y++) { if (Stop) { DrawBoxRegion(Items, length, 1); return; } if (used.Any(u => u.X == x && u.Y == y)) { continue; } Clipboard.Clear(); if (length == 12) { POE_GetItemInfo((int)(startPos1.X + cellWidth1 * x), (int)(startPos1.Y + cellHeight1 * y)); } else { POE_GetItemInfo((int)(startPos4.X + cellWidth4 * x), (int)(startPos4.Y + cellHeight4 * y)); } string clip = Clipboard.GetText(TextDataFormat.UnicodeText); if (clip == "") { clip = Clipboard.GetText(TextDataFormat.UnicodeText); } if (clip == "") { continue; } m = r.Match(clip); Item temp = new Item(); if (m.Groups[3].ToString() == "") { temp.Name = PrivateFunction.GetStringAfterSomething(m.Groups[2].ToString().Trim(), "」"); } else { if (m.Groups[1].ToString() == "傳奇" || m.Groups[1].ToString() == "Unique") { temp.Name = m.Groups[2].ToString().Trim() + " " + m.Groups[3].ToString().Trim(); } else { temp.Name = m.Groups[3].ToString().Trim(); } } temp.Rarity = m.Groups[1].ToString().Trim(); m_itemlevel = r_itemlevel.Match(m.Groups[4].ToString()); m_itemlevel = m_itemlevel.Groups.Count == 1 ? r_itemlevel_eng.Match(m.Groups[4].ToString()) : m_itemlevel; m_level = r_level.Match(m.Groups[4].ToString()); m_level = m_level.Groups.Count == 1 ? r_level_eng.Match(m.Groups[4].ToString()) : m_level; m_maplevel = r_maplevel.Match(m.Groups[4].ToString()); m_maplevel = m_maplevel.Groups.Count == 1 ? r_maplevel_eng.Match(m.Groups[4].ToString()) : m_maplevel; m_quality = r_quality.Match(m.Groups[4].ToString()); m_quality = m_quality.Groups.Count == 1 ? r_quality_eng.Match(m.Groups[4].ToString()) : m_quality; temp.itemlevel = m_itemlevel.Groups.Count == 1 ? 0 : int.Parse(m_itemlevel.Groups[1].ToString()); temp.level = m_level.Groups.Count == 1 ? 0 : int.Parse(m_level.Groups[1].ToString()); temp.quality = m_quality.Groups.Count == 1 ? 0 : int.Parse(m_quality.Groups[1].ToString()); temp.maplevel = m_maplevel.Groups.Count == 1 ? 0 : int.Parse(m_maplevel.Groups[1].ToString()); Data t; if (m.Groups[1].ToString() == "傳奇" || m.Groups[1].ToString() == "Unique") { t = ItemList_Unique.Where(a => a.Name_Chinese.EndsWith(PrivateFunction.GetStringAfterSomething(temp.Name, "」")) || PrivateFunction.GetStringAfterSomething(temp.Name, "」").StartsWith(a.Name_English) || PrivateFunction.GetStringAfterSomething(temp.Name, "」").Contains(a.Name_English) ).FirstOrDefault(); } else { t = ItemList.Where(a => temp.Name.Equals(a.Name_Chinese) || temp.Name.Equals(a.Name_English)).FirstOrDefault(); if (t == null) { t = ItemList.Where(a => temp.Name.EndsWith(a.Name_Chinese) || temp.Name.EndsWith(a.Name_English)).FirstOrDefault(); } if (t == null) { t = ItemList.Where(a => temp.Name.Contains(a.Name_English)).FirstOrDefault(); } } if (t == null) { t = ItemList_Adden.Where(a => a.Name_Chinese.EndsWith(PrivateFunction.GetStringAfterSomething(temp.Name, "」")) || a.Name_English.StartsWith(PrivateFunction.GetStringAfterSomething(temp.Name, "」"))).FirstOrDefault(); } while (t == null) { Form2 f = new Form2(clip, temp.Name); f.ShowDialog(); var databasePath = Path.Combine(Application.StartupPath, "Datas_Adden.db"); var db = new SQLiteAsyncConnection(databasePath); await db.CreateTableAsync <Data>(); await db.CreateIndexAsync("Data", "Name_Chinese"); await db.CreateIndexAsync("Data", "Name_English"); ItemList_Adden = await db.Table <Data>().ToListAsync(); await db.CloseAsync(); t = ItemList_Adden.Where(a => temp.Name.Equals(a.Name_Chinese) || temp.Name.Equals(a.Name_English)).FirstOrDefault(); } temp.w = t.Width; temp.h = t.Height; temp.point = new POINT(x, y); temp.url = t.ImageURL; temp.GC = t.GemColor.ToCharArray()[0]; temp.Name_eng = t.Name_English; temp.type = t.Type; temp.priority = Array.IndexOf(Config.Species, t.Type); temp.id = ++id; for (int i = x; i < x + t.Width; i++) { for (int j = y; j < y + t.Height; j++) { used.Add(new POINT(i, j)); } } Items.Add(temp); } } DrawBoxRegion(Items, length, 1); }
/// <summary> /// 取得並分析POE倉庫頁面中所有物品的資訊 /// </summary> /// <param name="length">倉庫頁的大小,12或24,由於本人沒有24*24倉庫頁,因此24未完成</param> public async void GetWarehouse(int length = 12) { await Task.Delay(0); Items.Clear(); used.Clear(); resoult.Clear(); //可能需要英文化 string reg_itemlevel = @"物品等級:\s(\d+)", reg_itemlevel_eng = @"Item Level:\s(\d+)"; string reg_quality = @"品質:\s\+(\d+)", reg_quality_eng = @"Quality:\s\+(\d+)"; string reg_level = @"(?<!需求:)\r\n^等級:\s(\d+)", reg_level_eng = @"(?<!Requirements:)\r\n^Level:\s(\d+)"; string reg_maplevel = @"地圖階級:\s(\d+)", reg_maplevel_eng = @"Map Tier:\s(\d+)"; Regex r_itemlevel = new Regex(reg_itemlevel, RegexOptions.IgnoreCase | RegexOptions.Multiline), r_itemlevel_eng = new Regex(reg_itemlevel_eng, RegexOptions.IgnoreCase | RegexOptions.Multiline); Regex r_quality = new Regex(reg_quality, RegexOptions.IgnoreCase | RegexOptions.Multiline), r_quality_eng = new Regex(reg_quality_eng, RegexOptions.IgnoreCase | RegexOptions.Multiline); Regex r_level = new Regex(reg_level, RegexOptions.IgnoreCase | RegexOptions.Multiline), r_level_eng = new Regex(reg_level_eng, RegexOptions.IgnoreCase | RegexOptions.Multiline); Regex r_maplevel = new Regex(reg_maplevel, RegexOptions.IgnoreCase | RegexOptions.Multiline), r_maplevel_eng = new Regex(reg_maplevel_eng, RegexOptions.IgnoreCase | RegexOptions.Multiline); Regex r = new Regex(reg, RegexOptions.IgnoreCase | RegexOptions.Singleline); Match m, m_itemlevel, m_quality, m_level, m_maplevel; int id = 0; for (int x = 0; x < length; x++) { for (int y = 0; y < length; y++) { if (Stop) { DrawBoxRegion(Items, length, 1); return; } if (used.Any(u => u.X == x && u.Y == y)) { continue; } Clipboard.Clear(); if (length == 12) { POE_GetItemInfo((int)(startPos1.X + cellWidth1 * x), (int)(startPos1.Y + cellHeight1 * y)); } else { POE_GetItemInfo((int)(startPos4.X + cellWidth4 * x), (int)(startPos4.Y + cellHeight4 * y)); } string clip = Clipboard.GetText(TextDataFormat.UnicodeText); if (clip == "") { clip = Clipboard.GetText(TextDataFormat.UnicodeText); } if (clip == "") { continue; } m = r.Match(clip); Item temp = new Item(); if (m.Groups[3].ToString() == "") { temp.Name = PrivateFunction.GetStringAfterSomething(m.Groups[2].ToString().Trim(), "」"); } else { if (m.Groups[1].ToString() == "傳奇" || m.Groups[1].ToString() == "Unique") { temp.Name = m.Groups[2].ToString().Trim() + " " + m.Groups[3].ToString().Trim(); } else { temp.Name = m.Groups[3].ToString().Trim(); } } temp.Rarity = m.Groups[1].ToString().Trim(); m_itemlevel = r_itemlevel.Match(m.Groups[4].ToString()); m_itemlevel = m_itemlevel.Groups.Count == 1 ? r_itemlevel_eng.Match(m.Groups[4].ToString()) : m_itemlevel; m_level = r_level.Match(m.Groups[4].ToString()); m_level = m_level.Groups.Count == 1 ? r_level_eng.Match(m.Groups[4].ToString()) : m_level; m_maplevel = r_maplevel.Match(m.Groups[4].ToString()); m_maplevel = m_maplevel.Groups.Count == 1?r_maplevel_eng.Match(m.Groups[4].ToString()):m_maplevel; m_quality = r_quality.Match(m.Groups[4].ToString()); m_quality = m_quality.Groups.Count == 1? r_quality_eng.Match(m.Groups[4].ToString()):m_quality; temp.itemlevel = m_itemlevel.Groups.Count == 1 ? 0 : int.Parse(m_itemlevel.Groups[1].ToString()); temp.level = m_level.Groups.Count == 1 ? 0 : int.Parse(m_level.Groups[1].ToString()); temp.quality = m_quality.Groups.Count == 1 ? 0 : int.Parse(m_quality.Groups[1].ToString()); temp.maplevel = m_maplevel.Groups.Count == 1 ? 0 : int.Parse(m_maplevel.Groups[1].ToString()); JsonClass.RootObject t; if (m.Groups[1].ToString() == "傳奇" || m.Groups[1].ToString() == "Unique") { t = ItemList_Unique.Where(a => a.c.EndsWith(PrivateFunction.GetStringAfterSomething(temp.Name, "」")) || a.e.EndsWith(PrivateFunction.GetStringAfterSomething(temp.Name, "」"))).FirstOrDefault(); } else { t = ItemList.Where(a => temp.Name.Equals(a.c) || temp.Name.Equals(a.e)).FirstOrDefault(); if (t == null) { t = ItemList.Where(a => temp.Name.EndsWith(a.c) || temp.Name.EndsWith(a.e)).FirstOrDefault(); } if (t == null) { t = ItemList.Where(a => temp.Name.Contains(a.e)).FirstOrDefault(); } } if (t == null) { t = ItemList_Adden.Where(a => a.c.EndsWith(PrivateFunction.GetStringAfterSomething(temp.Name, "」")) || a.e.EndsWith(PrivateFunction.GetStringAfterSomething(temp.Name, "」"))).FirstOrDefault(); } while (t == null) { Form2 f = new Form2(clip, temp.Name); f.ShowDialog(); if (File.Exists(Path.Combine(Application.StartupPath, "ItemList_Adden.txt"))) { using (StreamReader rr = new StreamReader(Path.Combine(Application.StartupPath, "ItemList_Adden.txt"), Encoding.UTF8)) { ItemList_Adden = JsonConvert.DeserializeObject <List <JsonClass.RootObject> >(rr.ReadToEnd()); if (ItemList_Adden == null) { ItemList_Adden = new List <RootObject>(); } } } t = ItemList_Adden.Where(a => temp.Name.Equals(a.c) || temp.Name.Equals(a.e)).FirstOrDefault(); } temp.w = t.w; temp.h = t.h; temp.point = new POINT(x, y); temp.url = t.url; temp.GC = t.GC; temp.Name_eng = t.e; temp.type = t.type; temp.priority = Array.IndexOf(Config.Species, t.type); temp.id = ++id; for (int i = x; i < x + t.w; i++) { for (int j = y; j < y + t.h; j++) { used.Add(new POINT(i, j)); } } Items.Add(temp); } } DrawBoxRegion(Items, length, 1); }