protected internal virtual void Initialize(Symbol symbol, LineInfo position) { if (symbol == null) { throw new ArgumentNullException("symbol"); } this.symbol = symbol; this.position = position; }
/// <summary> /// Parse node contents add return a fresh node. /// </summary> /// <param name="prototypes">List containing all node types</param> /// <param name="parent">Node that this is a subnode to. Can be null</param> /// <param name="line">Line to parse</param> /// <param name="offset">Where to start the parsing. Should be set to where the next node should start parsing.</param> /// <returns>A node corresponding to the bla bla; null if parsing failed.</returns> /// <exception cref="Exceptions.CodeGeneratorException"></exception> public override Node Parse(NodeList prototypes, Node parent, LineInfo line, ref int offset) { offset = line.Data.Length; return new DocTypeTag( @"<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Strict//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"">".Replace("\"", "\"\""), parent); }
public string Read(int count, out LineInfo position) { position = new LineInfo(bufferPosition+bufferOffset, line, column); if (count == 0) { return string.Empty; } if (!EnsureBuffer(count-1)) { throw new ArgumentOutOfRangeException("count"); } rollbackBufferOffset = bufferOffset; rollbackBufferPosition = bufferPosition; rollbackColumn = column; rollbackLine = line; rollbackPrevious = previous; var result = new string(buffer, bufferOffset, count); for (int i = 0; i < count; i++) { char current = buffer[bufferOffset++]; switch (current) { case '\r': HandleNewline(current, '\n'); break; case '\n': HandleNewline(current, '\r'); break; default: column++; previous = current; break; } } return result; }
/// <summary> /// Parse node contents add return a fresh node. /// </summary> /// <param name="parent">Node that this is a subnode to. Can be null</param> /// <param name="prototypes">A list with node types</param> /// <param name="line">Line to parse</param> /// <param name="offset">Where to start the parsing. Will be set to where the next node should start parsing</param> /// <returns>A node corresponding to the bla bla; null if parsing failed.</returns> /// <exception cref="CodeGeneratorException"></exception> public override Node Parse(NodeList prototypes, Node parent, LineInfo line, ref int offset) { if (offset > line.Data.Length - 1) throw new CodeGeneratorException(line.LineNumber, line.Data, "Tried to parse after end of line"); if (line.Data[offset] != '_') throw new CodeGeneratorException(line.LineNumber, line.Data, "Not a PartialNode"); // From the first " sign (offset + 2) find the next " sign int pos = -1; for (int i = offset + 2; i < line.Data.Length; ++i) { if (line.Data[i] == '\"') { pos = i; break; } } if (pos == -1) throw new CodeGeneratorException(line.LineNumber, line.Data, "PartialNode does not contain an end paranthesis."); // Cut out the data between the two above found " signs and then start processing the address // The address is converted from the format /example/example/ to \\example\\example.haml PartialNode node = (PartialNode)prototypes.CreateNode("_", parent); node._target = line.Data.Substring(offset + 2, pos - offset - 2); if (node._target[node._target.Length - 1] == '/') node._target = node._target.Substring(0, node._target.Length - 1); if (node._target[0] == '/') node._target = node._target.Substring(1); node._target = node._target.Replace("/", "\\\\"); node._target += ".haml"; offset = pos + 1; return node; }
private readonly string text; // Token text. internal TextToken(Symbol symbol, LineInfo position, string text) { if (symbol == null) { throw new ArgumentNullException("symbol"); } if (text == null) { throw new ArgumentNullException("text"); } this.symbol = symbol; this.position = position; this.text = this.symbol.Name.Equals(text, StringComparison.Ordinal) ? this.symbol.Name : text; // "intern" short strings which are equal to the terminal name }
private LineInfo NewLine ( int i ) { if ( lIndex >= 999 ) { lIndex = 0; } LineInfo newLine = new LineInfo ( i, lineHeight ); lines[lIndex] = ( newLine ); height += lineHeight; lIndex++; return newLine; }
/// <summary> /// Parse node contents add return a fresh node. /// </summary> /// <param name="prototypes">List containing all node types</param> /// <param name="parent">Node that this is a subnode to. Can be null</param> /// <param name="line">Line to parse</param> /// <param name="offset">Where to start the parsing. Should be set to where the next node should start parsing.</param> /// <returns>A node corresponding to the bla bla; null if parsing failed.</returns> /// <exception cref="Exceptions.CodeGeneratorException"></exception> public override Node Parse(NodeList prototypes, Node parent, LineInfo line, ref int offset) { // text on tag rows are identified by a single space. if (parent != null && line.Data[offset] == ' ') ++offset; TextNode node = new TextNode(parent, line.Data.Substring(offset)); if (parent == null) node.LineInfo = line; offset = line.Data.Length; return node; }
internal FunctionImportEntityTypeMapping(IEnumerable<EntityType> isOfTypeEntityTypes, IEnumerable<EntityType> entityTypes, IEnumerable<FunctionImportEntityTypeMappingCondition> conditions, Collection<FunctionImportReturnTypePropertyMapping> columnsRenameList, LineInfo lineInfo) : base(columnsRenameList, lineInfo) { this.IsOfTypeEntityTypes = new ReadOnlyCollection<EntityType>( EntityUtil.CheckArgumentNull(isOfTypeEntityTypes, "isOfTypeEntityTypes").ToList()); this.EntityTypes = new ReadOnlyCollection<EntityType>( EntityUtil.CheckArgumentNull(entityTypes, "entityTypes").ToList()); this.Conditions = new ReadOnlyCollection<FunctionImportEntityTypeMappingCondition>( EntityUtil.CheckArgumentNull(conditions, "conditions").ToList()); }
public void GivenModeIsAlwaysQuotedWhenLineInfoIsNotQuotedThenAnExceptionIsThrown() { var fi = new Mock<FieldInfo>(); fi.Setup(f => f.FieldType).Returns(typeof (string)); var fieldUnderTest = new DelimitedField(fi.Object, ";") { QuoteChar = '%', QuoteMode = QuoteMode.AlwaysQuoted }; var invalidLineInfo = new LineInfo("Hello, World") { mReader = new ForwardReader(new Mock<IRecordReader>().Object, 0), }; Assert.Throws<BadUsageException>(() => fieldUnderTest.ExtractFieldString(invalidLineInfo)); }
/// <summary> /// Creates a DIV node and add's the specified node to it. /// </summary> /// <param name="prototypes">Contains all prototypes for each control char. used to instanciate new nodes.</param> /// <param name="parent">parent node</param> /// <param name="line">current line information</param> /// <param name="me">node to add to the DIV node</param> /// <returns>current node</returns> public Node AddMe(NodeList prototypes, Node parent, LineInfo line, Node me) { if (parent == null) { TagNode tag = (TagNode)prototypes.CreateNode("%", null); tag.Name = "div"; tag.LineInfo = line; tag.AddModifier(me); return tag; } return me; }
/// <summary> /// Determines if this node spans over multiple lines. /// </summary> /// <param name="line">contains line information (and text)</param> /// <param name="isContinued">true if the previous line was continued.</param> /// <returns>true if this line continues onto the next.</returns> public override bool IsMultiLine(LineInfo line, bool isContinued) { string trimmed = line.Data.TrimEnd(); if (trimmed.Length == 0) return false; if (trimmed.EndsWith("|")) { line.TrimRight(1); return true; } return false; }
/// <summary> /// Determines if this node spans over multiple lines. /// </summary> /// <param name="line">contains line information (and text)</param> /// <param name="isContinued">true if the previous line was continued.</param> /// <returns>true if this line continues onto the next.</returns> public override bool IsMultiLine(LineInfo line, bool isContinued) { // hack to dont include code // a more proper way would have bene to scan after each tag if (!isContinued) { char ch = line.Data[0]; if (ch != '#' && ch != '%' && ch != '.') return false; } bool inQuote = false; bool inAttribute = false; if (isContinued && line.Data.IndexOf('{') == -1) inAttribute = true; foreach (char ch in line.Data) { if (ch == '"') inQuote = !inQuote; else if (ch == '{' && !inQuote) { if (inAttribute) throw new CodeGeneratorException(line.LineNumber, line.Data, "Found another start of attributes, but no close tag. Have you forgot one '}'?"); inAttribute = true; } else if (ch == '}' && !inQuote) inAttribute = false; } if (inQuote) throw new CodeGeneratorException(line.LineNumber, line.Data, "Attribute quotes can not span over multiple lines."); if (inAttribute) { //todo: Attach a log writer. //Console.WriteLine("Attribute is not closed, setting unfinished rule"); line.UnfinishedRule = this; line.Data.TrimEnd(); if (line.Data.EndsWith("|")) line.TrimRight(1); return true; } return inAttribute; }
/// <summary> /// Parse node contents add return a fresh node. /// </summary> /// <param name="prototypes">List containing all node types</param> /// <param name="parent">Node that this is a subnode to. Can be null</param> /// <param name="line">Line to parse</param> /// <param name="offset">Where to start the parsing. Should be set to where the next node should start parsing.</param> /// <returns>A node corresponding to the bla bla; null if parsing failed.</returns> /// <exception cref="CodeGeneratorException"></exception> public override Node Parse(NodeList prototypes, Node parent, LineInfo line, ref int offset) { if (offset > line.Data.Length) throw new CodeGeneratorException(line.LineNumber, line.Data, "Too little data"); int pos = line.Data.Length; ++offset; string code = line.Data.Substring(offset, pos - offset); offset = pos; SilentCodeNode node = (SilentCodeNode)prototypes.CreateNode("-", parent); node._code = code; if (parent != null) node.LineInfo = line; return node; }
/// <summary> /// The general idea is to create a regex based of the "Format: "-line in .ass file. Which /// then can be used to easily filter the required information (namely timestamps, text and /// actor). /// </summary> /// <param name="settings">Settings.</param> /// <param name="rawLines">Raw lines.</param> public List<LineInfo> parse(Settings settings, LinkedList<String> rawLines) { List<LineInfo> lines = new List<LineInfo> (); string formatRegex = GetFormatRegex (rawLines); if (formatRegex == null) return null; // parse every line with format regex and save lines in LineInfo foreach(string rawLine in rawLines) { Match lineMatch = Regex.Match(rawLine, formatRegex, RegexOptions.IgnoreCase | RegexOptions.Compiled); if (!lineMatch.Success) continue; string startTimeString = lineMatch.Groups ["StartTime"].ToString ().Trim (); string endTimeString = lineMatch.Groups ["EndTime"].ToString ().Trim (); string nameString = lineMatch.Groups ["Name"].ToString ().Trim (); string textString = lineMatch.Groups ["Text"].ToString ().Trim (); if (settings.IgnoreStyledSubLines && textString.StartsWith ("{") // NOTE: this is a really big hint for styled subtitles but might create false-negatives -- research common patterns in subtitle files && !textString.StartsWith ("{\\b1}") // bold && !textString.StartsWith ("{\\u1}") // underline && !textString.StartsWith ("{\\i1}") // italics && !textString.StartsWith ("{\\an8}") // text align: up ) { continue; } // remove styling in subtitles textString = Regex.Replace(textString, "{.*?}", ""); if (textString == "") continue; // ignore lines without text // generate line info LineInfo li = new LineInfo(parseTime(startTimeString), parseTime(endTimeString), textString, new List<String>(new String[]{ nameString })); lines.Add(li); } return lines; }
/// <summary> /// Parse node contents add return a fresh node. /// </summary> /// <param name="prototypes">List containing all node types</param> /// <param name="parent">Node that this is a subnode to. Can be null</param> /// <param name="line">Line to parse</param> /// <param name="offset">Where to start the parsing. Should be set to where the next node should start parsing.</param> /// <returns>A node corresponding to the bla bla; null if parsing failed.</returns> /// <exception cref="CodeGeneratorException"></exception> public override Node Parse(NodeList prototypes, Node parent, LineInfo line, ref int offset) { if (offset > line.Data.Length - 1) throw new CodeGeneratorException(line.LineNumber, line.Data, "Too little data"); int pos = GetEndPos(offset, line.Data); if (pos == -1) pos = line.Data.Length; ++offset; string name = line.Data.Substring(offset, pos - offset); offset = pos; ClassNode node = (ClassNode)prototypes.CreateNode(".", parent); node._name = name; return AddMe(prototypes, parent, line, node); }
/// <summary> /// Parse node contents add return a fresh node. /// </summary> /// <param name="prototypes">List containing all node types</param> /// <param name="parent">Node that this is a subnode to. Can be null</param> /// <param name="line">Line to parse</param> /// <param name="offset">Where to start the parsing. Should be set to where the next node should start parsing.</param> /// <returns>A node corresponding to the bla bla; null if parsing failed.</returns> /// <exception cref="CodeGeneratorException"></exception> public override Node Parse(NodeList prototypes, Node parent, LineInfo line, ref int offset) { if (line.Data[offset] != '#') throw new CodeGeneratorException(line.LineNumber, line.Data, "Node is not an id node."); int endPos = GetEndPos(offset, line.Data); if (endPos == -1) endPos = line.Data.Length; ++offset; string id = line.Data.Substring(offset, endPos - offset); offset = endPos; IdNode node = (IdNode)prototypes.CreateNode("#", parent); node._id = id; return AddMe(prototypes, parent, line, node); }
public override void onSwitchIn() { string pureBasName = m_stateMgr.CUR_CODE_FILE_NAME; // remove the extesion name if( !string.IsNullOrEmpty(pureBasName) ) pureBasName = pureBasName.Substring(0, pureBasName.Length - 4); m_fileName = new LineInfo(pureBasName); m_curIndex = 0; m_stateMgr.m_textDisplay.Clear(); m_stateMgr.m_textDisplay.DrawText(0, 0, "Input file name:"); m_stateMgr.m_textDisplay.DrawText(0, 1, pureBasName); m_stateMgr.m_textDisplay.Refresh(); m_stateMgr.m_textDisplay.SetCursor(0,1); }
/// <summary> /// Parse node contents add return a fresh node. /// </summary> /// <param name="prototypes">List containing all node types</param> /// <param name="parent">Node that this is a subnode to. Can be null</param> /// <param name="line">Line to parse</param> /// <param name="offset">Where to start the parsing. Should be set to where the next node should start parsing.</param> /// <returns>A node corresponding to the bla bla; null if parsing failed.</returns> /// <exception cref="CodeGeneratorException"></exception> public override Node Parse(NodeList prototypes, Node parent, LineInfo line, ref int offset) { if (offset >= line.Data.Length) throw new CodeGeneratorException(line.LineNumber, line.Data, "Too little data"); int pos = line.Data.Length; ++offset; string name = line.Data.Substring(offset, pos - offset); offset = pos; string trimmedData = line.Data.Trim(); if (trimmedData.Length > 0 && trimmedData[trimmedData.Length - 1] == ';') throw new CodeGeneratorException(line.LineNumber, line.Data, "Displayed code should not end with semicolon."); DisplayCodeNode node = (DisplayCodeNode)prototypes.CreateNode("=", parent); node._code = name; if (parent == null) node.LineInfo = line; return node; }
public static void Run() { // ExStart:lnkAnnotationLineWidth // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_Annotations(); Document doc = new Document(); doc.Pages.Add(); ArrayList inkList = new ArrayList(); LineInfo lineInfo = new LineInfo(); lineInfo.VerticeCoordinate = new float[] { 55, 55, 70, 70, 70, 90, 150, 60 }; lineInfo.Visibility = true; lineInfo.LineColor = System.Drawing.Color.Red; lineInfo.LineWidth = 2; int length = lineInfo.VerticeCoordinate.Length / 2; Aspose.Pdf.Point[] gesture = new Aspose.Pdf.Point[length]; for (int i = 0; i < length; i++) { gesture[i] = new Aspose.Pdf.Point(lineInfo.VerticeCoordinate[2 * i], lineInfo.VerticeCoordinate[2 * i + 1]); } inkList.Add(gesture); InkAnnotation a1 = new InkAnnotation(doc.Pages[1], new Aspose.Pdf.Rectangle(100, 100, 300, 300), inkList); a1.Subject = "Test"; a1.Title = "Title"; a1.Color = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Green); Border border = new Border(a1); border.Width = 3; border.Effect = BorderEffect.Cloudy; border.Dash = new Dash(1, 1); border.Style = BorderStyle.Solid; doc.Pages[1].Annotations.Add(a1); dataDir = dataDir + "lnkAnnotationLineWidth_out.pdf"; // Save output file doc.Save(dataDir); // ExEnd:lnkAnnotationLineWidth Console.WriteLine("\nlnk annotation line width setup successfully.\nFile saved at " + dataDir); }
// ExStart:DrawBox private static void DrawBox(PdfContentEditor editor, int page, TextSegment segment, System.Drawing.Color color) { var lineInfo = new LineInfo(); lineInfo.VerticeCoordinate = new[] { (float)segment.Rectangle.LLX, (float)segment.Rectangle.LLY, (float)segment.Rectangle.LLX, (float)segment.Rectangle.URY, (float)segment.Rectangle.URX, (float)segment.Rectangle.URY, (float)segment.Rectangle.URX, (float)segment.Rectangle.LLY }; lineInfo.Visibility = true; lineInfo.LineColor = color; editor.CreatePolygon(lineInfo, page, new System.Drawing.Rectangle(0, 0, 0, 0), null); }
/// <inheritdoc /> public override void ReportError(EvaluationErrors errors, ModuleLiteral environment, LineInfo location, Expression expression, Context context) { errors.ReportDisallowedUnsafeAmbientCallError(environment, expression, MethodName, location); }
static private void Merging(int nBGIndxPixel, LineInfo cLI) { MergeInfo cMergeInfo = (MergeInfo)_cDisComProcessing._cInfo; if (nBGIndxPixel < cMergeInfo.nBackgroundSize) //2-й - это размер BG, 3-й - ширина BG, 4-й - делать ли задник? 5-й - инфа про FG1; { //Периодичность PRECOMPUTED_INFO_PERIOD - 1-й. 0-й - это количество слоёв int M, nIndxIndent, nRow; int nBGIndxRed, nBGIndxGreen, nBGIndxBlue, nBGIndxAlpha, nFGIndx; byte nFGColorRed = 0, nFGColorGreen = 0, nFGColorBlue = 0, nFGColorAlpha = 0; int nNextIndxRed, nNextIndxGreen, nNextIndxBlue, nNextIndxAlpha, nPixelAlphaIndx; byte nPixelAlpha; int nMaskIndx = -1; LayerInfo cLayerInfo; LineInfo.LineLayerInfo cLLI; nBGIndxRed = nBGIndxPixel * 4; nBGIndxGreen = nBGIndxRed + 1; nBGIndxBlue = nBGIndxRed + 2; nBGIndxAlpha = nBGIndxRed + 3; _cDisComProcessing._aLayers[0][nBGIndxRed] = 0; _cDisComProcessing._aLayers[0][nBGIndxGreen] = 0; _cDisComProcessing._aLayers[0][nBGIndxBlue] = 0; if (1 == cMergeInfo.nBackgroundAlphaType) nMaskIndx = nBGIndxAlpha; else _cDisComProcessing._aLayers[0][nBGIndxAlpha] = cMergeInfo.nBackgroundAlphaType; for (ushort nLayerIndx = 1; cMergeInfo.nLayersQty > nLayerIndx; nLayerIndx++) { cLayerInfo = cMergeInfo.aLayerInfos[(int)(nLayerIndx - 1)]; cLLI = cLI.aLineLayers[(int)(nLayerIndx - 1)]; if (nBGIndxPixel >= cLLI.nBGCropStart && nBGIndxPixel <= cLLI.nBGCropEnd) { nFGIndx = (nBGIndxPixel - cLLI.nBGCropStart + cLLI.nFGCropStart) * 4; if (1 == cLayerInfo.nAlphaType) //леер является маской { if (_cDisComProcessing._aLayers[nLayerIndx].Length - 1 < (nMaskIndx = nFGIndx + 3)) nMaskIndx = -1; continue; } nFGColorAlpha = _cDisComProcessing._aLayers[nLayerIndx][nFGIndx + 3]; if (-1 < nMaskIndx) //применяем маску { if (255 == _cDisComProcessing._aLayers[nLayerIndx - 1][nMaskIndx]) //отрезали пиксел по маске { nMaskIndx = -1; continue; } else if (0 < _cDisComProcessing._aLayers[nLayerIndx - 1][nMaskIndx]) nFGColorAlpha = (byte)(nFGColorAlpha * (1 - _cDisComProcessing._aLayers[nLayerIndx - 1][nMaskIndx] / 255f) + 0.5); nMaskIndx = -1; } nFGColorRed = _cDisComProcessing._aLayers[nLayerIndx][nFGIndx]; nFGColorGreen = _cDisComProcessing._aLayers[nLayerIndx][nFGIndx + 1]; nFGColorBlue = _cDisComProcessing._aLayers[nLayerIndx][nFGIndx + 2]; if (0 == cLayerInfo.nAlphaType) // т.е. наш слой не альфирующий, а обычный слой с альфой RGBA { if (0 != cLayerInfo.nShiftPosition || 0 != cLayerInfo.nShiftTotal)// обработка расположения между пикселями. Берем инфу с того места откуда она приехала в этот пиксель { if (cLayerInfo.bShiftVertical) // для вертикальных cLayerInfo.nShiftTotal == 0 { if (0 < cLayerInfo.nShiftPosition) { nPixelAlpha = nFGColorAlpha; nFGColorAlpha = (byte)((nFGColorAlpha + 1) * (1 - cLayerInfo.nShiftPosition)); if (cLLI.bRowUnder) { nNextIndxRed = nFGIndx + (cLayerInfo.nWidth * 4); nNextIndxGreen = nNextIndxRed + 1; nNextIndxBlue = nNextIndxRed + 2; nNextIndxAlpha = nNextIndxRed + 3; if (0 < _cDisComProcessing._aLayers[nLayerIndx][nNextIndxAlpha]) { if (0 < (nPixelAlpha = (byte)((_cDisComProcessing._aLayers[nLayerIndx][nNextIndxAlpha] + 1) * cLayerInfo.nShiftPosition))) { if (0 == nFGColorAlpha || 254 < nPixelAlpha) { nFGColorRed = _cDisComProcessing._aLayers[nLayerIndx][nNextIndxRed]; nFGColorGreen = _cDisComProcessing._aLayers[nLayerIndx][nNextIndxGreen]; nFGColorBlue = _cDisComProcessing._aLayers[nLayerIndx][nNextIndxBlue]; } else { nPixelAlphaIndx = nPixelAlpha - 1; nFGColorRed = _aAlphaMap[nPixelAlphaIndx, nFGColorRed, _cDisComProcessing._aLayers[nLayerIndx][nNextIndxRed]]; nFGColorGreen = _aAlphaMap[nPixelAlphaIndx, nFGColorGreen, _cDisComProcessing._aLayers[nLayerIndx][nNextIndxGreen]]; nFGColorBlue = _aAlphaMap[nPixelAlphaIndx, nFGColorBlue, _cDisComProcessing._aLayers[nLayerIndx][nNextIndxBlue]]; } } if (255 < nFGColorAlpha + nPixelAlpha) nFGColorAlpha = 255; else nFGColorAlpha += nPixelAlpha; } } } else // тестовый элз - это если в роле не 1 - (....) а просто - (.....) в шифт идёт. тут другой способ. { if (cLLI.bRowUpper) { int nUpPxIndx = nFGIndx - (cLayerInfo.nWidth * 4); nFGColorRed = (byte)(_cDisComProcessing._aLayers[nLayerIndx][nFGIndx] * (1 + cLayerInfo.nShiftPosition) + _cDisComProcessing._aLayers[nLayerIndx][nUpPxIndx] * (-cLayerInfo.nShiftPosition)); nFGColorGreen = (byte)(_cDisComProcessing._aLayers[nLayerIndx][nFGIndx + 1] * (1 + cLayerInfo.nShiftPosition) + _cDisComProcessing._aLayers[nLayerIndx][nUpPxIndx + 1] * (-cLayerInfo.nShiftPosition)); nFGColorBlue = (byte)(_cDisComProcessing._aLayers[nLayerIndx][nFGIndx + 2] * (1 + cLayerInfo.nShiftPosition) + _cDisComProcessing._aLayers[nLayerIndx][nUpPxIndx + 2] * (-cLayerInfo.nShiftPosition)); nFGColorAlpha = (byte)(_cDisComProcessing._aLayers[nLayerIndx][nFGIndx + 3] * (1 + cLayerInfo.nShiftPosition) + _cDisComProcessing._aLayers[nLayerIndx][nUpPxIndx + 3] * (-cLayerInfo.nShiftPosition)); } else { nFGColorRed = (byte)(_cDisComProcessing._aLayers[nLayerIndx][nFGIndx] * (1 + cLayerInfo.nShiftPosition)); nFGColorGreen = (byte)(_cDisComProcessing._aLayers[nLayerIndx][nFGIndx + 1] * (1 + cLayerInfo.nShiftPosition)); nFGColorBlue = (byte)(_cDisComProcessing._aLayers[nLayerIndx][nFGIndx + 2] * (1 + cLayerInfo.nShiftPosition)); nFGColorAlpha = (byte)(_cDisComProcessing._aLayers[nLayerIndx][nFGIndx + 3] * (1 + cLayerInfo.nShiftPosition)); } } } else // движение горизонтальное { if (0 > cLayerInfo.nShiftPosition || 0 > cLayerInfo.nShiftTotal) // значит движение было влево (определяем по двум, т.к. могло попасть ровно пиксель в пиксель) { int nRowBeginingIndx = cLLI.nFGLineBeginning * 4; if (0 == ((cLLI.nBgFgLinesDelta + cLayerInfo.nOffsetTop) & 1)) // -----в dvPal это та по чётности строка, которая первой должна показывааться! Т.е. половина движения { double nHalf = (cLayerInfo.nShiftTotal / 2) + cLayerInfo.nShiftPosition; int nDeltaPx = (int)nHalf; double nNewShift = nHalf - nDeltaPx; nFGIndx = nFGIndx + 4 * nDeltaPx; int nLeftPxIndx = nFGIndx - 4; if (nLeftPxIndx >= nRowBeginingIndx) { nFGColorRed = (byte)(_cDisComProcessing._aLayers[nLayerIndx][nFGIndx] * (1 + nNewShift) + _cDisComProcessing._aLayers[nLayerIndx][nLeftPxIndx] * (-nNewShift)); nFGColorGreen = (byte)(_cDisComProcessing._aLayers[nLayerIndx][nFGIndx + 1] * (1 + nNewShift) + _cDisComProcessing._aLayers[nLayerIndx][nLeftPxIndx + 1] * (-nNewShift)); nFGColorBlue = (byte)(_cDisComProcessing._aLayers[nLayerIndx][nFGIndx + 2] * (1 + nNewShift) + _cDisComProcessing._aLayers[nLayerIndx][nLeftPxIndx + 2] * (-nNewShift)); nFGColorAlpha = (byte)(_cDisComProcessing._aLayers[nLayerIndx][nFGIndx + 3] * (1 + nNewShift) + _cDisComProcessing._aLayers[nLayerIndx][nLeftPxIndx + 3] * (-nNewShift)); } else if (nFGIndx >= nRowBeginingIndx) { nFGColorRed = (byte)(_cDisComProcessing._aLayers[nLayerIndx][nFGIndx] * (1 + nNewShift)); nFGColorGreen = (byte)(_cDisComProcessing._aLayers[nLayerIndx][nFGIndx + 1] * (1 + nNewShift)); nFGColorBlue = (byte)(_cDisComProcessing._aLayers[nLayerIndx][nFGIndx + 2] * (1 + nNewShift)); nFGColorAlpha = (byte)(_cDisComProcessing._aLayers[nLayerIndx][nFGIndx + 3] * (1 + nNewShift)); } } else // -----в dvPal это та по чётности строка, которая второй должна показывааться! Т.е. целое движение { // берем инфу с двух соседних пикселей в пропорции шифта - с этого и с пикселя слева от этого. Т.к. был перелет из-за отбрасывания дробной части от X // this_pixel = this_pixel * (1+shift) + left_pixel * (-shift) тут shift<0 |shift|<1 int nLeftPxIndx = nFGIndx - 4; if (nLeftPxIndx >= nRowBeginingIndx) // левый пиксель ещё в нашей строке { nFGColorRed = (byte)(_cDisComProcessing._aLayers[nLayerIndx][nFGIndx] * (1 + cLayerInfo.nShiftPosition) + _cDisComProcessing._aLayers[nLayerIndx][nLeftPxIndx] * (-cLayerInfo.nShiftPosition)); nFGColorGreen = (byte)(_cDisComProcessing._aLayers[nLayerIndx][nFGIndx + 1] * (1 + cLayerInfo.nShiftPosition) + _cDisComProcessing._aLayers[nLayerIndx][nLeftPxIndx + 1] * (-cLayerInfo.nShiftPosition)); nFGColorBlue = (byte)(_cDisComProcessing._aLayers[nLayerIndx][nFGIndx + 2] * (1 + cLayerInfo.nShiftPosition) + _cDisComProcessing._aLayers[nLayerIndx][nLeftPxIndx + 2] * (-cLayerInfo.nShiftPosition)); nFGColorAlpha = (byte)(_cDisComProcessing._aLayers[nLayerIndx][nFGIndx + 3] * (1 + cLayerInfo.nShiftPosition) + _cDisComProcessing._aLayers[nLayerIndx][nLeftPxIndx + 3] * (-cLayerInfo.nShiftPosition)); } else // если наш пиксель первый в строке - он просто "ослабнет" { nFGColorRed = (byte)(_cDisComProcessing._aLayers[nLayerIndx][nFGIndx] * (1 + cLayerInfo.nShiftPosition)); nFGColorGreen = (byte)(_cDisComProcessing._aLayers[nLayerIndx][nFGIndx + 1] * (1 + cLayerInfo.nShiftPosition)); nFGColorBlue = (byte)(_cDisComProcessing._aLayers[nLayerIndx][nFGIndx + 2] * (1 + cLayerInfo.nShiftPosition)); nFGColorAlpha = (byte)(_cDisComProcessing._aLayers[nLayerIndx][nFGIndx + 3] * (1 + cLayerInfo.nShiftPosition)); } } //nColumn = nIndxIndent - cLayerInfo.nCropLeft; } else // значит движение было вправо { } } } nPixelAlpha = cLayerInfo.nAlphaConstant; if (255 == nPixelAlpha) nPixelAlpha = nFGColorAlpha; else if (0 == nFGColorAlpha) nPixelAlpha = 0; else if (0 < nPixelAlpha && 255 > nFGColorAlpha) // объединение альфы слоя с константной альфой !!!! nPixelAlpha = (byte)((float)nFGColorAlpha * nPixelAlpha / 255 + 0.5); } else nPixelAlpha = 255; if (0 < nPixelAlpha) { if (255 == nPixelAlpha || 0 == _cDisComProcessing._aLayers[0][nBGIndxAlpha]) { _cDisComProcessing._aLayers[0][nBGIndxRed] = nFGColorRed; _cDisComProcessing._aLayers[0][nBGIndxGreen] = nFGColorGreen; _cDisComProcessing._aLayers[0][nBGIndxBlue] = nFGColorBlue; } else { //индекс меньше, т.к. 0-е значение альфы мы не считаем и все индексы сдвинулись... nPixelAlphaIndx = nPixelAlpha - 1; _cDisComProcessing._aLayers[0][nBGIndxRed] = _aAlphaMap[nPixelAlphaIndx, _cDisComProcessing._aLayers[0][nBGIndxRed], nFGColorRed]; _cDisComProcessing._aLayers[0][nBGIndxGreen] = _aAlphaMap[nPixelAlphaIndx, _cDisComProcessing._aLayers[0][nBGIndxGreen], nFGColorGreen]; _cDisComProcessing._aLayers[0][nBGIndxBlue] = _aAlphaMap[nPixelAlphaIndx, _cDisComProcessing._aLayers[0][nBGIndxBlue], nFGColorBlue]; } if (_cDisComProcessing._aLayers[0][nBGIndxAlpha] < nPixelAlpha) // очередная попытка примирить альфу с действительностью )) _cDisComProcessing._aLayers[0][nBGIndxAlpha] = nPixelAlpha; } } else nMaskIndx = -1; } } }
public static void Return(LineInfo value) { pool.Push(value); }
/// <nodoc /> public static TryGetMountException MountNameCaseMismatch(ModuleLiteral environment, string name, string mountName, ErrorContext errorContext, LineInfo lineInfo) { Contract.Requires(environment != null); Action <EvaluationErrors> logAction = errors => errors.ReportGetMountNameCaseMisMatch(environment, name, mountName, lineInfo: lineInfo); return(new TryGetMountException(logAction, errorContext)); }
private static async ValueTask ScanDependenciesAsync(ScanFileContext context, JObject deps) { foreach (var dep in deps.Properties()) { if (dep.Value is null) { continue; } var packageName = dep.Name; string?version = null; if (dep.Value.Type == JTokenType.String) { if (dep.Value != null) { version = dep.Value.Value <string>(); } } else if (dep.Value.Type == JTokenType.Object) { if (dep.Value != null) { var token = dep.Value.SelectToken("$.version"); if (token != null) { version = token.Value <string>(); } } } else { continue; } if (version is null) { continue; } if (dep.Value != null) { var dependency = new Dependency(packageName, version, DependencyType.Npm, new JsonLocation(context.FullPath, LineInfo.FromJToken(dep), dep.Value.Path)); await context.ReportDependency(dependency).ConfigureAwait(false); } } }
public async Task Reset() { CancellationTokenSource cts = new CancellationTokenSource(); CancellationToken cancel = cts.Token; CancellationTokenSource cts2 = Interlocked.Exchange(ref CurrentCancel, cts); if (cts2 != null) { cts2.Cancel(); cts2.Dispose(); } await ResetMutex.WaitAsync(); try { // We need to collect infomation about lines on the UI thread. ITextSnapshot snapshot = OriginalSnapshot.TextBuffer.CurrentSnapshot; if (Snapshot == null || snapshot.Length < Snapshot.Length) { FindLongestLine(snapshot, cancel); } List <LineInfo[]> chunkInfo = new List <LineInfo[]>(snapshot.LineCount / ChunkSize + 1); int lineCount = snapshot.LineCount; for (int lineNumber = 0; lineNumber < lineCount; lineNumber += ChunkSize) { int chunkSize = lineCount - lineNumber; if (chunkSize > ChunkSize) { chunkSize = ChunkSize; } LineInfo[] lineInfo = new LineInfo[chunkSize]; SetLineInfo( lineInfo, snapshot, lineNumber, lineNumber + chunkSize - 1, cancel ); chunkInfo.Add(lineInfo); } ValidateChunks(chunkInfo); await Task.Run(() => { List <LineSpanChunk> lineSpans = GetLineSpans(chunkInfo, cancel); lock (Chunks) { Chunks.Clear(); Chunks.AddRange(lineSpans); } }); Snapshot = snapshot; } finally { ResetMutex.Release(); } }
private void FrmEditProject_Load(object sender, EventArgs e) { double?q1 = null; double?q2 = null; double?q3 = null; string q4 = ""; double?q5 = null; double?q6 = null; string q7 = ""; string q8 = ""; string c1 = ""; string c2 = ""; string c3 = ""; int t1 = 0; PowerProTypes ppt = new PowerProTypes(); ppt.ID = poweruid; ppt.Flag2 = flag; PowerProTypes ps = Common.Services.BaseService.GetOneByKey <PowerProTypes>(ppt); if (ps != null) { groupBox1.Text = ps.Title; powerid = ps.Code; c1 = ps.StartYear.ToString(); c2 = ps.EndYear.ToString(); c3 = ps.Remark; t1 = ps.Flag; q1 = ps.L1; q2 = ps.L2; q3 = ps.L3; q4 = ps.L4; q5 = ps.L5; q6 = ps.L6; } LineInfo li22 = Common.Services.BaseService.GetOneByKey <LineInfo>(powerid); if (li22 != null || t1 == 1) { isline = true; } substation sb = Common.Services.BaseService.GetOneByKey <substation>(powerid); if (sb != null || t1 == 2) { isPower = true; } PowerProValues ppv = new PowerProValues(); ppv.TypeID = poweruid; ppv.TypeID1 = flag; IList <PowerProValues> listValues = Common.Services.BaseService.GetList <PowerProValues>("SelectPowerProValuesList", ppv); PowerProYears pps = new PowerProYears(); pps.Flag = flag; IList <PowerProYears> li = Common.Services.BaseService.GetList <PowerProYears>("SelectPowerProYearsListByFlag", pps); lb = new Label[li.Count]; te = new TextEdit[li.Count]; int i = 0; if (!isPower) { lt1.Text = "长度:"; lt1.Location = new Point(52, 27 + 33 * i); groupBox1.Controls.Add(lt1); tt1 = new TextEdit(); tt1.Location = new Point(157, 26 + 33 * i); tt1.Size = new Size(231, 21); tt1.Properties.DisplayFormat.FormatString = "n4"; tt1.Properties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric; tt1.Properties.EditFormat.FormatString = "n4"; tt1.Properties.EditFormat.FormatType = DevExpress.Utils.FormatType.Numeric; tt1.Properties.Mask.EditMask = "#####0.####"; tt1.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Numeric; groupBox1.Controls.Add(tt1); i++; lt2.Text = "型号:"; lt2.Location = new Point(52, 27 + 33 * i); groupBox1.Controls.Add(lt2); tt2 = new TextEdit(); tt2.Location = new Point(157, 26 + 33 * i); tt2.Size = new Size(231, 21); groupBox1.Controls.Add(tt2); i++; } if (!isline) { lt3.Text = "台数:"; lt3.Location = new Point(52, 27 + 33 * i); groupBox1.Controls.Add(lt3); tt3 = new TextEdit(); tt3.Location = new Point(157, 26 + 33 * i); tt3.Size = new Size(231, 21); tt3.Properties.DisplayFormat.FormatString = "n0"; tt3.Properties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric; tt3.Properties.EditFormat.FormatString = "n0"; tt3.Properties.EditFormat.FormatType = DevExpress.Utils.FormatType.Numeric; tt3.Properties.Mask.EditMask = "########"; tt3.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Numeric; groupBox1.Controls.Add(tt3); i++; lt4.Text = "容量:"; lt4.Location = new Point(52, 27 + 33 * i); groupBox1.Controls.Add(lt4); tt4 = new TextEdit(); tt4.Location = new Point(157, 26 + 33 * i); tt4.Size = new Size(231, 21); tt4.Properties.DisplayFormat.FormatString = "n4"; tt4.Properties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric; tt4.Properties.EditFormat.FormatString = "n4"; tt4.Properties.EditFormat.FormatType = DevExpress.Utils.FormatType.Numeric; tt4.Properties.Mask.EditMask = "#####0.####"; tt4.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Numeric; groupBox1.Controls.Add(tt4); i++; lt5.Text = "负荷率(%):"; lt5.Location = new Point(52, 27 + 33 * i); groupBox1.Controls.Add(lt5); tt5 = new TextEdit(); tt5.Location = new Point(157, 26 + 33 * i); tt5.Size = new Size(231, 21); tt5.Properties.DisplayFormat.FormatString = "####.##"; tt5.Properties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric; tt5.Properties.EditFormat.FormatString = "####.##"; tt5.Properties.EditFormat.FormatType = DevExpress.Utils.FormatType.Numeric; tt5.Properties.Mask.EditMask = "P2"; tt5.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Numeric; groupBox1.Controls.Add(tt5); i++; lt6.Text = "最大负荷:"; lt6.Location = new Point(52, 27 + 33 * i); groupBox1.Controls.Add(lt6); tt6 = new TextEdit(); tt6.Location = new Point(157, 26 + 33 * i); tt6.Size = new Size(231, 21); tt6.Properties.DisplayFormat.FormatString = "n4"; tt6.Properties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric; tt6.Properties.EditFormat.FormatString = "n4"; tt6.Properties.EditFormat.FormatType = DevExpress.Utils.FormatType.Numeric; tt6.Properties.Mask.EditMask = "#####0.####"; tt6.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Numeric; groupBox1.Controls.Add(tt6); i++; } int j = 0; foreach (PowerProYears ppy in li) { lb[j] = new Label(); lb[j].Name = "Label" + ppy.Year; lb[j].Text = ppy.Year + ":"; lb[j].Location = new Point(52, 27 + 33 * i); groupBox1.Controls.Add(lb[j]); te[j] = new TextEdit(); te[j].Name = "Text" + ppy.Year; te[j].Location = new Point(157, 26 + 33 * i); te[j].Size = new Size(231, 21); groupBox1.Controls.Add(te[j]); foreach (PowerProValues ppy1 in listValues) { if (ppy.Year == ppy1.Year) { te[j].Text = ppy1.Value; } } j++; i++; } if (!isstuff) { ls1.Text = "计划开始时间:"; ls1.Location = new Point(52, 27 + 33 * i); groupBox1.Controls.Add(ls1); ts1 = new TextEdit(); ts1.Location = new Point(157, 27 + 33 * i); ts1.Size = new Size(231, 21); if (c1 == "0" || c1 == "") { ts1.Text = ""; } else { ts1.Text = c1; } ts1.Properties.DisplayFormat.FormatString = "n0"; ts1.Properties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric; ts1.Properties.EditFormat.FormatString = "n0"; ts1.Properties.EditFormat.FormatType = DevExpress.Utils.FormatType.Numeric; ts1.Properties.Mask.EditMask = "####"; ts1.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Numeric; groupBox1.Controls.Add(ts1); i++; ls2.Text = "预计投产时间:"; ls2.Location = new Point(52, 27 + 33 * i); groupBox1.Controls.Add(ls2); ts2 = new TextEdit(); ts2.Location = new Point(157, 27 + 33 * i); ts2.Size = new Size(231, 21); ts2.Properties.DisplayFormat.FormatString = "n0"; ts2.Properties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric; ts2.Properties.EditFormat.FormatString = "n0"; ts2.Properties.EditFormat.FormatType = DevExpress.Utils.FormatType.Numeric; ts2.Properties.Mask.EditMask = "####"; ts2.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Numeric; groupBox1.Controls.Add(ts2); if (c2 == "0" || c2 == "") { ts2.Text = ""; } else { ts2.Text = c2; } i++; } ls3.Text = "备注:"; ls3.Location = new Point(52, 27 + 33 * i); groupBox1.Controls.Add(ls3); ts3 = new TextEdit(); ts3.Location = new Point(157, 27 + 33 * i); ts3.Size = new Size(231, 21); groupBox1.Controls.Add(ts3); ts3.Text = c3; if (isline) { try { tt1.Text = q3.ToString(); tt2.Text = q4.ToString(); if (li22 != null) { tt1.Text = li22.Length; tt2.Text = li22.LineType; } } catch { } } if (isPower) { try { tt3.Text = q1.ToString(); tt4.Text = q2.ToString(); tt5.Text = q5.ToString(); tt6.Text = q6.ToString(); if (sb != null) { tt4.Text = sb.Number.ToString(); tt5.Text = sb.ObligateField2; tt6.Text = sb.Burthen.ToString(); } } catch { } } groupBox1.Size = new Size(434, 130 + 33 * i); simpleButton1.Location = new Point(296, 150 + 33 * i); simpleButton2.Location = new Point(389, 150 + 33 * i); this.Size = new Size(490, 230 + 33 * i); }
private void gridView_DoubleClick(object sender, EventArgs e) { List <LineInfo> clist = new List <LineInfo>(); clist.Clear(); LineInfo a = gridView.GetRow(this.gridView.FocusedRowHandle) as LineInfo; if (a.EleID == "1") { string con = "WHERE Type='05' AND SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + a.SvgUID + "'and type='线路'and ZTstatus='等待') "; IList list1 = Services.BaseService.GetList("SelectPSPDEVByCondition", con); for (int i = 0; i < list1.Count; i++) { LineInfo l1 = new LineInfo(); PSPDEV psp = list1[i] as PSPDEV; l1.EleID = psp.EleID; l1.ObligateField2 = psp.Name; l1.ObligateField3 = "淘汰"; clist.Add(l1); } con = "WHERE Type='05' AND SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + a.SvgUID + "'and type='线路'and ZTstatus='待选') "; list1 = Services.BaseService.GetList("SelectPSPDEVByCondition", con); for (int i = 0; i < list1.Count; i++) { LineInfo l1 = new LineInfo(); PSPDEV psp = list1[i] as PSPDEV; l1.EleID = psp.EleID; l1.ObligateField2 = psp.Name; l1.ObligateField3 = "待选"; clist.Add(l1); } } else if (a.EleID == "2") { string con = "WHERE Type='05' AND SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + a.SvgUID + "'and type='线路'and JQstatus='待选') "; IList list1 = Services.BaseService.GetList("SelectPSPDEVByCondition", con); for (int i = 0; i < list1.Count; i++) { LineInfo l1 = new LineInfo(); PSPDEV psp = list1[i] as PSPDEV; l1.EleID = psp.EleID; l1.ObligateField2 = psp.Name; l1.ObligateField3 = "待选"; clist.Add(l1); } con = "WHERE Type='05' AND SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + a.SvgUID + "'and type='线路'and JQstatus='投放') "; list1 = Services.BaseService.GetList("SelectPSPDEVByCondition", con); for (int i = 0; i < list1.Count; i++) { LineInfo l1 = new LineInfo(); PSPDEV psp = list1[i] as PSPDEV; l1.EleID = psp.EleID; l1.ObligateField2 = psp.Name; l1.ObligateField3 = "待建"; clist.Add(l1); } } else if (a.EleID == "3") { string con = "WHERE Type='05' AND SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + a.SvgUID + "'and type='线路'and ZQstatus='待选') "; IList list1 = Services.BaseService.GetList("SelectPSPDEVByCondition", con); for (int i = 0; i < list1.Count; i++) { LineInfo l1 = new LineInfo(); PSPDEV psp = list1[i] as PSPDEV; l1.EleID = psp.EleID; l1.ObligateField2 = psp.Name; l1.ObligateField3 = "待选"; clist.Add(l1); } con = "WHERE Type='05' AND SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + a.SvgUID + "'and type='线路'and ZQstatus='投放') "; list1 = Services.BaseService.GetList("SelectPSPDEVByCondition", con); for (int i = 0; i < list1.Count; i++) { LineInfo l1 = new LineInfo(); PSPDEV psp = list1[i] as PSPDEV; l1.EleID = psp.EleID; l1.ObligateField2 = psp.Name; l1.ObligateField3 = "待建"; clist.Add(l1); } } else if (a.EleID == "4") { string con = "WHERE Type='05' AND SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + a.SvgUID + "'and type='线路'and YQstatus='待选') "; IList list1 = Services.BaseService.GetList("SelectPSPDEVByCondition", con); for (int i = 0; i < list1.Count; i++) { LineInfo l1 = new LineInfo(); PSPDEV psp = list1[i] as PSPDEV; l1.EleID = psp.EleID; l1.ObligateField2 = psp.Name; l1.ObligateField3 = "待选"; clist.Add(l1); } con = "WHERE Type='05' AND SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + a.SvgUID + "'and type='线路'and YQstatus='投放') "; list1 = Services.BaseService.GetList("SelectPSPDEVByCondition", con); for (int i = 0; i < list1.Count; i++) { LineInfo l1 = new LineInfo(); PSPDEV psp = list1[i] as PSPDEV; l1.EleID = psp.EleID; l1.ObligateField2 = psp.Name; l1.ObligateField3 = "待建"; clist.Add(l1); } } FormGXXlist gxx = new FormGXXlist(); gxx.gridview.GroupPanelText = a.ObligateField1 + "线路情况"; gxx.Show(); gxx.LoadData(clist); }
internal static ExtractedInfo ExtractQuotedString(LineInfo line, char quoteChar, bool allowMultiline) { // if (line.mReader == null) // throw new BadUsageException("The reader can´t be null"); if (line.IsEOL()) { throw new BadUsageException("An empty String found and can be parsed like a QuotedString try to use SafeExtractQuotedString"); } if (line.mLine[line.mCurrentPos] != quoteChar) { throw new BadUsageException("The source string not begins with the quote char: " + quoteChar); } var res = new StringBuilder(32); //int lines = 0; var firstFound = false; var i = line.mCurrentPos + 1; //bool mustContinue = true; while (line.mLineStr != null) { while (i < line.mLine.Length) { if (line.mLine[i] == quoteChar) { if (firstFound) { // Is an escaped quoted char res.Append(quoteChar); firstFound = false; } else { firstFound = true; } } else { if (firstFound) { // This was the end of the string line.mCurrentPos = i; return(new ExtractedInfo(res.ToString())); // ExtractedInfo ei = ; // return ei; } else { res.Append(line.mLine[i]); } } i++; } if (firstFound) { line.mCurrentPos = i; return(new ExtractedInfo(res.ToString())); } else { if (allowMultiline == false) { throw new BadUsageException("The current field has an UnClosed quoted string. Complete line: " + res); } line.ReadNextLine(); res.Append(NewLine); //lines++; i = 0; } } throw new BadUsageException("The current field has an unclosed quoted string. Complete Filed String: " + res); }
private void butLineSave_Click(object sender, System.EventArgs e) { try { string value = this.labDevModel.Tag.ToString(); int num = System.Convert.ToInt32(value); DeviceInfo deviceByID = DeviceOperation.getDeviceByID(num); DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(deviceByID.ModelNm, deviceByID.FWVersion); if (this.lineCheck(deviceModelConfig)) { string text = this.labLineNo.Text; int num2 = System.Convert.ToInt32(text); LineInfo lineInfo = new LineInfo(num, num2); DevSnmpConfig sNMPpara = commUtil.getSNMPpara(deviceByID); LineThreshold lineThreshold = new LineThreshold(num2); if (this.gbThreshold.Visible) { lineInfo.Min_current = ThresholdUtil.UI2DB(this.tbLMinCurrent, lineInfo.Min_current, 0); lineInfo.Max_current = ThresholdUtil.UI2DB(this.tbLMaxCurrent, lineInfo.Max_current, 0); lineInfo.Min_voltage = ThresholdUtil.UI2DB(this.tbLMinVoltage, lineInfo.Min_voltage, 0); lineInfo.Max_voltage = ThresholdUtil.UI2DB(this.tbLMaxVoltage, lineInfo.Max_voltage, 0); lineInfo.Min_power = ThresholdUtil.UI2DB(this.tbLMinPower, lineInfo.Min_power, 0); lineInfo.Max_power = ThresholdUtil.UI2DB(this.tbLMaxPower, lineInfo.Max_power, 0); int thflg = devcfgUtil.ThresholdFlg(deviceModelConfig, "line"); lineThreshold.MinCurrentMt = lineInfo.Min_current; lineThreshold.MaxCurrentMT = lineInfo.Max_current; lineThreshold.MinVoltageMT = lineInfo.Min_voltage; lineThreshold.MaxVoltageMT = lineInfo.Max_voltage; lineThreshold.MinPowerMT = lineInfo.Min_power; lineThreshold.MaxPowerMT = lineInfo.Max_power; ThresholdUtil.UI2Dev(thflg, lineThreshold); } bool flag = true; if (deviceModelConfig.commonThresholdFlag != Constant.EatonPDUThreshold) { DevAccessAPI devAccessAPI = new DevAccessAPI(sNMPpara); flag = devAccessAPI.SetLineThreshold(lineThreshold, deviceByID.Mac); } if (flag) { if (lineInfo != null) { lineInfo.Update(); EcoGlobalVar.setDashBoardFlg(128uL, string.Concat(new object[] { "#UPDATE#D", lineInfo.DeviceID, ":L", lineInfo.ID, ";" }), 2); string valuePair = ValuePairs.getValuePair("Username"); if (!string.IsNullOrEmpty(valuePair)) { LogAPI.writeEventLog("0630015", new string[] { lineInfo.LineNumber.ToString(), deviceByID.DeviceIP, deviceByID.DeviceName, valuePair }); } else { LogAPI.writeEventLog("0630015", new string[] { lineInfo.LineNumber.ToString(), deviceByID.DeviceIP, deviceByID.DeviceName }); } } EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.Dev_ThresholdSucc, new string[0])); } else { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail, new string[0])); } } } catch (System.Exception ex) { System.Console.WriteLine("PropLine Exception" + ex.Message); EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail, new string[0])); } }
private void butLineAssign_Click(object sender, System.EventArgs e) { bool flag = false; DBConn dBConn = null; string text = this.labDevModel.Tag.ToString(); try { int num = System.Convert.ToInt32(text); DeviceInfo deviceByID = DeviceOperation.getDeviceByID(num); DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(deviceByID.ModelNm, deviceByID.FWVersion); if (this.lineCheck(deviceModelConfig)) { DialogResult dialogResult = EcoMessageBox.ShowWarning(EcoLanguage.getMsg(LangRes.Dev_ApplyLine, new string[0]), MessageBoxButtons.OKCancel); if (dialogResult != DialogResult.Cancel) { string text2 = this.labLineNo.Text; int i_linenum = System.Convert.ToInt32(text2); LineInfo lineInfo = new LineInfo(num, i_linenum); DevSnmpConfig sNMPpara = commUtil.getSNMPpara(deviceByID); LineThreshold lineThreshold = new LineThreshold(1); if (this.gbThreshold.Visible) { lineInfo.Min_current = ThresholdUtil.UI2DB(this.tbLMinCurrent, lineInfo.Min_current, 0); lineInfo.Max_current = ThresholdUtil.UI2DB(this.tbLMaxCurrent, lineInfo.Max_current, 0); lineInfo.Min_voltage = ThresholdUtil.UI2DB(this.tbLMinVoltage, lineInfo.Min_voltage, 0); lineInfo.Max_voltage = ThresholdUtil.UI2DB(this.tbLMaxVoltage, lineInfo.Max_voltage, 0); lineInfo.Min_power = ThresholdUtil.UI2DB(this.tbLMinPower, lineInfo.Min_power, 0); lineInfo.Max_power = ThresholdUtil.UI2DB(this.tbLMaxPower, lineInfo.Max_power, 0); int thflg = devcfgUtil.ThresholdFlg(deviceModelConfig, "line"); lineThreshold.MinCurrentMt = lineInfo.Min_current; lineThreshold.MaxCurrentMT = lineInfo.Max_current; lineThreshold.MinVoltageMT = lineInfo.Min_voltage; lineThreshold.MaxVoltageMT = lineInfo.Max_voltage; lineThreshold.MinPowerMT = lineInfo.Min_power; lineThreshold.MaxPowerMT = lineInfo.Max_power; ThresholdUtil.UI2Dev(thflg, lineThreshold); } DevAccessAPI devAccessAPI = new DevAccessAPI(sNMPpara); string myMac = deviceByID.Mac; System.Collections.Generic.List <LineInfo> lineInfo2 = deviceByID.GetLineInfo(); dBConn = DBConnPool.getConnection(); foreach (LineInfo current in lineInfo2) { LineThreshold lineThreshold2 = new LineThreshold(current.LineNumber); if (this.gbThreshold.Visible) { lineThreshold2.MaxCurrentMT = lineThreshold.MaxCurrentMT; lineThreshold2.MinCurrentMt = lineThreshold.MinCurrentMt; lineThreshold2.MaxPowerMT = lineThreshold.MaxPowerMT; lineThreshold2.MinPowerMT = lineThreshold.MinPowerMT; lineThreshold2.MaxVoltageMT = lineThreshold.MaxVoltageMT; lineThreshold2.MinVoltageMT = lineThreshold.MinVoltageMT; } bool flag2 = true; if (deviceModelConfig.commonThresholdFlag != Constant.EatonPDUThreshold) { flag2 = devAccessAPI.SetLineThreshold(lineThreshold2, myMac); } if (!flag2) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail, new string[0])); return; } if (this.gbThreshold.Visible) { current.CopyThreshold(lineInfo); } current.UpdateLineThreshold(dBConn); flag = true; myMac = ""; } if (dBConn != null) { dBConn.close(); } string valuePair = ValuePairs.getValuePair("Username"); if (!string.IsNullOrEmpty(valuePair)) { LogAPI.writeEventLog("0630016", new string[] { deviceByID.ModelNm, deviceByID.DeviceIP, deviceByID.DeviceName, valuePair }); } else { LogAPI.writeEventLog("0630016", new string[] { deviceByID.ModelNm, deviceByID.DeviceIP, deviceByID.DeviceName }); } EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.Dev_ThresholdSucc, new string[0])); } } } catch (System.Exception ex) { System.Console.WriteLine("butLineAssign_Click Exception" + ex.Message); EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail, new string[0])); } finally { if (dBConn != null) { dBConn.close(); } DeviceOperation.RefreshDBCache(false); if (flag) { EcoGlobalVar.setDashBoardFlg(128uL, "#UPDATE#D" + text + ":L*;", 2); } } }
/// <inheritdoc/> public override void ReportError(EvaluationErrors errors, ModuleLiteral environment, LineInfo location, Expression expression, Context context) { m_logAction(errors); }
/// <nodoc /> public static TryGetTemplateException TemplateNotAvailable(ModuleLiteral environment, ErrorContext errorContext, LineInfo lineInfo) { Contract.Requires(environment != null); Action <EvaluationErrors> logAction = errors => errors.ReportTemplateNotAvailable(environment, lineInfo); return(new TryGetTemplateException(logAction, errorContext)); }
/// <inheritdoc/> public override void ReportError(EvaluationErrors errors, ModuleLiteral environment, LineInfo location, Expression expression, Context context) { errors.ReportContractFail(environment, Message, location, context.GetStackTraceAsString(UniversalLocation.FromLineInfo(location, environment.Path, context.PathTable))); }
// 根据已有的配置,填充InstanceList int FillInstanceList(out string strError) { strError = ""; this.listView_instance.Items.Clear(); int nErrorCount = 0; for (int i = 0; ; i++) { string strInstanceName = ""; string strDataDir = ""; string strCertSN = ""; string[] existing_urls = null; bool bRet = InstallHelper.GetInstanceInfo("dp2Kernel", i, out strInstanceName, out strDataDir, out existing_urls, out strCertSN); if (bRet == false) break; ListViewItem item = new ListViewItem(); ListViewUtil.ChangeItemText(item, COLUMN_NAME, strInstanceName); ListViewUtil.ChangeItemText(item, COLUMN_DATADIR, strDataDir); ListViewUtil.ChangeItemText(item, COLUMN_BINDINGS, string.Join(";", existing_urls)); this.listView_instance.Items.Add(item); LineInfo info = new LineInfo(); item.Tag = info; info.CertificateSN = strCertSN; // return: // -1 error // 0 file not found // 1 succeed int nRet = info.Build(strDataDir, out strError); if (nRet == -1) { ListViewUtil.ChangeItemText(item, COLUMN_ERRORINFO, strError); item.BackColor = Color.Red; item.ForeColor = Color.White; nErrorCount++; } if (nRet == 1) { string strRootUserName = ""; string strRootUserRights = ""; // 获得root用户信息 // return: // -1 error // 0 succeed nRet = GetRootUserInfo(strDataDir, out strRootUserName, out strRootUserRights, out strError); if (nRet == -1) { ListViewUtil.ChangeItemText(item, COLUMN_ERRORINFO, strError); item.BackColor = Color.Red; item.ForeColor = Color.White; nErrorCount++; } else { info.RootUserName = strRootUserName; info.RootUserRights = strRootUserRights; } } } if (nErrorCount > 0) this.listView_instance.Columns[COLUMN_ERRORINFO].Width = 200; else this.listView_instance.Columns[COLUMN_ERRORINFO].Width = 0; return 0; }
void DrawArea_BeforeAddSvgElement(object sender, ItopVector.DrawArea.AddSvgElementEventArgs e) { symbolElement = e.SvgElement as Use; if (symbolElement == null) { return; } isNewElementBranch = false; currentElement = xltDocument.CurrentElement; if (symbolElement.GraphId.IndexOf(BDZTag) < 0 && !CheckCanInsert()) { xltVectorCtrl.CurrentOperation = ToolOperation.Select; xltVectorCtrl.DrawArea.PreGraph = null; e.Cancel = true; return; } if (currentElement != null) { newElementXLDM = currentElement.GetAttribute(NodeXLDMTag); } newElementGuid = Guid.NewGuid().ToString(); //要插入的为变电站 if (symbolElement.GraphId.IndexOf(BDZTag) > -1) { newElementName = "变电站"; newElementXLDM = ""; } else//要插入的为其它设备 { newElementName = "节点"; if (IsBDZElement(currentElement) && OnNewLine != null) { List<string> listLineCode = GetBDZConnectLines(currentElement); newElementXLDM = OnNewLine(listLineCode); } } if (IsBDZElement(currentElement)) { List<string> listLineCode = GetBDZConnectLines(currentElement); string strEleID="'m0y4'"; for(int i=0;i<listLineCode.Count;i++){ strEleID = strEleID + ",'" + listLineCode[i]+"'"; } if (listLineCode.Count > 0) { LineInfo l = new LineInfo(); l.SvgUID = xltVectorCtrl.SVGDocument.SvgdataUid; l.EleID=strEleID; IList lineList= Services.BaseService.GetList("SelectLineInfoByEleIDList",l); frmAddLineSel f = new frmAddLineSel(); f.StrList = listLineCode; f.LineList = lineList; if (f.ShowDialog() == DialogResult.OK) { if (f.newLine) { newElementXLDM = OnNewLine(listLineCode); } else { newElementXLDM = f.LineCode; } } else { e.Cancel = true; return; } } } }
internal static ExpressionToken Create(Symbol symbol, LineInfo position) { ExpressionToken result = new ExpressionToken(); result.Initialize(symbol, position); return result; }
public override void onInit() { m_fileName = new LineInfo(); }
private void simpleButton1_Click(object sender, EventArgs e) { for (int i = 0; i < te.Length; i++) { SaveCellValue(te[i].Name.Replace("Text", ""), poweruid, te[i].Text.Trim()); } if (isline) { try { LineInfo li = Common.Services.BaseService.GetOneByKey <LineInfo>(powerid); if (li != null) { li.Length = tt1.Text; li.LineType = tt2.Text;// tb.Text; Common.Services.BaseService.Update <LineInfo>(li); } } catch { } } if (isPower) { try { substation sb = Common.Services.BaseService.GetOneByKey <substation>(powerid); if (sb != null) { try { sb.Number = decimal.Parse(tt4.Text); sb.Burthen = decimal.Parse(tt6.Text); } catch { } sb.ObligateField2 = tt5.Text; Common.Services.BaseService.Update <substation>(sb); } } catch { } } try { PowerProTypes ppts = new PowerProTypes(); ppts.ID = poweruid; ppts.Flag2 = flag; PowerProTypes ppt1 = Common.Services.BaseService.GetOneByKey <PowerProTypes>(ppts); try { if (!isstuff) { ppt1.StartYear = int.Parse(ts1.Text); ppt1.EndYear = int.Parse(ts2.Text); } ppt1.Remark = ts3.Text; if (isline) { if (tt1.Text != "") { ppt1.L3 = double.Parse(tt1.Text); } if (tt2.Text != "") { ppt1.L4 = tt2.Text; } } if (isPower) { if (tt3.Text != "") { ppt1.L1 = double.Parse(tt3.Text); } if (tt4.Text != "") { ppt1.L2 = double.Parse(tt4.Text); } if (tt5.Text != "") { ppt1.L5 = double.Parse(tt5.Text); } if (tt6.Text != "") { ppt1.L6 = double.Parse(tt6.Text); } } //ppt1.Col1 = ts4.Text; } catch { } Common.Services.BaseService.Update <PowerProTypes>(ppt1); } catch { } this.DialogResult = DialogResult.OK; }
private void simpleButton1_Click(object sender, EventArgs e) { if (line.LineName == "") { MessageBox.Show("线路名称不能为空。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (line.Length == "") { MessageBox.Show("线路长度不能为空。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (dj.Text == "") { MessageBox.Show("电压等级不能为空。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (comboBox1.Text == "") { MessageBox.Show("线路状态不能为空。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (comboTcnf.Text != "" && comy.Text != "") { line.ObligateField3 = comboTcnf.Text;// +"-" + comy.Text; } if (IsCreate) { LineInfo _l = new LineInfo(); _l.LineName = line.LineName; _l.SvgUID = line.SvgUID; IList mlist = Services.BaseService.GetList("SelectLineInfoByLineNameCK", _l); if (mlist.Count > 0) { MessageBox.Show("线路名称重复。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); //return; } line.Voltage = line.Voltage.ToLower().Replace("kv", ""); line.ObligateField6 = FNode.Text; line.ObligateField7 = LNode.Text; Services.BaseService.Create <LineInfo>(line); } else { line.LayerID = layerID; line.Voltage = line.Voltage.ToLower().Replace("kv", ""); line.ObligateField1 = comboBox1.Text; line.ObligateField6 = FNode.Text; line.ObligateField7 = LNode.Text; Services.BaseService.Update <LineInfo>(line); } string uid = dj.EditValue.ToString(); DataRowView rowView = (DataRowView)dj.Properties.GetDataSourceRowByKeyValue(uid); if (rowView != null) { line.ObligateField2 = rowView.Row["Color"].ToString(); LineWidth = rowView.Row["ObligateField1"].ToString(); //line.ObligateField2 = lineType; } if (SubUpdate) { Line_Info temp = (Line_Info)Services.BaseService.GetObject("SelectLine_InfoByCode", line.UID); if (temp != null) { temp.Code = ""; Services.BaseService.Update <Line_Info>(temp); } LineInfo _s = new LineInfo(); _s.UID = OldUID; LineInfo _temps = Services.BaseService.GetOneByKey <LineInfo>(_s); if (_temps != null) { if (_temps.EleID == "") { Services.BaseService.Update("DeleteLineInfo", _temps); } } Services.BaseService.Update <Line_Info>(p); } Line_Info ppt = null; try{ ppt = (Line_Info)Services.BaseService.GetObject("SelectLine_InfoByCode", line); }catch {} if (ppt != null) { ppt.DY = Convert.ToInt32(line.Voltage.ToLower().Replace("kv", "")); ppt.Title = line.LineName;//名称 //ppt.L1 = "";//台数 //ppt.L2 = "";//容量 try { ppt.K5 = Convert.ToDouble(line.Length); //长度 ppt.L5 = Convert.ToDouble(line.Length); //长度 ppt.L4 = line.LineType; //型号 ppt.K2 = line.LineType; //型号 ppt.L6 = line.ObligateField3; //ppt.L5 = "";//负荷率 //ppt.L6 = "";//最大负荷 Services.BaseService.Update <Line_Info>(ppt); } catch { } } this.DialogResult = DialogResult.OK; this.Close(); }
/// <nodoc /> public static TryGetMountException MountNameNotFound(ModuleLiteral environment, string name, IEnumerable <string> mountNames, ErrorContext errorContext, LineInfo lineInfo) { Contract.Requires(environment != null); Action <EvaluationErrors> logAction = errors => errors.ReportGetMountNameNotFound(environment, name, mountNames, lineInfo: lineInfo); return(new TryGetMountException(logAction, errorContext)); }
public int GetLineLength(LineInfo lineInfo) => GetLineLength(lineInfo.LineNumber);
/// <nodoc /> public static TryGetMountException MountNameNullOrEmpty(ModuleLiteral environment, ErrorContext errorContext, LineInfo lineInfo) { Contract.Requires(environment != null); Action <EvaluationErrors> logAction = errors => errors.ReportGetMountNameNullOrEmpty(environment, lineInfo); return(new TryGetMountException(logAction, errorContext)); }
public int GetCharacterPosition(LineInfo lineInfo) => GetCharacterPosition(lineInfo.LineNumber, lineInfo.LinePosition);
static private void Worker(object cState) { try { ushort nID = (ushort)cState; ManualResetEvent cMREStart = _aMREStart[nID]; ManualResetEvent cMREDone = _aMREDone[nID]; int nLineToDo, nMax, nCount = 0, nCropWidth; while (true) { try { cMREStart.Reset(); ManualResetEvent.SignalAndWait(cMREDone, cMREStart); if (_cDisComProcessing._cInfo is MergeInfo) { MergeInfo cMergeInfo = (MergeInfo)_cDisComProcessing._cInfo; nCount = 0; //----Logger.Timings cTiming = new helpers.Logger.Timings("BTL:pixelmap:discom:"); while ((nLineToDo = GetTask(_cDisComProcessing)) < int.MaxValue) { LineInfo cLineInfo = new LineInfo(); cLineInfo.nBGStart = nLineToDo * cMergeInfo.nBackgroundWidth; // nBGStart - если BG начинается с начала линии всегда - вроде тек и есть cLineInfo.aLineLayers = new LineInfo.LineLayerInfo[cMergeInfo.aLayerInfos.Length]; for (int nI = 0; nI < cLineInfo.aLineLayers.Length; nI++) { cLineInfo.aLineLayers[nI] = new LineInfo.LineLayerInfo(); if (nLineToDo < _cDisComProcessing.aCropTopLineInBG[nI] || nLineToDo > _cDisComProcessing.aCropBottomLineInBG[nI]) { cLineInfo.aLineLayers[nI].nBGCropStart = int.MaxValue; cLineInfo.aLineLayers[nI].nBGCropEnd = int.MinValue; cLineInfo.aLineLayers[nI].nFGCropStart = int.MaxValue; } else { cLineInfo.aLineLayers[nI].nBGCropStart = cLineInfo.nBGStart + cMergeInfo.aLayerInfos[nI].nCropLeft; cLineInfo.aLineLayers[nI].nBGCropEnd = cLineInfo.aLineLayers[nI].nBGCropStart + cMergeInfo.aLayerInfos[nI].nCropWidth - 1; //nCropWidth = cLineInfo.aLineLayers[nI].nBGCropEnd + 1 - cLineInfo.aLineLayers[nI].nBGCropStart; if (_cDisComProcessing.aCropTopLineInBG[nI] == 0) cLineInfo.aLineLayers[nI].nFGCropStart = (nLineToDo - cMergeInfo.aLayerInfos[nI].nTop) * cMergeInfo.aLayerInfos[nI].nWidth; else cLineInfo.aLineLayers[nI].nFGCropStart = (nLineToDo - _cDisComProcessing.aCropTopLineInBG[nI]) * cMergeInfo.aLayerInfos[nI].nWidth; if (cLineInfo.nBGStart < cLineInfo.aLineLayers[nI].nBGCropStart) { cLineInfo.aLineLayers[nI].nFGLineBeginning = cLineInfo.aLineLayers[nI].nFGCropStart; } else { cLineInfo.aLineLayers[nI].nFGCropStart -= cMergeInfo.aLayerInfos[nI].nLeft; cLineInfo.aLineLayers[nI].nFGLineBeginning = ((int)((double)cLineInfo.aLineLayers[nI].nFGCropStart / cMergeInfo.aLayerInfos[nI].nWidth)) * cMergeInfo.aLayerInfos[nI].nWidth; } if (nLineToDo - 1 >= _cDisComProcessing.aCropTopLineInBG[nI] && nLineToDo - 1 <= _cDisComProcessing.aCropBottomLineInBG[nI]) cLineInfo.aLineLayers[nI].bRowUpper = true; if (nLineToDo + 1 >= _cDisComProcessing.aCropTopLineInBG[nI] && nLineToDo + 1 <= _cDisComProcessing.aCropBottomLineInBG[nI]) cLineInfo.aLineLayers[nI].bRowUnder = true; cLineInfo.aLineLayers[nI].nBgFgLinesDelta = nLineToDo - _cDisComProcessing.aCropTopLineInBG[nI]; } } for (int nI = cLineInfo.nBGStart; nI < cLineInfo.nBGStart + cMergeInfo.nBackgroundWidth; nI++) Merging(nI, cLineInfo); nCount++; } //-----cTiming.Stop("merged " + nID + "-th > 30 [count=" + nCount + "]", 40); } } catch (Exception ex) { if (ex is ThreadInterruptedException) throw; (new Logger()).WriteError(ex); } } //(new Logger()).WriteNotice("[id:" + GetHashCode() + ":" + nID + "][total:" + nThreadsTotalQty + "][stop]"); } catch (Exception ex) { if (!(ex is ThreadInterruptedException)) (new Logger()).WriteError(ex); } }
private static int CalculateIndentation( string baseline, ITextSnapshotLine line, IEditorOptions options, PythonTextBufferInfo buffer ) { var snapshot = line.Snapshot; if (snapshot.TextBuffer != buffer.Buffer) { throw new ArgumentException("buffer mismatch"); } int indentation = GetIndentation(baseline, options.GetTabSize()); int tabSize = options.GetIndentSize(); var tokens = buffer.GetTokens(line).ToList(); while (tokens.Count > 0 && IsWhitespace(tokens[tokens.Count - 1].Category)) { tokens.RemoveAt(tokens.Count - 1); } if (tokens.Count == 0 || IsUnterminatedStringToken(tokens[tokens.Count - 1], snapshot)) { return(indentation); } if (HasExplicitLineJoin(tokens, snapshot)) { // explicit line continuation, we indent 1 level for the continued line unless // we're already indented because of multiple line continuation characters. indentation = GetIndentation(line.GetText(), options.GetTabSize()); var joinedLine = line.LineNumber - 1; if (joinedLine >= 0) { var prevLineTokens = buffer.GetTokens(snapshot.GetLineFromLineNumber(joinedLine)).ToList(); if (prevLineTokens.Count == 0 || !HasExplicitLineJoin(prevLineTokens, snapshot)) { indentation += tabSize; } } else { indentation += tabSize; } return(indentation); } var tokenStack = new Stack <TrackingTokenInfo?>(); tokenStack.Push(null); // end with an implicit newline int endAtLine = -1, currentLine = tokens.Last().LineNumber; foreach (var t in buffer.GetTokensInReverseFromPoint(tokens.Last().ToSnapshotSpan(snapshot).Start)) { if (t.LineNumber == currentLine) { tokenStack.Push(t); } else { tokenStack.Push(null); } if (t.LineNumber == endAtLine) { break; } else if (t.Category == TokenCategory.Keyword && PythonKeywords.IsOnlyStatementKeyword(t.GetText(snapshot), buffer.LanguageVersion)) { endAtLine = t.LineNumber - 1; } if (t.LineNumber != currentLine) { currentLine = t.LineNumber; if (t.Category != TokenCategory.WhiteSpace && t.Category != TokenCategory.Comment && t.Category != TokenCategory.LineComment) { tokenStack.Push(t); } } } var indentStack = new Stack <LineInfo>(); var current = LineInfo.Empty; while (tokenStack.Count > 0) { var t = tokenStack.Pop(); if (t == null) { current.NeedsUpdate = true; continue; } var tline = new Lazy <string>(() => snapshot.GetLineFromLineNumber(t.Value.LineNumber).GetText()); if (IsOpenGrouping(t.Value, snapshot)) { indentStack.Push(current); var next = tokenStack.Count > 0 ? tokenStack.Peek() : null; if (next != null && next.Value.LineNumber == t.Value.LineNumber) { // Put indent at same depth as grouping current = new LineInfo { Indentation = t.Value.ToSourceSpan().End.Column - 1 }; } else { // Put indent at one indent deeper than this line current = new LineInfo { Indentation = GetIndentation(tline.Value, tabSize) + tabSize }; } } else if (IsCloseGrouping(t.Value, snapshot)) { if (indentStack.Count > 0) { current = indentStack.Pop(); } else { current.NeedsUpdate = true; } } else if (IsExplicitLineJoin(t.Value, snapshot)) { while (t != null && tokenStack.Count > 0) { t = tokenStack.Pop(); } if (!t.HasValue) { continue; } } else if (current.NeedsUpdate == true) { current = new LineInfo { Indentation = GetIndentation(tline.Value, tabSize) }; } if (ShouldDedentAfterKeyword(t.Value, snapshot)) // dedent after some statements { current.ShouldDedentAfter = true; } if (IsColon(t.Value, snapshot) && // indent after a colon indentStack.Count == 0) // except in a grouping { current.ShouldIndentAfter = true; // If the colon isn't at the end of the line, cancel it out. // If the following is a ShouldDedentAfterKeyword, only one dedent will occur. current.ShouldDedentAfter = (tokenStack.Count != 0 && tokenStack.Peek() != null); } } indentation = current.Indentation + (current.ShouldIndentAfter ? tabSize : 0) - (current.ShouldDedentAfter ? tabSize : 0); return(indentation); }
public void AddLine(LineInfo ls) { lines.Add(ls); }
private void LoadComments() { foreach (KeyValuePair <int, LineInfo> kvp in _lines) { try { LineInfo line = kvp.Value; if (line.SpanIDs.Count == 0) { continue; } SpanInfo span = _spans[line.SpanIDs[0]]; SegmentInfo segment = _segments[span.SegmentID]; if (_files[line.FileID].Data == null) { //File was not found. if (_filesNotFound.Add(_files[line.FileID].Name)) { _errorCount++; } continue; } bool isAsm = _files[line.FileID].IsAssembly; string comment = ""; for (int i = line.LineNumber; i >= 0; i--) { string sourceCodeLine = _files[line.FileID].Data[i]; if (sourceCodeLine.Trim().Length == 0) { //Ignore empty lines continue; } Regex regex; if (i == line.LineNumber) { regex = isAsm ? _asmFirstLineRegex : _cFirstLineRegex; } else { regex = isAsm ? _asmPreviousLinesRegex : _cPreviousLinesRegex; } Match match = regex.Match(sourceCodeLine); if (match.Success) { string matchedComment = match.Groups[1].Value.Replace("\t", " "); if (string.IsNullOrWhiteSpace(comment)) { comment = matchedComment; } else { comment = matchedComment + Environment.NewLine + comment; } } else if (i != line.LineNumber) { break; } } if (comment.Length > 0) { int address = -1; AddressType?addressType; if (segment.IsRam) { GetRamLabelAddressAndType(span.Offset + segment.Start, out address, out addressType); } else { address = GetPrgAddress(span); addressType = AddressType.PrgRom; } if (address >= 0 && addressType != null) { CodeLabel label = this.CreateLabel(address, addressType.Value, 1); if (label != null) { label.Comment = comment; } } } } catch { _errorCount++; } } }
/// <summary> /// Parse node contents add return a fresh node. /// </summary> /// <param name="prototypes">List containing all node types</param> /// <param name="parent">Node that this is a subnode to. Can be null</param> /// <param name="line">Line to parse</param> /// <param name="offset">Where to start the parsing. Should be set to where the next node should start parsing.</param> /// <returns>A node corresponding to the bla bla; null if parsing failed.</returns> /// <exception cref="Exceptions.CodeGeneratorException"></exception> public abstract Node Parse(NodeList prototypes, Node parent, LineInfo line, ref int offset);
/// <inheritdoc/> public override void ReportError(EvaluationErrors errors, ModuleLiteral environment, LineInfo location, Expression expression, Context context) { errors.ReportUndefinedMapKeyException(environment, ErrorContext, Message, location); }
void modify_instance_dlg_LoadXmlFileInfo(object sender, LoadXmlFileInfoEventArgs e) { Debug.Assert(String.IsNullOrEmpty(e.DataDir) == false, ""); string strError = ""; LineInfo info = new LineInfo(); // return: // -1 error // 0 file not found // 1 succeed int nRet = info.Build(e.DataDir, out strError); if (nRet == -1) { e.ErrorInfo = strError; return; } Debug.Assert(nRet == 1, ""); if (nRet == 1) { string strRootUserName = ""; string strRootUserRights = ""; // 获得root用户信息 // return: // -1 error // 0 succeed nRet = GetRootUserInfo(e.DataDir, out strRootUserName, out strRootUserRights, out strError); if (nRet == -1) { e.ErrorInfo = strError; return; } else { info.RootUserName = strRootUserName; info.RootUserRights = strRootUserRights; } } e.LineInfo = info; }
public WpfLineInfoDecorator(LineInfo lineInfo) { LineInfo = lineInfo; }
private void ThreadProc() { Contracts.Assert(_batchSize >= 2); try { if (_limit <= 0) { return; } long total = 0; long batch = -1; for (int ifile = 0; ifile < _files.Count; ifile++) { string path = _files.GetPathOrNull(ifile); using (var rdr = _files.OpenTextReader(ifile)) { string text; long line = 0; for (; ;) { // REVIEW: Avoid allocating a string for every line. This would probably require // introducing a CharSpan type (similar to ReadOnlyMemory but based on char[] or StringBuilder) // and implementing all the necessary conversion functionality on it. See task 3871. text = rdr.ReadLine(); if (text == null) { goto LNext; } line++; if (text.Length > 0 && text[0] != '#' && !text.StartsWith("//")) { break; } } // REVIEW: Use a pool of batches? int index = 0; var infos = new LineInfo[_batchSize]; if (!_hasHeader) { // Not a header or comment, so first line is a real line. infos[index++] = new LineInfo(line, text); if (++total >= _limit) { PostPartial(path, total - index, ref batch, index, infos); return; } } for (; ;) { if (_abort) { return; } text = rdr.ReadLine(); if (text == null) { // We're done with this file. Queue the last partial batch. PostPartial(path, total - index, ref batch, index, infos); goto LNext; } line++; // Filter out comments and empty strings. if (text.Length >= 2) { // Don't use string.StartsWith("//") - it is too slow. if (text[0] == '/' && text[1] == '/') { continue; } } else if (text.Length == 0) { continue; } infos[index] = new LineInfo(line, text); if (++index >= infos.Length) { batch++; var lines = new LineBatch(path, total - index + 1, batch, infos); while (!_queue.TryAdd(lines, TimeOut)) { if (_abort) { return; } } infos = new LineInfo[_batchSize]; index = 0; } if (++total >= _limit) { PostPartial(path, total - index, ref batch, index, infos); return; } } LNext: ; } } } catch (Exception ex) { while (!_queue.TryAdd(new LineBatch(ex), TimeOut)) { if (_abort) { return; } } } finally { _queue.CompleteAdding(); } }
private static int CalculateIndentation(string baseline, ITextSnapshotLine line, IEditorOptions options, IClassifier classifier, ITextView textView) { int indentation = GetIndentation(baseline, options.GetTabSize()); int tabSize = options.GetIndentSize(); var tokens = classifier.GetClassificationSpans(line.Extent); if (tokens.Count > 0 && !IsUnterminatedStringToken(tokens[tokens.Count - 1])) { int tokenIndex = tokens.Count - 1; while (tokenIndex >= 0 && (tokens[tokenIndex].ClassificationType.IsOfType(PredefinedClassificationTypeNames.Comment) || tokens[tokenIndex].ClassificationType.IsOfType(PredefinedClassificationTypeNames.WhiteSpace))) { tokenIndex--; } if (tokenIndex < 0) { return(indentation); } if (ReverseExpressionParser.IsExplicitLineJoin(tokens[tokenIndex])) { // explicit line continuation, we indent 1 level for the continued line unless // we're already indented because of multiple line continuation characters. indentation = GetIndentation(line.GetText(), options.GetTabSize()); var joinedLine = tokens[tokenIndex].Span.Start.GetContainingLine(); if (joinedLine.LineNumber > 0) { var prevLineSpans = classifier.GetClassificationSpans(tokens[tokenIndex].Span.Snapshot.GetLineFromLineNumber(joinedLine.LineNumber - 1).Extent); if (prevLineSpans.Count == 0 || !ReverseExpressionParser.IsExplicitLineJoin(prevLineSpans[prevLineSpans.Count - 1])) { indentation += tabSize; } } else { indentation += tabSize; } return(indentation); } string sline = tokens[tokenIndex].Span.GetText(); var lastChar = sline.Length == 0 ? '\0' : sline[sline.Length - 1]; // use the expression parser to figure out if we're in a grouping... var spans = textView.BufferGraph.MapDownToFirstMatch( tokens[tokenIndex].Span, SpanTrackingMode.EdgePositive, PythonContentTypePrediciate ); if (spans.Count == 0) { return(indentation); } var revParser = new ReverseExpressionParser( spans[0].Snapshot, spans[0].Snapshot.TextBuffer, spans[0].Snapshot.CreateTrackingSpan( spans[0].Span, SpanTrackingMode.EdgePositive ) ); var tokenStack = new System.Collections.Generic.Stack <ClassificationSpan>(); tokenStack.Push(null); // end with an implicit newline bool endAtNextNull = false; foreach (var token in revParser) { tokenStack.Push(token); if (token == null && endAtNextNull) { break; } else if (token != null && token.ClassificationType == revParser.Classifier.Provider.Keyword && PythonKeywords.IsOnlyStatementKeyword(token.Span.GetText())) { endAtNextNull = true; } } var indentStack = new System.Collections.Generic.Stack <LineInfo>(); var current = LineInfo.Empty; while (tokenStack.Count > 0) { var token = tokenStack.Pop(); if (token == null) { current.NeedsUpdate = true; } else if (token.IsOpenGrouping()) { indentStack.Push(current); var start = token.Span.Start; var line2 = start.GetContainingLine(); var next = tokenStack.Count > 0 ? tokenStack.Peek() : null; if (next != null && next.Span.End <= line2.End) { current = new LineInfo { Indentation = start.Position - line2.Start.Position + 1 }; } else { current = new LineInfo { Indentation = GetIndentation(line2.GetText(), tabSize) + tabSize }; } } else if (token.IsCloseGrouping()) { if (indentStack.Count > 0) { current = indentStack.Pop(); } else { current.NeedsUpdate = true; } } else if (ReverseExpressionParser.IsExplicitLineJoin(token)) { while (token != null && tokenStack.Count > 0) { token = tokenStack.Pop(); } } else if (current.NeedsUpdate == true) { var line2 = token.Span.Start.GetContainingLine(); current = new LineInfo { Indentation = GetIndentation(line2.GetText(), tabSize) }; } if (token != null && ShouldDedentAfterKeyword(token)) // dedent after some statements { current.ShouldDedentAfter = true; } if (token != null && token.Span.GetText() == ":" && // indent after a colon indentStack.Count == 0) // except in a grouping { current.ShouldIndentAfter = true; // If the colon isn't at the end of the line, cancel it out. // If the following is a ShouldDedentAfterKeyword, only one dedent will occur. current.ShouldDedentAfter = (tokenStack.Count != 0 && tokenStack.Peek() != null); } } indentation = current.Indentation + (current.ShouldIndentAfter ? tabSize : 0) - (current.ShouldDedentAfter ? tabSize : 0); } return(indentation); }
internal FunctionImportReturnTypeScalarPropertyMapping(string cMember, string sColumn, LineInfo lineInfo) : base(cMember, sColumn, lineInfo) { }
public void Calculate(string str, OGTextStyle style, float size, Rect rect) { lineHeight = style.font.info.lineSpacing * size; LineInfo line = NewLine(0); int lastSpace = 0; float lineWidthAtLastSpace = 0; float space = (style.font.GetCharacterInfo(" "[0]).width *size); float right = rect.width - style.padding.right - style.padding.left; int c = 0; for (c = 0; c < str.Length; c++) { OGCharacterInfo info = style.font.GetCharacterInfo(str[c]); // This character is a carriage return if (str[c] == "\n"[0]) { line.End(c); line = NewLine(line.end); // This character is a space } else if (info.space) { line.width += space; lastSpace = c; // The line width has exceeded the border if (line.width >= right) { line.width = lineWidthAtLastSpace; c = lastSpace == 0 ? lastSpace : c; line.End(c - 1); line = NewLine(c + 1); } else { lineWidthAtLastSpace = line.width - space; line.AddChar(info); } // This character is a regular glyph } else { line.width += info.width * size; // The line width has exceeded the border if (line.width >= right) { line.width = lineWidthAtLastSpace; c = lastSpace == 0 ? lastSpace : c; line.End(c - 1); line = NewLine(c + 1); } else { line.AddChar(info); } } } line.End(c); length = lIndex; lIndex = 0; }
private static int CalculateIndentation(string baseline, ITextSnapshotLine line, IEditorOptions options, IClassifier classifier, ITextView textView) { int indentation = GetIndentation(baseline, options.GetTabSize()); int tabSize = options.GetIndentSize(); var tokens = classifier.GetClassificationSpans(line.Extent); if (tokens.Count > 0 && !IsUnterminatedStringToken(tokens[tokens.Count - 1])) { int tokenIndex = tokens.Count - 1; while (tokenIndex >= 0 && (tokens[tokenIndex].ClassificationType.IsOfType(PredefinedClassificationTypeNames.Comment) || tokens[tokenIndex].ClassificationType.IsOfType(PredefinedClassificationTypeNames.WhiteSpace))) { tokenIndex--; } if (tokenIndex < 0) { return indentation; } if (ReverseExpressionParser.IsExplicitLineJoin(tokens[tokenIndex])) { // explicit line continuation, we indent 1 level for the continued line unless // we're already indented because of multiple line continuation characters. indentation = GetIndentation(line.GetText(), options.GetTabSize()); var joinedLine = tokens[tokenIndex].Span.Start.GetContainingLine(); if (joinedLine.LineNumber > 0) { var prevLineSpans = classifier.GetClassificationSpans(tokens[tokenIndex].Span.Snapshot.GetLineFromLineNumber(joinedLine.LineNumber - 1).Extent); if (prevLineSpans.Count == 0 || !ReverseExpressionParser.IsExplicitLineJoin(prevLineSpans[prevLineSpans.Count - 1])) { indentation += tabSize; } } else { indentation += tabSize; } return indentation; } string sline = tokens[tokenIndex].Span.GetText(); var lastChar = sline.Length == 0 ? '\0' : sline[sline.Length - 1]; // use the expression parser to figure out if we're in a grouping... var spans = textView.BufferGraph.MapDownToFirstMatch( tokens[tokenIndex].Span, SpanTrackingMode.EdgePositive, PythonContentTypePrediciate ); if (spans.Count == 0) { return indentation; } var revParser = new ReverseExpressionParser( spans[0].Snapshot, spans[0].Snapshot.TextBuffer, spans[0].Snapshot.CreateTrackingSpan( spans[0].Span, SpanTrackingMode.EdgePositive ) ); var tokenStack = new System.Collections.Generic.Stack<ClassificationSpan>(); tokenStack.Push(null); // end with an implicit newline bool endAtNextNull = false; foreach (var token in revParser) { tokenStack.Push(token); if (token == null && endAtNextNull) { break; } else if (token != null && token.ClassificationType == revParser.Classifier.Provider.Keyword && PythonKeywords.IsOnlyStatementKeyword(token.Span.GetText())) { endAtNextNull = true; } } var indentStack = new System.Collections.Generic.Stack<LineInfo>(); var current = LineInfo.Empty; while (tokenStack.Count > 0) { var token = tokenStack.Pop(); if (token == null) { current.NeedsUpdate = true; } else if (token.IsOpenGrouping()) { indentStack.Push(current); var start = token.Span.Start; var line2 = start.GetContainingLine(); var next = tokenStack.Count > 0 ? tokenStack.Peek() : null; if (next != null && next.Span.End <= line2.End) { current = new LineInfo { Indentation = start.Position - line2.Start.Position + 1 }; } else { current = new LineInfo { Indentation = GetIndentation(line2.GetText(), tabSize) + tabSize }; } } else if (token.IsCloseGrouping()) { if (indentStack.Count > 0) { current = indentStack.Pop(); } else { current.NeedsUpdate = true; } } else if (ReverseExpressionParser.IsExplicitLineJoin(token)) { while (token != null && tokenStack.Count > 0) { token = tokenStack.Pop(); } } else if (current.NeedsUpdate == true) { var line2 = token.Span.Start.GetContainingLine(); current = new LineInfo { Indentation = GetIndentation(line2.GetText(), tabSize) }; } if (token != null && ShouldDedentAfterKeyword(token)) { // dedent after some statements current.ShouldDedentAfter = true; } if (token != null && token.Span.GetText() == ":" && // indent after a colon indentStack.Count == 0) { // except in a grouping current.ShouldIndentAfter = true; // If the colon isn't at the end of the line, cancel it out. // If the following is a ShouldDedentAfterKeyword, only one dedent will occur. current.ShouldDedentAfter = (tokenStack.Count != 0 && tokenStack.Peek() != null); } } indentation = current.Indentation + (current.ShouldIndentAfter ? tabSize : 0) - (current.ShouldDedentAfter ? tabSize : 0); } // Map indentation back to the view's text buffer. int offset = 0; var viewLineStart = textView.BufferGraph.MapUpToSnapshot(line.Start, PointTrackingMode.Positive, PositionAffinity.Successor, textView.TextSnapshot); if (viewLineStart.HasValue) { offset = viewLineStart.Value.Position - viewLineStart.Value.GetContainingLine().Start.Position; } return offset + indentation; }
/// <inheritdoc /> public override void ReportError(EvaluationErrors errors, ModuleLiteral environment, LineInfo location, Expression expression, Context context) { errors.ReportKeyFormDllLoadedWithDifferentDll(environment, this, location); }
public UnknownVariableReferenceException(LineInfo line, string variable) : base(line) { _variable = variable; }
/// <inheritdoc /> public override void ReportError(EvaluationErrors errors, ModuleLiteral environment, LineInfo location, Expression expression, Context context) { errors.ReportKeyFormDllWrongFileName(environment, this, location); }