Skip to content

Commit 64721ce

Browse files
author
Stefan Ruepp
committed
stop playback if toast closed, notify on first run to enable log move feature
1 parent ef6b580 commit 64721ce

8 files changed

Lines changed: 87 additions & 18 deletions

File tree

EveChatNotifier/FormMain.cs

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ public partial class FormMain : Form
1818
{
1919
private Timer t = new Timer();
2020
private List<LogFile> _LogFiles = new List<LogFile>();
21-
private static bool isPlaying = false;
2221
private DateTime lastNotified = DateTime.Now;
2322
private PopupNotifier Notifier = new PopupNotifier();
2423
private Settings _Settings = null;
24+
private IWavePlayer wp = new WaveOut();
2525

2626
private string PathEveChatLogs;
2727
private string PathMoveOldLogs;
@@ -56,6 +56,22 @@ public FormMain()
5656
Properties.Settings.Default.Reload();
5757
}
5858

59+
// first launch ask for move logs
60+
if(!Properties.Settings.Default.AskedToMoveLogs)
61+
{
62+
if(!Properties.Settings.Default.MoveOldLogs)
63+
{
64+
if (MessageBox.Show(string.Format("Do you want to let the program move your old log files?{0}{0}Moving the log files is a huge performance boost and highly recommended! If you do not move the logs, this program could need a lot of cpu power.{0}{0}This can be enabled/disabled in the settings at any time.", Environment.NewLine), "Activate log moving", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
65+
{
66+
Properties.Settings.Default.MoveOldLogs = true;
67+
}
68+
}
69+
70+
Properties.Settings.Default.AskedToMoveLogs = true;
71+
Properties.Settings.Default.Save();
72+
Properties.Settings.Default.Reload();
73+
}
74+
5975
// set real paths
6076
PathEveChatLogs = PathHelper.DecryptPath(Properties.Settings.Default.EveChatLogsPath);
6177
PathMoveOldLogs = PathHelper.DecryptPath(Properties.Settings.Default.MoveOldLogsPath);
@@ -286,14 +302,11 @@ private void NewChatLines(object sender, LogFile.EveChatEventArgs e)
286302
{
287303
try
288304
{
289-
if(!isPlaying)
305+
if(wp.PlaybackState == PlaybackState.Stopped)
290306
{
291307
// try playing the file
292-
isPlaying = true;
293-
IWavePlayer wp = new WaveOut();
294308
AudioFileReader afr = new AudioFileReader(PathSoundFile);
295309
wp.Init(afr);
296-
wp.PlaybackStopped += Wp_PlaybackStopped;
297310
wp.Play();
298311
}
299312
}
@@ -317,15 +330,22 @@ private void Notifier_Click(object sender, EventArgs e)
317330
{
318331
PopupNotifier pn = (PopupNotifier)sender;
319332
pn.Hide();
333+
334+
try
335+
{
336+
if(wp.PlaybackState != PlaybackState.Stopped)
337+
{
338+
wp.Stop();
339+
}
340+
}
341+
catch (Exception ex)
342+
{
343+
Logging.WriteLine(string.Format("Unable to stop playback of sound file: {0}", ex.ToString()));
344+
}
320345
}
321346
catch { }
322347
}
323348

324-
private void Wp_PlaybackStopped(object sender, NAudio.Wave.StoppedEventArgs e)
325-
{
326-
isPlaying = false;
327-
}
328-
329349
private void notifyIcon_DoubleClick(object sender, EventArgs e)
330350
{
331351
if(_Settings == null)

EveChatNotifier/Properties.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
6+
namespace EveChatNotifier
7+
{
8+
public class GlobalProperties
9+
{
10+
public string SoundFilePath { get; set; }
11+
public string EveChatLogsPath { get; set; }
12+
}
13+
}

EveChatNotifier/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
3333
// übernehmen, indem Sie "*" eingeben:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("2.3.0.0")]
36-
[assembly: AssemblyFileVersion("2.3.0.0")]
35+
[assembly: AssemblyVersion("2.4.0.0")]
36+
[assembly: AssemblyFileVersion("2.4.0.0")]

EveChatNotifier/Properties/Settings.Designer.cs

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

EveChatNotifier/Properties/Settings.settings

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,8 @@
6868
<Setting Name="EveChatLogCheckInterval" Type="System.Int32" Scope="Application">
6969
<Value Profile="(Default)">5</Value>
7070
</Setting>
71+
<Setting Name="AskedToMoveLogs" Type="System.Boolean" Scope="User">
72+
<Value Profile="(Default)">False</Value>
73+
</Setting>
7174
</Settings>
7275
</SettingsFile>

EveChatNotifier/Props/Program.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Text;
6+
7+
namespace EveChatNotifier.Props
8+
9+
{
10+
class Program
11+
{
12+
[System.ComponentModel.DefaultValue(false)]
13+
public bool UseRegex { get; set; }
14+
15+
[System.ComponentModel.DefaultValue(@"\[(?<senddate>(.+))\](?<sender>(.*))\>(?<text>(.*))")]
16+
public string RegexMatch { get; set; }
17+
}
18+
}

EveChatNotifier/Settings.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,32 +139,32 @@ private void fileNotifySound_EnabledChanged(object sender, EventArgs e)
139139

140140
private void lblEveChatLogs_MouseEnter(object sender, EventArgs e)
141141
{
142-
tbHelp.Text = "Path to the folder where all eve chat logs are. These files are going to be monitored.";
142+
tbHelp.Text = "Path to the folder where all eve chat logs are located in. This folder is watched for new logs and each log is monitored by this tool for changes.";
143143
}
144144

145145
private void lblLogFile_MouseEnter(object sender, EventArgs e)
146146
{
147-
tbHelp.Text = "Path to the file this program is writing its logfile into. All actions done by this tool are protocolled in there.";
147+
tbHelp.Text = "Path to the file this program is writing its logfile into. All actions done by this tool are protocolled in there. (You can see all actions in here - even possible errors for support reasons.)";
148148
}
149149

150150
private void lblMoveLogs_MouseEnter(object sender, EventArgs e)
151151
{
152-
tbHelp.Text = "If activated the programm tries to move all eve chat log files to the old folder directory.";
152+
tbHelp.Text = "If activated the programm tries to move all eve chat log files to the old folder directory. Highly recommended to save computer ressources!";
153153
}
154154

155155
private void lblNotifyOption_Enter(object sender, EventArgs e)
156156
{
157-
tbHelp.Text = string.Format("Kind of notification:{0}Toast: Outlook like notification; Sound: only play the sound file; Both: ...", Environment.NewLine);
157+
tbHelp.Text = string.Format("Kind of notification:{0}Toast: Outlook like notification; Sound: only play the sound file; and both", Environment.NewLine);
158158
}
159159

160160
private void lblSoundFile_MouseEnter(object sender, EventArgs e)
161161
{
162-
tbHelp.Text = string.Format("The sound file which should be played. Please keep in mind that this sound should be short because there is no abort function!{0}Supported files are e.g.: mp3, wav, ogg", Environment.NewLine);
162+
tbHelp.Text = string.Format("The sound file which should be played. Keep in mind that as long the playback needs there will be no new notifications!{0}Supported files are e.g.: mp3, wav, ogg", Environment.NewLine);
163163
}
164164

165165
private void lblNotifyKeywords_MouseEnter(object sender, EventArgs e)
166166
{
167-
tbHelp.Text = "Here you can add additional keywords you want to use for notification. Please seperate them using ','! Not case sensitive.";
167+
tbHelp.Text = "Here you can add additional keywords you want to use for notification. Please seperate them using ',' - not case sensitive. (e.g. if you have nickname everyone uses";
168168
}
169169
}
170170
}

EveChatNotifier/app.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
<setting name="MoveOldLogsPath" serializeAs="String">
3535
<value>%DEFAULT_EVEOLDPATH%</value>
3636
</setting>
37+
<setting name="AskedToMoveLogs" serializeAs="String">
38+
<value>False</value>
39+
</setting>
3740
</EveChatNotifier.Properties.Settings>
3841
</userSettings>
3942
<applicationSettings>

0 commit comments

Comments
 (0)