Exemple #1
0
 public void ReadXml(XmlReader reader)
 {
     int sequenceCount = 0;
       bool isEmpty = reader.IsEmptyElement;
       reader.ReadStartElement();
       if (isEmpty)
     return;
       while (reader.NodeType == XmlNodeType.Element)
       {
     if (sequenceCount == 0 || reader.IsStartElement("title"))
     {
       PitchSequences.Add(new PitchSequence());
       sequenceCount++;
     }
     if (reader.IsStartElement("title"))
       PitchSequences[sequenceCount - 1].Title = reader.ReadElementString();
     else if (reader.IsStartElement("pitch"))
     {
       var pitch = new Pitch();
       pitch.ReadXml(reader);
       PitchSequences[sequenceCount - 1].Pitches.Add(pitch);
     }
     else
       reader.ReadOuterXml();
       }
       reader.ReadEndElement();
 }
Exemple #2
0
        private void WriteSimpleTackleList(Pitch pitch, Body body, bool majorCave)
        {
            var builder = new StringBuilder();
              if (pitch.Name != null && pitch.Name != "" && pitch.Name != "Entrance" && pitch.Name != "1st" && pitch.Name != "First")
            builder.Append(" (" + pitch.Name + ") ");

              bool ladder = false;
              if (pitch.Ladder != null && pitch.Ladder.Text != null && pitch.Ladder.Text != "")
              {
            builder.Append(pitch.Ladder.ToString());
            if (pitch.Ladder.Length.HasValue)
              builder.Append(" ladder");
            ladder = true;
              }
              if (pitch.Belay != null && pitch.Belay.Text != null && pitch.Belay.Text != "")
              {
            if (ladder)
               builder.Append("; ");
            string belayString = AnchorString(pitch.Belay.ToString()) + " belay";
            builder.Append(belayString);
            ladder = true;
              }
              if (pitch.Lifeline != null && pitch.Lifeline.Text != null && pitch.Lifeline.Text != "")
              {
            builder.Append((ladder ? "; " : "") + pitch.Lifeline.ToString());
            if (pitch.Lifeline.Length.HasValue)
              builder.Append(" lifeline");
            ladder = true;
              }

              StringBuilder builder2 = new StringBuilder();
              bool rope = false;
              if (pitch.Rope != null && pitch.Rope.Text != null && pitch.Rope.Text != "")
              {
            builder2.Append(pitch.Rope.ToString());
            if (pitch.Rope.Length.HasValue)
              builder2.Append(" rope");
            rope = true;
              }
              if (pitch.SrtBelay != null && pitch.SrtBelay != "")
              {
            if (rope)
              builder2.Append("; ");
            string anchorString = AnchorString(pitch.SrtBelay);
            if (anchorString=="Bar" || anchorString=="Stake")
              builder2.Append(anchorString + " belay");
            else
              builder2.Append(anchorString + " anchors");
            rope = true;
              }
              if (ladder & rope)
            builder.Append(" or ");
              if (rope)
            builder.Append(builder2.ToString());

              Run tackleRun = Docx.StyledRun(builder.ToString(), majorCave ? StyleNames.Tackle : StyleNames.MinorTackle);
              Paragraph paragraph = Docx.CreateParagraph(majorCave ? StyleNames.TackleHeader : StyleNames.MinorTackleHeader, new Run(new Text("Tackle: ") { Space = SpaceProcessingModeValues.Preserve }));
              paragraph.Append(tackleRun);
              body.Append(paragraph);
        }