本文整理汇总了C#中ItemCollection.TryGetValue方法的典型用法代码示例。如果您正苦于以下问题:C# ItemCollection.TryGetValue方法的具体用法?C# ItemCollection.TryGetValue怎么用?C# ItemCollection.TryGetValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ItemCollection
的用法示例。
在下文中一共展示了ItemCollection.TryGetValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ForEachItems
private static void ForEachItems(ToolStripMenuItem item, ItemCollection translateTable)
{
foreach (ToolStripMenuItem subItem in item.DropDownItems)
{
string message = "";
translateTable.TryGetValue(subItem.Name, out message);
if (!string.IsNullOrEmpty(message))
subItem.Text = message;
ForEachItems(subItem, translateTable);
}
}
示例2: ForEachSubControls
private static void ForEachSubControls(Control item, ItemCollection translateTable)
{
foreach (Control subItem in item.Controls)
{
string message = "";
translateTable.TryGetValue(subItem.Name, out message);
if (!string.IsNullOrEmpty(message))
{
RichTextBox box = subItem as RichTextBox;
if (null != box && !(box is Controls.Text.AdvRichTextBox))
box.Rtf = message;
else
subItem.Text = message;
}
ForEachSubControls(subItem, translateTable);
}
}
示例3: TranslateControls
/// <summary>
/// Translate a control an its sub controls
/// </summary>
/// <param name="control">target control to translate</param>
/// <param name="strings">language items for translation</param>
public static void TranslateControls(Control control, ItemCollection strings)
{
string caption = "";
strings.TryGetValue("this", out caption);
if (!string.IsNullOrEmpty(caption))
control.Text = caption;
ILocalizationDesign toolBoxControl = control as ILocalizationDesign;
if ((null != toolBoxControl) && (null != toolBoxControl.Components))
{
foreach (System.ComponentModel.IComponent controlComponent in toolBoxControl.Components.Components)
{
ContextMenuStrip menuStrip = controlComponent as ContextMenuStrip;
if (null != menuStrip)
{
string message = "";
strings.TryGetValue(menuStrip.Name, out message);
if (!string.IsNullOrEmpty(message))
menuStrip.Text = message;
foreach (ToolStripItem unkownItem in menuStrip.Items)
{
ToolStripMenuItem menuItem = unkownItem as ToolStripMenuItem;
if (null != menuItem)
{
message = "";
strings.TryGetValue(menuItem.Name, out message);
if (!string.IsNullOrEmpty(message))
menuItem.Text = message;
ForEachItems(menuItem, strings);
}
}
}
}
}
foreach (Control item in control.Controls)
{
ToolStrip toolStrip = item as ToolStrip;
if (null != toolStrip)
{
string message = "";
strings.TryGetValue(toolStrip.Name, out message);
if (!string.IsNullOrEmpty(message))
toolStrip.Text = message;
foreach (ToolStripItem unkownItem in toolStrip.Items)
{
ToolStripItem menuItem = unkownItem as ToolStripItem;
if (null != menuItem)
{
message = "";
strings.TryGetValue(menuItem.Name, out message);
if (!string.IsNullOrEmpty(message))
menuItem.Text = message;
ForEachItems(menuItem, strings);
}
}
}
}
foreach (Control item in control.Controls)
{
string message = "";
strings.TryGetValue(item.Name, out message);
if (!string.IsNullOrEmpty(message))
{
RichTextBox box =item as RichTextBox;
if (null != box)
box.Rtf = message;
else
item.Text = message;
}
ForEachSubControls(item, strings);
}
}