Created
September 19, 2015 19:12
-
-
Save mafflerbach/afa4b4a885d76b964cc5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace WpfApplication1.Gw | |
{ | |
class ItemList | |
{ | |
public byte[] Image { get; set; } | |
public string Title { get; set; } | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Window x:Class="WpfApplication1.MainWindow" | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |
xmlns:local="clr-namespace:WpfApplication1" | |
mc:Ignorable="d" | |
Title="MainWindow" Height="350" Width="525"> | |
<Grid> | |
<ListBox Name="ListBox" Initialized="ListBox_OnInitialized"> | |
<ListBox.ItemTemplate> | |
<DataTemplate> | |
<ListBoxItem> | |
<StackPanel Orientation="Horizontal"> | |
<Image Source="{Binding Image}" Width="25"/> | |
<TextBlock VerticalAlignment="Center" Text="{Binding Title}"></TextBlock> | |
</StackPanel> | |
</ListBoxItem> | |
</DataTemplate> | |
</ListBox.ItemTemplate> | |
</ListBox> | |
</Grid> | |
</Window> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Windows; | |
using WpfApplication1.Gw; | |
using GW2NET; | |
using GW2NET.Common; | |
namespace WpfApplication1 | |
{ | |
/// <summary> | |
/// Interaction logic for MainWindow.xaml | |
/// </summary> | |
public partial class MainWindow : Window | |
{ | |
public MainWindow() | |
{ | |
InitializeComponent(); | |
} | |
private void ListBox_OnInitialized(object sender, EventArgs e) | |
{ | |
var service = GW2.V2.Items.ForDefaultCulture(); | |
var iconService = GW2.Rendering.RenderService; | |
IPageContext ctx = service.FindPage(pageSize: 10, pageIndex: 0); | |
var items = new List<ItemList>(); | |
foreach (var page in service.FindAllPages(ctx.PageSize, ctx.PageCount)) | |
{ | |
foreach (var itemContent in page.Value) | |
{ | |
byte[] png = iconService.GetImage(itemContent, "png"); | |
items.Add(new ItemList() { Title = itemContent.Name, Image = png }); | |
} | |
} | |
/** | |
Litle hardcoded old stuff | |
items.Add(new ItemList() { Title = "Learn C#", Image = "Images/Bandage.png" }); | |
items.Add(new ItemList() { Title = "Wash the car", Image = "Images/Bandage.png" }); | |
*/ | |
ListBox.ItemsSource = items; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment