Skip to content

Commit

Permalink
Load version number from embedded data
Browse files Browse the repository at this point in the history
  • Loading branch information
Johan Geluk committed Jul 15, 2017
1 parent 0f10b68 commit 3a60cb2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
23 changes: 22 additions & 1 deletion pass-winmenu/src/EmbeddedResources.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Drawing;
using System;
using System.Drawing;
using System.IO;
using System.Reflection;

Expand All @@ -8,5 +9,25 @@ public static class EmbeddedResources
{
public static Icon Icon => new Icon(Assembly.GetEntryAssembly().GetManifestResourceStream("PassWinmenu.embedded.pass-winmenu.ico"));
public static Stream DefaultConfig => Assembly.GetExecutingAssembly().GetManifestResourceStream("PassWinmenu.embedded.default-config.yaml");
public static string Version { get; private set; }


static EmbeddedResources()
{

}

public static void Load()
{
var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("PassWinmenu.embedded.version.txt");
if (stream == null)
{
throw new InvalidOperationException("Version number could not be read from the assembly.");
}
using (var reader = new StreamReader(stream))
{
Version = reader.ReadToEnd();
}
}
}
}
5 changes: 3 additions & 2 deletions pass-winmenu/src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace PassWinmenu
{
internal class Program : Form
{
private const string Version = "1.5-pre";
private string Version => EmbeddedResources.Version; // "1.5-pre";
private const string EncryptedFileExtension = ".gpg";
private const string PlaintextFileExtension = ".txt";
private readonly NotifyIcon icon = new NotifyIcon();
Expand All @@ -35,6 +35,7 @@ internal class Program : Form

public Program()
{
EmbeddedResources.Load();
CreateNotifyIcon();
LoadConfigFile();
hotkeys = AssignHotkeys();
Expand Down Expand Up @@ -358,7 +359,7 @@ private void CreateNotifyIcon()
icon.Icon = EmbeddedResources.Icon;
icon.Visible = true;
var menu = new ContextMenuStrip();
menu.Items.Add(new ToolStripLabel("pass-winmenu v" + Version));
menu.Items.Add(new ToolStripLabel("pass-winmenu " + Version));
menu.Items.Add(new ToolStripSeparator());
menu.Items.Add("Decrypt Password", null, (sender, args) => Task.Run(() => DecryptPassword(true, false, false)));
menu.Items.Add("Add new Password", null, (sender, args) => Task.Run((Action)AddPassword));
Expand Down

0 comments on commit 3a60cb2

Please sign in to comment.