protected override BitmapSource Convert(CrewRoleType?roleType, string databaseRootPath) { try { if (roleType == null) { return(null); } string iconKey; switch (roleType.Value) { case CrewRoleType.Commander: iconKey = "commander"; break; case CrewRoleType.Driver: iconKey = "driver"; break; case CrewRoleType.Gunner: iconKey = "gunner"; break; case CrewRoleType.Loader: iconKey = "loader"; break; case CrewRoleType.Radioman: iconKey = "radioman"; break; default: throw new NotSupportedException(); } string type; switch (this.Type) { case CrewRoleIconType.Big: type = "big"; break; case CrewRoleIconType.Small: type = "small"; break; default: throw new NotSupportedException(); } var path = $"gui/maps/icons/tankmen/roles/{type}/{iconKey}.png"; return(PackageImage.Load(databaseRootPath, PackageImage.GuiPackage, path)); } catch (Exception) { return(null); } }
public ImageSource GetSkillIcon(string icon) { if (icon == null) { return(null); } return(_skillIcons.GetOrCreate(icon, () => PackageImage.Load(_paths.GuiPackageFile, "gui/maps/icons/tankmen/skills/big/" + icon))); }
public ImageSource GetAccessoryIcon(string icon) { if (icon == null) { return(null); } return(_accessoryIcons.GetOrCreate(icon, () => PackageImage.Load(_paths.GuiPackageFile, "gui" + icon.Split(' ').First().Substring(2)))); }
private ImageSource LoadTankIcon(string relativePath, string hyphenKey) { var localPath = string.Format("{0}/{1}.png", relativePath, hyphenKey); if (PackageStream.IsFileExisted(_paths.GuiPackageFile, localPath)) { return(PackageImage.Load(_paths.GuiPackageFile, localPath)); } localPath = string.Format("{0}/noImage.png", relativePath); return(PackageImage.Load(_paths.GuiPackageFile, localPath)); }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { string path = null; var propertyName = parameter as string; if (string.IsNullOrEmpty(propertyName)) { path = value as string; } else { if (value.TryGetPropertyValue(propertyName, out object pathObject)) { path = pathObject as string; } } if (string.IsNullOrEmpty(path)) { return(null); } string databaseRootPath = null; var databaseObject = value as IDatabaseObject; if (databaseObject != null) { databaseRootPath = databaseObject.Database.RootPath; } if (string.IsNullOrEmpty(databaseRootPath)) { databaseRootPath = Database.Current.RootPath; } try { return(PackageImage.Load(databaseRootPath, PackageImage.GuiPackage, path)); } catch (Exception) { return(null); } }
protected override BitmapSource Convert(object[] values, string databaseRootPath) { try { if (values == null) { return(null); } var nationKey = (string)values[0]; var rankLevel = (int)values[1]; if (nationKey != "china") { rankLevel = 12 - rankLevel; } string type; switch (this.Type) { case CrewRankIconType.Big: type = "big"; break; case CrewRankIconType.Small: type = "small"; break; default: throw new NotSupportedException(); } var path = $"gui/maps/icons/tankmen/ranks/{type}/{nationKey}-{rankLevel}.png"; return(PackageImage.Load(databaseRootPath, PackageImage.GuiPackage, path)); } catch (Exception) { return(null); } }
internal LocalGameClientPackageImage(LocalGameClientPath paths) { _paths = paths; using (var reader = new BigworldXmlReader(_paths.GetShellListFile(_paths.Nations[0]))) { var element = XElement.Load(reader); _shellIcons = element.Element("icons") .Elements() .ToDictionary(e => e.Name.ToString(), e => PackageImage.Load(_paths.GuiPackageFile, "gui/maps/icons/shell/" + e.Value.Split(' ').First())); } _accessoryIcons = new Dictionary <string, ImageSource>(); _skillIcons = new Dictionary <string, ImageSource>(); _skillSmallIcons = new Dictionary <string, ImageSource>(); _nationSmallIcons = new Dictionary <string, ImageSource>(); _tankSmallIcons = new Dictionary <string, ImageSource>(); _tankBigIcons = new Dictionary <string, ImageSource>(); _tankCountorIcons = new Dictionary <string, ImageSource>(); using (var reader = new BigworldXmlReader(_paths.CommonCrewDataFile)) { var element = XElement.Load(reader); _crewRoleIcons = element.Element("roles") .Elements() .ToDictionary(e => e.Name.ToString(), e => PackageImage.Load(_paths.GuiPackageFile, "gui/maps/icons/tankmen/roles/big/" + e.Element("icon").Value)); _crewRoleSmallIcons = element.Element("roles") .Elements() .ToDictionary(e => e.Name.ToString(), e => PackageImage.Load(_paths.GuiPackageFile, "gui/maps/icons/tankmen/roles/small/" + e.Element("icon").Value)); } }
public ImageSource GetClassSmallIcon(string @class) { return(_nationSmallIcons.GetOrCreate(@class, () => PackageImage.Load(_paths.GuiPackageFile, string.Format("gui/maps/icons/filters/tanks/{0}.png", @class)))); }
public ImageSource GetNationSmallIcon(string nationKey) { return(_nationSmallIcons.GetOrCreate(nationKey, () => PackageImage.Load(_paths.GuiPackageFile, string.Format("gui/maps/icons/filters/nations/{0}.png", nationKey)))); }