コード例 #1
0
        protected void RenderDefaultMatch(DrawingContext ctx, ITextPosition pos)
        {
            Brush brush = null;

            if (!ViewParent.TextCore.DictBrush.TryGetValue("background_rawtext_defaultmatch", out brush))
            {
                return;
            }
            ITextItem item = pos.Item;

            if (item is ITextKey)
            {
                return;
            }
            string        word  = item.ToString();
            ITextPosition start = Core.Start;
            ITextPosition end   = Core.End;

            if (Core is IMRAZoneSkipInfo)
            {
                IMRAZoneSkipInfo zkcore = (IMRAZoneSkipInfo)Core;
                while (start != null && !zkcore.SkipZone.IsAncestorOf(start.Item))
                {
                    if (!(start.Item is ITextTrim) && !(start.Item is ITextKey) &&
                        start.Item.ToString().Equals(word))
                    {
                        ITextPosition wstart = start.LeftPart.Length > 0 ? start.PrevItem() : start;
                        ITextPosition wend   = start.RightPart.Length > 0 ? start.NextItem() : start;
                        DrawTextRectangle(ctx, brush, null, wstart, wend);
                    }
                    start = start?.NextItem();
                }
                while (end != null && !zkcore.SkipZone.IsAncestorOf(end.Item))
                {
                    if (!(end.Item is ITextTrim) && !(end.Item is ITextKey) &&
                        end.Item.ToString().Equals(word))
                    {
                        ITextPosition wstart = end.LeftPart.Length > 0 ? end.PrevItem() : end;
                        ITextPosition wend   = end.RightPart.Length > 0 ? end.NextItem() : end;
                        DrawTextRectangle(ctx, brush, null, wstart, wend);
                    }
                    end = end?.PrevItem();
                }
            }
            else
            {
                while (start.Item != end.Item)
                {
                    if (!(start.Item is ITextTrim) && !(start.Item is ITextKey) &&
                        start.Item.ToString().Equals(word))
                    {
                        ITextPosition wstart = start.LeftPart.Length > 0 ? start.PrevItem() : start;
                        ITextPosition wend   = start.RightPart.Length > 0 ? start.NextItem() : start;
                        DrawTextRectangle(ctx, brush, null, wstart, wend);
                    }
                    start = start?.NextItem();
                }
            }
        }
コード例 #2
0
        protected void RenderBracket(DrawingContext ctx, ITextPosition pos)
        {
            ITextItem item = pos.Item;
            ITextZone zone = item.Parent;

            if (!(item is ITextKey))
            {
                return;
            }
            ITextKey key = (ITextKey)item;

            if ((key.KeyCore.Feature & (TextKeyFeatures.ZoneLeft | TextKeyFeatures.ZoneRight)) == TextKeyFeatures.None)
            {
                return;
            }
            Brush brush = null;

            ViewParent.TextCore.DictBrush.TryGetValue("background_rawtext_bracket", out brush);
            if (Core.ContainLine(pos.Line))
            {
                ITextPosition start = pos.LeftPart.Length > 0 ? pos.PrevItem() : pos;
                ITextPosition end   = pos.RightPart.Length > 0 ? pos.NextItem() : pos;
                DrawTextRectangle(ctx, brush, null, start.Column - 1, end.Column - start.Column);
            }
            if (item.ID == 0)
            {
                ITextItem rightkey = zone.Items.LastOrDefault();
                if (Core.ContainLine(pos.Line + zone.LineCount - 1))
                {
                    ITextPosition rstart = new TextPosition()
                    {
                        Item = rightkey, ItemIndex = 0, Line = pos.Line + zone.LineCount - 1, Column = -1
                    };
                    ITextPosition rend = rstart?.NextItem();
                    if (rstart != null && rend != null)
                    {
                        DrawTextRectangle(ctx, brush, null, rstart, rend);
                    }
                }
            }
            else
            {
                ITextItem leftkey = zone.Items.FirstOrDefault();
                if (Core.ContainLine(pos.Line - zone.LineCount + 1))
                {
                    ITextPosition lstart = new TextPosition()
                    {
                        Item = leftkey, ItemIndex = 0, Line = pos.Line - zone.LineCount + 1, Column = -1
                    };
                    ITextPosition lend = lstart?.NextItem();
                    if (lstart != null && lend != null)
                    {
                        DrawTextRectangle(ctx, brush, null, lstart, lend);
                    }
                }
            }
        }
コード例 #3
0
        public ITextPosition NextItemNonTrim()
        {
            ITextPosition nextpos = NextItem();

            while (nextpos != null && nextpos.Item is ITextTrim)
            {
                nextpos = nextpos.NextItem();
            }
            return(nextpos);
        }