public PitchController() { InitializeComponent(); Rectangle[,] pitchGrid = new Rectangle[maxCol, maxRow] { {rectangle00, rectangle01, rectangle02, rectangle03, rectangle04, rectangle05, rectangle06, rectangle07, rectangle08}, {rectangle10, rectangle11, rectangle12, rectangle13, rectangle14, rectangle15, rectangle16, rectangle17, rectangle18}, {rectangle20, rectangle21, rectangle22, rectangle23, rectangle24, rectangle25, rectangle26, rectangle27, rectangle28}, {rectangle30, rectangle31, rectangle32, rectangle33, rectangle34, rectangle35, rectangle36, rectangle37, rectangle38}, {rectangle40, rectangle41, rectangle42, rectangle43, rectangle44, rectangle45, rectangle46, rectangle47, rectangle48}, {rectangle50, rectangle51, rectangle52, rectangle53, rectangle54, rectangle55, rectangle56, rectangle57, rectangle58}, {rectangle60, rectangle61, rectangle62, rectangle63, rectangle64, rectangle65, rectangle66, rectangle67, rectangle68}, {rectangle70, rectangle71, rectangle72, rectangle73, rectangle74, rectangle75, rectangle76, rectangle77, rectangle78} }; PitchController.pitchSequence = new PitchSequence(pitchGrid); this.state = new Boolean[BeatMaker.noteNum, maxCol, maxRow]; this.resetState(); }
private void WritePitchSequenceDocx(PitchSequence pitchSequence, Body body) { if (pitchSequence.Title != null) body.Append(Docx.SimpleParagraph(pitchSequence.Title, StyleNames.PitchTableHeader)); if (pitchSequence.Pitches.Count > 0) { var table = new Table(); TableProperties tableProps = new TableProperties(new TableStyle { Val = "ncTackleTable" }); table.Append(tableProps); bool ladder = false; bool srt = false; foreach (Pitch pitch in pitchSequence.Pitches) { if (pitch.Ladder != null && pitch.Ladder.Text != null && pitch.Ladder.Text != "" || pitch.Lifeline != null && pitch.Lifeline.Text != null && pitch.Lifeline.Text != "" || pitch.Belay != null && pitch.Belay.Text != null && pitch.Belay.Text != "") ladder = true; if (pitch.Rope != null && pitch.Rope.Text != null && pitch.Rope.Text != "" || pitch.SrtBelay != null && pitch.SrtBelay != null && pitch.SrtBelay != "") srt = true; } const double pageWidth = 12.3; //?? const double NarrowColWidth = 1.5; const double WideColWidth = 2; double firstColWidth; if (ladder && srt) firstColWidth = pageWidth - 5 * NarrowColWidth; else if (ladder) firstColWidth = pageWidth - 3 * WideColWidth; else firstColWidth = pageWidth - 2 * WideColWidth; double otherColWidth = ladder && srt ? NarrowColWidth : WideColWidth; var firstRow = new TableRow(); firstRow.Append(Docx.FixedWidthCell(Docx.SimpleParagraph("Pitch"), firstColWidth)); if (ladder) firstRow.Append( Docx.FixedWidthCell(Docx.SimpleParagraph("Ladder"), otherColWidth), Docx.FixedWidthCell(Docx.SimpleParagraph("Belay"), otherColWidth), Docx.FixedWidthCell(Docx.SimpleParagraph("Lifeline"), otherColWidth)); if (srt) firstRow.Append( Docx.FixedWidthCell(Docx.SimpleParagraph("Rope"), otherColWidth), Docx.FixedWidthCell(Docx.SimpleParagraph("Anchors"), otherColWidth)); table.Append(firstRow); foreach (Pitch pitch in pitchSequence.Pitches) { var row = new TableRow(); string pitchName = pitch.Name + (pitch.Height != null ? string.Format(" ({0}m)", pitch.Height) : ""); row.Append(new TableCell(Docx.SimpleParagraph(pitchName))); if (ladder) { //double ladderLength; //double belayLength; //string ladderString = double.TryParse(pitch.Ladder, out ladderLength) ? ladderLength.ToString() + "m" : pitch.Ladder; //string belayString = double.TryParse(pitch.Belay, out belayLength) ? belayLength.ToString() + "m" : pitch.Belay; //string lifelineString = pitch.Lifeline.HasValue ? pitch.Lifeline.ToString() + "m" : ""; row.Append( new TableCell(Docx.SimpleParagraph(pitch.Ladder.ToString())), new TableCell(Docx.SimpleParagraph(pitch.Belay.ToString())), new TableCell(Docx.SimpleParagraph(pitch.Lifeline.ToString()))); } if (srt) { //string rope = pitch.Rope != null && pitch.Rope.Text != "") //?? span row.Append( new TableCell(Docx.SimpleParagraph(pitch.Rope.ToString())), new TableCell(Docx.SimpleParagraph(SrtAnchorString(pitch.SrtBelay)))); } table.Append(row); } body.Append(table); } }