温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:MyWebPages51aspx汉化最终版
当前文件:
MyWebPagesStarterKit/App_Code/Controls/PageBaseClass.cs,打开代码结构图
MyWebPagesStarterKit/App_Code/Controls/PageBaseClass.cs,打开代码结构图1//=============================================================================================== 2
// 3
// (c) Copyright Microsoft Corporation. 4
// This source is subject to the Microsoft Permissive License. 5
// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx. 6
// All other rights reserved. 7
// 8
//=============================================================================================== 9
10
using System; 11
using System.Web.UI; 12
using System.IO; 13
using System.Threading; 14
using System.Globalization; 15
using System.Web.UI.HtmlControls; 16
17
namespace MyWebPagesStarterKit.Controls 18
{ 19
public abstract class PageBaseClass : Page 20
{ 21
protected WebSite _website; 22
23
public PageBaseClass(){} 24
25
protected override void OnPreInit(EventArgs e) 26
{ 27
base.OnPreInit(e); 28
_website = WebSite.GetInstance(); 29
30
if((_website.Theme == string.Empty) || (!Directory.Exists(Server.MapPath(string.Format("~/App_Themes/{0}", _website.Theme))))){ 31
string appThemesPath = Server.MapPath("~/App_Themes"); 32
string[] themes = Directory.GetDirectories(appThemesPath); 33
if (themes.Length > 0) 34
{ 35
//if theme TravelDiary, select as default, else choose first theme 36
bool blnTravelDiary = false; 37
foreach (string theme in themes) 38
{ 39
if (Path.GetFileName(theme) == "TravelDiary") 40
blnTravelDiary = true; 41
} 42
_website.Theme = blnTravelDiary == true ? "TravelDiary" : Path.GetFileName(themes[0]); 43
} 44
else 45
{ 46
_website.Theme = string.Empty; 47
} 48
_website.SaveData(); 49
} 50
Theme = _website.Theme; 51
} 52
53
protected override void InitializeCulture() 54
{ 55
// Initialize Resource Manager - with no effect if it's already been initialized 56
string LocaleID = WebSite.GetInstance().LocaleID; 57
UICulture = LocaleID; 58
Culture = LocaleID; 59
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(LocaleID); 60
Thread.CurrentThread.CurrentUICulture = new CultureInfo(LocaleID); 61
base.InitializeCulture(); 62
} 63
64
protected void Page_PreRender(object sender, EventArgs e) 65
{ 66
if (_website.Theme == "Arabic") 67
{ 68
HtmlGenericControl body = (HtmlGenericControl)Master.FindControl("body1"); 69
body.Attributes.Add("dir", "rtl"); 70
} 71
} 72
} 73
} 74





}
}