diff --git a/ATxTray/AutoTxTray.cs b/ATxTray/AutoTxTray.cs index c07d3773c87cc3303f94ee699da9ba114e487086..0bd82b4fa390f42e37de799dc9508414be37a6ea 100644 --- a/ATxTray/AutoTxTray.cs +++ b/ATxTray/AutoTxTray.cs @@ -36,6 +36,7 @@ namespace ATxTray private static bool _txInProgress = false; private static long _txSize; + private static int _txProgressPct; private readonly NotifyIcon _notifyIcon = new NotifyIcon(); private readonly Icon _tiDefault = new Icon("icon-default.ico"); @@ -51,6 +52,8 @@ namespace ATxTray private readonly ToolStripMenuItem _miTxProgress = new ToolStripMenuItem(); private readonly ToolStripMenuItem _miTxEnqueue = new ToolStripMenuItem(); + private readonly ToolStripProgressBar _miTxProgressBar = new ToolStripProgressBar(); + public AutoTxTray() { #region logging configuration @@ -129,11 +132,19 @@ namespace ATxTray _miTxEnqueue.Text = @"+++ Add new directory for transfer. +++"; _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[] { _miTitle, _miSvcRunning, _miSvcSuspended, _miTxProgress, + _miTxProgressBar, new ToolStripSeparator(), _miTxEnqueue, new ToolStripSeparator(), @@ -225,7 +236,7 @@ namespace ATxTray if (age == _statusAge) return; - Log.Debug("Status file was updated, trying to re-read..."); + Log.Trace("Status file was updated, trying to re-read..."); _statusAge = age; _status = ServiceStatus.Deserialize(StatusFile, _config); } @@ -292,12 +303,14 @@ namespace ATxTray private void UpdateTxInProgress() { if (_txInProgress == _status.TransferInProgress && - _txSize == _status.CurrentTransferSize) + _txSize == _status.CurrentTransferSize && + _txProgressPct == _status.CurrentTransferPercent) return; _statusChanged = true; _txInProgress = _status.TransferInProgress; _txSize = _status.CurrentTransferSize; + _txProgressPct = _status.CurrentTransferPercent; if (_txInProgress) { _miTxProgress.Text = @"Transfer in progress (size: " + Conv.BytesToString(_txSize) + ")"; @@ -305,11 +318,17 @@ namespace ATxTray _notifyIcon.ShowBalloonTip(500, AppTitle, "New transfer started (size: " + Conv.BytesToString(_txSize) + ").", ToolTipIcon.Info); + Log.Debug("Transfer progress: {0}%", _txProgressPct); + _miTxProgressBar.Visible = true; + _miTxProgressBar.Value = _txProgressPct; + _miTxProgressBar.Text = _txProgressPct.ToString(); } else { _miTxProgress.Text = @"No transfer running."; _miTxProgress.ResetBackColor(); _notifyIcon.ShowBalloonTip(500, AppTitle, - "Transfer completed.", ToolTipIcon.Info); + "Transfer completed.", ToolTipIcon.Info); + _miTxProgressBar.Value = 0; + _miTxProgressBar.Visible = false; } }