//-------------------------------------------------------------- #region Creation & Cleanup //-------------------------------------------------------------- /// <summary> /// Initializes a new instance of the <see cref="TextureDocumentViewModel" /> class. /// </summary> /// <param name="document">The TextureDocument.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="document"/> is <see langword="null"/>. /// </exception> public TextureDocumentViewModel(TextureDocument document) : base(document) { // Disable unsupported color channels. var channels = TextureHelper.GetColorChannels(document.Texture2D.Format); if ((channels & ColorChannels.Red) != 0) { EnableRedChannel = true; IsRedChannelSupported = true; } if ((channels & ColorChannels.Green) != 0) { EnableGreenChannel = true; IsGreenChannelSupported = true; } if ((channels & ColorChannels.Blue) != 0) { EnableBlueChannel = true; IsBlueChannelSupported = true; } if ((channels & ColorChannels.Alpha) != 0) { EnableAlphaChannel = true; IsAlphaChannelSupported = true; } AlphaBlendTypes = new[] { "Straight alpha", "Premultiplied alpha" }; MipLevelNames = new string[document.Texture2D.LevelCount]; for (int i = 0; i < document.Texture2D.LevelCount; i++) { MipLevelNames[i] = Invariant($"Mip level {i}"); } ChangeMipLevelCommand = new DelegateCommand <object>(ChangeMipLevel); }
//-------------------------------------------------------------- #region Creation & Cleanup //-------------------------------------------------------------- /// <summary> /// Initializes a new instance of the <see cref="TextureDocumentViewModel" /> class. /// </summary> /// <param name="document">The TextureDocument.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="document"/> is <see langword="null"/>. /// </exception> public TextureDocumentViewModel(TextureDocument document) : base(document) { // Disable unsupported color channels. var channels = TextureHelper.GetColorChannels(document.Texture2D.Format); if ((channels & ColorChannels.Red) != 0) { EnableRedChannel = true; IsRedChannelSupported = true; } if ((channels & ColorChannels.Green) != 0) { EnableGreenChannel = true; IsGreenChannelSupported = true; } if ((channels & ColorChannels.Blue) != 0) { EnableBlueChannel = true; IsBlueChannelSupported = true; } if ((channels & ColorChannels.Alpha) != 0) { EnableAlphaChannel = true; IsAlphaChannelSupported = true; } AlphaBlendTypes = new[] { "Straight alpha", "Premultiplied alpha" }; MipLevelNames = new string[document.Texture2D.LevelCount]; for (int i = 0; i < document.Texture2D.LevelCount; i++) MipLevelNames[i] = Invariant($"Mip level {i}"); ChangeMipLevelCommand = new DelegateCommand<object>(ChangeMipLevel); }