public static List <runes> PopulateRunes() { List <runes> RuneList = new List <runes>(); string runeJSON = File.ReadAllText(Path.Combine(Client.ExecutingDirectory, "Assets", "data", "en_US", "rune.json")); JavaScriptSerializer serializer = new JavaScriptSerializer(); Dictionary <string, object> deserializedJSON = serializer.Deserialize <Dictionary <string, object> >(runeJSON); Dictionary <string, object> runeData = deserializedJSON["data"] as Dictionary <string, object>; foreach (KeyValuePair <string, object> rune in runeData) { runes newRune = new runes(); Dictionary <string, object> singularRuneData = rune.Value as Dictionary <string, object>; newRune.id = Convert.ToInt32(rune.Key); newRune.name = singularRuneData["name"] as string; newRune.description = singularRuneData["description"] as string; newRune.description = newRune.description.Replace("(", "\n"); newRune.description = newRune.description.Replace(")", ""); newRune.stats = singularRuneData["stats"] as Dictionary <string, object>; newRune.tags = singularRuneData["tags"] as ArrayList; Dictionary <string, object> imageData = singularRuneData["image"] as Dictionary <string, object>; var uriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "rune", (string)imageData["full"]); newRune.icon = Client.GetImage(uriSource); RuneList.Add(newRune); } return(RuneList); }
private void AvailableRuneList_DoubleClickOrRightClick(object sender, MouseButtonEventArgs e) { if (((ListBox)sender).SelectedItem != null) //Fix crash if you double click scrollbar (no item selected) { if (((RuneItem)((ListBox)sender).SelectedItem).Used <= 0) { return; } runes Rune = ((runes)((RuneItem)((ListBox)sender).SelectedItem).Tag); RuneItem item = new RuneItem(); item.RuneImage.Source = Rune.icon; item.Margin = new Thickness(2, 2, 2, 2); item.Tag = Rune; item.RuneName.Content = Rune.name; item.RuneEffect.Content = Rune.description; item.MouseRightButtonDown += item_MouseRightButtonDown; item.MouseMove += item_MouseMove; item.MouseLeave += item_MouseLeave; ListBox tempRuneListBox = new ListBox(); double tempAvailCount = 0; if (Rune.name.Contains("Mark")) { tempAvailCount = RedRunesAvail; tempRuneListBox = RedListBox; } if (Rune.name.Contains("Seal")) { tempAvailCount = YellowRunesAvail; tempRuneListBox = YellowListBox; } if (Rune.name.Contains("Glyph")) { tempAvailCount = BlueRunesAvail; tempRuneListBox = BlueListBox; } if (Rune.name.Contains("Quint")) { tempAvailCount = BlackRunesAvail; tempRuneListBox = BlackListBox; } if (tempRuneListBox.Items.Count < tempAvailCount) { tempRuneListBox.Items.Add(item); UpdateStatList(); ((RuneItem)((ListBox)sender).SelectedItem).Used--; AvailableRuneList.Items.Refresh(); } } }
private void item_MouseMove(object sender, MouseEventArgs e) { runes playerItem = (runes)((RuneItem)sender).Tag; if (PlayerItem == null) { PlayerItem = new LargeChatPlayer(); Client.MainGrid.Children.Add(PlayerItem); Panel.SetZIndex(PlayerItem, 4); //Only load once PlayerItem.ProfileImage.Source = playerItem.icon; PlayerItem.PlayerName.Content = playerItem.name; PlayerItem.PlayerName.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); if (PlayerItem.PlayerName.DesiredSize.Width > 250) //Make title fit in item { PlayerItem.Width = PlayerItem.PlayerName.DesiredSize.Width; } else { PlayerItem.Width = 250; } PlayerItem.PlayerLeague.Content = playerItem.id; PlayerItem.UsingLegendary.Visibility = System.Windows.Visibility.Hidden; PlayerItem.PlayerWins.Content = ((string)playerItem.description.Replace("<br>", Environment.NewLine)); PlayerItem.PlayerStatus.Text = ""; PlayerItem.LevelLabel.Content = ""; PlayerItem.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; PlayerItem.VerticalAlignment = System.Windows.VerticalAlignment.Top; } Point MouseLocation = e.GetPosition(Client.MainGrid); double YMargin = MouseLocation.Y; double XMargin = MouseLocation.X; if (XMargin + PlayerItem.Width + 10 > Client.MainGrid.ActualWidth) { XMargin = Client.MainGrid.ActualWidth - PlayerItem.Width - 10; } PlayerItem.Margin = new Thickness(XMargin + 5, YMargin + 5, 0, 0); }
public static List <runes> PopulateRunes() { var runeList = new List <runes>(); var runeJson = File.ReadAllText(Path.Combine(Client.ExecutingDirectory, "Assets", "data", "en_US", "rune.json")); var serializer = new JavaScriptSerializer(); var deserializedJson = serializer.Deserialize <Dictionary <string, object> >(runeJson); var runeData = deserializedJson["data"] as Dictionary <string, object>; if (runeData == null) { return(runeList); } foreach (var rune in runeData) { var singularRuneData = rune.Value as Dictionary <string, object>; if (singularRuneData == null) { continue; } var newRune = new runes { id = Convert.ToInt32(rune.Key), name = singularRuneData["name"] as string, description = singularRuneData["description"] as string }; newRune.description = newRune.description.Replace("(", "\n"); newRune.description = newRune.description.Replace(")", string.Empty); newRune.stats = singularRuneData["stats"] as Dictionary <string, object>; newRune.tags = singularRuneData["tags"] as ArrayList; var imageData = singularRuneData["image"] as Dictionary <string, object>; if (imageData != null) { var UriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "rune", (string)imageData["full"]); newRune.icon = Client.GetImage(UriSource); } runeList.Add(newRune); } return(runeList); }
private void AvailableRuneList_DoubleClickOrRightClick(object sender, MouseButtonEventArgs e) { if (((RuneItem)((ListView)sender).SelectedItem).Used <= 0) { return; } runes Rune = ((runes)((RuneItem)((ListView)sender).SelectedItem).Tag); RuneItem item = new RuneItem(); item.RuneImage.Source = Rune.icon; item.Margin = new Thickness(2, 2, 2, 2); item.Tag = Rune; item.MouseRightButtonDown += item_MouseRightButtonDown; item.MouseMove += item_MouseMove; item.MouseLeave += item_MouseLeave; ListView tempRuneListView = new ListView(); double tempAvailCount = 0; if (Rune.name.Contains("Mark")) { tempAvailCount = RedRunesAvail; tempRuneListView = RedListView; } if (Rune.name.Contains("Seal")) { tempAvailCount = YellowRunesAvail; tempRuneListView = YellowListView; } if (Rune.name.Contains("Glyph")) { tempAvailCount = BlueRunesAvail; tempRuneListView = BlueListView; } if (Rune.name.Contains("Quint")) { tempAvailCount = BlackRunesAvail; tempRuneListView = BlackListView; } if (tempRuneListView.Items.Count < tempAvailCount) { tempRuneListView.Items.Add(item); UpdateStatList(); ((RuneItem)((ListView)sender).SelectedItem).Used--; AvailableRuneList.Items.Refresh(); } }