Tiens, je viens de faire un petit utilitaire en C#/WPF pour afficher les infos des add-on.
Si ça peut t'aider / te donner des idées ^^
En images ça donne ça :
La partie C# (c'est très verbeux parce que je préfère quand les propriétés commencent par une majuscule, mais dans le xml, tout est en minuscule '^^)
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using System.Xml;
using System.IO;
namespace Avalloc
{
public class Systeme
{
[XmlElement("server")]
public string Serveur { get; set; }
[XmlElement("version")]
public string Version { get; set; }
[XmlElement("sysdate")]
public string Sysdate { get; set; }
[XmlIgnore()]
public string DateSysteme
{
get
{
DateTime ret;
if (DateTime.TryParse(Sysdate, out ret))
return ret.ToString();
return new DateTime().ToString();
}
}
}
public class Compte
{
[XmlElement("pseudo")]
public string Pseudo { get; set; }
[XmlElement("points_totaux")]
public int PointsTotaux { get; set; }
[XmlElement("points_economiques")]
public int PointsEconomiques { get; set; }
[XmlElement("points_militaires")]
public int PointsMilitaires { get; set; }
[XmlElement("progression_total")]
public int ProgressionTotal { get; set; }
[XmlElement("progression_economique")]
public int ProgressionEconomique { get; set; }
[XmlElement("progression_militaire")]
public int ProgressionMilitaire { get; set; }
[XmlElement("classement")]
public int Classement { get; set; }
[XmlElement("messages")]
public int Messages { get; set; }
[XmlElement("notifications")]
public int Notifications { get; set; }
[XmlElement("specialite_primaire")]
public string SpecialitePrimaire { get; set; }
[XmlElement("specialite_secondaire")]
public string SpecialiteSecondaire { get; set; }
public int AncienClassement { get { return Classement + ProgressionTotal; } }
public bool IsUpProgressionEconomique { get { return ProgressionEconomique >= 0; } }
public bool IsUpProgressionMilitaire { get { return ProgressionMilitaire >= 0; } }
public bool IsUpClassement { get { return ProgressionTotal >= 0; } }
}
public class Zone
{
public Zone()
{
Batiments = new List<Addon.Batiment>();
}
[XmlElement("nom")]
public string Nom { get; set; }
[XmlElement("x")]
public int X { get; set; }
[XmlElement("y")]
public int Y { get; set; }
[XmlElement("slots_pris")]
public int SlotsPris { get; set; }
[XmlElement("slots_totaux")]
public int SlotsTotaux { get; set; }
[XmlElement("pierre")]
public double Pierre { get; set; }
[XmlElement("metal")]
public double Metal { get; set; }
[XmlElement("petrole")]
public double Petrole { get; set; }
[XmlElement("uranium")]
public double Uranium { get; set; }
[XmlElement("debris")]
public double Debris { get; set; }
[XmlElement("electricite_pris")]
public int ElectricitePris { get; set; }
[XmlElement("electricite_totale")]
public int ElectriciteTotale { get; set; }
[XmlArray("batiments")]
[XmlArrayItem("batiment")]
public List<Addon.Batiment> Batiments { get; set; }
public int SlotsLibre { get { return SlotsTotaux - SlotsPris; } }
public int ElectriciteLibre { get { return ElectriciteTotale - ElectricitePris; } }
}
[XmlType("addons")]
public class Addon
{
public class Batiment
{
[XmlElement("nom")]
public string Nom
{
get { return _Nom; }
set
{
_Nom = System.Web.HttpUtility.HtmlDecode(value);
}
}
[XmlElement("niveau")]
public int Niveau { get; set; }
private string _Nom;
}
public class Technologie
{
[XmlElement("nom")]
public string Nom
{
get { return _Nom; }
set
{
_Nom = System.Web.HttpUtility.HtmlDecode(value);
}
}
[XmlElement("niveau")]
public int Niveau { get; set; }
private string _Nom;
}
public Addon()
{
Technologies = new List<Addon.Technologie>();
Zones = new List<Zone>();
}
[XmlElement("systeme")]
public Systeme Systeme { get; set; }
[XmlElement("compte")]
public Compte Compte { get; set; }
[XmlArray("technologies")]
[XmlArrayItem("technologie")]
public List<Addon.Technologie> Technologies { get; set; }
[XmlArray("zones")]
[XmlArrayItem("zone")]
public List<Zone> Zones { get; set; }
public static Addon Create(XmlReader reader)
{
try
{
XmlSerializer xs = new XmlSerializer(typeof(Addon), new Type[] {
typeof(Systeme),
typeof(Compte)
});
return (Addon)xs.Deserialize(reader);
}
catch (Exception e) { return null; }
}
public static Addon Create(string file)
{
try
{
using (Stream stream = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read))
{
return Create(XmlReader.Create(stream));
}
}
catch (Exception) { return null; }
}
}
}
et le XAML
<Window x:Class="WpfAddon.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib"
xmlns:ava="clr-namespace:Avalloc;assembly=Avalloc"
Title="MainWindow" Height="560" Width="885">
<Window.Resources>
<ObjectDataProvider x:Key="Addon"
ObjectType="{x:Type ava:Addon}"
MethodName="Create">
<ObjectDataProvider.MethodParameters>
<system:String>Veuillez entrer le chemin vers votre fichier XML</system:String>
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
</Window.Resources>
<Window.DataContext>
<Binding Source="{StaticResource ResourceKey=Addon}" />
</Window.DataContext>
<Grid>
<Label Content="Chemin fichier XML :"
Height="25"
HorizontalAlignment="Left"
Margin="12,12,0,0"
Name="label23"
VerticalAlignment="Top"
Width="115" />
<TextBox Height="25"
Margin="127,12,12,0"
Name="textBox1"
VerticalAlignment="Top"
Text="{Binding Source={StaticResource ResourceKey=Addon}, BindsDirectlyToSource=True, Path=MethodParameters[0], UpdateSourceTrigger=PropertyChanged}" />
<GroupBox Header="Infos Serveur"
Height="100"
HorizontalAlignment="Left"
Margin="12,37,0,0"
Name="gbServeur"
VerticalAlignment="Top"
Width="200"
DataContext="{Binding Systeme}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="65" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Label Content="Serveur"
Height="25"
Margin="3,3,0,0"
Name="label1"
VerticalAlignment="Top" />
<Label Content="Version"
Height="25"
Margin="3,28,0,0"
Name="label2"
VerticalAlignment="Top" />
<Label Content="Date XML"
Height="25"
Margin="3,53,0,0"
Name="label3"
VerticalAlignment="Top" />
<Label Content="{Binding Serveur}"
Height="25"
Margin="0,3,3,0"
Name="label4"
VerticalAlignment="Top"
Grid.Column="1" />
<Label Content="{Binding Version}"
Height="25"
Margin="0,28,3,0"
Name="label5"
VerticalAlignment="Top"
Grid.Column="1" />
<Label Content="{Binding DateSysteme}"
Height="25"
Margin="0,53,3,0"
Name="label6"
VerticalAlignment="Top"
Grid.Column="1" />
</Grid>
</GroupBox>
<GroupBox Header="Compte"
HorizontalAlignment="Left"
Margin="12,149,0,0"
Name="gbCompte"
Width="200"
DataContext="{Binding Compte}"
Height="350"
VerticalAlignment="Top">
<Grid>
<Label Content="{Binding Pseudo}"
ContentStringFormat="Pseudo : {0}"
Height="25"
Margin="3,3,3,0"
Name="label7"
VerticalAlignment="Top" />
<GroupBox Header="Points"
Height="100"
Margin="3,28,3,0"
Name="gpPoints"
VerticalAlignment="Top">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="90" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Label Content="Economique"
Height="25"
Margin="3,3,0,0"
Name="label8"
VerticalAlignment="Top" />
<Label Content="Militaire"
Height="25"
Margin="3,28,0,0"
Name="label9"
VerticalAlignment="Top" />
<Label Content="Total"
Height="25"
Margin="3,53,0,0"
Name="label10"
VerticalAlignment="Top" />
<Label Content="{Binding PointsEconomiques}"
Height="25"
Margin="0,3,3,0"
Name="label11"
VerticalAlignment="Top"
Grid.Column="1" />
<Label Content="{Binding PointsMilitaires}"
Height="25"
Margin="0,28,3,0"
Name="label12"
VerticalAlignment="Top"
Grid.Column="1" />
<Label Content="{Binding PointsTotaux}"
Height="25"
Margin="0,53,3,0"
Name="label13"
VerticalAlignment="Top"
Grid.Column="1" />
</Grid>
</GroupBox>
<GroupBox Header="Classement"
Height="100"
Margin="3,128,3,0"
Name="gbClassement"
VerticalAlignment="Top">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="90" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Label Content="Economique"
Height="25"
Margin="3,3,0,0"
Name="label14"
VerticalAlignment="Top" />
<Label Content="Militaire"
Height="25"
Margin="3,28,0,0"
Name="label15"
VerticalAlignment="Top" />
<Label Content="Actuel / Ancien"
Height="25"
Margin="3,53,0,0"
Name="label16"
VerticalAlignment="Top" />
<Label Content="{Binding ProgressionEconomique}"
Grid.Column="1"
Height="25"
Margin="0,3,3,0"
Name="label17"
VerticalAlignment="Top">
<Label.Style>
<Style>
<Setter Property="Label.Foreground"
Value="Red" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsUpProgressionEconomique}" Value="true">
<Setter Property="Label.Foreground"
Value="Green" />
</DataTrigger>
</Style.Triggers>
</Style>
</Label.Style>
</Label>
<Label Content="{Binding ProgressionMilitaire}"
Grid.Column="1"
Height="25"
Margin="0,28,3,0"
Name="label18"
VerticalAlignment="Top">
<Label.Style>
<Style>
<Setter Property="Label.Foreground"
Value="Red" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsUpProgressionMilitaire}"
Value="true">
<Setter Property="Label.Foreground"
Value="Green" />
</DataTrigger>
</Style.Triggers>
</Style>
</Label.Style>
</Label>
<Grid Grid.Column="1"
Margin="0,53,3,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<Label Grid.Column="0"
Content="{Binding Classement}">
<Label.Style>
<Style>
<Setter Property="Label.Foreground"
Value="Red" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsUpClassement}"
Value="true">
<Setter Property="Label.Foreground"
Value="Green" />
</DataTrigger>
</Style.Triggers>
</Style>
</Label.Style>
</Label>
<Label Grid.Column="1"
Content="{Binding AncienClassement}">
<Label.Style>
<Style>
<Setter Property="Label.Foreground"
Value="Red" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsUpClassement}"
Value="false">
<Setter Property="Label.Foreground"
Value="Green" />
</DataTrigger>
</Style.Triggers>
</Style>
</Label.Style>
</Label>
</Grid>
</Grid>
</GroupBox>
<Label Content="{Binding Messages}"
ContentStringFormat="Messages : {0}"
Height="25"
Margin="3,228,3,0"
Name="label19"
VerticalAlignment="Top" />
<Label Content="{Binding Notifications}"
ContentStringFormat="Notifications : {0}"
Height="25"
Margin="3,253,3,0"
Name="label20"
VerticalAlignment="Top" />
<Label Content="{Binding SpecialitePrimaire}"
ContentStringFormat="1ère Spécialité : {0}"
Height="25"
Margin="3,278,3,0"
Name="label21"
VerticalAlignment="Top" />
<Label Content="{Binding SpecialiteSecondaire}"
ContentStringFormat="2ème Spécialité : {0}"
Height="25"
Margin="3,303,3,0"
Name="label22"
VerticalAlignment="Top" />
</Grid>
</GroupBox>
<GroupBox Header="Technologies"
HorizontalAlignment="Left"
Margin="224,37,0,12"
Name="gbTech"
Width="285">
<Grid>
<ListView Name="listView1"
ItemsSource="{Binding Technologies}">
<ListView.View>
<GridView>
<GridViewColumn Header="Nom"
Width="Auto"
DisplayMemberBinding="{Binding Nom}" />
<GridViewColumn Header="Niveau"
Width="60"
DisplayMemberBinding="{Binding Niveau}" />
</GridView>
</ListView.View>
</ListView>
</Grid>
</GroupBox>
<GroupBox Header="Zones"
Margin="521,37,12,12"
Name="gbZones"
DataContext="{Binding Zones}">
<Grid>
<ComboBox Height="25"
HorizontalAlignment="Left"
Margin="3,3,0,0"
Name="cbZone"
VerticalAlignment="Top"
Width="150"
ItemsSource="{Binding .}"
HorizontalContentAlignment="Stretch">
<ComboBox.ItemTemplate>
<DataTemplate>
<Grid Width="Auto">
<TextBlock Text="{Binding Nom}" />
<TextBlock FlowDirection="RightToLeft"
HorizontalAlignment="Right">
<TextBlock.Text>
<MultiBinding StringFormat="{}{0}:{1}">
<Binding Path="X" />
<Binding Path="Y" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</Grid>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<Label Content="{Binding Count}"
ContentStringFormat="Vous contrôlez {0} terrains"
Height="25"
Margin="153,3,3,0"
Name="label24"
VerticalAlignment="Top" />
<TextBlock Height="25"
Margin="3,28,3,0"
VerticalAlignment="Top">
<TextBlock.Text>
<MultiBinding StringFormat="{}Place libre / prise / totale : {0} / {1} / {2}">
<Binding ElementName="cbZone"
Path="SelectedItem.SlotsLibre"
FallbackValue="" />
<Binding ElementName="cbZone"
Path="SelectedItem.SlotsPris"
FallbackValue="" />
<Binding ElementName="cbZone"
Path="SelectedItem.SlotsTotaux"
FallbackValue="" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
<GroupBox Header="Ressources"
Height="90"
Margin="3,53,3,0"
Name="gbRess"
VerticalAlignment="Top"
DataContext="{Binding ElementName=cbZone, Path=SelectedItem}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="60" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="60" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Label Grid.Row="0"
Grid.Column="0"
Content="Pierre" />
<Label Grid.Row="1"
Grid.Column="0"
Content="Métal" />
<Label Grid.Row="2"
Grid.Column="0"
Content="Pétrole" />
<Label Grid.Row="0"
Grid.Column="2"
Content="Uranium" />
<Label Grid.Row="1"
Grid.Column="2"
Content="Electricité" />
<Label Grid.Row="2"
Grid.Column="2"
Content="Débris" />
<Label Grid.Row="0"
Grid.Column="1"
Content="{Binding Pierre}" />
<Label Grid.Row="1"
Grid.Column="1"
Content="{Binding Metal}" />
<Label Grid.Row="2"
Grid.Column="1"
Content="{Binding Petrole}" />
<Label Grid.Row="0"
Grid.Column="3"
Content="{Binding Uranium}" />
<TextBlock Grid.Row="1"
Grid.Column="3"
VerticalAlignment="Center">
<TextBlock.Text>
<MultiBinding StringFormat="{}{0} / {1}">
<Binding Path="ElectriciteLibre"
FallbackValue="" />
<Binding Path="ElectriciteTotale"
FallbackValue="" />
</MultiBinding>
</TextBlock.Text>
<TextBlock.Style>
<Style>
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=cbZone, Path=SelectedIndex}"
Value="-1">
<Setter Property="TextBlock.Visibility"
Value="Hidden" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
<Label Grid.Row="2"
Grid.Column="3"
Content="{Binding Debris}" />
</Grid>
</GroupBox>
<ListView Margin="3,146,3,3"
Name="listView2"
ItemsSource="{Binding ElementName=cbZone, Path=SelectedItem.Batiments}">
<ListView.View>
<GridView>
<GridViewColumn Header="Nom"
Width="Auto"
DisplayMemberBinding="{Binding Nom}" />
<GridViewColumn Header="Niveau"
Width="60"
DisplayMemberBinding="{Binding Niveau}" />
</GridView>
</ListView.View>
</ListView>
</Grid>
</GroupBox>
</Grid>
</Window>
Il me semble avoir tout mis ce qu'il faut