public QuadTreeLodDebugRenderer()
        {
            this.Visible = true;
            this.DrawOrder = 0;

            this.tilePatches = new List<PatchDescriptor>();

            this.Components.Add(lineBuffer = new LineBuffer(8192));
            this.Loading += QuadTreeLodDebugRenderer_Loading;
            this.Unloading += QuadTreeLodDebugRenderer_Unloading;
        }
Пример #2
0
 private static long WriteToken(byte[] token, int tokenOffset, MimeStringLength tokenLength, System.IO.Stream stream, ref MimeStringLength currentLineLength, ref LineBuffer lineBuffer, ref bool autoAddedLastLWSP, bool allowUTF8)
 {
     var num1 = 0L;
     var flag1 = token != null && tokenLength.InChars == 1 && MimeScan.IsFWSP(token[tokenOffset]);
     if (!flag1 && currentLineLength.InChars + lineBuffer.Length.InChars + tokenLength.InChars > 78 && lineBuffer.LengthTillLastLWSP.InBytes >= 0) {
         if (lineBuffer.LengthTillLastLWSP.InBytes > 0) {
             stream.Write(lineBuffer.Bytes, 0, lineBuffer.LengthTillLastLWSP.InBytes);
             num1 += lineBuffer.LengthTillLastLWSP.InBytes;
             currentLineLength.IncrementBy(lineBuffer.LengthTillLastLWSP);
         }
         if (currentLineLength.InBytes > 0)
             num1 += Header.WriteLineEnd(stream, ref currentLineLength);
         if (autoAddedLastLWSP) {
             autoAddedLastLWSP = false;
             lineBuffer.LengthTillLastLWSP.IncrementBy(1);
         }
         if (lineBuffer.LengthTillLastLWSP.InBytes != lineBuffer.Length.InBytes) {
             System.Buffer.BlockCopy(lineBuffer.Bytes, lineBuffer.LengthTillLastLWSP.InBytes, lineBuffer.Bytes, 0, lineBuffer.Length.InBytes - lineBuffer.LengthTillLastLWSP.InBytes);
             lineBuffer.Length.DecrementBy(lineBuffer.LengthTillLastLWSP);
             if (lineBuffer.Length.InBytes > 0 && MimeScan.IsFWSP(lineBuffer.Bytes[0]))
                 lineBuffer.LengthTillLastLWSP.SetAs(0);
             else
                 lineBuffer.LengthTillLastLWSP.SetAs(-1);
         } else {
             lineBuffer.Length.SetAs(0);
             lineBuffer.LengthTillLastLWSP.SetAs(-1);
         }
         var flag2 = false;
         if (lineBuffer.Length.InBytes > 0) {
             if (!MimeScan.IsFWSP(lineBuffer.Bytes[0]))
                 flag2 = true;
         } else if (!flag1)
             flag2 = true;
         if (flag2) {
             stream.Write(LineStartWhitespace, 0, LineStartWhitespace.Length);
             num1 += LineStartWhitespace.Length;
             currentLineLength.IncrementBy(LineStartWhitespace.Length);
         }
     }
     if (currentLineLength.InBytes + lineBuffer.Length.InBytes + tokenLength.InBytes > 998) {
         if (lineBuffer.Length.InBytes > 0) {
             stream.Write(lineBuffer.Bytes, 0, lineBuffer.Length.InBytes);
             num1 += lineBuffer.Length.InBytes;
             currentLineLength.IncrementBy(lineBuffer.Length);
             lineBuffer.Length.SetAs(0);
             autoAddedLastLWSP = false;
             lineBuffer.LengthTillLastLWSP.SetAs(-1);
         }
         if (token != null) {
             while (currentLineLength.InBytes + tokenLength.InBytes > 998) {
                 var num2 = System.Math.Max(0, 998 - currentLineLength.InBytes);
                 var countInChars = 0;
                 var num3 = 0;
                 if (allowUTF8) {
                     var num4 = 0;
                     while (num4 < tokenLength.InBytes) {
                         var num5 = token[tokenOffset + num4];
                         var bytesUsed = 1;
                         if (num5 >= 128 && !MimeScan.IsUTF8NonASCII(token, tokenOffset + num4, tokenOffset + tokenLength.InBytes, out bytesUsed))
                             bytesUsed = 1;
                         if (num3 + bytesUsed <= num2) {
                             ++countInChars;
                             num3 += bytesUsed;
                             num4 += bytesUsed;
                         } else
                             break;
                     }
                 } else {
                     countInChars = num2;
                     num3 = num2;
                 }
                 stream.Write(token, tokenOffset, num3);
                 var num6 = num1 + num3;
                 currentLineLength.IncrementBy(countInChars, num3);
                 tokenOffset += num3;
                 tokenLength.DecrementBy(countInChars, num3);
                 num1 = num6 + Header.WriteLineEnd(stream, ref currentLineLength);
                 if (!flag1) {
                     stream.Write(LineStartWhitespace, 0, LineStartWhitespace.Length);
                     num1 += LineStartWhitespace.Length;
                     currentLineLength.IncrementBy(LineStartWhitespace.Length);
                 }
             }
         }
     }
     if (token != null) {
         System.Buffer.BlockCopy(token, tokenOffset, lineBuffer.Bytes, lineBuffer.Length.InBytes, tokenLength.InBytes);
         if (flag1 && (lineBuffer.Length.InBytes == 0 || !MimeScan.IsFWSP(lineBuffer.Bytes[lineBuffer.Length.InBytes - 1]))) {
             autoAddedLastLWSP = false;
             lineBuffer.LengthTillLastLWSP.SetAs(lineBuffer.Length);
         }
         lineBuffer.Length.IncrementBy(tokenLength);
     }
     return num1;
 }
Пример #3
0
 internal static long QuoteAndFold(
     System.IO.Stream stream, MimeStringList fragments, uint inputMask, bool quoteOutput, bool addSpaceAtStart, bool allowUTF8, int lastLineReserve, ref MimeStringLength currentLineLength, ref byte[] scratchBuffer)
 {
     var num = 0L;
     var lineBuffer = new LineBuffer();
     lineBuffer.Length = new MimeStringLength(0);
     lineBuffer.LengthTillLastLWSP = new MimeStringLength(-1);
     if (scratchBuffer == null || scratchBuffer.Length < 998)
         scratchBuffer = new byte[998];
     lineBuffer.Bytes = scratchBuffer;
     var token = quoteOutput ? MimeScan.Token.Spec | MimeScan.Token.Fwsp : MimeScan.Token.Fwsp;
     var autoAddedLastLWSP = false;
     if (addSpaceAtStart && currentLineLength.InBytes != 0) {
         num += Header.WriteToken(Space, 0, new MimeStringLength(1), stream, ref currentLineLength, ref lineBuffer, ref autoAddedLastLWSP, allowUTF8);
         autoAddedLastLWSP = true;
     }
     if (quoteOutput)
         num += Header.WriteToken(DoubleQuote, 0, new MimeStringLength(1), stream, ref currentLineLength, ref lineBuffer, ref autoAddedLastLWSP, allowUTF8);
     for (var index = 0; index < fragments.Count; ++index) {
         var mimeString = fragments[index];
         var offset = 0;
         var count = 0;
         var data = mimeString.GetData(out offset, out count);
         if (((int) mimeString.Mask & (int) inputMask) != 0) {
             do {
                 var characterCount = 0;
                 var nextOf = MimeScan.FindNextOf(token, data, offset, count, out characterCount, allowUTF8);
                 if (nextOf > 0) {
                     num += Header.WriteToken(data, offset, new MimeStringLength(characterCount, nextOf), stream, ref currentLineLength, ref lineBuffer, ref autoAddedLastLWSP, allowUTF8);
                     offset += nextOf;
                     count -= nextOf;
                 }
                 if (count != 0) {
                     switch (data[offset]) {
                         case 34:
                         case 92:
                             if (((int) mimeString.Mask & -536870913) != 0) {
                                 num += Header.WriteToken(
                                     new byte[2] {
                                         92,
                                         data[offset]
                                     },
                                     0,
                                     new MimeStringLength(2),
                                     stream,
                                     ref currentLineLength,
                                     ref lineBuffer,
                                     ref autoAddedLastLWSP,
                                     allowUTF8);
                                 ++offset;
                                 --count;
                                 goto label_15;
                             }
                             break;
                     }
                     num += Header.WriteToken(
                         new byte[1] {
                             data[offset]
                         },
                         0,
                         new MimeStringLength(1),
                         stream,
                         ref currentLineLength,
                         ref lineBuffer,
                         ref autoAddedLastLWSP,
                         allowUTF8);
                     ++offset;
                     --count;
                 }
                 label_15:
                 ;
             } while (count != 0);
         }
     }
     if (quoteOutput)
         num += Header.WriteToken(DoubleQuote, 0, new MimeStringLength(1), stream, ref currentLineLength, ref lineBuffer, ref autoAddedLastLWSP, allowUTF8);
     if (lastLineReserve > 0)
         num += Header.WriteToken(null, 0, new MimeStringLength(lastLineReserve), stream, ref currentLineLength, ref lineBuffer, ref autoAddedLastLWSP, allowUTF8);
     if (lineBuffer.Length.InBytes > 0) {
         stream.Write(lineBuffer.Bytes, 0, lineBuffer.Length.InBytes);
         num += lineBuffer.Length.InBytes;
         currentLineLength.IncrementBy(lineBuffer.Length);
     }
     return num;
 }
Пример #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Scanner"/> class.
 /// </summary>
 /// <param name="inp">The input text reader.</param>
 /// <param name="prompt">The prompt.</param>
 internal Scanner(TextReader inp, string prompt)
 {
     this.inp = inp;
     this.lineBuffer = new LineBuffer(inp, prompt);
 }
        /// <summary>
        ///     Implements IDebugOutputCallbacks2::Output2
        /// </summary>
        public int Output2(DEBUG_OUTCB Which, DEBUG_OUTCBF Flags, UInt64 Arg, string Text)
        {
            var mask = (DEBUG_OUTPUT)Arg;

            if (Which == DEBUG_OUTCB.EXPLICIT_FLUSH)
            {
                //Flush();
                return(S_OK);
            }
            if (string.IsNullOrEmpty(Text))
            {
                return(S_OK);
            }
            bool textIsDml = (Which == DEBUG_OUTCB.DML);

            if (OutputActive)
            {
                lock (this)
                {
                    OutputActive       = false;
                    PreviousTextWasDml = textIsDml;
                    PreviousDmlFlags   = Flags;
                    DbgStringBuilder LineBuffer;
                    LineBuffers.TryGetValue(mask, out LineBuffer);
                    int LineInputPos = 0;
                    LineInputPositions.TryGetValue(mask, out LineInputPos);
                    bool waitForClosingDML = false;

                    if (LineBuffer == null)
                    {
                        LineBuffer        = new DbgStringBuilder(ExecutionUtilities, 1024);
                        LineBuffers[mask] = LineBuffer;
                    }
                    for (int i = 0; i < Text.Length; ++i)
                    {
                        char c = Text[i];
                        if (c == '<')
                        {
                            waitForClosingDML = true;
                        }
                        if (waitForClosingDML)
                        {
                            if (c == '>')
                            {
                                waitForClosingDML = false;
                            }
                        }
                        if (c == '\n' && waitForClosingDML == false)
                        {
                            LineBuffer.AppendLine();
                            ProcessLine(mask, LineBuffer.ToString(), textIsDml, Flags);
                            LineBuffer.Clear();
                            LineInputPos = 0;
                        }
                        else if (c == '\r')
                        {
                            LineInputPos = 0;
                        }
                        else
                        {
                            if (LineInputPos >= LineBuffer.Length)
                            {
                                LineBuffer.Append(c);
                            }
                            else
                            {
                                LineBuffer[LineInputPos] = c;
                            }
                            ++LineInputPos;
                        }
                    }

                    LineInputPositions[mask] = LineInputPos;

                    OutputActive = true;
                }
            }

            return(S_OK);
        }
        public static bool ContainsLine(
            this TextRange textRange,
            LineBuffer lineBuffer,
            int lineIndex,
            out CharacterPosition beginCharacterPosition,
            out CharacterPosition endCharacterPosition)
        {
            // If this is a single line, short cut the processing.
            TextPosition firstTextPosition = textRange.FirstTextPosition;
            TextPosition lastTextPosition  = textRange.LastTextPosition;

            int firstLineIndex = firstTextPosition.LinePosition.GetLineIndex(lineBuffer);

            if (textRange.IsSameLine)
            {
                if (firstLineIndex == lineIndex)
                {
                    beginCharacterPosition = firstTextPosition.CharacterPosition;
                    endCharacterPosition   = lastTextPosition.CharacterPosition;
                    return(true);
                }

                beginCharacterPosition = CharacterPosition.Begin;
                endCharacterPosition   = CharacterPosition.End;
                return(false);
            }

            // Figure out the line range index and see if the given line is with
            // the range.
            int lastLineIndex = lastTextPosition.LinePosition.GetLineIndex(lineBuffer);

            if (lineIndex < firstLineIndex ||
                lineIndex > lastLineIndex)
            {
                beginCharacterPosition = CharacterPosition.Begin;
                endCharacterPosition   = CharacterPosition.Begin;
                return(false);
            }

            // If the line is the same, we just use the same line.
            if (firstLineIndex == lastLineIndex)
            {
                beginCharacterPosition = firstTextPosition.CharacterPosition;
                endCharacterPosition   = lastTextPosition.CharacterPosition;
                return(true);
            }

            // We have at least one additional line. If we are on the first,
            // then it is everything to the right of the starting.
            if (firstLineIndex == lineIndex)
            {
                beginCharacterPosition = firstTextPosition.CharacterPosition;
                endCharacterPosition   = CharacterPosition.End;
                return(true);
            }

            // If we are on the last line, then it is everything before the index.
            if (lastLineIndex == lineIndex)
            {
                beginCharacterPosition = CharacterPosition.Begin;
                endCharacterPosition   = lastTextPosition.CharacterPosition;
                return(true);
            }

            // In all other cases, it is the entire line.
            beginCharacterPosition = CharacterPosition.Begin;
            endCharacterPosition   = CharacterPosition.End;
            return(true);
        }
Пример #7
0
        public unsafe void DrawBeamApp(PolylineRender poly, LineBuffer points, float globalTime, NodeReference reference, ParticleEffectInstance instance, ResourceManager res, Billboards billboards, ref Matrix4 transform, float sparam)
        {
            //TODO: Cross-plane not showing
            //TODO: In some cases particles are going backwards? (Broken emitter or LineBuffer)
            //TODO: See if z sorting can be better for Polyline
            //TODO: Implement FLBeamAppearance properties
            if (points.Count() < 2)
            {
                return;
            }
            //Get only active indices, alloc on stack for 0 GC pressure
            //int* indices = stackalloc int[512];
            var indices   = new int[512];
            var particles = new Particle[512];

            for (int i = 0; i < 512; i++)
            {
                indices[i] = -1;
            }
            int ptCount = 0;

            for (int i = 0; i < points.Count(); i++)
            {
                if (points[i].Active)
                {
                    indices[ptCount++] = points[i].ParticleIndex;
                }
            }
            if (ptCount < 2)
            {
                return;
            }
            for (int i = 0; i < ptCount; i++)
            {
                particles[i] = instance.Particles[indices[i]];
            }
            for (int i = 1; i < ptCount; i++)
            {
                if (particles[i - 1].TimeAlive > particles[i].TimeAlive)
                {
                    Console.WriteLine("bad order");
                }
            }
            var       node_tr = GetAttachment(reference, transform);
            Texture2D tex;
            Vector2   tl, tr, bl, br;

            HandleTexture(res, globalTime, sparam, ref instance.Particles[indices[0]], out tex, out tl, out tr, out bl, out br);
            //Sorting hack kinda
            var z = RenderHelpers.GetZ(billboards.Camera.Position, node_tr.Transform(Vector3.Zero));

            for (int j = 0; j < 2; j++)             //two planes
            {
                poly.StartLine(tex, BlendInfo);
                bool    odd = true;
                Vector3 dir = Vector3.Zero;

                for (int i = 0; i < ptCount; i++)
                {
                    var pos = node_tr.Transform(instance.Particles[indices[i]].Position);
                    if (i + 1 < ptCount)
                    {
                        var pos2     = node_tr.Transform(instance.Particles[indices[i + 1]].Position);
                        var forward  = (pos2 - pos).Normalized();
                        var toCamera = (billboards.Camera.Position - pos).Normalized();
                        var up       = Vector3.Cross(toCamera, forward);
                        up.Normalize();
                        dir = up;
                        if (j == 1)
                        {
                            //Broken? Doesn't show up
                            var right = Vector3.Cross(up, forward).Normalized();
                            dir = right;
                        }
                    }
                    var time = instance.Particles[indices[i]].TimeAlive / instance.Particles[indices[i]].LifeSpan;
                    var w    = Width.GetValue(sparam, time);
                    poly.AddPoint(
                        pos + (dir * w / 2),
                        pos - (dir * w / 2),
                        odd ? tl : bl,
                        odd ? tr : br,
                        new Color4(
                            Color.GetValue(sparam, time),
                            Alpha.GetValue(sparam, time)
                            )
                        );
                    odd = !odd;
                }
                poly.FinishLine(z);
            }
        }
