public static Control CloneCtrl(Control ctrl) { CBFormCtrl cbCtrl = new CBFormCtrl(ctrl); Control newCtrl = (Control)CreateControl(cbCtrl.CtrlName, cbCtrl.PartialName); SetControlProperties(newCtrl, cbCtrl.PropertyList); return(newCtrl); }
public static void CopyCtrl2ClipBoard(Control ctrl) { CBFormCtrl cbCtrl = new CBFormCtrl(ctrl); IDataObject ido = new System.Windows.Forms.DataObject(); //ido.SetData(CBFormCtrl.Format.Name, true, cbCtrl); //ido = Clipboard.GetDataObject(); ido.SetData(CBFormCtrl.Format.Name, false, cbCtrl); Clipboard.SetDataObject(ido, false); }
public static Control GetCtrlFromClipBoard() { Control ctrl; IDataObject ido = Clipboard.GetDataObject(); if (ido.GetDataPresent(CBFormCtrl.Format.Name)) { CBFormCtrl cbCtrl = ido.GetData(CBFormCtrl.Format.Name) as CBFormCtrl; ctrl = (Control)CreateControl(cbCtrl.CtrlName, cbCtrl.PartialName); SetControlProperties(ctrl, cbCtrl.PropertyList); cbCtrl.retreiveAllChildControl(ctrl); return(ctrl); } return(null); }
private void CreateCBFormCtrl(object ctrl) { CtrlName = ctrl.GetType().Name; PartialName = ctrl.GetType().Namespace; if (ctrl is EIBMenuBar) { PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(ctrl);//, new Attribute[] { new SerializableAttribute(),new BrowsableAttribute(true)}); foreach (PropertyDescriptor myProperty in properties) { try { if (myProperty.PropertyType.IsSerializable && myProperty.IsBrowsable) { propertyList.Add(myProperty.Name, myProperty.GetValue(ctrl)); } else if (myProperty.Name == "Controls") { //propertyList.Add(myProperty.Name,myProperty.GetValue(ctrl)); } } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.Message); //do nothing, just continue } } } else { PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(ctrl); foreach (PropertyDescriptor myProperty in properties) { try { if (myProperty.PropertyType.IsSerializable) { propertyList.Add(myProperty.Name, myProperty.GetValue(ctrl)); } else if (myProperty.Name == "Controls") { //propertyList.Add(myProperty.Name,myProperty.GetValue(ctrl)); } else if (myProperty.Name == "Nodes") { } } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.Message); //do nothing, just continue } } } if (ctrl is ToolStrip) { ToolStrip toolStrip = (ToolStrip)ctrl; foreach (ToolStripItem ctl in toolStrip.Items) { if (ctl is EIBMenu) { CBFormCtrl cbCtrl = new CBFormCtrl(ctl); this.CBControls.Add(cbCtrl); } else if (ctl is EIBMenuItem) { CBFormCtrl cbCtrl = new CBFormCtrl(ctl); this.CBControls.Add(cbCtrl); } } } else if (ctrl is EIBMenu) { EIBMenu menu = (EIBMenu)ctrl; foreach (ToolStripItem ctl in menu.DropDownItems) { if (ctl is EIBMenu) { CBFormCtrl cbCtrl = new CBFormCtrl(ctl); this.CBControls.Add(cbCtrl); } else if (ctl is EIBMenuItem) { CBFormCtrl cbCtrl = new CBFormCtrl(ctl); this.CBControls.Add(cbCtrl); } } } else if (!(ctrl is EIBMenuItem)) { if (ctrl is EIBTreeView) { foreach (EIBTreeNode ctl in ((EIBTreeView)ctrl).Nodes) { CBFormCtrl cbCtrl = new CBFormCtrl(ctl); this.CBControls.Add(cbCtrl); } } else if (ctrl is EIBTreeNode) { foreach (EIBTreeNode ctl in ((EIBTreeNode)ctrl).Nodes) { CBFormCtrl cbCtrl = new CBFormCtrl(ctl); this.CBControls.Add(cbCtrl); } } else { foreach (Control ctl in ((Control)ctrl).Controls) { if (ctl is IEIBControl) { CBFormCtrl cbCtrl = new CBFormCtrl(ctl); this.CBControls.Add(cbCtrl); } else if (ctl is ToolStrip) { CBFormCtrl cbCtrl = new CBFormCtrl(ctl); this.CBControls.Add(cbCtrl); } } } } }
public static Control CloneCtrl(Control ctrl) { CBFormCtrl cbCtrl = new CBFormCtrl(ctrl); Control newCtrl = (Control)CreateControl(cbCtrl.CtrlName, cbCtrl.PartialName); SetControlProperties(newCtrl, cbCtrl.PropertyList); return newCtrl; }
private void CreateCBFormCtrl(object ctrl) { CtrlName = ctrl.GetType().Name; PartialName = ctrl.GetType().Namespace; if (ctrl is EIBMenuBar) { PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(ctrl);//, new Attribute[] { new SerializableAttribute(),new BrowsableAttribute(true)}); foreach (PropertyDescriptor myProperty in properties) { try { if (myProperty.PropertyType.IsSerializable && myProperty.IsBrowsable) propertyList.Add(myProperty.Name, myProperty.GetValue(ctrl)); else if (myProperty.Name == "Controls") { //propertyList.Add(myProperty.Name,myProperty.GetValue(ctrl)); } } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.Message); //do nothing, just continue } } } else { PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(ctrl); foreach (PropertyDescriptor myProperty in properties) { try { if (myProperty.PropertyType.IsSerializable) propertyList.Add(myProperty.Name, myProperty.GetValue(ctrl)); else if (myProperty.Name == "Controls") { //propertyList.Add(myProperty.Name,myProperty.GetValue(ctrl)); } else if (myProperty.Name == "Nodes") { } } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.Message); //do nothing, just continue } } } if (ctrl is ToolStrip) { ToolStrip toolStrip = (ToolStrip)ctrl; foreach (ToolStripItem ctl in toolStrip.Items) { if (ctl is EIBMenu) { CBFormCtrl cbCtrl = new CBFormCtrl(ctl); this.CBControls.Add(cbCtrl); } else if (ctl is EIBMenuItem) { CBFormCtrl cbCtrl = new CBFormCtrl(ctl); this.CBControls.Add(cbCtrl); } } } else if (ctrl is EIBMenu) { EIBMenu menu = (EIBMenu)ctrl; foreach (ToolStripItem ctl in menu.DropDownItems) { if (ctl is EIBMenu) { CBFormCtrl cbCtrl = new CBFormCtrl(ctl); this.CBControls.Add(cbCtrl); } else if (ctl is EIBMenuItem) { CBFormCtrl cbCtrl = new CBFormCtrl(ctl); this.CBControls.Add(cbCtrl); } } } else if (!(ctrl is EIBMenuItem)) { if (ctrl is EIBTreeView) { foreach (EIBTreeNode ctl in ((EIBTreeView)ctrl).Nodes) { CBFormCtrl cbCtrl = new CBFormCtrl(ctl); this.CBControls.Add(cbCtrl); } } else if (ctrl is EIBTreeNode) { foreach (EIBTreeNode ctl in ((EIBTreeNode)ctrl).Nodes) { CBFormCtrl cbCtrl = new CBFormCtrl(ctl); this.CBControls.Add(cbCtrl); } } else { foreach (Control ctl in ((Control)ctrl).Controls) { if (ctl is IEIBControl) { CBFormCtrl cbCtrl = new CBFormCtrl(ctl); this.CBControls.Add(cbCtrl); } else if (ctl is ToolStrip) { CBFormCtrl cbCtrl = new CBFormCtrl(ctl); this.CBControls.Add(cbCtrl); } } } } }