public CodeCoverageStringTextSource(string source) { this.textSource = source; lineInfo line; var lineInfoList = new List<lineInfo>(); int offset = 0; int counter = 0; bool newLine = false; bool cr = false; bool lf = false; foreach ( ushort ch in textSource ) { switch (ch) { case 0xD: if (lf||cr) { newLine = true; // cr after cr|lf } else { cr = true; // cr found } break; case 0xA: if (lf) { newLine = true; // lf after lf } else { lf = true; // lf found } break; default: if (cr||lf) { newLine = true; // any non-line-end char after any line-end } break; } if (newLine) { // newLine detected - add line line = new lineInfo(); line.Offset = offset; line.Length = counter - offset; lineInfoList.Add(line); offset = counter; cr = false; lf = false; newLine = false; } ++counter; } // Add last line line = new lineInfo(); line.Offset = offset; line.Length = counter - offset; lineInfoList.Add(line); // Store to readonly field lines = lineInfoList.ToArray(); }
gcLine createRandomizedStretchLine(gcLine gcl, lineInfo lineinf) { lineinf.x = Random.Range(-(Cnc_Settings.WidthInMM / 2), (float)gcl.X); return(new gcLine { G = gcl.G, F = gcl.F, X = lineinf.x, Y = lineinf.y, Z = gcl.Z }); }
/// <summary>Return SequencePoint enumerated line /// </summary> /// <param name="LineNo"></param> /// <returns></returns> public string GetLine(int LineNo) { string retString = String.Empty; if (LineNo > 0 && LineNo <= lines.Length) { lineInfo lineInfo = lines[LineNo - 1]; retString = textSource.Substring(lineInfo.Offset, lineInfo.Length); } else { //Debug.Fail( "Line number out of range" ); } return(retString); }
/// <summary> /// Allows for customised or precalculated ascent mesurements to be passed, fastest way to draw a string /// </summary> /// <param name="g"></param> /// <param name="pos"></param> /// <param name="fontTable"></param> /// <param name="mesurements"></param> public void drawString(Graphics g, PointF pos, FontFamily[] fontTable, lineInfo mesurements) { int i, j; string printString; Font printFont; SizeF charSize; //float across=pos.X; RTFChar fc; PointF charPos = pos; if (data == null) { return; } for (i = 0; i < data.Length; i++) { fc = data[i]; printString = fc.Char.ToString(); //adjust character position to meat the baseline charPos.Y = pos.Y + mesurements.baseline - mesurements.ascents[i]; //apend any characters drawn in the same style for (j = (i + 1); (j < data.Length) && (fc.compareFormat(data[j])); j++) { printString += data[j].Char; } //update i to the end of the common string i = j - 1; //cache the print font printFont = fc.getFont(fontTable); //charSize = fc.measure(g, fontTable); charSize = g.MeasureString(printString, printFont, 999, RTFLine.defalutFormat()); //draw the string g.DrawString(printString, printFont, new SolidBrush(fc.col), charPos, RTFLine.defalutFormat()); charPos.X += charSize.Width; } }
internal void SetCoordsAndMultiLine(List <Coords> coords, bool multiline = false) { ResetScales(); Linebuilder.ClearLines(); OriginalCoords = coords; lineInfoList.Clear(); for (int i = 0; i < OriginalCoords.Count - 1; i += 2) { float deltaX = (float)OriginalCoords[i].X - (float)OriginalCoords[i + 1].X; float deltaY = (float)OriginalCoords[i].Y - (float)OriginalCoords[i + 1].Y; float a = deltaX / (deltaY > 0 ? deltaY : 1); float b = ((float)OriginalCoords[i + 1].Y) / a > 0 ? (a * (float)OriginalCoords[i + 1].X) : 1; lineInfo lineInf = new lineInfo { a = a, b = b }; lineInfoList.Add(lineInf); } }
public CodeCoverageStringTextSource(string source) { this.textSource = source; lineInfo line; var lineInfoList = new List <lineInfo>(); int offset = 0; int counter = 0; bool newLine = false; bool cr = false; bool lf = false; foreach (ushort ch in textSource) { switch (ch) { case 0xD: if (lf || cr) { newLine = true; // cr after cr|lf } else { cr = true; // cr found } break; case 0xA: if (lf) { newLine = true; // lf after lf } else { lf = true; // lf found } break; default: if (cr || lf) { newLine = true; // any non-line-end char after any line-end } break; } if (newLine) // newLine detected - add line { line = new lineInfo(); line.Offset = offset; line.Length = counter - offset; lineInfoList.Add(line); offset = counter; cr = false; lf = false; newLine = false; } ++counter; } // Add last line line = new lineInfo(); line.Offset = offset; line.Length = counter - offset; lineInfoList.Add(line); // Store to readonly field lines = lineInfoList.ToArray(); }
protected override void OnRecache(EventArgs e) { if (this.DataView == null) { _lines = null; Invalidate(); return; } uint numVisLines = this.VisibleSize / this.SizePerLine; if (_lines == null || _lines.Length != numVisLines) { _lines = new lineInfo[numVisLines]; } this.DataView.Seek(this.Address); for (uint i = 0; i < _lines.Length; ++i) { if (this.DataView.Eof) { _lines[i] = null; continue; } ulong curAddress = (ulong)this.Address + (i * this.SizePerLine); if (_lines[i] == null) { _lines[i] = new lineInfo(); } _lines[i].address = (uint)curAddress; string text; bool dataAvail = this.DataView.GetInstruction(out _lines[i].data, out text); _lines[i].dataAvailable = dataAvail; _lines[i].textAvailable = dataAvail; if (dataAvail) { string comment = ""; var spStringX = text.Split(new char[] { ';' }, 2); if (spStringX.Length > 1) { comment = "; " + spStringX[1].Trim(); } var spString = spStringX[0].Trim().Split(new char[] { ' ' }, 2); if (spString.Length > 1) { var mne = spString[0]; while (mne.Length < 7) { mne = mne + " "; } text = mne + " " + spString[1]; } else { text = spString[0]; } uint targetAddr = parseAddress(text); if (targetAddr != 0) { DebugSymbolInfo sym = this.DebugManager.FindSymbol(targetAddr); if (sym != null) { var symMod = this.DebugManager.GetModule(sym.moduleIdx); string symText = symMod.name + "." + sym.name; comment = symText + " " + comment; } } _lines[i].text = text; _lines[i].comment = comment; } } }