Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Applying DesignerSerializerAttribute to interface: abstractive UI
 

Applying DesignerSerializerAttribute to interface: abstractive UI

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?
Igor Buchelnikov  Saturday, May 16, 2009 10:23 AM
Is my question unclear? If so, please ask me what unclear.
Igor Buchelnikov  Friday, May 22, 2009 10:58 AM
That's a fair question indeed !

I have been thinking of something like this for very long time. It could be very usefull thing to have such an ability, because as I understand it helps us to abstract our user interface from concreete control implementations. Using the feature we could constract a form from some IInputBox, ILabel, IAny... "controls" and then plug concreete implemetations using this.iMyControl1= InstanceManager.GetInstanceOfType(typeof(IMyControl)); in the form designer .cs file. That is a cool thing !!!. We can plug any concreete controls that implement particular interface, so one form beeing constructed once - can look and behave differently depending on plugged concreete controls.

Looking forward to hear an answer to this post. It is very interesting to know your opinion about all that said above
Thank you.

artim  Tuesday, May 26, 2009 10:47 AM
Yes, abstractive user interface is more powerful instrument than skins or CSS. For example, user could feel free to change ribbon UI (like MS Office 2007) to standart button bar UI.

But question remains unanswered:
is it possible to show some interface on toolbox and applyDesignerSerializerAttribute to it?
Igor Buchelnikov  Sunday, May 31, 2009 9:23 AM
Igor Buchelnikov  Tuesday, June 30, 2009 12:04 PM

You can use google to search for other answers

Custom Search

More Threads

• Problem with VS 2003 user controls in VS 2005 RC1 Toolbox
• Controls, Particularly User Controls, disappearing or Being Resized on Build
• Child controls are not removed from Controls Collection from within IComponentChangeService event handlers
• Creating Translucent Rectangle
• Color properties in Visual Studio 2008 Windows Forms Designer
• how to know Current active tab
• How to make a copy of a Form?
• CodeDomDesignerLoader crashes in Flush() method when a component is deleted
• Cannot open Designer
• Design time compilation symbol