private void button_Generate_Click(object sender, EventArgs e) { if (input_Panel1.Field_Value == "") { "You need to setup panel1 before you can generate code!".zOk(); return; } try { // Select the first panel var panelName = input_Panel1.Field_Value; listBox_Components.zListBox_SearchItem(panelName); // This will select the panel Control controlPanel = UIDesigner_Tools.Host_Controls_SelectedFirst(_host); var panel = controlPanel as Panel; var group = controlPanel as GroupBox; var form = controlPanel as System.Windows.Forms.Form; if (panel == null && group == null && form == null) { "Please select a parent control".zOk(); } else { var input = UIDesigner_Tools.Host_Controls_Add2Form <Input_Control>(_host, controlPanel); if (input == null) { "Unable to create control!".zOk(); return; } input.Parent = controlPanel; input.Top = 10; input.Left = 10; input.Dock = DockStyle.Top; input.Text = "It works!"; input.Field_Caption = "Field Caption:"; input.Field_Name = "Field_Name"; // Add Event handler // input.Event_OnValueChange IEventBindingService eventBindingService = UIDesigner_Service.IEventBindingService_FromHost(_host); EventDescriptorCollection eventColl = TypeDescriptor.GetEvents(input, new Attribute[0]); if (eventColl != null) { var eventDescriptor = eventColl["Event_OnValueChange"] as EventDescriptor; if (eventDescriptor != null) { PropertyDescriptor propertyDescriptor = eventBindingService.GetEventProperty(eventDescriptor); propertyDescriptor.SetValue(input, "OnValueChangeEvent"); } } } } catch (Exception exception) { Console.WriteLine(exception); exception.Message.zOk(); } }
private void Setup_PanelMain() { if (IsNotSave()) { return; } // Create the main panel var panel = UIDesigner_Tools.Host_Controls_Add2Form <Panel>(_formHost, _formName); panel.BorderStyle = BorderStyle.FixedSingle; panel.Dock = DockStyle.Fill; panel.Tag = "MainPanel"; _panelMain = panel; }