private void Update() { if (!this.IsLoaded || !this.dirty) { return; } var bbcode = this.BBCode; 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) { // parsing failed, display BBCode value as-is inline = new Run { Text = bbcode }; } this.Inlines.Add(inline); } this.dirty = false; }
private void Update() { if (!IsLoaded || !dirty) { return; } string bbcode = BBCode; Inlines.Clear(); if (!string.IsNullOrWhiteSpace(bbcode)) { Inline inline; try { BBCodeParser parser = new BBCodeParser(bbcode, this, BBCodeQuoteBackground) { Commands = LinkNavigator.Commands }; inline = parser.Parse(); } catch (Exception) { // parsing failed, display BBCode value as-is inline = new Run { Text = bbcode }; } Inlines.Add(inline); } dirty = false; }
/// <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); } }