public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { int type = parameter is string?int.Parse((string)parameter, CultureInfo.InvariantCulture) : 0; switch (type) { case 0: return(TextureHelpers.BuildOptTexture(value as Texture)); case 1: return(TextureHelpers.BuildOptTextureAlpha(value as Texture)); } return(null); }
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (values.Length < 2 || values[0] == DependencyProperty.UnsetValue || values[1] == null) { return(null); } string pal = (string)values[1]; if (pal == "Default") { return(TextureHelpers.BuildOptTexture(values[0] as Texture, TextureHelpers.DefaultPalette)); } else { return(TextureHelpers.BuildOptTexture(values[0] as Texture, int.Parse(pal))); } }
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { if (values.Length < 2 || values[0] == DependencyProperty.UnsetValue || values[1] == DependencyProperty.UnsetValue) { return(null); } OptFile optFile = values[1] as OptFile; if (optFile == null) { return(null); } Texture texture = optFile.Textures.ContainsKey((string)values[0]) ? optFile.Textures[(string)values[0]] : null; return(TextureHelpers.BuildOptTexture(texture)); }