public void Open(string filename, string icoName = null, bool tmp = false) { iconName = icoName ?? Path.GetFileNameWithoutExtension(filename); texFilename = filename; error = false; if (teximportprev != null) { ImGuiHelper.DeregisterTexture(teximportprev); teximportprev.Dispose(); teximportprev = null; } var src = TextureImport.OpenFile(filename); loadType = src.Type; teximportprev = src.Texture; if (loadType == TexLoadType.ErrorLoad || loadType == TexLoadType.ErrorNonSquare || loadType == TexLoadType.ErrorNonPowerOfTwo) { win.ErrorDialog(TextureImport.LoadErrorString(loadType, filename)); return; } teximportid = ImGuiHelper.RegisterTexture(teximportprev); doOpen = true; this.tmp = tmp; }
public static string LoadErrorString(TexLoadType type, string filename) { switch (type) { case TexLoadType.ErrorLoad: return($"Could not load file {filename}"); case TexLoadType.ErrorNonSquare: return($"Dimensions of {filename} are not square"); case TexLoadType.ErrorNonPowerOfTwo: return($"Dimensions of {filename} are not powers of two"); default: throw new InvalidOperationException(); } }