Skip to content
Snippets Groups Projects
Commit 2a450fc7 authored by Niko Ehrenfeuchter's avatar Niko Ehrenfeuchter :keyboard:
Browse files

Add transfer progress information to menu and tooltips.

Refers to #2
parent e8d188c4
No related branches found
No related tags found
No related merge requests found
...@@ -24,6 +24,9 @@ namespace ATXTray ...@@ -24,6 +24,9 @@ namespace ATXTray
private static bool _svcRunning = false; private static bool _svcRunning = false;
private static bool _svcSuspended = true; private static bool _svcSuspended = true;
private static string _svcSuspendReason; private static string _svcSuspendReason;
private static bool _txInProgress = false;
private static long _txSize;
private readonly NotifyIcon _notifyIcon = new NotifyIcon(); private readonly NotifyIcon _notifyIcon = new NotifyIcon();
private readonly ContextMenuStrip _cmStrip = new ContextMenuStrip(); private readonly ContextMenuStrip _cmStrip = new ContextMenuStrip();
...@@ -31,6 +34,7 @@ namespace ATXTray ...@@ -31,6 +34,7 @@ namespace ATXTray
private readonly ToolStripMenuItem _miTitle = new ToolStripMenuItem(); private readonly ToolStripMenuItem _miTitle = new ToolStripMenuItem();
private readonly ToolStripMenuItem _miSvcRunning = new ToolStripMenuItem(); private readonly ToolStripMenuItem _miSvcRunning = new ToolStripMenuItem();
private readonly ToolStripMenuItem _miSvcSuspended = new ToolStripMenuItem(); private readonly ToolStripMenuItem _miSvcSuspended = new ToolStripMenuItem();
private readonly ToolStripMenuItem _miTxProgress = new ToolStripMenuItem();
public AutoTxTray() { public AutoTxTray() {
_notifyIcon.Visible = true; _notifyIcon.Visible = true;
...@@ -66,10 +70,14 @@ namespace ATXTray ...@@ -66,10 +70,14 @@ namespace ATXTray
_miSvcSuspended.Text = @"No limits apply, service active."; _miSvcSuspended.Text = @"No limits apply, service active.";
_miSvcSuspended.Click += ShowContextMenu; _miSvcSuspended.Click += ShowContextMenu;
_miTxProgress.Text = "No transfer running.";
_miTxProgress.Click += ShowContextMenu;
_cmStrip.Items.AddRange(new ToolStripItem[] { _cmStrip.Items.AddRange(new ToolStripItem[] {
_miTitle, _miTitle,
_miSvcRunning, _miSvcRunning,
_miSvcSuspended, _miSvcSuspended,
_miTxProgress,
_miExit _miExit
}); });
...@@ -101,10 +109,11 @@ namespace ATXTray ...@@ -101,10 +109,11 @@ namespace ATXTray
serviceRunning = "OK"; serviceRunning = "OK";
ReadStatus(); ReadStatus();
UpdateSvcSuspended(); UpdateSvcSuspended();
UpdateTxInProgress();
if ((DateTime.Now - _status.LastStatusUpdate).TotalSeconds < 60) if ((DateTime.Now - _status.LastStatusUpdate).TotalSeconds < 60)
heartBeat = "OK"; heartBeat = "OK";
if (_status.TransferInProgress) if (_txInProgress)
txInProgress = "Yes"; txProgress = _txSize.ToString();
} }
if (!_statusChanged) if (!_statusChanged)
...@@ -196,5 +205,26 @@ namespace ATXTray ...@@ -196,5 +205,26 @@ namespace ATXTray
*/ */
} }
} }
private void UpdateTxInProgress() {
if (_txInProgress == _status.TransferInProgress &&
_txSize == _status.CurrentTransferSize)
return;
_statusChanged = true;
_txInProgress = _status.TransferInProgress;
_txSize = _status.CurrentTransferSize;
if (_txInProgress) {
_miTxProgress.Text = @"Transfer in progress (size: " + _txSize + ")";
_miTxProgress.BackColor = Color.LightGreen;
_notifyIcon.ShowBalloonTip(500, AppTitle,
"New transfer started (size: " + _txSize + ").", ToolTipIcon.Info);
} else {
_miTxProgress.Text = @"No transfer running.";
_miTxProgress.ResetBackColor();
_notifyIcon.ShowBalloonTip(500, AppTitle,
"Transfer completed.", ToolTipIcon.Info);
}
}
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment