示例#1
0
        public fTrayForm()
        {
            InitializeComponent();

            Notifications.TrayTextNotification += (o, n) =>
            {
                if (IsHandleCreated)
                {
                    this.Invoke(new MethodInvoker(() => SetStatusLabel(n)));
                }
                else
                {
                    _lastStatus = n;
                }
            };
            // Make status label same color as the icons
            lCurrentStatus.ForeColor = Color.FromArgb(105, 105, 105);

            Program.Account.Client.TransferProgress = new Progress <TransferProgress>(n =>
            {
                // Only when Downloading/Uploading.
                if (!IsHandleCreated || string.IsNullOrWhiteSpace(_lastStatus.AssossiatedFile))
                {
                    return;
                }

                // Update item in recent list
                _transferItem.FileStatusLabel = string.Format(_transferItem.SubTitleFormat, n.ProgressFormatted);
            });
        }
示例#2
0
文件: fMain.cs 项目: stlcours/FTPbox
        public void SetTray(object o, TrayTextNotificationArgs e)
        {
            try
            {
                // Save latest tray status
                _lastTrayStatus = e;

                switch (e.MessageType)
                {
                case MessageType.Connecting:
                case MessageType.Reconnecting:
                case MessageType.Syncing:
                    tray.Icon = Resources.syncing;
                    tray.Text = Common.Languages[e.MessageType];
                    break;

                case MessageType.Uploading:
                case MessageType.Downloading:
                    tray.Icon = Resources.syncing;
                    tray.Text = Common.Languages[MessageType.Syncing];
                    break;

                case MessageType.AllSynced:
                case MessageType.Ready:
                    tray.Icon = Resources.AS;
                    tray.Text = Common.Languages[e.MessageType];
                    break;

                case MessageType.Offline:
                case MessageType.Disconnected:
                    tray.Icon = Resources.offline1;
                    tray.Text = Common.Languages[e.MessageType];
                    break;

                case MessageType.Listing:
                    tray.Icon = Resources.AS;
                    tray.Text = (Program.Account.Account.SyncMethod == SyncMethod.Automatic)
                            ? Common.Languages[MessageType.AllSynced]
                            : Common.Languages[MessageType.Listing];
                    break;

                case MessageType.Nothing:
                    tray.Icon = Resources.ftpboxnew;
                    tray.Text = Common.Languages[e.MessageType];
                    break;
                }
            }
            catch (Exception ex)
            {
                ex.LogException();
            }
        }
示例#3
0
        public void SetStatusLabel(object o, TrayTextNotificationArgs e)
        {
            try
            {
                // Save latest status
                _lastStatus = e;

                if (!string.IsNullOrWhiteSpace(e.AssossiatedFile))
                {
                    var name = Common._name(e.AssossiatedFile);

                    var format = Common.Languages[e.MessageType];

                    _transferItem.FileNameLabel   = name;
                    _transferItem.SubTitleFormat  = format;
                    _transferItem.FileStatusLabel = string.Format(format, string.Empty);
                    // Add to top of recent list
                    fRecentList.Controls.Add(_transferItem);
                    fRecentList.Controls.SetChildIndex(_transferItem, 0);
                }

                switch (e.MessageType)
                {
                case MessageType.Uploading:
                case MessageType.Downloading:
                    lCurrentStatus.Text = Common.Languages[MessageType.Syncing];
                    break;

                case MessageType.Listing:
                    lCurrentStatus.Text = (Program.Account.Account.SyncMethod == SyncMethod.Automatic)
                            ? Common.Languages[MessageType.AllSynced]
                            : Common.Languages[MessageType.Listing];
                    break;

                default:
                    lCurrentStatus.Text = Common.Languages[e.MessageType];
                    break;
                }
                // Remove 'FTPbox - ' from the beginning of the label
                if (lCurrentStatus.Text.StartsWith("FTPbox - "))
                {
                    lCurrentStatus.Text = lCurrentStatus.Text.Substring("FTPbox - ".Length);
                }
            }
            catch (Exception ex)
            {
                Common.LogError(ex);
            }
        }
示例#4
0
        public fTrayForm()
        {
            InitializeComponent();

            Notifications.TrayTextNotification += (o, n) =>
            {
                if (IsHandleCreated)
                {
                    Invoke(new MethodInvoker(() => SetStatusLabel(o, n)));
                }
                else
                {
                    _lastStatus = n;
                }
            };
            // Make status label same color as the icons
            lCurrentStatus.ForeColor = Color.FromArgb(105, 105, 105);
        }
示例#5
0
文件: fTrayForm.cs 项目: st4ck/FTPbox
        public void SetStatusLabel(object o, TrayTextNotificationArgs e)
        {
            try
            {
                // Save latest status
                _lastStatus = e;

                if (!string.IsNullOrWhiteSpace(e.AssossiatedFile))
                {
                    var name = Common._name(e.AssossiatedFile);

                    var format = Common.Languages[e.MessageType];

                    _transferItem.FileNameLabel   = name;
                    _transferItem.SubTitleFormat  = format;
                    _transferItem.FileStatusLabel = string.Format(format, string.Empty);
                    // Add to top of recent list
                    fRecentList.Controls.Add(_transferItem);
                    fRecentList.Controls.SetChildIndex(_transferItem, 0);
                }

                switch (e.MessageType)
                {
                case MessageType.Uploading:
                case MessageType.Downloading:
                    lCurrentStatus.Text = Common.Languages[MessageType.Syncing];
                    break;

                case MessageType.Listing:
                    lCurrentStatus.Text = (Program.Account.Account.SyncMethod == SyncMethod.Automatic)
                            ? Common.Languages[MessageType.AllSynced]
                            : Common.Languages[MessageType.Listing];
                    break;

                case MessageType.Size:
                    remoteTotalSize += e.sizeValue;
                    if (remoteTotalSize < 0)
                    {
                        remoteTotalSize = 0;
                    }
                    lSize.Text = Common.Languages[MessageType.Size] + " " + TransferProgressArgs.ConvertSize(remoteTotalSize);
                    break;

                case MessageType.NullSize:
                    remoteTotalSize = 0;
                    lSize.Text      = "";
                    break;

                case MessageType.Scanning:
                    if (e.customString.Length > 40)
                    {
                        e.customString = "..." + e.customString.Substring(e.customString.Length - 40, 40);
                    }
                    lSize.Text = e.customString;
                    break;

                default:
                    lCurrentStatus.Text = Common.Languages[e.MessageType];
                    break;
                }
            }
            catch (Exception ex)
            {
                Common.LogError(ex);
            }
        }