?? tooltips.cs
字號:
/*
* ToolTips.cs @Microsoft Visual Studio 2008 <.NET Framework 3.5>
* AfritXia
* 2006-09-22
*
* Copyright(c) http://www.AfritXia.NET/
*
*/
using System;
using System.Collections;
using System.Xml;
using System.Threading;
using System.Web;
namespace NET.AfritXia.Components.Web.TextPane
{
/// <summary>
/// 工具提示信息類
/// </summary>
internal class ToolTips
{
// ToolTips 靜態對象
private static ToolTips g_theInstance = null;
// 工具提示字典 中文
private StringDictionary m_toolTipDict_ch = new StringDictionary();
// 工具提示字典 英文
private StringDictionary m_toolTipDict_en = new StringDictionary();
#region 類 ToolTips 構造器
/// <summary>
/// 類 ToolTips 默認構造器
/// </summary>
private ToolTips()
{
}
#endregion
/// <summary>
/// 獲取工具提示對象實例,該屬性是線程安全的
/// </summary>
public static ToolTips TheInstance
{
get
{
if (g_theInstance != null)
return g_theInstance;
lock (typeof(ToolTips))
{
if (g_theInstance == null)
{
ToolTips theInstance = new ToolTips();
// 讀取 XML 資源內容
theInstance.LoadXmlResource("ch");
theInstance.LoadXmlResource("en");
g_theInstance = theInstance;
}
}
return g_theInstance;
}
}
/// <summary>
/// 讀取 XML 資源內容到工具提示字典對象
/// </summary>
/// <param name="language"></param>
private void LoadXmlResource(string language)
{
XmlDocument xmlDoc = new XmlDocument();
// 工具提示字典
StringDictionary toolTipDict;
if (language == "ch")
{
// 獲取中文工具提示
xmlDoc.LoadXml(MyResources.WebTextPaneXmlToolTips_ch);
// 指向中文字典
toolTipDict = this.m_toolTipDict_ch;
}
else
{
// 獲取英文工具提示
xmlDoc.LoadXml(MyResources.WebTextPaneXmlToolTips_en);
// 指向英文字典
toolTipDict = this.m_toolTipDict_en;
}
// <toolBar></toolBar>
XmlNode root = xmlDoc.DocumentElement;
foreach (XmlNode node in root.ChildNodes)
{
// <commandID></commandID>
XmlNode cmdIDNode = node.SelectSingleNode("commandID");
// <tipText></tipText>
XmlNode tipTextNode = node.SelectSingleNode("tipText");
if (cmdIDNode == null)
continue;
// 添加工具提示文本到字典
toolTipDict.Add(cmdIDNode.InnerXml, tipTextNode.InnerXml);
}
}
/// <summary>
/// 獲取工具提示字符串
/// </summary>
/// <param name="commandID">命令 ID</param>
/// <returns>工具提示字符串</returns>
public string GetString(string commandID)
{
if (commandID == null)
return null;
// 獲取工具提示字典
StringDictionary toolTipDict = this.GetToolTipDictionary();
if (!toolTipDict.ContainsKey(commandID))
return null;
return toolTipDict[commandID];
}
/// <summary>
/// 獲取命令關鍵字枚舉
/// </summary>
/// <returns></returns>
public IEnumerator GetCommandIDEnumerator()
{
// 獲取工具提示字典
StringDictionary toolTipDict = this.GetToolTipDictionary();
return toolTipDict.Keys.GetEnumerator();
}
/// <summary>
/// 獲取工具提示文本枚舉
/// </summary>
/// <returns></returns>
public IEnumerator GetTipTextEnumerator()
{
// 獲取工具提示字典
StringDictionary toolTipDict = this.GetToolTipDictionary();
return toolTipDict.Values.GetEnumerator();
}
/// <summary>
/// 獲取工具提示字典
/// </summary>
/// <returns></returns>
private StringDictionary GetToolTipDictionary()
{
StringDictionary toolTipDict;
if (HttpContext.Current.Request.UserLanguages[0] == "zh-cn")
{
// 指向中文字典
toolTipDict = this.m_toolTipDict_ch;
}
else
{
// 指向英文字典
toolTipDict = this.m_toolTipDict_en;
}
return toolTipDict;
}
#region StringDictionary 字符串字典類
/// <summary>
/// 字符串字典類
/// </summary>
internal class StringDictionary : System.Collections.Hashtable
{
#region 類 StringDictionary 構造器
/// <summary>
/// 類 StringDictionary 默認構造器
/// </summary>
public StringDictionary() : base()
{
}
#endregion
/// <summary>
/// 向字典中添加鍵和值
/// </summary>
/// <param name="key">關鍵字</param>
/// <param name="value">字符串值</param>
public void Add(string key, string value)
{
base.Add(key, value);
}
/// <summary>
/// 通過索引器設置或獲取鍵值
/// </summary>
public string this[string key]
{
set
{
base[key] = value;
}
get
{
return base[key] as string;
}
}
}
#endregion
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -