public void Render(Imi.Wms.Mobile.Server.Interface.Form form) { _eventDictionary.Clear(); SuspendLayout(); Width = form.Width; Height = form.Height; Control focusControl; var controls = RenderControls(form, out focusControl); Control[] existingControls = new Control[Controls.Count]; Controls.CopyTo(existingControls, 0); foreach (Control control in existingControls) { if (!controls.Contains(control)) { Controls.Remove(control); } } foreach (Control control in controls) { if (!Controls.Contains(control)) { Controls.Add(control); } control.BringToFront(); } ResumeLayout(); if (focusControl != null) { focusControl.Focus(); } }
private List <Control> RenderControls(Imi.Wms.Mobile.Server.Interface.Form form, out Control focusControl) { var controls = new List <Control>(); focusControl = null; if (form.Controls.CheckBox != null) { foreach (Imi.Wms.Mobile.Server.Interface.CheckBox renderCheckBox in form.Controls.CheckBox) { var checkBox = RenderCheckBox(renderCheckBox); controls.Add(checkBox); if (renderCheckBox.Focused) { focusControl = checkBox; } } } if (form.Controls.Label != null) { foreach (Imi.Wms.Mobile.Server.Interface.Label renderLabel in form.Controls.Label) { var label = RenderLabel(renderLabel); controls.Add(label); } } if (form.Controls.ListBox != null) { foreach (Imi.Wms.Mobile.Server.Interface.ListBox renderListBox in form.Controls.ListBox) { var listBox = RenderListBox(renderListBox); controls.Add(listBox); if (renderListBox.Focused) { focusControl = listBox; } } } if (form.Controls.TextBox != null) { foreach (Imi.Wms.Mobile.Server.Interface.TextBox renderTextBox in form.Controls.TextBox) { var textBox = RenderTextBox(renderTextBox); controls.Add(textBox); if (renderTextBox.Focused) { focusControl = textBox; } } } if (form.Controls.Button != null) { foreach (Imi.Wms.Mobile.Server.Interface.Button renderButton in form.Controls.Button) { var button = RenderButton(renderButton); controls.Add(button); if (renderButton.Focused) { focusControl = button; } } } return(controls); }