Skip to content

Commit

Permalink
Merge pull request for 0.7.0
Browse files Browse the repository at this point in the history
Remove NuGet packages, update Installer script, finish NotifyIcon work
  • Loading branch information
banksio committed Feb 3, 2019
2 parents 0e9299c + 9921a9c commit 571285e
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 82 deletions.
1 change: 1 addition & 0 deletions KeyboardDisplay/Functions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ public static bool GetStartupRegistryKeyStatus(string scope)
catch (Exception e)
{
// AAAAAAAAAAARGH, an error!
MessageBox.Show(e.Message);
return false;
}
}
Expand Down
9 changes: 9 additions & 0 deletions KeyboardDisplay/IYourForm1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Windows.Forms;

namespace KeyboardDisplay
{
interface IYourForm1
{
void ShowBalloonTip(int timeout, string tipTitle, string tipText, ToolTipIcon tipIcon);
}
}
5 changes: 1 addition & 4 deletions KeyboardDisplay/KeyboardDisplay.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@
<ApplicationIcon>Resources\KBDDisp.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="Hardcodet.Wpf.TaskbarNotification, Version=1.0.5.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Hardcodet.NotifyIcon.Wpf.1.0.8\lib\net451\Hardcodet.Wpf.TaskbarNotification.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
Expand All @@ -63,6 +60,7 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="IYourForm1.cs" />
<Compile Include="Updater.cs" />
<Compile Include="Window1.xaml.cs">
<DependentUpon>Window1.xaml</DependentUpon>
Expand Down Expand Up @@ -105,7 +103,6 @@
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
Expand Down
47 changes: 4 additions & 43 deletions KeyboardDisplay/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@ namespace KeyboardDisplay
/// Interaction logic for MainWindow.xaml
/// </summary>

public partial class MainWindow : Window, IYourForm
public partial class MainWindow : Window
{
public bool startUp = true;

private NotifyIcon ni;

UpdateManager updater = new UpdateManager();
//Disable window focus
private const int GWL_EXSTYLE = -20;
private const int WS_EX_NOACTIVATE = 0x08000000;
Expand All @@ -42,34 +40,20 @@ public partial class MainWindow : Window, IYourForm
//for detecting keypresses
private KeyboardHook _hook;

public NotifyIcon Ni { get => ni; set => ni = value; }

public MainWindow()
{
InitializeComponent();

CreateNotifyIcon();
Ni.BalloonTipClicked += new EventHandler(Updater.UpdateManager.DoUpdate);
Ni.Text = "Keyboard Display is running.";


//DispatcherTimer fadeDelay = new DispatcherTimer();
//fadeDelay.Interval = new TimeSpan(0,0,5);

_hook = new KeyboardHook();
_hook.KeyUp += new KeyboardHook.HookEventHandler(OnHookKeyUp);

//check for updates last, it is least important
Updater.UpdateManager.GetUpdateInfo();
updater.GetUpdateInfo();

}

public void CreateNotifyIcon()
{
Ni = new System.Windows.Forms.NotifyIcon();
Ni.Icon = System.Drawing.Icon.ExtractAssociatedIcon(
System.Reflection.Assembly.GetEntryAssembly().ManifestModule.Name);
Ni.Visible = true;
}

void OnHookKeyUp(object sender, HookEventArgs e)
{
Expand Down Expand Up @@ -219,29 +203,6 @@ private void Window_Loaded(object sender, RoutedEventArgs e)
this.Top = desktopWorkingArea.Bottom - this.Height;
startUp = false;
}

private void MenuItem_Click(object sender, RoutedEventArgs e)
{
System.Windows.Application.Current.Shutdown();
}

private void SettingsMenuItem_Click(object sender, RoutedEventArgs e)
{
Window1 settings = new Window1();
settings.Show();
}



public void ShowBalloonTip(int timeout, string tipTitle, string tipText, ToolTipIcon tipIcon)
{
Ni.ShowBalloonTip(timeout, tipTitle, tipText, tipIcon);
}
}

interface IYourForm
{
void ShowBalloonTip(int timeout, string tipTitle, string tipText, ToolTipIcon tipIcon);
}
}

2 changes: 1 addition & 1 deletion KeyboardDisplay/Properties/Resources.Designer.cs

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

2 changes: 1 addition & 1 deletion KeyboardDisplay/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,6 @@
<value>..\Resources\KBDDisp.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="version" xml:space="preserve">
<value>0.6.0</value>
<value>0.7.0</value>
</data>
</root>
58 changes: 40 additions & 18 deletions KeyboardDisplay/Updater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,60 @@

