This is a migrated thread and some comments may be shown as answers.

EmbeddedSkinAttribute in external Assembly

1 Answer 44 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Andrew Ross
Top achievements
Rank 1
Andrew Ross asked on 22 Oct 2010, 05:46 PM
Hi,

I really didn't know where to post this, as this account that i'm using doesn't have support access, and I was not able to do a Feature request.  I get Telerik from my Client that does have an account.  Well, I've been playing around with creating WebControls that inherit from RadWebControl, and wanted the ability to extend Skins to our new product.  I will try to explain this as best as i could.  In order to get this to work properly I need to modify 2 files within the telerik assembly and am curious if this would be possible to get put in the release code.

First let me I'll paste some code from one of my classes.

[assembly: WebResource("RossPc.Web.UI.Skins.Default.RossForm.Default.css", "text/css", PerformSubstitution = true)]
[assembly: WebResource("RossPc.Web.UI.Skins.Vista.RossForm.Vista.css", "text/css", PerformSubstitution = true)]
[assembly: WebResource("RossPc.Web.UI.Skins.RossForm.css", "text/css", PerformSubstitution = true)]
 
namespace RossPc.Web.UI
{
 
    /// <summary>
    /// RossPc Form control
    /// </summary>
    ///
    [EmbeddedSkin("RossForm", typeof(RossForm), "RossPc.Web.UI.Skins")]
    [EmbeddedSkin("RossForm", "Default", typeof(RossForm), "RossPc.Web.UI.Skins")]
    [EmbeddedSkin("RossForm", "Vista", typeof(RossForm), "RossPc.Web.UI.Skins")]

As you can see here what i'm doing is using your EmbededSkin attribute, with a modification, I added the namespace to the EmbededSkinAtribute.  The following is the modification I did to that file.

[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
public sealed class EmbeddedSkinAttribute : Attribute
{
    public EmbeddedSkinAttribute(string shortControlName, Type type) :
        this(shortControlName, null, type)
    {
    }
 
    public EmbeddedSkinAttribute(string shortControlName, Type type, string nameSpace) :
        this(shortControlName, null, type, nameSpace)
    {
    }
     
    public EmbeddedSkinAttribute(string shortControlName) :
        this(shortControlName, null, typeof(EmbeddedSkinAttribute))
    {
    }
 
    public EmbeddedSkinAttribute(string shortControlName, string skin) :
        this(shortControlName, skin, typeof(EmbeddedSkinAttribute))
    {
    }
 
    public EmbeddedSkinAttribute(string shortControlName, string skin, string nameSpace) :
        this(shortControlName, skin, typeof(EmbeddedSkinAttribute), nameSpace)
    {
    }
 
    public EmbeddedSkinAttribute(string shortControlName, string skin, Type type)
    {
        _shortControlName = shortControlName;
        _skin = skin;
        _type = type;
    }
 
    public EmbeddedSkinAttribute(string shortControlName, string skin, Type type, string nameSpace)
    {
        _shortControlName = shortControlName;
        _skin = skin;
        _type = type;
        _namespace = nameSpace;
    }
 
    public Type Type
    {
        get
        {
            return _type;
        }
    }
 
    public string Skin
    {
        get
        {
            return _skin;
        }
    }
 
    public string NameSpace
    {
        get
        {
            return _namespace;
        }
    }
     
    public string ShortControlName
    {
        get
        {
            return _shortControlName;
        }
    }
 
 
    public bool IsCommonCss
    {
        get
        {
            return _skin == null;
        }
    }
 
    public string CssResourceName
    {
        get
        {
            if (IsCommonCss)
            {
                return string.Format(NameSpace + ".{0}.css", ShortControlName);
            }
            return string.Format(NameSpace + ".{0}.{1}.{0}.css", Skin, ShortControlName);
        }
    }
 
    private string _skin;
    private string _shortControlName;
    private Type _type;
    private string _namespace = "Telerik.Web.UI.Skins";
}


What these changes to is allow us to use the EmbededSkinAttribute in our own controls that inherit from RadWebControl.

Well this is where i ran into my first issue, Everyting work perfectly "IF" i set EnableStyleSheetCombine="false" on the RadStyleSheetManager.  So, I started to dig a bit and found that if i change the following line 95 of StyleSheetManager.cs to the following.

StyleSheets.Add(new StyleSheetReference(skin.CssResourceName, control.GetType().Assembly.FullName));

Which now loads the skins perfectly.

I have not tested these changes with CDN support or anything, not sure if there might be other places to make changes, but as of now, everything seems to work very nicely.

So what i've done here is added the ability to specify built in skins, and added my own css files to match these skin in my own project.  Once you look more into the sample project you should see what i'm doing and how it works.  It would be very nice if you could add this to the release code, so that I would not have to recompile everytime i needs to release a new version.

Just so you know why we wanted to do this, we wanted to make is easy for us to make our controls follow the same styles you do for all of you skins.

The project was too big to attach below, If you send me a special place to upload it i can, as i won't make the download public as it does contain all source code(telerik, and mine).  I would like to have created a support ticket, but as i said, this account didn't have access.  I would like to get your feedback on this.

Thanks,
Andrew Ross

1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 27 Oct 2010, 11:49 AM
Hello Andrew,

Thank you for your suggestion. We will research whether it is OK to implement it and do it if no unwanted side effects are observed.

Regards,
Dimo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
Andrew Ross
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or