private void Entity_Click(TextEntityType type, string data) { if (type is TextEntityTypeBotCommand) { } else if (type is TextEntityTypeEmailAddress) { ViewModel.OpenUrl("mailto:" + data, false); } else if (type is TextEntityTypePhoneNumber) { ViewModel.OpenUrl("tel:" + data, false); } else if (type is TextEntityTypeHashtag || type is TextEntityTypeCashtag) { } else if (type is TextEntityTypeMention) { ViewModel.OpenUsername(data); } else if (type is TextEntityTypeMentionName mentionName) { ViewModel.OpenUser(mentionName.UserId); } else if (type is TextEntityTypeTextUrl textUrl) { ViewModel.OpenUrl(textUrl.Url, true); } else if (type is TextEntityTypeUrl) { ViewModel.OpenUrl(data, false); } }
private TextStyleRun(TextStyleRun run) { Flags = run.Flags; Start = run.Start; End = run.End; Type = run.Type; }
private void Merge(TextStyleRun run) { Flags |= run.Flags; if (Type == null && run.Type != null) { Type = run.Type; } }
private void Replace(TextStyleRun run) { Flags = run.Flags; Type = run.Type; }
private static bool AreEquals(TextEntityType x, TextEntityType y) { if (x is TextEntityTypeTextUrl xTextUrl && y is TextEntityTypeTextUrl yTextUrl) { return(string.Equals(xTextUrl.Url, yTextUrl.Url, StringComparison.OrdinalIgnoreCase)); }
private static void CreateOrMerge(int offset, int length, IList <TextEntity> entities, TextEntityType type) { var last = entities.LastOrDefault(x => x.Length + x.Offset == offset && AreEquals(x.Type, type)); if (last != null) { last.Length += length; } else { entities.Add(new TextEntity(offset, length, type)); } }