I have:
public interface IMyControl
{
string MyProperty {get; set;}
}
public class MyControl : UserControl, IMyControl
{
public string MyProperty {get; set;}
}
public static class InstanceManager
{
public static object GetInstanceOfType(Type type)
{
if (type.Name == "IMyControl")
return new MyControl();
}
}
I want:1) See IMyControl interface on toolbox
2) Have ability to drag IMyControl on aform or control designer
3) When i`ve dragged IMyControl interface from toolbox on aform or control designer, following code should be generated in SomeForm.Designer.cs file:
this.iMyControl1= InstanceManager.GetInstanceOfType(typeof(IMyControl));
// ...
((UserControl)this.iMyControl1).Location = new System.Drawing.Point(94, 119);
((UserControl)this.iMyControl1).Name = "iMyControl1";
((UserControl)this.iMyControl1).Size = new System.Drawing.Size(75, 23);
((UserControl)this.iMyControl1).TabIndex = 0;
iMyControl1.MyProperty = "MyText";
// ...
private IMyControl iMyControl1;
Please show me way and maybe code snippets or working opensource examples. Can I use DesignerAttribute, DesignerSerializerAttribute, ToolboxItemAttribute?