namespace KeyboardDisplay
{
class Updater
{

public static class UpdateManager
public class UpdateManager
{
private static bool _updateAvailable;
private static readonly WebClient wc;
private static readonly IYourForm obj;
private static WebClient wc;
//private static readonly IYourForm1 interf = new MainWindow();

private static string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
private static string savepath = Path.Combine(path, "KbdDisp\\Temp");
private static string path = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
private static string savepath = Path.Combine(path, "Keyboard Display\\Temp");
private static string filepath = Path.Combine(savepath, "updateSetup.exe");
private static string version;
private static NotifyIcon MainNI;
private static ContextMenu NiCM;

public static bool UpdateAvailable
{
get => _updateAvailable;
set => _updateAvailable = value;
}

static UpdateManager()
public UpdateManager()
{
obj = new MainWindow();
CreateNotifyIcon();
wc = new WebClient();
wc.DownloadFileCompleted += Wc_DownloadFileCompleted;
UpdateAvailable = false;
}

public static void GetUpdateInfo()
public void CreateNotifyIcon()
{
MainNI = new System.Windows.Forms.NotifyIcon();
MainNI.Icon = System.Drawing.Icon.ExtractAssociatedIcon(
System.Reflection.Assembly.GetEntryAssembly().ManifestModule.Name);
MainNI.Visible = true;
NiCM = new ContextMenu();
NiCM.MenuItems.Add("Settings", new EventHandler(SettingsMenuItem_Click));
NiCM.MenuItems.Add("Exit", new EventHandler(MenuItem_Click));
MainNI.ContextMenu = NiCM;
MainNI.BalloonTipClicked += new EventHandler(DoUpdate);
MainNI.Text = "Keyboard Display is running.";
}

private void MenuItem_Click(object sender, System.EventArgs e)
{
MainNI.Dispose();
System.Windows.Application.Current.Shutdown();
}

private void SettingsMenuItem_Click(object sender, System.EventArgs e)
{
Window1 settings = new Window1();
settings.Show();
}

public void GetUpdateInfo()
{
// Set URL.
var url = "https://raw.githubusercontent.com/banksio/KeyboardDisplay/master/versions.txt";
Expand All @@ -54,7 +79,6 @@ public static void GetUpdateInfo()

ProcessURLResponse(url, urlContents);


// Update the total.
total += urlContents.Length;

Expand Down Expand Up @@ -151,7 +175,7 @@ private static void DownloadUpdate(string updateUrl)
}
}

public static void DoUpdate(object sender, System.EventArgs e)
private void DoUpdate(object sender, System.EventArgs e)
{
try
{
Expand All @@ -164,19 +188,17 @@ public static void DoUpdate(object sender, System.EventArgs e)
Application.Current.Shutdown();
}

private static void NotifyUpdate()
static void NotifyUpdate()
{
obj.ShowBalloonTip(1, "Keyboard Display Update", "Version " + version + " has been downloaded. Tap or click here to install it.", ToolTipIcon.Info);
MainNI.ShowBalloonTip(1, "Keyboard Display Update", "Version " + version + " has been downloaded. Tap or click here to install it.", ToolTipIcon.Info);
}

private static void Wc_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
private void Wc_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
{
//if (!e.Cancelled || e.Error != null) return;
NotifyUpdate();

}

}

}
}
4 changes: 0 additions & 4 deletions KeyboardDisplay/packages.config

This file was deleted.

18 changes: 9 additions & 9 deletions KeyboardDisplayTests/KeyboardDisplayTests.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.props')" />
<Import Project="..\packages\MSTest.TestAdapter.1.4.0\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.1.4.0\build\net45\MSTest.TestAdapter.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
Expand Down Expand Up @@ -40,10 +40,10 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\MSTest.TestFramework.1.2.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
<HintPath>..\packages\MSTest.TestFramework.1.4.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\MSTest.TestFramework.1.2.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
<HintPath>..\packages\MSTest.TestFramework.1.4.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand All @@ -52,23 +52,23 @@
<Compile Include="KeyDetectTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\KeyboardDisplay\KeyboardDisplay.csproj">
<Project>{db63c0e8-0a17-4175-aceb-df8081829d86}</Project>
<Name>KeyboardDisplay</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.props'))" />
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.targets'))" />
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.4.0\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.4.0\build\net45\MSTest.TestAdapter.props'))" />
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.4.0\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.4.0\build\net45\MSTest.TestAdapter.targets'))" />
</Target>
<Import Project="..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.targets')" />
<Import Project="..\packages\MSTest.TestAdapter.1.4.0\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.1.4.0\build\net45\MSTest.TestAdapter.targets')" />
</Project>
4 changes: 2 additions & 2 deletions KeyboardDisplayTests/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MSTest.TestAdapter" version="1.2.0" targetFramework="net471" />
<package id="MSTest.TestFramework" version="1.2.0" targetFramework="net471" />
<package id="MSTest.TestAdapter" version="1.4.0" targetFramework="net472" />
<package id="MSTest.TestFramework" version="1.4.0" targetFramework="net472" />
</packages>
Binary file removed Output/setup.exe
Binary file not shown.

0 comments on commit 571285e

Please sign in to comment.