/// <summary>
/// 更新
/// </summary>
private void Update()
{
try
{
if (!this.IsLoaded || !this.dirty)
{
return;
}
var bbcode = this.BBCode;
if (this.Inlines.Count > 0)
{
this.Inlines.Clear();
}
if (!string.IsNullOrWhiteSpace(bbcode))
{
Inline inline;
try
{
var parser = new BBCodeParser(bbcode, this)
{
Commands = this.LinkNavigator.Commands
};
inline = parser.Parse();
}
catch (Exception)
{
// 分析失败,按原样显示BBCode值 parsing failed, display BBCode value as-is
inline = new Run {
Text = bbcode
};
}
this.Inlines.Add(inline);
}
this.dirty = false;
}
catch (Exception error)
{
ModernDialog.ShowMessage(error.Message, ModernUI.Resources.NavigationFailed, MessageBoxButton.OK);
}
}