Skip to content

Commit

Permalink
Added: Open Log Directory functionality bujocek#19
Browse files Browse the repository at this point in the history
Added a context menu to the notify icon with options to open log directory and quit the application
  • Loading branch information
NikTheWin committed Feb 8, 2018
1 parent 64edd52 commit 2f411a5
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 10 deletions.
61 changes: 51 additions & 10 deletions LyncIMLocalHistory/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ Jonas Bujok
private const int BALLOON_POPUP_TIMEOUT_MS = 3000;
private const int KEEP_ALIVE_INTERVAL_MS = 5000;
private const int CONNECT_RETRY_WAIT_TIME_MS = 5000;
private ContextMenuStrip notifyIconContextMenu;
private ToolStripMenuItem MenuItemOpenLogDir;
private ToolStripMenuItem MenuItemQuit;
private const int CONNECT_RETRY_MAX = -1; // -1 to retry indefinitely


Expand Down Expand Up @@ -293,6 +296,10 @@ private void InitializeComponent()
this.textBox1 = new System.Windows.Forms.TextBox();
this.consoleBox = new System.Windows.Forms.TextBox();
this.notifyIcon = new System.Windows.Forms.NotifyIcon(this.components);
this.notifyIconContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
this.MenuItemOpenLogDir = new System.Windows.Forms.ToolStripMenuItem();
this.MenuItemQuit = new System.Windows.Forms.ToolStripMenuItem();
this.notifyIconContextMenu.SuspendLayout();
this.SuspendLayout();
//
// textBox1
Expand Down Expand Up @@ -323,6 +330,37 @@ private void InitializeComponent()
this.consoleBox.TabIndex = 1;
this.consoleBox.TabStop = false;
//
// notifyIcon
//
this.notifyIcon.BalloonTipIcon = System.Windows.Forms.ToolTipIcon.Info;
this.notifyIcon.BalloonTipText = "Lync history minimized";
this.notifyIcon.BalloonTipTitle = "Lync history";
this.notifyIcon.MouseDoubleClick += notifyIcon_MouseDoubleClick;
this.notifyIcon.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.notifyIcon.Text = "Lync history recorder";
//
// notifyIconContextMenu
//
this.notifyIconContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.MenuItemOpenLogDir,
this.MenuItemQuit});
this.notifyIconContextMenu.Name = "notifyIconContextMenu";
this.notifyIconContextMenu.Size = new System.Drawing.Size(178, 70);
//
// MenuItemOpenLogDir
//
this.MenuItemOpenLogDir.Name = "MenuItemOpenLogDir";
this.MenuItemOpenLogDir.Size = new System.Drawing.Size(177, 22);
this.MenuItemOpenLogDir.Text = "Open Log Directory";
this.MenuItemOpenLogDir.Click += new System.EventHandler(this.MenuItemOpenLogDir_Click);
//
// MenuItemQuit
//
this.MenuItemQuit.Name = "MenuItemQuit";
this.MenuItemQuit.Size = new System.Drawing.Size(177, 22);
this.MenuItemQuit.Text = "Quit";
this.MenuItemQuit.Click += new System.EventHandler(this.MenuItemQuit_Click);
//
// Program
//
this.ClientSize = new System.Drawing.Size(471, 384);
Expand All @@ -331,16 +369,7 @@ private void InitializeComponent()
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "Program";
this.Text = "Lync IM Local History";
//
// notifyIcon
//
this.notifyIcon.BalloonTipIcon = System.Windows.Forms.ToolTipIcon.Info; //Shows the info icon so the user doesn't thing there is an error.
this.notifyIcon.BalloonTipText = "Lync history minimized";
this.notifyIcon.BalloonTipTitle = "Lync history";
this.notifyIcon.Icon = this.Icon; //The tray icon to use
this.notifyIcon.Text = "Lync history recorder";
this.notifyIcon.DoubleClick += notifyIcon_MouseDoubleClick;

this.notifyIconContextMenu.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();

Expand All @@ -354,6 +383,8 @@ private void Form_Resize(object sender, EventArgs e)
notifyIcon.BalloonTipText = "Lync history minimized";
notifyIcon.ShowBalloonTip(BALLOON_POPUP_TIMEOUT_MS);
this.ShowInTaskbar = false;

notifyIcon.ContextMenuStrip = notifyIconContextMenu;
}
}

Expand All @@ -363,6 +394,16 @@ private void notifyIcon_MouseDoubleClick(object sender, EventArgs e)
this.ShowInTaskbar = true;
notifyIcon.Visible = false;
}

private void MenuItemOpenLogDir_Click(object sender, EventArgs e)
{
Process.Start(mydocpath + programFolder);
}

private void MenuItemQuit_Click(object sender, EventArgs e)
{
this.Close();
}
}

class ConversationContainer
Expand Down
3 changes: 3 additions & 0 deletions LyncIMLocalHistory/Program.resx
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@
<metadata name="notifyIcon.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="notifyIconContextMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>123, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
Expand Down

0 comments on commit 2f411a5

Please sign in to comment.