Example #1
0
        void ImportTexture()
        {
            string path;

            if ((path = FileDialog.Open()) != null)
            {
                var src = TextureImport.OpenFile(path);
                if (src.Type == TexLoadType.ErrorLoad ||
                    src.Type == TexLoadType.ErrorNonSquare ||
                    src.Type == TexLoadType.ErrorNonPowerOfTwo)
                {
                    main.ErrorDialog(TextureImport.LoadErrorString(src.Type, path));
                }
                else if (src.Type == TexLoadType.DDS)
                {
                    src.Texture.Dispose();
                    selectedNode.Children = null;
                    selectedNode.Data     = File.ReadAllBytes(path);
                }
                else
                {
                    teximportprev = src.Texture;
                    teximportpath = path;
                    teximportid   = ImGuiHelper.RegisterTexture(teximportprev);
                    popups.OpenPopup("Texture Import");
                }
            }
        }
        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;
        }