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

Add a progress bar to the context menu.

NOTE: currently any update to the progress bar will also re-display the
balloon tooltip. These two things should be separated!

Refers to #2
parent 07325fec
No related branches found
No related tags found
No related merge requests found
...@@ -36,6 +36,7 @@ namespace ATxTray ...@@ -36,6 +36,7 @@ namespace ATxTray
private static bool _txInProgress = false; private static bool _txInProgress = false;
private static long _txSize; private static long _txSize;
private static int _txProgressPct;
private readonly NotifyIcon _notifyIcon = new NotifyIcon(); private readonly NotifyIcon _notifyIcon = new NotifyIcon();
private readonly Icon _tiDefault = new Icon("icon-default.ico"); private readonly Icon _tiDefault = new Icon("icon-default.ico");
...@@ -51,6 +52,8 @@ namespace ATxTray ...@@ -51,6 +52,8 @@ namespace ATxTray
private readonly ToolStripMenuItem _miTxProgress = new ToolStripMenuItem(); private readonly ToolStripMenuItem _miTxProgress = new ToolStripMenuItem();
private readonly ToolStripMenuItem _miTxEnqueue = new ToolStripMenuItem(); private readonly ToolStripMenuItem _miTxEnqueue = new ToolStripMenuItem();
private readonly ToolStripProgressBar _miTxProgressBar = new ToolStripProgressBar();
public AutoTxTray() { public AutoTxTray() {
#region logging configuration #region logging configuration
...@@ -129,11 +132,19 @@ namespace ATxTray ...@@ -129,11 +132,19 @@ namespace ATxTray
_miTxEnqueue.Text = @"+++ Add new directory for transfer. +++"; _miTxEnqueue.Text = @"+++ Add new directory for transfer. +++";
_miTxEnqueue.Click += StartNewTransfer; _miTxEnqueue.Click += StartNewTransfer;
_miTxProgressBar.Text = @"Current Transfer Progress";
_miTxProgressBar.ToolTipText = _miTxProgressBar.Text;
_miTxProgressBar.Value = 0;
var size = _miTxProgressBar.Size;
size.Width = 300;
_miTxProgressBar.Size = size;
_cmStrip.Items.AddRange(new ToolStripItem[] { _cmStrip.Items.AddRange(new ToolStripItem[] {
_miTitle, _miTitle,
_miSvcRunning, _miSvcRunning,
_miSvcSuspended, _miSvcSuspended,
_miTxProgress, _miTxProgress,
_miTxProgressBar,
new ToolStripSeparator(), new ToolStripSeparator(),
_miTxEnqueue, _miTxEnqueue,
new ToolStripSeparator(), new ToolStripSeparator(),
...@@ -225,7 +236,7 @@ namespace ATxTray ...@@ -225,7 +236,7 @@ namespace ATxTray
if (age == _statusAge) if (age == _statusAge)
return; return;
Log.Debug("Status file was updated, trying to re-read..."); Log.Trace("Status file was updated, trying to re-read...");
_statusAge = age; _statusAge = age;
_status = ServiceStatus.Deserialize(StatusFile, _config); _status = ServiceStatus.Deserialize(StatusFile, _config);
} }
...@@ -292,12 +303,14 @@ namespace ATxTray ...@@ -292,12 +303,14 @@ namespace ATxTray
private void UpdateTxInProgress() { private void UpdateTxInProgress() {
if (_txInProgress == _status.TransferInProgress && if (_txInProgress == _status.TransferInProgress &&
_txSize == _status.CurrentTransferSize) _txSize == _status.CurrentTransferSize &&
_txProgressPct == _status.CurrentTransferPercent)
return; return;
_statusChanged = true; _statusChanged = true;
_txInProgress = _status.TransferInProgress; _txInProgress = _status.TransferInProgress;
_txSize = _status.CurrentTransferSize; _txSize = _status.CurrentTransferSize;
_txProgressPct = _status.CurrentTransferPercent;
if (_txInProgress) { if (_txInProgress) {
_miTxProgress.Text = @"Transfer in progress (size: " + _miTxProgress.Text = @"Transfer in progress (size: " +
Conv.BytesToString(_txSize) + ")"; Conv.BytesToString(_txSize) + ")";
...@@ -305,11 +318,17 @@ namespace ATxTray ...@@ -305,11 +318,17 @@ namespace ATxTray
_notifyIcon.ShowBalloonTip(500, AppTitle, _notifyIcon.ShowBalloonTip(500, AppTitle,
"New transfer started (size: " + "New transfer started (size: " +
Conv.BytesToString(_txSize) + ").", ToolTipIcon.Info); Conv.BytesToString(_txSize) + ").", ToolTipIcon.Info);
Log.Debug("Transfer progress: {0}%", _txProgressPct);
_miTxProgressBar.Visible = true;
_miTxProgressBar.Value = _txProgressPct;
_miTxProgressBar.Text = _txProgressPct.ToString();
} else { } else {
_miTxProgress.Text = @"No transfer running."; _miTxProgress.Text = @"No transfer running.";
_miTxProgress.ResetBackColor(); _miTxProgress.ResetBackColor();
_notifyIcon.ShowBalloonTip(500, AppTitle, _notifyIcon.ShowBalloonTip(500, AppTitle,
"Transfer completed.", ToolTipIcon.Info); "Transfer completed.", ToolTipIcon.Info);
_miTxProgressBar.Value = 0;
_miTxProgressBar.Visible = false;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment