void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.serverControl = ((MailSendWPF.UserControls.ServerControl)(target));
                return;

            case 2:
                this.serverExPander = ((System.Windows.Controls.Expander)(target));
                return;

            case 3:
                this.outerBorder = ((System.Windows.Controls.Border)(target));
                return;

            case 4:
                this.outputStackPanel = ((System.Windows.Controls.StackPanel)(target));
                return;

            case 5:
                this.outerStackPanel = ((System.Windows.Controls.StackPanel)(target));
                return;

            case 6:
                this.startMailPanel1 = ((MailSendWPF.UserControls.StartMailPanel)(target));
                return;

            case 7:
                this.resToMailPanel1 = ((MailSendWPF.UserControls.ResToMailPanel)(target));
                return;

            case 8:
                this.mailsPanel = ((MailSendWPF.UserControls.MailsPanel)(target));
                return;

            case 9:
                this.mailingOutput = ((System.Windows.Controls.ListBox)(target));
                return;

            case 10:
                this.statusBar = ((System.Windows.Controls.Primitives.StatusBar)(target));
                return;

            case 11:
                this.txtStatus = ((System.Windows.Controls.TextBox)(target));
                return;
            }
            this._contentLoaded = true;
        }
        public void MailSendHandler(object sender, RoutedEventArgs e)
        {
            lock (startSemaphore)
            {
                StartMailPanel startMailPanel = null;
                if (sender is StartMailPanel)
                {
                    startMailPanel = (StartMailPanel)sender;
                }
                MainWindow    tempWin           = (MainWindow)Application.Current.MainWindow;
                ServerControl tempServerControl = tempWin.GetServerControl(startMailPanel.Id);
                ServerSchema  mySchema          = (ServerSchema)tempServerControl.DataContext;
                if (!String.IsNullOrEmpty(tempServerControl.resToMailPanel1.txtServer.Text) && !String.IsNullOrEmpty(tempServerControl.resToMailPanel1.txtPort.Text) && !String.IsNullOrEmpty(tempServerControl.resToMailPanel1.txtFrom.Text) && ((!String.IsNullOrEmpty(tempServerControl.resToMailPanel1.txtTo.Text))) || (mySchema.CHKUseRecipientGroup && mySchema.CHKUseSenderGroup) || (!String.IsNullOrEmpty(tempServerControl.resToMailPanel1.txtTo.Text) && mySchema.CHKUseSenderGroup) || !String.IsNullOrEmpty(tempServerControl.resToMailPanel1.txtFrom.Text) && mySchema.CHKUseRecipientGroup)
                {
                    tempServerControl.startMailPanel1.startButton.IsEnabled = false;



                    //startMailPanel1.startButton.IsEnabled = false;
                    if (!tempServerControl.run)
                    {
                        tempServerControl.resToMailPanel1.IsEnabled = false;

                        tempServerControl.mailsPanel.IsEnabled = false;

                        m_connections         = Int32.Parse(mySchema.Connections);
                        tempServerControl.run = true;
                        tempServerControl.mailingOutput.Items.Clear();
                        lock (tempErrorMailCountLock)
                        {
                            TempErrorMailCount = 0;
                        }
                        tempServerControl.resToMailPanel1.txtActMails.Text  = "0";
                        tempServerControl.resToMailPanel1.progressBar.Value = 0;
                        TextBox statusBox = (TextBox)tempServerControl.statusBar.Items[0];
                        statusBox.Text = "";
                        tempServerControl.startMailPanel1.startButton.Content = "Stop";
                        ServerStatus serverStatus = Singleton <ServerSendManager> .Instance.InitialiseServer(tempServerControl.Id, (ServerSchema)tempServerControl.DataContext);

                        //serverStatus.StartTime = DateTime.Now;
                        //serverStatus.Server = (ServerSchema)this.DataContext;
                        serverStatus.ServerImpl.MailsendEvent          += ServerImpl_MailsendEvent;       //new Client.MailsendHandler(ServerImpl_MailsendEvent);
                        serverStatus.ServerImpl.MaxMailsToSendEvent    += ServerImpl_MaxMailsToSendEvent; //new Client.MaxMailsToSendHandler(ServerImpl_MaxMailsToSendEvent);
                        serverStatus.ServerImpl.SendMailEndsEvent      += ServerImpl_SendMailEndsEvent;   //new Client.SendMailEndsHandler(ServerImpl_SendMailEndsEvent);
                        serverStatus.ServerImpl.BeforeMailsentEvent    += ServerImpl_BeforeSentMailSendingEvent;
                        serverStatus.ServerImpl.RequestSendEvent       += ServerImpl_RequestSendEvent;
                        serverStatus.ServerImpl.RequestSendFailedEvent += ServerImpl_RequestSendFailedEvent;
                        serverStatus.ServerImpl.StatusMessageEvent     += ServerImpl_StatusMessageEvent;
                        //serverStatus.ServerImpl.
                        //public delegate void RequestSendHandler(MessageWrapper msg, MailState mailState);
                        //public delegate void RequestSendFailedHandler(MessageWrapper msg, MailState mailState);
                        Singleton <ServerSendManager> .Instance.start(tempServerControl.Id);

                        Console.WriteLine("cool!!!!!!!!!!");
                        tempServerControl.startMailPanel1.startButton.IsEnabled = true;
                        e.Handled = true;
                    }
                    else
                    {
                        //startMailPanel1.startButton.Content = "Start";
                        tempServerControl.run = false;
                        Singleton <ServerSendManager> .Instance.AboardThreads(tempServerControl.Id);
                    }
                }
                else
                {
                    tempServerControl.mailingOutput.Items.Add(new LogMessage("Missing Parameter"));
                }//end if auf Null abfragen
            }
            e.Handled = true;
        }