void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
     switch (connectionId)
     {
     case 1:
     this.ircConnectionDialog1 = ((HypeBotCSharp.IrcConnectionDialog)(target));
     return;
     case 2:
     this.ircConnectHostTextBox = ((System.Windows.Controls.TextBox)(target));
     
     #line 18 "..\..\IrcConnectionDialog.xaml"
     this.ircConnectHostTextBox.GotFocus += new System.Windows.RoutedEventHandler(this.ircConnectHostTextBox_GotFocus);
     
     #line default
     #line hidden
     
     #line 18 "..\..\IrcConnectionDialog.xaml"
     this.ircConnectHostTextBox.LostFocus += new System.Windows.RoutedEventHandler(this.ircConnectHostTextBox_LostFocus);
     
     #line default
     #line hidden
     return;
     case 3:
     this.label = ((System.Windows.Controls.Label)(target));
     return;
     case 4:
     this.ircConnectNickTextBox = ((System.Windows.Controls.TextBox)(target));
     
     #line 20 "..\..\IrcConnectionDialog.xaml"
     this.ircConnectNickTextBox.GotFocus += new System.Windows.RoutedEventHandler(this.ircConnectNickTextBox_GotFocus);
     
     #line default
     #line hidden
     
     #line 20 "..\..\IrcConnectionDialog.xaml"
     this.ircConnectNickTextBox.LostFocus += new System.Windows.RoutedEventHandler(this.ircConnectNickTextBox_LostFocus);
     
     #line default
     #line hidden
     return;
     case 5:
     this.ircConnectUserTextBox = ((System.Windows.Controls.TextBox)(target));
     
     #line 21 "..\..\IrcConnectionDialog.xaml"
     this.ircConnectUserTextBox.GotFocus += new System.Windows.RoutedEventHandler(this.ircConnectUserTextBox_GotFocus);
     
     #line default
     #line hidden
     
     #line 21 "..\..\IrcConnectionDialog.xaml"
     this.ircConnectUserTextBox.LostFocus += new System.Windows.RoutedEventHandler(this.ircConnectUserTextBox_LostFocus);
     
     #line default
     #line hidden
     return;
     case 6:
     this.ircConnectUsePassCheckBox = ((System.Windows.Controls.CheckBox)(target));
     
     #line 22 "..\..\IrcConnectionDialog.xaml"
     this.ircConnectUsePassCheckBox.Checked += new System.Windows.RoutedEventHandler(this.ircConnectUsePassCheckBox_Checked);
     
     #line default
     #line hidden
     
     #line 22 "..\..\IrcConnectionDialog.xaml"
     this.ircConnectUsePassCheckBox.Unchecked += new System.Windows.RoutedEventHandler(this.ircConnectUsePassCheckBox_Unchecked);
     
     #line default
     #line hidden
     return;
     case 7:
     this.ircConnectPassTextBox = ((System.Windows.Controls.TextBox)(target));
     
     #line 23 "..\..\IrcConnectionDialog.xaml"
     this.ircConnectPassTextBox.GotFocus += new System.Windows.RoutedEventHandler(this.ircConnectPassTextBox_GotFocus);
     
     #line default
     #line hidden
     
     #line 23 "..\..\IrcConnectionDialog.xaml"
     this.ircConnectPassTextBox.LostFocus += new System.Windows.RoutedEventHandler(this.ircConnectPassTextBox_LostFocus);
     
     #line default
     #line hidden
     return;
     case 8:
     this.ircConnectSubmitButton = ((System.Windows.Controls.Button)(target));
     
     #line 24 "..\..\IrcConnectionDialog.xaml"
     this.ircConnectSubmitButton.Click += new System.Windows.RoutedEventHandler(this.ircConnectSubmitButton_Click);
     
     #line default
     #line hidden
     return;
     }
     this._contentLoaded = true;
 }
        private void mainWindowMenuSetupDropDownConnectButton_Click(object sender, RoutedEventArgs e)
        {
            IrcConnectionDialog ircConnectResult = new IrcConnectionDialog();
            ircConnectResult.ShowDialog();

            // Handle connection info dialog
            if (ircConnectResult != null)
            {
                ircConnectResult.Close();
            }

            // Check for full information entry
            if (ircNick == "" || ircUser == "" || ircHostname == "" || ircNick == null || ircUser == null || ircHostname == null)
            {
                // User did not enter full information; do not attempt to connect
                appendErrorText(botOutputBox, "Please enter all required fields (Host, nick, user)\r");
                return;
            }

            botOutputBox.Document.Blocks.Clear();
            if (ircUsePass)
            {
                ircConnectionUser = new IrcUser(ircNick, ircUser, ircPass);
            }
            else
            {
                ircConnectionUser = new IrcUser(ircNick, ircUser);
            }

            if (UtilFunc.IsHostnameValid(ircHostname))
            {
                // Provided hostname is valid, continue
                ircClient = new IrcClient(ircHostname, ircConnectionUser);
            }
            else
            {
                // Provided hostname is not valid, stop and inform user
                appendErrorText(botOutputBox, "Please enter a valid IRC server hostname!\r");
                return;
            }

            ircClient.ConnectionComplete += (s, e2) =>
            {
                asyncOutputBoxAppend(botOutputBox, "Connection Completed");
                isIrcConnected = true;
                asyncElementSetEnabled(mainWindowMenuSetupDropDownConnectButton, false);
                asyncElementSetEnabled(mainWindowMenuDestroyDropDownIrcButton, true);
            };

            ircClient.PrivateMessageRecieved += (s, channelMessageReceivedEventArgs) => handleMessage(channelMessageReceivedEventArgs);

            ircClient.RawMessageRecieved += (s, messageReceivedEventArgs) => {
                if (messageReceivedEventArgs.Message.Contains("PRIVMSG"))
                {
                    // Message is a private message
                    // Ignore, message will be handled by Private Message code
                    return;
                }
                else
                {
                    asyncOutputBoxAppend(botOutputBox, "    " + messageReceivedEventArgs.Message.ToString());
                }
            };

            try
            {
                ircClient.ConnectAsync();
            }
            catch (SocketException connectionError)
            {
                appendErrorText(botOutputBox, "Something went wrong. Error:\r");
                appendErrorText(botOutputBox, connectionError.Message + "\r");
                appendErrorText(botOutputBox, "Please try with a different IRC server.\r");
            }
        }