private void TestRelayService(RelayServiceWrapper relayServiceWrapper, bool sdi) { if (sdi) { TestRelayServiceControl relayServiceControl = null; try { panelMain.SuspendDrawing(); foreach (var userControl in panelMain.Controls.OfType<UserControl>()) { userControl.Dispose(); } panelMain.Controls.Clear(); panelMain.BackColor = SystemColors.GradientInactiveCaption; relayServiceControl = new TestRelayServiceControl(this, WriteToLog, StopAndRestartLog, relayServiceWrapper, serviceBusHelper); relayServiceControl.SuspendDrawing(); relayServiceControl.Location = new Point(1, panelLog.HeaderHeight + 1); panelMain.Controls.Add(relayServiceControl); SetControlSize(relayServiceControl); relayServiceControl.OnCancel += MainForm_OnCancel; } catch (Exception ex) { HandleException(ex); } finally { panelMain.ResumeDrawing(); if (relayServiceControl != null) { relayServiceControl.ResumeDrawing(); } } } }
public TestRelayServiceControl(MainForm mainForm, WriteToLogDelegate writeToLog, Action stopAndRestartLog, RelayServiceWrapper relayServiceWrapper, ServiceBusHelper serviceBusHelper) { this.mainForm = mainForm; this.writeToLog = writeToLog; this.stopAndRestartLog = stopAndRestartLog; this.relayServiceWrapper = relayServiceWrapper; this.serviceBusHelper = serviceBusHelper; InitializeComponent(); InitializeControls(); }