private void CloseAllPops() { if (signPop != null) { signPop.IsOpen = false; signPop = null; } if (chestPop != null) { chestPop.IsOpen = false; chestPop = null; } }
private void Map_MouseRightButtonUp(object sender, MouseButtonEventArgs e) { if (!loaded) return; CloseAllPops(); Point curPos = e.GetPosition(Map); start = curPos; int sx, sy; getMapXY(curPos, out sx, out sy); foreach (Chest c in chests) { //chests are 2x2, and their x/y is upper left corner if ((c.x == sx || c.x + 1 == sx) && (c.y == sy || c.y + 1 == sy)) { ArrayList items = new ArrayList(); for (int i = 0; i < c.items.Length; i++) { if (c.items[i].stack > 0) { if (c.items[i].prefix == "") items.Add(String.Format("{0} {1}", c.items[i].stack, c.items[i].name)); else items.Add(String.Format("{0} {1} {2}", c.items[i].stack, c.items[i].prefix, c.items[i].name)); } } chestPop = new ChestPopup(items); chestPop.IsOpen = true; } } foreach (Sign s in signs) { //signs are 2x2, and their x/y is upper left corner if ((s.x == sx || s.x + 1 == sx) && (s.y == sy || s.y + 1 == sy)) { signPop = new SignPopup(s.text); signPop.IsOpen = true; } } }