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 OnselectionChanged(object sender, EventArgs e) { //Setup(_designer, true); Component component = UIDesigner_Tools.Host_Controls_SelectedFirst(_host); string name = UIDesigner_Component.Component_AsStr(component, true, true); if (name != "") { listBox_Components.zListBox_SearchItem(name); } }
private void OnselectionChanged(object sender, EventArgs e) { // Set the active controlname if (_SelectionChangeFlag) { return; } _SelectionChangeFlag = true; Control control = UIDesigner_Tools.Host_Controls_SelectedFirst(_host); if (control is ComboBox || control is ListBox) { input_ControlName.Field_Value = control.Name; Generate_Code(); } else if (control is Input_Control) { var inputControl = control as Input_Control; var name = inputControl.Name; if (inputControl.ControlType == enControl_InputType.Combobox) { input_ControlName.Field_Value = name + ".Ctrl_Combobox"; } else if (inputControl.ControlType == enControl_InputType.Listbox) { input_ControlName.Field_Value = name + ".Ctrl_ListBox"; } else { "Please change the control type to 'Combobox' or 'Listbox'".zOk(); } } Generate_Code(); _SelectionChangeFlag = false; }