Skip to content

Commit

Permalink
Merge pull request #50 from Sandip124/fix/appfreezing
Browse files Browse the repository at this point in the history
Fix/appfreezing
  • Loading branch information
Sandip124 authored Jul 22, 2022
2 parents 957a347 + 9e3ba52 commit b5b0e24
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 52 deletions.
20 changes: 7 additions & 13 deletions BatteryNotifier.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
<ApplicationIcon>battery-icon.ico</ApplicationIcon>
</PropertyGroup>

<ItemGroup>
<Compile Remove="Assets\**" />
<EmbeddedResource Remove="Assets\**" />
<None Remove="Assets\**" />
</ItemGroup>

<ItemGroup>
<None Remove="appSetting.settings" />
<None Remove="Assets\Fonts\Inter-Bold.ttf" />
<None Remove="Assets\Fonts\Inter-Regular.ttf" />
<None Remove="Assets\Fonts\SpaceMono-Bold.ttf" />
<None Remove="Assets\Fonts\SpaceMono-BoldItalic.ttf" />
<None Remove="Assets\Fonts\SpaceMono-Italic.ttf" />
<None Remove="Assets\Fonts\SpaceMono-Regular.ttf" />
<None Remove="battery-icon.ico" />
</ItemGroup>

Expand All @@ -29,12 +29,6 @@
</ItemGroup>

<ItemGroup>
<Content Include="Assets\Fonts\Inter-Bold.ttf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Assets\Fonts\Inter-Regular.ttf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<EmbeddedResource Include="Setting\appSetting.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>appSetting.Designer.cs</LastGenOutput>
Expand Down Expand Up @@ -87,7 +81,7 @@
<NugetTools>$(PkgNuGet_CommandLine)\tools</NugetTools>
<SquirrelTools>$(Pkgsquirrel_windows)\tools</SquirrelTools>

<Version>2.0.4</Version>
<Version>2.0.5</Version>

<NuspecFile>$(SolutionDir)ReleaseSpec.nuspec</NuspecFile>
</PropertyGroup>
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 3 additions & 1 deletion Deployment/Releases/RELEASES
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@ C74E7B149399495BA580E3C0787D003A08872910 BatteryNotifier-1.9.1-full.nupkg 169455
A3E0F13A323576C0092DDC02253BF231E74989E5 BatteryNotifier-2.0.3-delta.nupkg 24843
29C57A2CFA3CAE4FE5220E0CD4EFE998D56EBFF6 BatteryNotifier-2.0.3-full.nupkg 5112125
4DFB676BD02E366D0CB2FA2DFB30C4400783262E BatteryNotifier-2.0.4-delta.nupkg 26428
D31EA01AE7751E9189419053651CD91AD2391815 BatteryNotifier-2.0.4-full.nupkg 5112551
D31EA01AE7751E9189419053651CD91AD2391815 BatteryNotifier-2.0.4-full.nupkg 5112551
888426871ACA72DDDBB349EC4487FBD55109053A BatteryNotifier-2.0.5-delta.nupkg 256714
070FE78513AC08AF45226D2D3F1B8E1DD3AD45D2 BatteryNotifier-2.0.5-full.nupkg 4885813
Binary file modified Deployment/Releases/Setup.exe
Binary file not shown.
Binary file modified Deployment/Releases/Setup.msi
Binary file not shown.
12 changes: 6 additions & 6 deletions Forms/Dashboard.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 16 additions & 16 deletions Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,6 @@
<data name="Sufficient" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Sufficient.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="LowBatterynotification" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\LowBatterynotification.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Full" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Full.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
Expand All @@ -166,9 +163,6 @@
<data name="closeIconDark" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\closeIconDark.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="FullBatteryNotification" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\FullBatteryNotification.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="long_pop" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\long-pop.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
Expand All @@ -181,4 +175,10 @@
<data name="LightMode" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\LightMode.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Inter_Bold" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Assets\Fonts\Inter-Bold.ttf;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="Inter_Regular" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Assets\Fonts\Inter-Regular.ttf;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
</root>
29 changes: 19 additions & 10 deletions Providers/FontProvider.cs
Original file line number Diff line number Diff line change
@@ -1,34 +1,43 @@
using System;
using System.Drawing;
using System.Drawing.Text;

namespace BatteryNotifier.Providers
{
internal class FontProvider
{
private const string FontDirectory = "Assets/fonts";
[System.Runtime.InteropServices.DllImport("gdi32.dll")]
private static extern IntPtr AddFontMemResourceEx(IntPtr pbFont, uint cbFont, IntPtr pdv, [System.Runtime.InteropServices.In] ref uint pcFonts);

private const string RegularFont = "Inter-Regular.ttf";
private const string BoldFont = "Inter-Bold.ttf";


public PrivateFontCollection FontCollection = new();
public PrivateFontCollection FontsCollection = new();

public static FontProvider Default = new();

private FontProvider()
{
FontCollection.AddFontFile($"{FontDirectory}/{RegularFont}");
FontCollection.AddFontFile($"{FontDirectory}/{BoldFont}");
LoadFont(Properties.Resources.Inter_Regular);
LoadFont(Properties.Resources.Inter_Bold);
}

private void LoadFont(byte[] fontResource)
{
IntPtr fontPtr = System.Runtime.InteropServices.Marshal.AllocCoTaskMem(fontResource.Length);
System.Runtime.InteropServices.Marshal.Copy(fontResource, 0, fontPtr, fontResource.Length);
uint dummy = 0;
FontsCollection.AddMemoryFont(fontPtr, fontResource.Length);
AddFontMemResourceEx(fontPtr, (uint)fontResource.Length, IntPtr.Zero, ref dummy);
System.Runtime.InteropServices.Marshal.FreeCoTaskMem(fontPtr);
}

public static Font GetRegularFont(float size = 8)
{
return new Font(Default.FontCollection.Families[0], size, FontStyle.Regular, GraphicsUnit.Point);
return new Font(Default.FontsCollection.Families[0], size, FontStyle.Regular, GraphicsUnit.Point);
}

public static Font GetBoldFont(float size = 8)
{
return new Font(Default.FontCollection.Families[0], size, FontStyle.Bold, GraphicsUnit.Point);
return new Font(Default.FontsCollection.Families[0], size, FontStyle.Bold, GraphicsUnit.Point);
}
}

}

0 comments on commit b5b0e24

Please sign in to comment.