public ContainerForm(ServiceBusHelper serviceBusHelper, MainForm mainForm, FormTypeEnum formTypeType, QueueDescription queueDescription)
        {
            try
            {
                InitializeComponent();
                this.mainForm        = mainForm;
                mainSplitterDistance = mainSplitContainer.SplitterDistance;
                SuspendLayout();
                panelMain.SuspendDrawing();
                panelMain.Controls.Clear();
                panelMain.BackColor = SystemColors.GradientInactiveCaption;
                testQueueControl    = new TestQueueControl(mainForm, WriteToLog, new ServiceBusHelper(WriteToLog, serviceBusHelper), queueDescription)
                {
                    Location = new Point(1, panelMain.HeaderHeight + 1)
                };


                if (formTypeType == FormTypeEnum.Send)
                {
                    testQueueControl.mainTabControl.TabPages.RemoveAt(2);
                    testQueueControl.receiverEnabledCheckBox.Checked = false;
                    Text = string.Format(SendMessagesFormat, queueDescription.Path);
                }
                else
                {
                    Text             = string.Format(TestQueueFormat, queueDescription.Path);
                    logTraceListener = new LogTraceListener(WriteToLog);
                    Trace.Listeners.Add(logTraceListener);
                }

                testQueueControl.btnCancel.Text   = CloseLabel;
                testQueueControl.btnCancel.Click -= testQueueControl.btnCancel_Click;
                testQueueControl.btnCancel.Click += BtnCancelOnClick;
                testQueueControl.Focus();

                panelMain.HeaderText = string.Format(HeaderTextTestQueueFormat, queueDescription.Path);
                panelMain.Controls.Add(testQueueControl);
                SetStyle(ControlStyles.ResizeRedraw, true);
            }
            finally
            {
                panelMain.ResumeDrawing();
                ResumeLayout();
            }
        }
        public ContainerForm(ServiceBusHelper serviceBusHelper, MainForm mainForm, FormTypeEnum formType, QueueDescription queueDescription)
        {
            try
            {
                InitializeComponent();
                Task.Factory.StartNew(AsyncWriteToLog).ContinueWith(t =>
                {
                    if (t.IsFaulted && t.Exception != null)
                    {
                        WriteToLog(t.Exception.Message);
                    }
                });
                this.mainForm        = mainForm;
                mainSplitterDistance = mainSplitContainer.SplitterDistance;
                SuspendLayout();
                panelMain.SuspendDrawing();
                panelMain.Controls.Clear();
                panelMain.BackColor = SystemColors.GradientInactiveCaption;

                if (formType == FormTypeEnum.Listener)
                {
                    var listenerControl = new ListenerControl(WriteToLog, StopLog, StartLog, new ServiceBusHelper(WriteToLog, serviceBusHelper), queueDescription)
                    {
                        Location = new Point(1, panelMain.HeaderHeight + 1),
                        Size     = new Size(panelMain.Size.Width - 3, queueDescription.RequiresSession ? 544 : 520),
                        Anchor   = AnchorStyles.Bottom | AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right
                    };
                    listenerControl.Focus();

                    Text = string.Format(QueueListenerFormat, queueDescription.Path);
                    mainSplitContainer.SplitterDistance = queueDescription.RequiresSession ? 570 : listenerControl.Size.Height + 26;
                    panelMain.HeaderText = string.Format(HeaderTextQueueListenerFormat, queueDescription.Path);
                    panelMain.Controls.Add(listenerControl);
                }
                else
                {
                    testQueueControl = new TestQueueControl(mainForm, WriteToLog, StopLog, StartLog, new ServiceBusHelper(WriteToLog, serviceBusHelper), queueDescription)
                    {
                        Location = new Point(1, panelMain.HeaderHeight + 1),
                        Size     = new Size(panelMain.Size.Width - 3, panelMain.Size.Height - 26),
                        Anchor   = AnchorStyles.Bottom | AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right
                    };


                    if (formType == FormTypeEnum.Send)
                    {
                        testQueueControl.mainTabControl.TabPages.RemoveAt(2);
                        testQueueControl.receiverEnabledCheckBox.Checked = false;
                        testQueueControl.senderEnabledCheckBox.Checked   = true;
                        testQueueControl.senderEnabledCheckBox.Visible   = false;
                        testQueueControl.grouperMessage.Location         = new Point(testQueueControl.grouperMessage.Location.X, 8);
                        testQueueControl.grouperMessage.Size             = new Size(testQueueControl.grouperMessage.Size.Width,
                                                                                    testQueueControl.grouperMessage.Size.Height + 16);
                        testQueueControl.grouperSender.Location = new Point(testQueueControl.grouperSender.Location.X, 8);
                        testQueueControl.grouperSender.Size     = new Size(testQueueControl.grouperSender.Size.Width,
                                                                           testQueueControl.grouperSender.Size.Height + 16);
                        Text = string.Format(SendMessagesFormat, queueDescription.Path);
                    }
                    else
                    {
                        Text             = string.Format(TestQueueFormat, queueDescription.Path);
                        logTraceListener = new LogTraceListener(WriteToLog);
                        Trace.Listeners.Add(logTraceListener);
                    }

                    testQueueControl.btnCancel.Text   = CloseLabel;
                    testQueueControl.btnCancel.Click -= testQueueControl.btnCancel_Click;
                    testQueueControl.btnCancel.Click += BtnCancelOnClick;
                    testQueueControl.Focus();

                    panelMain.HeaderText = string.Format(HeaderTextTestQueueFormat, queueDescription.Path);
                    panelMain.Controls.Add(testQueueControl);
                }
                SetStyle(ControlStyles.ResizeRedraw, true);
            }
            finally
            {
                panelMain.ResumeDrawing();
                ResumeLayout();
            }
        }