示例#1
0
        public NewStartPage()
        {
            InitializeComponent();
            DoubleBuffered = true;

            if (!DesignMode)
            {
                pnlVersion.Hide();

                // Check for new version on GitHub in a background thread.
                // If a newer version is found make pnlVersion visible
                VersionChecker.NewVersionFound += (sender, e) => pnlVersion.Show();
                VersionChecker.CheckForNewVersion();

                _remoteServers = RemoteServer.CreateListFromSettings();

                InitServerFilterCombo();

                try
                {
                    // Try to make the SplitContainer double buffered to reduce flicker.
                    var propInfo = typeof(SplitContainer).GetProperty("DoubleBuffered", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
                    propInfo.SetValue(splitContainer1, true, null);
                }
                catch (Exception ex)
                {
                    // Not that important.  Probably never happens.
                    Debug.Write(ex);
                }

                Settings.Default.PropertyChanged += SettingsPropertyChanged;

                _refreshTimer.Tick    += new EventHandler(_refreshTimer_Tick);
                _refreshTimer.Interval = 2000;
            }
        }
示例#2
0
        private void TestConnection(ServerListItem item)
        {
            var remoteServer = new RemoteServer(item.Server);

            item.TestConnectionResult = remoteServer.TestConnection();

            if (this.IsHandleCreated)
            {
                try
                {
                    Invoke(new Action(() => ShowTestResult(item)));
                }
                catch (Exception ex)
                {
                    // User probably closed the form.
                    Debug.WriteLine("Exception: {0}", ex);
                }
            }
            else
            {
                // User probably closed the form.
                Debug.WriteLine("Form has no handle.");
            }
        }
示例#3
0
 private void RefreshGrids(RemoteServer newServer)
 {
     filesGrid.AddOrUpdatePaths(newServer.Files);
     foldersGrid.AddOrUpdatePaths(newServer.Folders);
 }
示例#4
0
        private void SetCurServer(RemoteServer newServer)
        {
            using (Log.InfoCall())
            {
                Log.Info("newServer = ", newServer, "_curServer = ", _curServer);

                if (newServer != _curServer)
                {
                    Log.Info("Setting _curServer to ", newServer);

                    if (newServer == _localHost)
                    {
                        ClearAllPaths();
                        SetPathsAreLocal(true);
                        StartLocalFileWatch(forceSetPaths: true);
                    }
                    else
                    {
                        Cursor originalCursor = this.Cursor;
                        this.Cursor = Cursors.WaitCursor;

                        StopLocalFileWatch();
                        ClearAllPaths();
                        SetPathsAreLocal(false);

                        DialogResult dr = DialogResult.Yes;

                        // Retry connecting to the server while dr == Yes.

                        while (dr == DialogResult.Yes)
                        {
                            Application.DoEvents();

                            try
                            {
                                // newServer.Refresh() is likely to throw an exception because it performs
                                // WCF calls to the TracerX-Service on the remote host.

                                Log.Info("Connecting to server ", newServer);
                                newServer.Refresh();
                                RefreshGrids(newServer);
                                break;
                            }
                            catch (Exception ex)
                            {
                                // Display an error message including the exception and inner
                                // exception messages.  If the exception is about bad credentials
                                // and failed logon, ask the user if he wants to specify new
                                // credentials for the server.

                                Log.Warn("Exception getting files from server ", newServer, ": ", ex);
                                string            msg     = "Error getting file list from server '" + newServer + "'.";
                                MessageBoxButtons buttons = MessageBoxButtons.OK;

                                if (ex is SecurityNegotiationException && ex.InnerException is InvalidCredentialException)
                                {
                                    msg    += "\nWould you like to specify credentials for the connection?";
                                    buttons = MessageBoxButtons.YesNo;
                                }

                                while (ex != null)
                                {
                                    msg += "\n\n" + ex.Message;
                                    ex   = ex.InnerException;
                                }

                                dr = MainForm.ShowMessageBoxBtns(msg, buttons);

                                if (dr == DialogResult.Yes)
                                {
                                    var credDlg = new CredentialsDialog();

                                    credDlg.UserID = newServer.UserId;
                                    credDlg.PW     = newServer.PW;

                                    if (credDlg.ShowDialog() == DialogResult.OK)
                                    {
                                        newServer.UserId = credDlg.UserID;

                                        if (credDlg.UserID == "")
                                        {
                                            newServer.PW = null;
                                        }
                                        else
                                        {
                                            newServer.PW = credDlg.PW;
                                        }

                                        serverTree1.SaveRemoteServers();
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }
                            }
                        }

                        this.Cursor = originalCursor;
                    }

                    filesGrid.RemoteServer   = newServer;
                    foldersGrid.RemoteServer = newServer;
                    _curServer = newServer;
                    OnServerChanged();
                }
            }
        }
示例#5
0
        protected override void OnLoad(EventArgs e)
        {
            using (Log.InfoCall())
            {
                base.OnLoad(e);
                InitColors();

                if (AppArgs.ServerName == null)
                {
                    ShowServerPane(Settings.Default.ShowServers, _localHost);
                }
                else
                {
                    // Search first for a matching display name then for a matching "address". If not found create a new one.

                    RemoteServer firstServer = _remoteServers.FirstOrDefault(remsvr => remsvr.HostName.ToLower() == AppArgs.ServerName.ToLower());

                    if (firstServer == null)
                    {
                        firstServer = _remoteServers.FirstOrDefault(remsvr => remsvr.HostAddress.ToLower() == AppArgs.ServerName.ToLower());

                        if (firstServer == null)
                        {
                            // Create a new RemoteServer from the given AppArgs.ServerName.

                            firstServer = new RemoteServer(AppArgs.ServerName);
                            _remoteServers.Add(firstServer);

                            // Call ShowServerPane() with doShow:true to force it to show the server pane and populate it with _remoteServers so
                            //  1) the server we just added will be visible (and if necessary editable) and
                            //  2) we can call SaveRemoteServers() to save the list with the new server.

                            ShowServerPane(doShow: true, serverToSelect: firstServer);

                            // Save the list of servers because we just added one.

                            serverTree1.SaveRemoteServers();
                        }
                        else
                        {
                            ShowServerPane(doShow: true, serverToSelect: firstServer);
                        }
                    }
                    else
                    {
                        ShowServerPane(doShow: true, serverToSelect: firstServer);
                    }
                }

                if (AppArgs.FilePath != null)
                {
                    // This means a file path was specified in the command line args.  Pretend the
                    // user user clicked the file so the event handler will attempt to read it.

                    ClickedPath = AppArgs.FilePath;
                    FileClicked(this, EventArgs.Empty);
                }

                //filesGrid.ArchiveVisibility = Settings.Default.ShowViewedArchives ? ArchiveVisibility.ViewedArchives : ArchiveVisibility.NoArchives;
                //filesGrid.ShowTimesAgo = Settings.Default.ShowFileTimesAgo;
                //foldersGrid.ShowTimesAgo = Settings.Default.ShowFolderTimesAgo;
            }
        }