public ContainerForm(ServiceBusHelper serviceBusHelper, MainForm mainForm, FormTypeEnum formType, SubscriptionWrapper subscriptionWrapper) { 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, StopAndRestartLog, new ServiceBusHelper(WriteToLog, serviceBusHelper), subscriptionWrapper.SubscriptionDescription) { Location = new Point(1, panelMain.HeaderHeight + 1), Size = new Size(panelMain.Size.Width - 3, subscriptionWrapper.SubscriptionDescription.RequiresSession ? 544 : 520), Anchor = AnchorStyles.Bottom | AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right }; listenerControl.Focus(); Text = string.Format(SubscriptionListenerFormat, subscriptionWrapper.SubscriptionDescription.Name); mainSplitContainer.SplitterDistance = subscriptionWrapper.SubscriptionDescription.RequiresSession ? 570 : listenerControl.Size.Height + 26; panelMain.HeaderText = string.Format(HeaderTextSubscriptionListenerFormat, subscriptionWrapper.SubscriptionDescription.Name); panelMain.Controls.Add(listenerControl); } else { testSubscriptionControl = new TestSubscriptionControl(mainForm, WriteToLog, StopAndRestartLog, new ServiceBusHelper(WriteToLog, serviceBusHelper), subscriptionWrapper) { 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 }; testSubscriptionControl.btnCancel.Click -= testSubscriptionControl.btnCancel_Click; testSubscriptionControl.btnCancel.Click += BtnCancelOnClick; testSubscriptionControl.Focus(); Text = string.Format(TestSubscriptionFormat, subscriptionWrapper.SubscriptionDescription.Name); panelMain.HeaderText = string.Format(HeaderTextTestSubscriptionFormat, subscriptionWrapper.SubscriptionDescription.Name); panelMain.Controls.Add(testSubscriptionControl); } SetStyle(ControlStyles.ResizeRedraw, true); } finally { panelMain.ResumeDrawing(); ResumeLayout(); } }
public ContainerForm(ServiceBusHelper serviceBusHelper, MainForm mainForm, SubscriptionWrapper subscriptionWrapper) { try { InitializeComponent(); this.mainForm = mainForm; mainSplitterDistance = mainSplitContainer.SplitterDistance; SuspendLayout(); panelMain.SuspendDrawing(); panelMain.Controls.Clear(); panelMain.BackColor = SystemColors.GradientInactiveCaption; testSubscriptionControl = new TestSubscriptionControl(mainForm, WriteToLog, new ServiceBusHelper(WriteToLog, serviceBusHelper), subscriptionWrapper) { Location = new Point(1, panelMain.HeaderHeight + 1) }; testSubscriptionControl.btnCancel.Click -= testSubscriptionControl.btnCancel_Click; testSubscriptionControl.btnCancel.Click += BtnCancelOnClick; testSubscriptionControl.Focus(); Text = string.Format(TestSubscriptionFormat, subscriptionWrapper.SubscriptionDescription.Name); panelMain.HeaderText = string.Format(HeaderTextTestSubscriptionFormat, subscriptionWrapper.SubscriptionDescription.Name); panelMain.Controls.Add(testSubscriptionControl); SetStyle(ControlStyles.ResizeRedraw, true); } finally { panelMain.ResumeDrawing(); ResumeLayout(); } }
public ContainerForm(ServiceBusHelper serviceBusHelper, MainForm mainForm, FormTypeEnum formType, SubscriptionWrapper subscriptionWrapper) { 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), subscriptionWrapper.SubscriptionDescription) { Location = new Point(1, panelMain.HeaderHeight + 1), Size = new Size(panelMain.Size.Width - 3, subscriptionWrapper.SubscriptionDescription.RequiresSession ? 544 : 520), Anchor = AnchorStyles.Bottom | AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right }; listenerControl.Focus(); Text = string.Format(SubscriptionListenerFormat, subscriptionWrapper.SubscriptionDescription.Name); mainSplitContainer.SplitterDistance = subscriptionWrapper.SubscriptionDescription.RequiresSession ? 570 : listenerControl.Size.Height + 26; panelMain.HeaderText = string.Format(HeaderTextSubscriptionListenerFormat, subscriptionWrapper.SubscriptionDescription.Name); panelMain.Controls.Add(listenerControl); } else { testSubscriptionControl = new TestSubscriptionControl(mainForm, WriteToLog, StopLog, StartLog, new ServiceBusHelper(WriteToLog, serviceBusHelper), subscriptionWrapper) { 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 }; testSubscriptionControl.btnCancel.Click -= testSubscriptionControl.btnCancel_Click; testSubscriptionControl.btnCancel.Click += BtnCancelOnClick; testSubscriptionControl.Focus(); Text = string.Format(TestSubscriptionFormat, subscriptionWrapper.SubscriptionDescription.Name); panelMain.HeaderText = string.Format(HeaderTextTestSubscriptionFormat, subscriptionWrapper.SubscriptionDescription.Name); panelMain.Controls.Add(testSubscriptionControl); } SetStyle(ControlStyles.ResizeRedraw, true); } finally { panelMain.ResumeDrawing(); ResumeLayout(); } }
private void TestSubscription(SubscriptionWrapper subscriptionWrapper, bool sdi) { if (sdi) { TestSubscriptionControl subscriptionControl = null; try { panelMain.SuspendDrawing(); foreach (var userControl in panelMain.Controls.OfType<UserControl>()) { userControl.Dispose(); } panelMain.Controls.Clear(); panelMain.BackColor = SystemColors.GradientInactiveCaption; subscriptionControl = new TestSubscriptionControl(this, WriteToLog, StopLog, StartLog, serviceBusHelper, subscriptionWrapper); subscriptionControl.SuspendDrawing(); subscriptionControl.Location = new Point(1, panelLog.HeaderHeight + 1); panelMain.Controls.Add(subscriptionControl); SetControlSize(subscriptionControl); subscriptionControl.OnCancel += MainForm_OnCancel; } catch (Exception ex) { HandleException(ex); } finally { panelMain.ResumeDrawing(); if (subscriptionControl != null) { subscriptionControl.ResumeDrawing(); } } } else { var form = new ContainerForm(serviceBusHelper, this, FormTypeEnum.Test, subscriptionWrapper); form.Show(); } }