Пример #8
0
        private void openPGMfile(int fileNumber)
        {
            if (fileNumber == 0)
            {
                CurrentFilePath = open.FileNames[0].ToString();    //Пътят до файла;
            }
            else if (fileNumber == 1)
            {
                CurrentFilePath = open.FileNames[1].ToString();    //Пътят до файла;
            }
            StreamReader ImageStreamReader = new StreamReader(CurrentFilePath);
            String       LineBuffer;

            //за запаметяване размерите на изображението дължина и ширина
            String[] ExtractDimension;
            PurgeGlobalData();       //Функция за нулиране на променливите, които се инизиализират в началото,
            // използват се в случай, че се отвори следваща картинка;
            LineBuffer = "#";        //Проверка дали файлът не започва с коментар "#";
            do
            {
                LineBuffer = ImageStreamReader.ReadLine();
            } while (LineBuffer.StartsWith("#"));

            // Проверка дали файлът започва с подходяща информация за форматът си в
            // противен случай се извежда подходящо съобщение

            if (LineBuffer.StartsWith("P2"))
            {
                ImageType = "P2";
            }
            else
            {
                ImageStreamReader.Close();
                MessageBox.Show("File error!");
                PurgeGlobalData();
            }
            //Проверка за други коментари в файла и прочитане на размерите за изображението
            LineBuffer = "#";
            do
            {
                LineBuffer = ImageStreamReader.ReadLine();
            } while (LineBuffer.StartsWith("#"));

            // Прочетените размери на изображението се запаметяват в масива ExtractDimensions
            // след което стойностите им се преобразуват в целочислен вид и се предават на
            // Bitmap изображението

            ExtractDimension = LineBuffer.Split(' ');
            ImageHeight      = int.Parse(ExtractDimension[1]);
            finalImageHeight = ImageHeight;
            ImageWidth       = int.Parse(ExtractDimension[0]);
            finalImageWidth  = ImageWidth;
            CurrentBitmap    = new Bitmap(ImageWidth, ImageHeight);
            CurrentBitmap2   = new Bitmap(ImageWidth, ImageHeight);
            FinalBitmap      = new Bitmap(finalImageWidth, finalImageHeight);


            // Ако файлът започва с правилната първоначална информация "P2", прочитат се
            // стойностите за сивия цвят от него, преобразуват се в целочислен вид и
            // се предават на променливата ImageMaxGreyValue;

            if (ImageType == "P2")
            {
                LineBuffer = "#";
                do
                {
                    LineBuffer = ImageStreamReader.ReadLine();
                } while (LineBuffer.StartsWith("#"));
                ImageMaxGreyValue = int.Parse(LineBuffer);
            }

            if (fileNumber == 0)
            {
                CurrentFile = ImageStreamReader.ReadToEnd();
                CurrentFile = CurrentFile.Replace("\r", " ");
                CurrentFile = CurrentFile.Replace("\n", " ");
            }

            else if (fileNumber == 1)
            {
                CurrentFile2 = ImageStreamReader.ReadToEnd();
                CurrentFile2 = CurrentFile2.Replace("\r", " ");
                CurrentFile2 = CurrentFile2.Replace("\n", " ");
            }


            //Затваряне на входния поток и извикане на функцията за изобразяване BiuldCanvas()
            ImageStreamReader.Close();
            if (fileNumber == 0)
            {
                BuildCanvas(0);
            }
            else if (fileNumber == 1)
            {
                BuildCanvas(1);
            }
        }
