Skip to content

Commit

Permalink
added working notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Ruepp committed Aug 7, 2017
1 parent 1942787 commit 576828e
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 52 deletions.
5 changes: 5 additions & 0 deletions EveChatNotifier/EveChatNotifier.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="Tulpep.NotificationWindow, Version=1.1.23.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Tulpep.NotificationWindow.1.1.23\lib\net40\Tulpep.NotificationWindow.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="FormMain.cs">
Expand All @@ -73,6 +76,7 @@
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="app.config" />
<None Include="packages.config" />
Expand All @@ -88,6 +92,7 @@
</ItemGroup>
<ItemGroup>
<Content Include="preferences_desktop_notification_bell.ico" />
<None Include="Resources\eve-logo-landing2.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
74 changes: 61 additions & 13 deletions EveChatNotifier/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Windows.Forms;
using NAudio;
using NAudio.Wave;
using Tulpep.NotificationWindow;

namespace EveChatNotifier
{
Expand All @@ -21,6 +22,7 @@ public partial class FormMain : Form
private bool firstShown = true;
private static bool isPlaying = false;
private DateTime lastNotified = DateTime.Now;
private PopupNotifier Notifier = new PopupNotifier();

public FormMain()
{
Expand All @@ -33,6 +35,24 @@ public FormMain()
Properties.Settings.Default.Reload();
}

// popup notifier settings
Notifier.IsRightToLeft = false;
Notifier.ShowCloseButton = true;
Notifier.ShowGrip = false;
Notifier.Image = Properties.Resources.eve_logo_landing2;

Notifier.Delay = 5000;
Notifier.AnimationDuration = 500;

Notifier.BodyColor = Color.Black;
Notifier.BorderColor = Color.Red;
Notifier.ContentColor = Color.Orange;
Notifier.ContentHoverColor = Color.Orange;
Notifier.HeaderColor = Color.White;
Notifier.TitleColor = Color.LightGray;

Notifier.Click += Notifier_Click;

Logging.WriteLine("Starting chat notifier.");

InitializeComponent();
Expand Down Expand Up @@ -134,9 +154,26 @@ private void NewChatLines(object sender, LogFile.EveChatEventArgs e)
// if notification is needed
if (needsNotify) // isPlaying is managing the notification using sound (only one at a time)
{
lastNotified = DateTime.Now;
Logging.WriteLine(string.Format("Notify for chat message of '{0}' in '{1}': {2}", le.Sender, curLog.LogInfo.ChannelName, le.Text));

if (string.IsNullOrWhiteSpace(Properties.Settings.Default.SoundFilePath) || Properties.Settings.Default.ShowNotification)
{
if ((DateTime.Now - lastNotified).TotalSeconds > 1)
{
lastNotified = DateTime.Now;
// send notification
//notifyIcon.ShowBalloonTip(10000, "[EVE] chat notification", string.Format("[{0}] {1}: {2}", curLog.LogInfo.ChannelName, le.Sender, le.Text), ToolTipIcon.Info);



Notifier.TitleText = string.Format("{0} in '{1}'", le.Sender, curLog.LogInfo.ChannelName);
Notifier.ContentText = le.Text;


Notifier.Popup();
}
}

// send sound alert
if (!string.IsNullOrWhiteSpace(Properties.Settings.Default.SoundFilePath))
{
Expand All @@ -163,20 +200,20 @@ private void NewChatLines(object sender, LogFile.EveChatEventArgs e)
Properties.Settings.Default.Reload();
}
}

if(string.IsNullOrWhiteSpace(Properties.Settings.Default.SoundFilePath) || Properties.Settings.Default.ShowNotification)
{
if((DateTime.Now - lastNotified).TotalSeconds > 1)
{
lastNotified = DateTime.Now;
// send notification
notifyIcon.ShowBalloonTip(10000, "[EVE] chat notification", string.Format("[{0}] {1}: {2}", curLog.LogInfo.ChannelName, le.Sender, le.Text), ToolTipIcon.Info);
}
}
}
}
}

private void Notifier_Click(object sender, EventArgs e)
{
try
{
PopupNotifier pn = (PopupNotifier)sender;
pn.Hide();
}
catch { }
}

private void Wp_PlaybackStopped(object sender, NAudio.Wave.StoppedEventArgs e)
{
isPlaying = false;
Expand All @@ -197,18 +234,29 @@ private void FormMain_Resize(object sender, EventArgs e)
{
if(this.WindowState == FormWindowState.Minimized)
{
notifyIcon.Visible = true;
//notifyIcon.Visible = true;
this.Hide();
}
else
{
notifyIcon.Visible = false;
//notifyIcon.Visible = false;
}
}

private void notifyIcon_DoubleClick(object sender, EventArgs e)
{
this.Show();
try
{
this.WindowState = FormWindowState.Normal;
}
catch { }
try
{
this.Focus();
}
catch { }

//this.Focus();
//this.TopMost = true;
//this.TopMost = false;
Expand Down
4 changes: 2 additions & 2 deletions EveChatNotifier/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.3.3.0")]
[assembly: AssemblyFileVersion("1.3.3.0")]
[assembly: AssemblyVersion("1.3.4.0")]
[assembly: AssemblyFileVersion("1.3.4.0")]
66 changes: 34 additions & 32 deletions EveChatNotifier/Properties/Resources.Designer.cs

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

17 changes: 12 additions & 5 deletions EveChatNotifier/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
Expand All @@ -60,6 +60,7 @@
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
Expand All @@ -68,9 +69,10 @@
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
Expand All @@ -85,9 +87,10 @@
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
Expand All @@ -109,9 +112,13 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="eve_logo_landing2" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\eve-logo-landing2.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
Binary file added EveChatNotifier/Resources/eve-logo-landing2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions EveChatNotifier/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NAudio" version="1.8.2" targetFramework="net40" />
<package id="Tulpep.NotificationWindow" version="1.1.23" targetFramework="net40" />
</packages>

0 comments on commit 576828e

Please sign in to comment.