Esempio n. 1
0
        public MarkSearcher(int id, TextView view)
        {
            if (view == null)
            {
                throw new ArgumentNullException("view");
            }

            _view = view;

            _id = id;

            _searcher = new TextSearch(_view);
            _searcher.SearchCompleted += new EventHandler <SearchCompletedEventArgs>(AsyncSearchCompleted);

            _marks = new MarkCollection(view);

            view.TextStreamEvents.StreamTextChanged +=
                new EventHandler <StreamTextChangedEventArgs>(StreamTextChangedHandler);
        }
Esempio n. 2
0
        private void DrawMarks(Graphics g, MarkCollection marks, Color markColor)
        {
            Rectangle[] rectangles = marks.GetRectanglesForVisibleMarks(this);

            if (rectangles == null || rectangles.Length == 0)
                return;

            if (AddinSettings.Instance.FilledMarks)
            {
                List<Rectangle> rectsToFilling = new List<Rectangle>();

                uint nativeBorderColor = (uint)markColor.R | (uint)markColor.G << 8 | (uint)markColor.B << 16;

                IntPtr hdc = g.GetHdc();

                for (int i = 0; i < rectangles.Length; i++)
                {
                    var rect = rectangles[i];

                    int score = 0;
                    if (Gdi32.GetPixel(hdc, rect.Left, rect.Top) == nativeBorderColor) score++;
                    if (Gdi32.GetPixel(hdc, rect.Left, rect.Bottom) == nativeBorderColor) score++;
                    if (score < 2 && Gdi32.GetPixel(hdc, rect.Right, rect.Bottom) == nativeBorderColor) score++;
                    if (score < 2 && Gdi32.GetPixel(hdc, rect.Right, rect.Top) == nativeBorderColor) score++;

                    bool isBorderDrawn = score >= 2;

                    if (!isBorderDrawn)
                        rectsToFilling.Add(rect);
                }

                g.ReleaseHdc();

                if (rectsToFilling.Count > 0)
                {
                    using (var bodyBrush = new SolidBrush(Color.FromArgb(32, markColor)))
                        g.FillRectangles(bodyBrush, rectsToFilling.ToArray());

                    //using (var borderPen = new Pen(markColor))
                    //    g.DrawRectangles(borderPen, rectsToFilling.ToArray());
                }
            }

            //Draw borders
            using (var borderPen = new Pen(markColor))
                g.DrawRectangles(borderPen, rectangles);
        }