Пример #9
0
        /// <inheritdoc />
        /// <summary>
        ///     This section when called will read the data that is contained in
        ///     the list that was passed in from the constructor.
        /// </summary>
        public override void ReadSection()
        {
            // Iterate through the list of tagged data
            for (var currentIndex = StartIndex;
                 currentIndex < DataList.Length;
                 ++currentIndex)
            {
                // set the current data
                var currentData = DataList.GetPair(currentIndex);

                // Set the ending index of the file and break out of the loop
                if (currentData.GroupCode == GroupCodesBase.EndSectionMarker)
                {
                    EndIndex = currentIndex;
                    break;
                }

                // The master switch for the values
                switch (currentData.Value)
                {
                /*
                 * All Entities Cases will follow the same formula:
                 * 1. Create a new Buffer class
                 * 2. pass the Data list to the buffer class with the starting
                 *    index of the entity.
                 * 3. Add the entity to the entity list
                 */

                // LINE
                case LineGroupCodes.StartMarker:
                    var lineBuffer = new LineBuffer();
                    lineBuffer.Parse(DataList, currentIndex);
                    Entities.Add(new Line(lineBuffer));
                    continue;

                // LWPOLYLINE
                case LwPolylineCodes.StartMarker:
                    var lwPolyLineBuffer = new LwPolyLineBuffer();
                    lwPolyLineBuffer.Parse(DataList, currentIndex);
                    Entities.Add(new LwPolyLine(lwPolyLineBuffer));
                    continue;

                // HATCH
                case HatchCodes.StartMarker:
                    var hatchBuffer = new HatchBuffer();
                    hatchBuffer.Parse(DataList, currentIndex);
                    Entities.Add(new Hatch(hatchBuffer));
                    continue;

                // ARC
                case CircularArcCodes.ArcStartMarker:
                    var arcBuffer = new CircularArcBuffer();
                    arcBuffer.Parse(DataList, currentIndex);
                    Entities.Add(new CircularArc(arcBuffer));
                    continue;

                // TEXT
                case TextCodes.StartMarker:
                    var textBuffer = new TextBuffer();
                    textBuffer.Parse(DataList, currentIndex);
                    Entities.Add(new Text(textBuffer));
                    continue;

                // MTEXT
                case MTextCodes.StartMarker:
                    var mTextBuffer = new MTextBuffer();
                    mTextBuffer.Parse(DataList, currentIndex);
                    Entities.Add(new MText(mTextBuffer));
                    continue;

                // POINT
                case PointCodes.StartMarker:
                    var pointBuffer = new PointBuffer();
                    pointBuffer.Parse(DataList, currentIndex);
                    Entities.Add(new Point(pointBuffer));
                    continue;

                // CIRCLE
                case CircularArcCodes.CircleStartMarker:
                    var circleBuffer = new CircularArcBuffer();
                    circleBuffer.Parse(DataList, currentIndex);
                    Entities.Add(new Circle(circleBuffer));
                    break;

                // DEFAULT
                default:
                    continue;
                }
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="CachedTextRenderer"/> class.
 /// </summary>
 /// <param name="displayContext">The display context.</param>
 /// <param name="lineBuffer">The line buffer.</param>
 public CachedTextRenderer(
     IDisplayContext displayContext,
     LineBuffer lineBuffer)
     : this(displayContext, new LineBufferRenderer(displayContext, lineBuffer))
 {
 }
        public static void Copy(EditorViewController controller)
        {
            // If we don't have anything selected, we don't do anything.
            IDisplayContext displayContext = controller.DisplayContext;
            TextRange       selection      = displayContext.Caret.Selection;

            if (selection.IsEmpty)
            {
                return;
            }

            // Go through the selection and figure out if we have a single-line
            // copy.
            LineBuffer lineBuffer = displayContext.LineBuffer;

            int    startLineIndex = selection.FirstLinePosition.GetLineIndex(lineBuffer);
            int    endLineIndex   = selection.LastLinePosition.GetLineIndex(lineBuffer);
            string firstLine      = lineBuffer.GetLineText(
                selection.FirstLinePosition, LineContexts.Unformatted);

            if (endLineIndex == startLineIndex)
            {
                // Single-line copy is much easier since we just need a substring.
                int startCharacterIndex =
                    selection.FirstTextPosition.GetCharacterIndex(lineBuffer);
                int endCharacterIndex =
                    selection.FirstTextPosition.GetCharacterIndex(lineBuffer);
                string singleLineText = firstLine.Substring(
                    startCharacterIndex, endCharacterIndex - startCharacterIndex);

                // Set the clipboard's text and return.
                displayContext.Clipboard.Text = singleLineText;
                return;
            }

            // For multiple line copies, we need to copy every line from the first
            // to the last. We already have the first, so just copy that.
            var buffer         = new StringBuilder();
            int firstLineIndex =
                selection.FirstTextPosition.CharacterPosition.GetCharacterIndex(firstLine);

            buffer.Append(firstLine.Substring(firstLineIndex));
            buffer.Append("\n");

            // Loop through the second to just shy of the last line, adding
            // each one as a full line.
            for (int lineIndex = startLineIndex + 1;
                 lineIndex < endLineIndex;
                 lineIndex++)
            {
                buffer.Append(lineBuffer.GetLineText(lineIndex, LineContexts.Unformatted));
                buffer.Append("\n");
            }

            // Add the last line, which is a substring, but we don't add a
            // newline to the end of this one.
            string lastLineText = lineBuffer.GetLineText(
                endLineIndex, LineContexts.Unformatted);
            int lastCharacterIndex =
                selection.EndCharacterPosition.GetCharacterIndex(lastLineText);

            buffer.Append(lastLineText.Substring(0, lastCharacterIndex));

            // Set the clipboard value.
            displayContext.Clipboard.Text = buffer.ToString();
        }
Пример #12
0
 /// <summary>
 /// Sets the line buffer since the renderer.
 /// </summary>
 /// <param name="value">The value.</param>
 public abstract void SetLineBuffer(LineBuffer value);
Пример #13
0
        internal UidWriter(UidCollector collector, Stream source, Stream target)
        {
            _collector     = collector;
            _sourceReader  = new StreamReader(source);

             UTF8Encoding encoding = new UTF8Encoding(true);
            _targetWriter  = new StreamWriter(target, encoding);
            _lineBuffer    = new LineBuffer(_sourceReader.ReadLine());
        }
Пример #14
0
        public void TestEmptyLineWidth()
        {
            var l = new LineBuffer(null);

            Assert.IsFalse(l.Match("bogus"));
        }
Пример #15
0
            public void EnumerateMetafile(Stream emf, float unitSize, PointF destination, DrawLineDelegate drawLine, FillPolygonDelegate fillPolygon)
            {
                Transform = new Matrix();
                _drawLine = drawLine;
                _fillPolygon = fillPolygon;
                _zero = destination;
                _lineBuffer = new LineBuffer(unitSize);
                _objects = new System.Collections.Generic.Dictionary<uint, ObjectHandle>();
                _brush = null;

                using (var reader = new EmfTools.EmfReader(emf))
                {
                    while (!reader.IsEndOfFile)
                    {
                        var record = reader.Read() as EmfTools.EmfUnknownRecord;
                        if (record == null)
                            continue;

                        switch (record.RecordType)
                        {
                            case EmfPlusRecordType.EmfHeader:
                            case EmfPlusRecordType.EmfEof:
                            case EmfPlusRecordType.EmfSaveDC:
                            case EmfPlusRecordType.EmfDeleteObject:
                            case EmfPlusRecordType.EmfExtCreatePen:
                            case EmfPlusRecordType.EmfCreatePen:
                            case EmfPlusRecordType.EmfRestoreDC:
                            case EmfPlusRecordType.EmfSetIcmMode:
                            case EmfPlusRecordType.EmfSetMiterLimit:
                            case EmfPlusRecordType.EmfSetPolyFillMode:
                                // Harmless records with no significant side-effects on the shape of the drawn outline
                                break;

                            case EmfPlusRecordType.EmfSelectObject:
                                ProcessSelectObject(record.Data);
                                break;

                            case EmfPlusRecordType.EmfCreateBrushIndirect:
                                ProcessCreateBrushIndirect(record.Data);
                                break;

                            case EmfPlusRecordType.EmfBeginPath:
                                ProcessBeginPath(record.Data);
                                break;

                            case EmfPlusRecordType.EmfEndPath:
                                // TODO:
                                break;

                            case EmfPlusRecordType.EmfStrokeAndFillPath:
                                ProcessStrokeAndFillPath(record.Data);
                                break;

                            case EmfPlusRecordType.EmfMoveToEx:
                                ProcessMoveToEx(record.Data);
                                break;

                            case EmfPlusRecordType.EmfModifyWorldTransform:
                                ProcessModifyWorldTransform(record.Data);
                                break;

                            case EmfPlusRecordType.EmfPolygon16:
                                ProcessPolygon16(record.Data);
                                break;

                            case EmfPlusRecordType.EmfPolyPolygon16:
                                ProcessPolyPolygon16(record.Data);
                                break;

                            case EmfPlusRecordType.EmfPolyline16:
                                ProcessPolyline16(record.Data);
                                break;

                            case EmfPlusRecordType.EmfPolylineTo16:
                                ProcessPolylineTo16(record.Data);
                                break;

                            case EmfPlusRecordType.EmfCloseFigure:
                                ProcessCloseFigure(record.Data);
                                break;

                            case EmfPlusRecordType.EmfPolyBezierTo16:
                                ProcessPolyBezierTo16(record.Data);
                                break;

                            default:
                                throw new NotImplementedException();
                        }
                    }
                }

                CommitLine();
            }