Skip to content

Commit

Permalink
Add ImageResource.FromResource without assembly;
Browse files Browse the repository at this point in the history
Bump to 1.1.8;
  • Loading branch information
onepiecefreak3 committed Oct 3, 2024
1 parent fd4d480 commit 026dc7e
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 13 deletions.
5 changes: 2 additions & 3 deletions ImGui.Forms/Controls/Button.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,8 @@ private void ApplyStyles(bool enabled, FontResource font)
private void RemoveStyles(bool enabled, FontResource font)
{
ImGuiNET.ImGui.PopStyleVar();

ImFontPtr? fontPtr = font?.GetPointer();
if (fontPtr != null)

if (Font?.GetPointer() != null)
ImGuiNET.ImGui.PopFont();

if (!enabled)
Expand Down
4 changes: 1 addition & 3 deletions ImGui.Forms/Controls/Label.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Drawing;
using System.Numerics;
using ImGui.Forms.Controls.Base;
using ImGui.Forms.Localization;
Expand Down Expand Up @@ -83,8 +82,7 @@ protected override void ApplyStyles()

protected override void RemoveStyles()
{
ImFontPtr? fontPtr = Font?.GetPointer();
if (fontPtr != null)
if (Font?.GetPointer() != null)
ImGuiNET.ImGui.PopFont();

if (!TextColor.IsEmpty)
Expand Down
1 change: 0 additions & 1 deletion ImGui.Forms/Controls/Menu/MenuBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Linq;
using ImGui.Forms.Resources;
using ImGuiNET;
using static System.Net.Mime.MediaTypeNames;

namespace ImGui.Forms.Controls.Menu
{
Expand Down
3 changes: 1 addition & 2 deletions ImGui.Forms/Controls/ProgressBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ protected override void ApplyStyles()

protected override void RemoveStyles()
{
ImFontPtr? fontPtr = Font?.GetPointer();
if (fontPtr != null)
if (Font?.GetPointer() != null)
ImGuiNET.ImGui.PopFont();
}
}
Expand Down
5 changes: 2 additions & 3 deletions ImGui.Forms/Controls/TextBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,8 @@ protected override void ApplyStyles()
protected override void RemoveStyles()
{
ImGuiNET.ImGui.PopStyleVar();

ImFontPtr? fontPtr = Font?.GetPointer();
if (fontPtr != null)

if (Font?.GetPointer() != null)
ImGuiNET.ImGui.PopFont();
}

Expand Down
2 changes: 1 addition & 1 deletion ImGui.Forms/ImGui.Forms.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package >
<metadata>
<id>Imgui.Forms</id>
<version>1.1.7</version>
<version>1.1.8</version>
<description>A WinForms-inspired object-oriented framework around Dear ImGui (https://github.com/ocornut/imgui)</description>

<authors>onepiecefreak</authors>
Expand Down
11 changes: 11 additions & 0 deletions ImGui.Forms/Resources/ImageResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ public static ImageResource FromFile(string path)
return FromImage(Image.Load<Rgba32>(path));
}

/// <summary>
/// Creates a new <see cref="ImageResource"/> from an embedded resource <paramref name="resourceName"/> in <see cref="Assembly.GetCallingAssembly"/>.
/// </summary>
/// <param name="resourceName">The name of the resource to load.</param>
/// <returns>An <see cref="ImageResource"/> representing the image.</returns>
/// <remarks>To load built-in images, see <see cref="ImageResources"/>.</remarks>
public static ImageResource FromResource(string resourceName)
{
return FromResource(Assembly.GetCallingAssembly(), resourceName);
}

/// <summary>
/// Creates a new <see cref="ImageResource"/> from an embedded resource <paramref name="resourceName"/> in <paramref name="assembly"/>.
/// </summary>
Expand Down

0 comments on commit 026dc7e

Please sign in to comment.