public void VisitTagPair(ITagPair tagPair) { TagPairs.Add((ITagPair)tagPair.Clone()); if (IncludeTagText) { TagUnits.Add(new TagUnit(tagPair.TagProperties.TagId.Id, tagPair.TagProperties.DisplayText, tagPair.StartTagProperties.TagContent, TagUnit.TagUnitState.IsOpening, TagUnit.TagUnitType.IsTag)); SegmentSections.Add(new SegmentSection(SegmentSection.ContentType.Tag, tagPair.TagProperties.TagId.Id, tagPair.StartTagProperties.TagContent)); PlainText.Append(tagPair.StartTagProperties.TagContent); } VisitChildren(tagPair); if (!IncludeTagText) { return; } TagUnits.Add(new TagUnit(tagPair.TagProperties.TagId.Id, string.Empty, tagPair.EndTagProperties.TagContent, TagUnit.TagUnitState.IsClosing, TagUnit.TagUnitType.IsTag)); SegmentSections.Add(new SegmentSection(SegmentSection.ContentType.TagClosing, tagPair.TagProperties.TagId.Id, tagPair.EndTagProperties.TagContent)); PlainText.Append(tagPair.EndTagProperties.TagContent); }
private void TableHeader_Click(object sender, RoutedEventArgs e) { OrderAsc = !OrderAsc; var bindingInfo = (sender as GridViewColumnHeader).Column.DisplayMemberBinding as System.Windows.Data.Binding; string bindingPropertyName = bindingInfo.Path.Path; Func <TagPair, object> keySelector = x => x.GetPropertyValue(bindingPropertyName); var sortedWordDictionary = OrderAsc ? TagPairs.OrderBy(keySelector) : TagPairs.OrderByDescending(keySelector); TagPairs.Update(sortedWordDictionary.ToList()); }
private void AddMove(string move, Piece piece, string fromLocation, string toLocation) { if (string.IsNullOrEmpty(fromLocation) && string.IsNullOrEmpty(toLocation)) { if (move == "O-O") { _board.AddMove(Move.GetCastle(piece.Color, BoardSide.KingSide)); } else if (move == "O-O-O") { _board.AddMove(Move.GetCastle(piece.Color, BoardSide.QueenSide)); } else { string result; if (TagPairs.TryGetValue("Result", out result) && result == move) { return; } throw new InvalidOperationException($"Castle pattern '{move}' is unknown"); } } else { Location targetLocation = Location.Parse(toLocation); Location sourceLocation; if (false == Location.TryParse(fromLocation, out sourceLocation)) { sourceLocation = GetSourceLocation(piece, targetLocation, fromLocation); } if (sourceLocation == null) { throw new Exception(string.Format("Could not find {2}'s original location '{0}' going to '{1}'", fromLocation ?? "<unknown>", targetLocation, piece)); } _board.AddMove(new Move(piece, sourceLocation, targetLocation)); } }
public void VisitTagPair(ITagPair tagPair) { TagPairs.Add((ITagPair)tagPair.Clone()); if (IncludeTagText) { var objTag = new Tag { AlignmentAnchor = "", Anchor = TagCounter.ToString(), TagId = tagPair.TagProperties.TagId.Id, TextEquivalent = tagPair.StartTagProperties.TagContent, SectionType = Tag.Type.Start }; TagUnits.Add(objTag); objTag.Revision = IsRevisionMarker ? RevisionMarker : null; SegmentSections.Add(objTag); PlainText.Append(tagPair.StartTagProperties.TagContent); var tgStart = new Sdl.LanguagePlatform.Core.Tag { Type = TagType.Start, Anchor = TagCounter, TagID = tagPair.StartTagProperties.TagId.Id, TextEquivalent = tagPair.StartTagProperties.DisplayText }; Segment.Add(tgStart); } VisitChildren(tagPair); if (IncludeTagText) { var objTag = new Tag { AlignmentAnchor = "", Anchor = TagCounter.ToString(), TagId = tagPair.TagProperties.TagId.Id, TextEquivalent = tagPair.EndTagProperties.TagContent, SectionType = Tag.Type.End }; TagUnits.Add(objTag); objTag.Revision = IsRevisionMarker ? RevisionMarker : null; SegmentSections.Add(objTag); PlainText.Append(tagPair.EndTagProperties.TagContent); var tgEnd = new Sdl.LanguagePlatform.Core.Tag { Type = TagType.End, TagID = tagPair.StartTagProperties.TagId.Id, Anchor = TagCounter, TextEquivalent = tagPair.EndTagProperties.DisplayText }; Segment.Add(tgEnd); } TagCounter++; }