private void LoadProperties(NodeBase node, bool onLoad)
        {
            if (node.Tag is IPropertyUI)
            {
                //A UI type that can display rendered IMGUI code.
                var propertyUI = (IPropertyUI)node.Tag;
                if (ActiveEditor == null || ActiveEditor.GetType() != propertyUI.GetTypeUI())
                {
                    var instance = Activator.CreateInstance(propertyUI.GetTypeUI());
                    ActiveEditor = instance;
                }
                if (onLoad)
                {
                    propertyUI.OnLoadUI(ActiveEditor);
                }

                propertyUI.OnRenderUI(ActiveEditor);
            }
            else if (node.Tag is STGenericTexture)
            {
                //A generic image viewer for image types.
                ImageEditor.LoadEditor((STGenericTexture)node.Tag);
            } //A basic UI type to generate properties like a property grid.
            else if (node.Tag is IPropertyDisplay)
            {
                var prop = ((IPropertyDisplay)node.Tag);
                if (prop.PropertyDisplay != null)
                {
                    ImGuiHelper.LoadProperties(prop.PropertyDisplay);
                }
            }
        }
        public void Render(STGenericTexture texture)
        {
            if (ImageCanvas == null)
            {
                Init();
            }

            var size = ImGui.GetWindowSize();

            ActiveTexture = texture;

            var menuSize           = new Vector2(22, 22);
            var propertyWindowSize = new Vector2(size.X, size.Y / 2 - 20);
            var canvasWindowSize   = new Vector2(size.X, size.Y / 2 - 20);

            if (ImGui.BeginChild("##IMAGE_TABMENU", propertyWindowSize, true))
            {
                ImGui.BeginTabBar("image_menu");
                if (ImguiCustomWidgets.BeginTab("image_menu", "Properties"))
                {
                    ImGuiHelper.LoadProperties(ActiveTexture.DisplayProperties, ActiveTexture.DisplayPropertiesChanged);
                    ImGui.EndTabItem();
                }
                if (ImguiCustomWidgets.BeginTab("image_menu", "Channels"))
                {
                    ImGui.EndTabItem();
                }
                if (ImguiCustomWidgets.BeginTab("image_menu", "User Data"))
                {
                    ImGui.EndTabItem();
                }
                ImGui.EndTabBar();
            }
            ImGui.EndChild();

            if (ImGui.BeginChild("CANVAS_WINDOW", canvasWindowSize, false,
                                 ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoScrollWithMouse | ImGuiWindowFlags.MenuBar))
            {
                if (ImGui.BeginMenuBar())
                {
                    if (ImGui.BeginMenu("File"))
                    {
                        ImGui.EndMenu();
                    }
                    if (ImGui.BeginMenu("Edit"))
                    {
                        ImGui.EndMenu();
                    }
                    if (ImGui.BeginMenu("View"))
                    {
                        ImGui.EndMenu();
                    }
                    if (ImGui.BeginMenu("Image"))
                    {
                        ImGui.EndMenu();
                    }
                    if (ImGui.BeginMenu("Adjustments"))
                    {
                        ImGui.EndMenu();
                    }
                    ImGui.PushItemWidth(150);
                    if (ImGui.BeginCombo("##imageCB", selectedBackground))
                    {
                        if (ImGui.Selectable("Checkerboard"))
                        {
                            selectedBackground = "Checkerboard";
                        }
                        ;
                        if (ImGui.Selectable("Black"))
                        {
                            selectedBackground = "Black";
                        }
                        ;
                        if (ImGui.Selectable("White"))
                        {
                            selectedBackground = "White";
                        }
                        ;
                        if (ImGui.Selectable("Custom"))
                        {
                            selectedBackground = "White";
                        }
                        ;

                        ImGui.EndMenu();
                    }
                    ImGui.PopItemWidth();

                    ImGui.EndMenuBar();
                }

                //Make icon buttons invisible aside from the icon itself.
                ImGui.PushStyleColor(ImGuiCol.Button, new Vector4());
                {
                    //Draw icon bar
                    ImGui.ImageButton((IntPtr)IconManager.GetTextureIcon("SAVE_BUTTON"), menuSize);
                    ImGui.SameLine();
                    ImGui.ImageButton((IntPtr)IconManager.GetTextureIcon("IMG_EDIT_BUTTON"), menuSize);
                    ImGui.SameLine();
                    ImguiCustomWidgets.ImageButtonToggle(
                        IconManager.GetTextureIcon("IMG_ALPHA_BUTTON"),
                        IconManager.GetTextureIcon("IMG_NOALPHA_BUTTON"), ref DisplayAlpha, menuSize);
                }
                ImGui.PopStyleColor();

                //Draw the array and mip level counter buttons
                ImGui.AlignTextToFramePadding();
                ImGui.Text("Array Level " + $"{currentArrayLevel} / {texture.ArrayCount - 1}");
                ImGui.SameLine();
                if (ImGui.Button("<", menuSize))
                {
                    AdjustArrayLevel(-1);
                }
                ImGui.SameLine();
                if (ImGui.Button(">", menuSize))
                {
                    AdjustArrayLevel(1);
                }
                ImGui.SameLine();

                ImGui.Text("Mip Level " + $"{currentMipLevel} / {texture.MipCount - 1}");
                ImGui.SameLine();
                if (ImGui.Button("<", menuSize))
                {
                    AdjustMipLevel(-1);
                }
                ImGui.SameLine();
                if (ImGui.Button(">", menuSize))
                {
                    AdjustMipLevel(1);
                }

                //Draw the main image canvas
                DrawImageCanvas(canvasWindowSize);
            }
            ImGui.EndChild();

            /*   if (ImGui.BeginMenuBar())
             * {
             *
             * }*/
        }