private void addButton_Click(object sender, EventArgs e)
 {
     var bookmark = new Bookmark();
     //TODO: When we add bookmarks we should make the name New Bookmark for the first bookmark.
     //      New Bookmark (2) for the second. New Bookmark (3) for the third.
     bookmark.Name = "New Bookmark";
     BookmarkManager.AddBookmark(bookmark, false);
     selectedBookmark = bookmark;
     PopulateList();
     bookmarkEntryControl.ShowPasswordBox(true);
     bookmarkEntryControl.Focus();
 }
        private void ChangeButtonStatus()
        {
            var buttonsEnabled = true;
            if (bookmarkList.SelectedItems.Count > 0) {
                var bookmark = bookmarkList.SelectedItems[0].Tag as Bookmark;
                selectedBookmark = bookmark;
                bookmarkEntryControl.SetBookmark(bookmark);
            } else {
                selectedBookmark = null;
                bookmarkEntryControl.Clear();
                buttonsEnabled = false;
            }

            connectButton.Enabled = buttonsEnabled;
            saveBookmarkButton.Enabled = buttonsEnabled;
            deleteButton.Enabled = buttonsEnabled;
            bookmarkEntryControl.Enabled = buttonsEnabled;
        }
Beispiel #3
0
 /// <summary>
 /// Connects the client to the server.
 /// </summary>
 public void Connect(Bookmark bookmark)
 {
     try {
         connectionManager.Connect(bookmark);
     } catch (ConnectionException ce) {
         errorController.ReportConnectionExceptionError(ce);
     }
 }
 private void SaveAndSelectBookmark(Bookmark bookmark)
 {
     BookmarkManager.RemoveBookmark(SelectedBookmark);
     BookmarkManager.AddBookmark(bookmark, false);
     SelectedBookmark = bookmark;
 }
 public ErrorMessage(string errorDescription, string solutionIdea, Bookmark bookmark)
 {
     this.errorDescription = errorDescription;
     this.solutionIdea = solutionIdea;
     this.bookmark = bookmark;
 }
Beispiel #6
0
 /// <summary>Call this method to report an error that should be printed to chat window</summary>
 /// <param name="errorDescription"></param>
 /// <param name="solutionIdea"></param>
 /// <param name="bookmark"></param>
 public void OnLoginFailed(string errorDescription, string solutionIdea, Bookmark bookmark)
 {
     var message = new ErrorMessage(errorDescription, solutionIdea, bookmark);
     AppendHTMLToWebBrowser(chatWebBrowser, message);
 }
        /// <summary>
        /// Connect to the Server in the Bookmark using the UserInfo from the
        /// bookmark as well.
        /// </summary>
        /// <param name="bookmark">The info about Server and
        /// UserInformation.</param>
        public void Connect(Bookmark bookmark)
        {
            commandSocket = new SecureSocket();
            commands = new Commands(commandSocket);
            lagHandler = new LagHandler();

            try {
                if (bookmark != null) {
                    commandSocket.MessageReceived += messages.MessageReceived;

                    commandSocket.Connect(bookmark.Server);
                    commands.Hello(bookmark.Server.MachineName, bookmark.Server.ServerPort, bookmark.Server.ServerName);
                    mCurrentBookmark = bookmark;

                    messages.PingReplyEvent += lagHandler.OnPingReceived;
                    commands.PingSentEvent += lagHandler.OnPingSent;
                } else {
                    //TODO: Handle error
                    Debug.WriteLine("CONNECTIONMANAGER -> Connect: Trying to connect to a null bookmark.");
                }
            } catch (ConnectionException ce) {
                ce.Bookmark = bookmark;
                throw (ce);
            }
        }
 /// <summary>
 /// Increases the port number for the server by one, so that it corresponds
 /// to the transfer port.
 /// </summary>
 /// <remarks>
 /// 1.3
 /// -- snip --
 ///
 /// Wired communication takes place over a TCP/IP connection using TLS
 /// [1]. The default port is TCP 2000, but other ports can be used. The
 /// transfer port is the default port incremented by one, or 2001 by
 /// default.
 /// </remarks>
 /// <param name="bookmark">The Bookmark to use as base.</param>
 /// <returns>A new Bookmark.</returns>
 private Bookmark MakeTransferBookmark(Bookmark bookmark)
 {
     var server = new Server(bookmark.Server.ServerPort + 1, bookmark.Server.MachineName, bookmark.Server.ServerName);
     return new Bookmark(server, bookmark.UserInformation);
 }
        /// <summary>Close the TCP connection to the server.</summary>
        public void Disconnect()
        {
            commandSocket.MessageReceived -= messages.MessageReceived;
            messages.PingReplyEvent -= lagHandler.OnPingReceived;
            commands.PingSentEvent -= lagHandler.OnPingSent;

            commandSocket.Disconnect();

            mCurrentBookmark = null;
        }
        /// <summary>Connect to the given bookmark. Note! Dissconnects any current connection.</summary>
        /// <param name="bookmark"></param>
        public void Connect(Bookmark bookmark)
        {
            try {
                //TODO: Probably want to let the user confirm dissconnecting the current connection
                if (Server != null && Server.PublicChat != null) {
                    Disconnect();
                }

                Server = new Server();
                ConnectionManager.Connect(bookmark);

            } catch (ConnectionException ce) {
                Errors.ReportConnectionExceptionError(ce);
            }
        }
 /// <summary>Constructor for error messages</summary>
 /// <param name="errorDescription"></param>
 /// <param name="solutionIdea"></param>
 /// <param name="bookmark"></param>
 public GuiMessageItem(string errorDescription, string solutionIdea,
                       Bookmark bookmark)
 {
     isErrorMessage = true;
     timeStamp = DateTime.Now;
     this.message = errorDescription;
     this.errorDescription = errorDescription;
     this.solutionIdea = solutionIdea;
     this.bookmark = bookmark;
 }