本文整理汇总了C#中System.Reference.ToStringSourced方法的典型用法代码示例。如果您正苦于以下问题:C# Reference.ToStringSourced方法的具体用法?C# Reference.ToStringSourced怎么用?C# Reference.ToStringSourced使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reference
的用法示例。
在下文中一共展示了Reference.ToStringSourced方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReferenceListItem
// TODO: Find a *much* nicer way of dealing with this. :X
public ReferenceListItem(Reference reference, Display display, Resource context)
{
this.Reference = reference;
string displayStr;
switch (display)
{
case Display.NoMod:
displayStr = reference.ToString(false, context);
break;
case Display.WithMod:
displayStr = reference.ToString(true, context);
break;
case Display.SourcedNoMod:
displayStr = reference.ToStringSourced(false, context);
break;
case Display.SourcedIncoming:
displayStr = "[INCOMING] " + reference.ToStringSourced(false, context);
break;
default:
throw new ArgumentException("display");
}
this.AddText(displayStr);
SetBackground(reference.Valid ? ItemStatus.Okay : ItemStatus.Error);
this.CommandBindings.Add(new System.Windows.Input.CommandBinding(
System.Windows.Input.ApplicationCommands.Copy,
(o, e) => System.Windows.Clipboard.SetText(string.Concat(reference.Origin.Location, " : ", reference.Target.Location))
));
this.ContextMenu = new ContextMenu();
var items = this.ContextMenu.Items;
items.Add(new MenuItem { Header = "_Copy...", Command = System.Windows.Input.ApplicationCommands.Copy, CommandTarget = this });
items.Add(CreateItem(Reference.Definition, "_Definition: "));
// Add the origin unless it's the same
if (Reference.Definition != reference.Origin)
items.Add(CreateItem(Reference.Origin, "_Origin: "));
// Add the definition *unless* it's either.
if (Reference.Definition != Reference.Target && Reference.Origin != Reference.Target)
items.Add(CreateItem(Reference.Target, "_Target: "));
}