DCSIMG
Create your own Designer or Introduction To Custom Designers - Part 3: SmartTags and Source Code. - Design .Net

Design .Net

Designers, Controls And everything between them.

Create your own Designer or Introduction To Custom Designers - Part 3: SmartTags and Source Code.

As I promised I will supply the source code for the Designer and I will explain about SmartTags, SmartTags enable us easier access to our control an extended to UI.

So SmartTags enable us to access designated operation to our control.

How to create SmartTas:

Step 1:

In my previous session I have demonstrated how to create a Custom Designer, now all you have to do to add SmartTags to your control is to override the ActionLists property of your desginer.

private DesignerActionList m_DesignerActionList;

private DesignerActionListCollection m_ActionLists;

public override DesignerActionListCollection ActionLists

{

    get

    {

        if(m_ActionLists == null)

        {

            m_ActionLists = new DesignerActionListCollection();

            m_DesignerActionList = new MyDesignerActionList(this.Control);

            m_ActionLists.Add(m_DesignerActionList);

        }

        return m_ActionLists;

    }

}

As you may have notice I have created my own implementation of the DesignerActionList class, the new implementation contains the definition of SmartTags abilities exposed by my new DesignerActionList class.

Step 2: Add abilities to your DesignerActionList

To add new SmartTags all you have to do is to override the GetSortedActionItems method and add the Method to be Invoked when the SmartTag is invoked. By adding DesignerActionItemCollection a DesignerActionMethodItem we will Invoke a method.

public override DesignerActionItemCollection GetSortedActionItems()

{

    DesignerActionItemCollection items = new DesignerActionItemCollection();

    items.Add(new DesignerActionMethodItem(this,

                "ImageLocation", "ImageLocation",true));

 

    return items;

}

Now when we will design our control we will be able to use SmartTags.

designerVerb

I have Included source code for our designer.  

 SourceCode

That's it.

*njoy!

Comments

Tamir said:

Excelent posts (all the series).

i realy enjoy and learn a lot. you realy help to me. i will use it in the projcet that i work on it now.

Thanks.

# March 6, 2008 2:24 PM

WPF novice said:

Can you help me start doing the same for WPF?

# July 28, 2009 7:31 AM

Yogev said:

Sure, please try to be more specific on your requirements and perhaps we can find you a adequate solution.

Yogev.

# June 17, 2010 11:54 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 


Enter the numbers above: