/// <summary>
        /// Returns a connection info object from the selected fields in the treeview
        /// - also sets the date of last usage
        /// </summary>
        /// <returns></returns>
        private IConnectionInfo GetConnectionFromTreeView()
        {
            if (this.serverTreeview.SelectedItem == null)
            {
                return(null);
            }
            var item    = this.serverTreeview.SelectedItem;
            var vm      = item as TeamProjectViewModel;
            var team    = vm.Team;
            var project = vm.Project;

            if (team != null)
            {
                project = team.ParentProject;
            }
            else if (project != null)
            {
                team = null;
            }

            IConnectionInfo connection = BugReporter.CreateConnectionInfo(this.ServerComboBox.Text.ToUri(), project, team);

            connection.SetLastUsage(DateTime.Now);
            return(connection);
        }
        /// <summary>
        /// Logs the user in and moves to editing server screen.
        /// Forces a configuration change to the saved connection so the server URL is set,
        /// but the team project and team are null
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void NextButton_Click(object sender, RoutedEventArgs e)
        {
            if (InteractionAllowed)
            {
                if (Uri.IsWellFormedUriString(ServerComboBox.Text, UriKind.Absolute))
                {
                    var serverUri = ServerComboBox.Text.ToUri();

                    // block clicking "next" until login request is done
                    ToggleLoading(true);
                    HandleLoginRequest(serverUri, true, () =>
                    {
                        if (BugReporter.IsConnected)
                        {
                            ConfigurationManager.GetDefaultInstance().AppConfig.SavedConnection = BugReporter.CreateConnectionInfo(serverUri, null, null);
                            ChangeStates(States.EditingServer);
                        }
                        else
                        {
                            ToggleLoading(false);
                            ServerComboBox.Focus();
                        }
                    });
                }
                else
                {
                    MessageDialog.Show("URL format is not valid. Example URL: https://accountname.visualstudio.com");
                }
            }
        }