ThmxTheme class of Microsoft.SharePoint.Utilities can be used to apply theme to SharePoint 2010 sites. Following example shows, how a theme can be applied to a site on feature activation:
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
base.FeatureActivated(properties);
try
{
SPWeb oWeb = properties.Feature.Parent as SPWeb;
oWeb.AllowUnsafeUpdates = true;
//If web site is a subsite, then inheit theme from top level site collection.
if (!oWeb.IsRootWeb)
{
ThmxTheme.SetThemeUrlForWeb(oWeb, ThmxTheme.GetThemeUrlForWeb(oWeb.Site.RootWeb));
}
else
{
string themeName = "Theme_Name";
ThmxTheme theme = ThmxTheme.Open(oWeb.Site, "_catalogs/theme/" + themeName + ".thmx");
theme.ApplyTo(oWeb, true);
}
oWeb.Update();
}
catch (Exception ex)
{
// Log exception
}
}