Skip to content
Browse files

Opening a bookmark from the bookmarks menu button in a window that al…

…ready has an active connection will first close the active connection and then open the clicked bookmark, which fixes #24.
  • Loading branch information...
1 parent 15f648f commit c717404f630f12aeb379268a279e31ad0b9575f1 @lstratman committed Jun 27, 2012
Showing with 20 additions and 1 deletion.
  1. +6 −0 ConnectionWindow.cs
  2. +11 −0 Protocols/BaseConnectionForm.cs
  3. +3 −1 Protocols/Rdp/RdpConnectionForm.cs
View
6 ConnectionWindow.cs
@@ -156,6 +156,12 @@ private void PopulateBookmarks(BookmarksFolder currentFolder, ToolStripItemColle
bookmark.DisplayName, new Icon(ConnectionFactory.GetProtocol(bookmark).ProtocolIcon, 16, 16).ToBitmap(),
(object sender, EventArgs e) =>
{
+ if (_connectionForm != null)
+ {
+ _connectionForm.CloseParentFormOnDisconnect = false;
+ _connectionForm.Close();
+ }
+
_connection = bookmark;
Connect();
});
View
11 Protocols/BaseConnectionForm.cs
@@ -8,6 +8,11 @@ namespace EasyConnect.Protocols
{
public abstract class BaseConnectionForm : Form, IConnectionForm
{
+ protected BaseConnectionForm()
+ {
+ CloseParentFormOnDisconnect = true;
+ }
+
public abstract event EventHandler Connected;
public bool IsConnected
@@ -16,6 +21,12 @@ public bool IsConnected
protected set;
}
+ public bool CloseParentFormOnDisconnect
+ {
+ get;
+ set;
+ }
+
public abstract void Connect();
}
View
4 Protocols/Rdp/RdpConnectionForm.cs
@@ -344,7 +344,9 @@ private void _rdpWindow_OnDisconnected(object sender, IMsTscAxEvents_OnDisconnec
MessageBox.Show("Unable to establish connection.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
IsConnected = false;
- ParentForm.Close();
+
+ if (CloseParentFormOnDisconnect)
+ ParentForm.Close();
}
void RdpConnectionForm_GotFocus(object sender, EventArgs e)

0 comments on commit c717404

Please sign in to comment.
Something went wrong with that request. Please try again.