public ScfProjectForm() { InitializeComponent(); // boilerplate starts var disposer = TrivialBehinds.CreateBehind(this, new ScfProjectUi { button1 = button1, label1 = label1 }); this.FormClosed += (o, e) => disposer.Dispose(); // boilerplate ends }
public Form1() { InitializeComponent(); // this is only thing you need to add to your form, to expose ui controls var d = TrivialBehinds.CreateBehind(this, new CalcUi { btnMinus = btnMinus, btnPlus = btnPlus, label1 = label1 }); Deactivate += (o, e) => d.Dispose(); // boilerplate ends }
public Form1() { InitializeComponent(); // this is only thing you need to add to your form, to expose ui controls var d = TrivialBehinds.CreateBehind(this, new Form1Ui { btnMinus = btnMinus, btnPlus = btnPlus, label1 = label1, btnLaunchDirect = btnLaunchDirect }); this.Disposed += (o, e) => d.Dispose(); // boilerplate ends }
public MainForm() { InitializeComponent(); behindDisposer = TrivialBehinds.CreateBehind(this, new MainFormUi { searchControl = searchControl, form = this, dirSelector = dirSelector, searchTextBox = searchTextBox, btnAbort = btnAbort, tableLayout = tableLayoutPanel1, statusLabel = statusLabel1, rgArgsComboBox = rgArgsComboBox, statusLabelCurrentArgs = statusLabelCurrentArgs }); this.Deactivate += (o, e) => behindDisposer.Dispose(); }