Skip to content

Commit

Permalink
Added font resource
Browse files Browse the repository at this point in the history
  • Loading branch information
Sonaza committed Dec 8, 2020
1 parent 7e4e247 commit 8e5efdb
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 4 deletions.
37 changes: 34 additions & 3 deletions Skedaddler/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,39 @@
using System.Windows.Forms;
using System.IO;
using System.Text.RegularExpressions;
using System.Drawing.Text;

namespace Skedaddler
{
public partial class Skedaddler : Form
{
[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 PrivateFontCollection fonts = new PrivateFontCollection();

SoundPlayer soundPlayer;

public Skedaddler()
{
InitializeComponent();
}

SoundPlayer soundPlayer;
byte[] fontData = Properties.Resources.OpenSans;
IntPtr fontPtr = System.Runtime.InteropServices.Marshal.AllocCoTaskMem(fontData.Length);
System.Runtime.InteropServices.Marshal.Copy(fontData, 0, fontPtr, fontData.Length);
uint dummy = 0;
fonts.AddMemoryFont(fontPtr, Properties.Resources.OpenSans.Length);
AddFontMemResourceEx(fontPtr, (uint)Properties.Resources.OpenSans.Length, IntPtr.Zero, ref dummy);
System.Runtime.InteropServices.Marshal.FreeCoTaskMem(fontPtr);

this.label4.Font = new Font(fonts.Families[0], 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.leaveTimeLabel.Font = new Font(fonts.Families[0], 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
this.timeUntilLabel.Font = new Font(fonts.Families[0], 23.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
this.label5.Font = new Font(fonts.Families[0], 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.alarmLabel.Font = new Font(fonts.Families[0], 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
this.Font = new Font(fonts.Families[0], 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
}

private void Skedaddler_Load(object sender, EventArgs e)
{
Expand Down Expand Up @@ -93,8 +115,17 @@ private void saveCurrentValues()

private bool reloadValues()
{
if (!Properties.Settings.Default.LastStateUpdate.Equals(DateTime.Today))

try
{
if (!Properties.Settings.Default.LastStateUpdate.Equals(DateTime.Today))
return false;
}
catch
{
// Any exception would tell things are wrong or uninitialized
return false;
}

System.Console.WriteLine("Loading data:");
System.Console.WriteLine(" LastArrivalTime " + Properties.Settings.Default.LastArrivalTime);
Expand Down
12 changes: 11 additions & 1 deletion Skedaddler/Properties/Resources.Designer.cs

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

3 changes: 3 additions & 0 deletions Skedaddler/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@
<data name="alarm" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\alarm.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="OpenSans" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\OpenSans-Regular.ttf;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="skedaddlerIcon" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\skedaddler.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
Expand Down
Binary file added Skedaddler/Resources/OpenSans-Regular.ttf
Binary file not shown.
44 changes: 44 additions & 0 deletions Skedaddler/Skedaddler.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,24 @@
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>D:\skedaddler\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<WebPage>publish.htm</WebPage>
<AutorunEnabled>true</AutorunEnabled>
<ApplicationRevision>2</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand All @@ -35,6 +53,18 @@
<PropertyGroup>
<ApplicationIcon>Resources\skedaddler.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<ManifestCertificateThumbprint>3AD42D9F2A12AB3F10CF8EE505B5698EFE26D086</ManifestCertificateThumbprint>
</PropertyGroup>
<PropertyGroup>
<ManifestKeyFile>Skedaddler_TemporaryKey.pfx</ManifestKeyFile>
</PropertyGroup>
<PropertyGroup>
<GenerateManifests>true</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<SignManifests>true</SignManifests>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down Expand Up @@ -79,6 +109,8 @@
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<None Include="Resources\OpenSans-Regular.ttf" />
<None Include="Skedaddler_TemporaryKey.pfx" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
Expand All @@ -89,6 +121,18 @@
<ItemGroup>
<Content Include="Resources\skedaddler.ico" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.5.2">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.5.2 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down

0 comments on commit 8e5efdb

Please sign in to comment.