Esempio n. 1
0
        private void fMain_Load(object sender, EventArgs e)
        {
            NetworkChange.NetworkAddressChanged += OnNetworkChange;

            //TODO: Should this stay?
            Program.Account.LoadLocalFolders();
            Load_Recent();

            if (!Log.DebugEnabled && Settings.General.EnableLogging)
                Log.DebugEnabled = true;

            Notifications.NotificationReady += (o, n) =>
                {
                    link = Program.Account.LinkToRecent();
                    tray.ShowBalloonTip(100, "FTPbox", n.Text, ToolTipIcon.Info);
                };

            Program.Account.FileLog.FileLogChanged += (o, n) => Load_Recent();

            Program.Account.Client.ConnectionClosed += (o, n) => Log.Write(l.Warning, "Connection closed: {0}", n.Text ?? string.Empty);

            Program.Account.Client.ReconnectingFailed += (o, n) => Log.Write(l.Warning, "Reconnecting failed"); //TODO: Use this...

            Program.Account.Client.ValidateCertificate += CheckCertificate;

            Program.Account.WebInterface.UpdateFound += (o, n) =>
                {
                    const string msg = "A new version of the web interface is available, do you want to upgrade to it?";
                    if (MessageBox.Show(msg, "FTPbox - WebUI Update", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                    {
                        Program.Account.WebInterface.UpdatePending = true;
                        Program.Account.WebInterface.Update();
                    }
                };
            Program.Account.WebInterface.InterfaceRemoved += (o, n) =>
                {
                    chkWebInt.Enabled = true;
                    labViewInBrowser.Enabled = false;
                    link = string.Empty;
                };
            Program.Account.WebInterface.InterfaceUploaded += (o, n) =>
                {
                    chkWebInt.Enabled = true;
                    labViewInBrowser.Enabled = true;
                    link = Program.Account.WebInterfaceLink;
                };

            Notifications.TrayTextNotification += (o,n) => this.Invoke(new MethodInvoker(() => SetTray(o,n)));

            Program.Account.Client.TransferProgress += (o, n) =>
            {
                // Only when Downloading/Uploading.
                if (string.IsNullOrWhiteSpace(_lastTrayStatus.AssossiatedFile)) return;
                // Update tray text.
                this.Invoke(new MethodInvoker(() =>
                    {
                        SetTray(null, _lastTrayStatus);
                        // Append progress details in a new line
                        tray.Text += string.Format("\n{0,3}% - {1}", n.Progress, n.Rate);
                    }));
            };
            fSetup = new Setup {Tag = this};
            ftranslate = new Translate {Tag = this};
            fSelective = new fSelectiveSync();

            if (!string.IsNullOrEmpty(Settings.General.Language))
                Set_Language(Settings.General.Language);

            StartUpWork();

            CheckForUpdate();
        }
Esempio n. 2
0
        private void fMain_Load(object sender, EventArgs e)
        {
            NetworkChange.NetworkAddressChanged += OnNetworkChange;

            //TODO: Should this stay?
            Program.Account.LoadLocalFolders();

            if (!Log.DebugEnabled && Settings.General.EnableLogging)
                Log.DebugEnabled = true;

            Notifications.NotificationReady += (o, n) =>
            {
                Link = Program.Account.LinkToRecent();
                tray.ShowBalloonTip(100, n.Title, n.Text, ToolTipIcon.Info);
            };

            Program.Account.Client.ConnectionClosed +=
                (o, n) => Log.Write(l.Warning, "Connection closed: {0}", n.Text ?? string.Empty);

            Program.Account.Client.ReconnectingFailed += (o, n) => Log.Write(l.Warning, "Reconnecting failed");
            //TODO: Use this...

            Program.Account.Client.ValidateCertificate += CheckCertificate;

            Program.Account.WebInterface.UpdateFound += (o, n) =>
            {
                const string msg = "A new version of the web interface is available, do you want to upgrade to it?";
                if (
                    MessageBox.Show(msg, "FTPbox - WebUI Update", MessageBoxButtons.YesNo, MessageBoxIcon.Information) ==
                    DialogResult.Yes)
                {
                    Program.Account.WebInterface.UpdatePending = true;
                    Program.Account.WebInterface.Update();
                }
            };
            Program.Account.WebInterface.InterfaceRemoved += (o, n) =>
            {
                Invoke(new MethodInvoker(() =>
                {
                    chkWebInt.Enabled = true;
                    labViewInBrowser.Enabled = false;
                }));
                Link = string.Empty;
            };
            Program.Account.WebInterface.InterfaceUploaded += (o, n) =>
            {
                Invoke(new MethodInvoker(() =>
                {
                    chkWebInt.Enabled = true;
                    labViewInBrowser.Enabled = true;
                }));
                Link = Program.Account.WebInterfaceLink;
            };

            Notifications.TrayTextNotification += (o, n) => Invoke(new MethodInvoker(() => SetTray(o, n)));

            _fSetup = new Setup {Tag = this};
            _ftranslate = new Translate {Tag = this};
            _fSelective = new fSelectiveSync();
            _fTrayForm = new fTrayForm {Tag = this};

            if (!string.IsNullOrEmpty(Settings.General.Language))
                Set_Language(Settings.General.Language);

            StartUpWork();

            CheckForUpdate();
        }
Esempio n. 3
0
        private async void fMain_Load(object sender, EventArgs e)
        {
            NetworkChange.NetworkAddressChanged += OnNetworkChange;

            //TODO: Should this stay?
            Program.Account.LoadLocalFolders();

            if (!Log.DebugEnabled && Settings.General.EnableLogging)
            {
                Log.DebugEnabled = true;
            }

            Notifications.NotificationReady += (o, n) =>
            {
                Link = Program.Account.LinkToRecent();
                tray.ShowBalloonTip(100, n.Title, n.Text, ToolTipIcon.Info);
            };

            Program.Account.WebInterface.UpdateFound += async(o, n) =>
            {
                const string msg = "A new version of the web interface is available, do you want to upgrade to it?";
                if (
                    MessageBox.Show(msg, "FTPbox - WebUI Update", MessageBoxButtons.YesNo, MessageBoxIcon.Information) ==
                    DialogResult.Yes)
                {
                    Program.Account.WebInterface.UpdatePending = true;
                    await Program.Account.WebInterface.Update();
                }
            };
            Program.Account.WebInterface.InterfaceRemoved += (o, n) =>
            {
                chkWebInt.Enabled        = true;
                labViewInBrowser.Enabled = false;
                Link = string.Empty;
            };
            Program.Account.WebInterface.InterfaceUploaded += (o, n) =>
            {
                chkWebInt.Enabled        = true;
                labViewInBrowser.Enabled = true;
                Link = Program.Account.WebInterfaceLink;
            };

            Notifications.TrayTextNotification += (o, n) => SetTray(o, n);

            _fSetup = new Setup {
                Tag = this
            };
            _ftranslate = new Translate {
                Tag = this
            };
            _fSelective = new fSelectiveSync();

            if (!string.IsNullOrEmpty(Settings.General.Language))
            {
                Set_Language(Settings.General.Language);
            }

            await StartUpWork();

            while (OfflineMode)
            {
                // wait 30 seconds before retrying to connect
                await Task.Delay(30000);

                // retry
                await StartUpWork();
            }

            _fTrayForm = new fTrayForm {
                Tag = this
            };

            CheckForUpdate();

            // Check local folder for changes
            var cpath = Program.Account.GetCommonPath(Program.Account.Paths.Local, true);
            await Program.Account.SyncQueue.Add(
                new SyncQueueItem(Program.Account)
            {
                Item       = new ClientItem(Common._name(cpath), Program.Account.Paths.Local, ClientItemType.Folder),
                ActionType = ChangeAction.changed,
                SyncTo     = SyncTo.Remote
            });

            await ContextMenuManager.RunServer();
        }