public new void handleEvent(LogEventArgs e) { string line = parseLine(e.line); bool wasLoot = false; string highlight = null; MatchCollection matches = lootTell.Matches(line); if (matches.Count > 0) { string name = matches[0].Groups[1].Value; string text = matches[0].Groups[2].Value; // read time string time = ""; System.DateTime added = System.DateTime.Now; MatchCollection timeMatch = timeStamp.Matches(e.line); if (timeMatch.Count == 1 && timeMatch[0].Groups.Count > 2) { time = timeMatch[0].Groups[2].Value; added = System.DateTime.ParseExact(timeMatch[0].Groups[1].Value + " " + time, "ddd MMM dd HH:mm", CultureInfo.InvariantCulture); } ObservableCollection <WatchListItem> watchList = watchListView.ItemsSource as ObservableCollection <WatchListItem>; if (watchList != null) { WatchListItem found = watchList.FirstOrDefault(x => text.Contains(x.Item)); if (found != null) { highlight = found.Item; string cleaned = text.Replace(found.Item, "").ToLower(); string type = "Main"; foreach (string test in cleaned.Split(null)) { if (test.Equals("alt")) { type = "Alt"; wasLoot = true; break; } else if (test.Equals("rot") || test.Equals("rots") || test.Equals("rotting") || test.Equals("roting")) { type = "Rot"; wasLoot = true; break; } else if (test.Equals("main")) { // default type wasLoot = true; break; } } // check that a list of players exists for the given Item if (requestListMap.ContainsKey(found.Item)) { wasLoot = true; ObservableCollection <RequestListItem> list = requestListMap[found.Item]; // case of updating existing RequestListItem foundRequestListItem = list.FirstOrDefault(x => name.Equals(x.Player)); if (foundRequestListItem != null && (added - foundRequestListItem.Added).TotalSeconds < 600) { list.Remove(foundRequestListItem); } // if nothing selected then select first item we received tells for // also do this early so the requestListItem change event sees it selected if (watchListView.SelectedIndex == -1) { watchListView.SelectedItem = found; } // Add player RequestListItem requestListItem = new RequestListItem { Item = found.Item, Player = name, Type = type, Main = 0, Alt = 0, Days = -1, Time = time, Added = added }; // Update with loot counts DataManager.updateLootCounts(requestListItem); list.Add(requestListItem); // update count found.TellCount = list.Count; watchListView.Items.Refresh(); IList selectList = new ArrayList(); selectList.Add(watchListView.SelectedItem); watchListView.RaiseEvent(new SelectionChangedEventArgs(DataGrid.SelectionChangedEvent, selectList, selectList)); } } } } if (!wasLoot) { if (lootChatOnly.IsChecked.Value) { appendLine(tellsChatBuffer, line, highlight); } else { appendLine(richTextBox.Document, line, highlight); } } else { appendLine(tellsChatBuffer, line, highlight); appendLine(richTextBox.Document, line, highlight); } }
public new void handleEvent(LogEventArgs e) { string line = parseLine(e.line); MatchCollection matches = yourLootChat.Matches(line); string highlight = null; if (matches.Count > 0 && matches[0].Groups.Count == 2) { string lootString = matches[0].Groups[1].Value; if (lootString.Length > 0 && char.IsUpper(lootString[0])) { WatchListItem listItem = null; // find loot in database string item = ""; // try to cut out end with possibly digit like x2 string output = System.String.Join(" ", lootString.Split(null).Where(x => !aNumber.IsMatch(x))); foreach (string piece in output.Split(null)) { if (!aNumber.IsMatch(piece)) { item = (item.Length == 0) ? piece : item + " " + piece; object foundItem = DataManager.findItem(item); if (foundItem != null) { if (foundItem.GetType() == typeof(Item)) { listItem = new WatchListItem { Item = (foundItem as Item).Name, Found = "Yes" }; break; } else if ((int)foundItem == -1) { // not even a partial match break; } } } } if (listItem == null) { // we got here and didn't find the loot so use what we have so far listItem = new WatchListItem { Item = output, TellCount = 0, Found = "No, Edit if needed" }; } highlight = listItem.Item; ObservableCollection <WatchListItem> collection = watchListView.ItemsSource as ObservableCollection <WatchListItem>; if (collection == null || collection.Count <= 0 || collection.FirstOrDefault(x => listItem.Item.Equals(x.Item)) == null) { collection.Add(listItem); } } } bool isLootChat = matches.Count > 0 || otherLootChat.IsMatch(line) || (e.line.Split(new string[] { " // " }, System.StringSplitOptions.None).Length > 1) || (e.line.Split(new string[] { " || " }, System.StringSplitOptions.None).Length > 1); if (!isLootChat) { if (lootChatOnly.IsChecked.Value) { appendLine(guildChatBuffer, line, highlight); } else { appendLine(richTextBox.Document, line, highlight); } } else { appendLine(guildChatBuffer, line, highlight); appendLine(richTextBox.Document, line, highlight); } }