Skip to content

Commit

Permalink
Merge pull request #10 from tralafiti/master
Browse files Browse the repository at this point in the history
fix unresolved item name
  • Loading branch information
Slivo-fr authored May 8, 2019
2 parents b972067 + d11da2e commit 43dc369
Showing 1 changed file with 12 additions and 26 deletions.
38 changes: 12 additions & 26 deletions Elinor/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ private void ProcessData(string s)

string sss = sell.Any() ? sell.ElementAt(0)[0] : "-1.0";
_sell = double.Parse(sss, CultureInfo.InvariantCulture);

}
else if (profile.sellRange == (int)Profile.ranges.ONEJUMP)
{
Expand All @@ -148,7 +148,7 @@ private void ProcessData(string s)

string sss = sell.Any() ? sell.ElementAt(0)[0] : "-1.0";
_sell = double.Parse(sss, CultureInfo.InvariantCulture);

}
else if (profile.sellRange == (int)Profile.ranges.TWOJUMP)
{
Expand All @@ -160,7 +160,7 @@ private void ProcessData(string s)

string sss = sell.Any() ? sell.ElementAt(0)[0] : "-1.0";
_sell = double.Parse(sss, CultureInfo.InvariantCulture);

} else
{
IOrderedEnumerable<List<string>> sell = from List<string> row in table
Expand Down Expand Up @@ -236,29 +236,15 @@ private void ProcessData(string s)
break;
}

var setItemName = new BackgroundWorker();
setItemName.DoWork += (sender, args) =>
{
var prod = new TypeName(new[] {_typeId.ToString(CultureInfo.InvariantCulture)});
prod.Query();

Dispatcher.Invoke(new Action(delegate
{
if (prod.types.Count > 0)
{
TypeName.GameType type = prod.types[0];
lblItemName.Content = type.typeName;
lblItemName.ToolTip = type.typeName;
}
else
{
lblItemName.Content = "Unknown";
lblItemName.ToolTip ="Product not found";
}
}));
};

setItemName.RunWorkerAsync();
// extract item name from market log file name
var fileNameParts = s.Split('-');
// remove first and last entry of splittet string[] (location and typeid) and join rest since we can have a dash in the item name
var _itemName = fileNameParts.Length <= 2 ? "" : String.Join("-", fileNameParts.Skip(1).Reverse().Skip(1).Reverse());
Dispatcher.Invoke(new Action(delegate
{
lblItemName.Content = _itemName.Length != 0 ? _itemName : "Unkown";
lblItemName.ToolTip = _itemName.Length != 0 ? _itemName : "Product not found";
}));

Dispatcher.Invoke(new Action(delegate
{
Expand Down

0 comments on commit 43dc369

Please sign in to comment.