/// <summary> 根据xchd文档来匹配实例(指定检查范围) </summary>
        /// <param name="docname">xchd文档元素名称</param>
        /// <param name="start">检查范围的开始</param>
        /// <param name="count">检查范围的个数</param>
        /// <returns>所有匹配合法的结果</returns>
        public IEnumerable <IMRADocMatchResult> DocMatch(string docname, int start, int count)
        {
            ITextBoxCore core    = zone is ITextBoxCore ? (ITextBoxCore)zone : zone.Core;
            IDocsCore    doccore = core?.DocsCore;

            if (doccore == null)
            {
                yield break;
            }
            IDocsItem docitem = doccore.GetItem(docname);

            if (docitem is IDocsCollection)
            {
                int ni = 0;
                for (int i = start; i < start + count; i++)
                {
                    MRADocMatchCollection match = _DocMatchGroup(zone.Items[i], docitem, ref ni);
                    if (match != null)
                    {
                        yield return(new MRADocMatchResult(match, i, ni - i));
                    }
                }
            }
            for (int i = start; i < start + count; i++)
            {
                MRADocMatchItem match = _DocMatch(zone.Items[i], docitem);
                if (match != null)
                {
                    yield return(new MRADocMatchResult(match, i, 1));
                }
            }
        }
Example #2
0
 public MRACltItemInfo(ITextBoxCore _core, MRACltBox _parent, MRACltItemTypes _type, int _id, string _text)
 {
     this.core   = _core;
     this.parent = _parent;
     this.type   = _type;
     this.id     = _id;
     this.text   = _text;
     this.bolds  = new List <MRACltBoldSegment>();
 }
Example #3
0
 public MRATextItemInfo(ITextBoxCore _core, int _id, int _line)
 {
     this.core           = _core;
     this.id             = _id;
     this.line           = _line;
     this.view           = null;
     this.openzonefocus  = false;
     this.closezonefocus = false;
     this.intozonefocus  = false;
 }
Example #4
0
 public MRAZoneSkipInfo(ITextBoxCore _core, int _id, int _linestart, int _lineend, ITextZone _skipzone)
 {
     this.core           = _core;
     this.id             = _id;
     this.linestart      = _linestart;
     this.lineend        = _lineend;
     this.skipzone       = _skipzone;
     this.openzonefocus  = false;
     this.closezonefocus = false;
     this.intozonefocus  = false;
 }
Example #5
0
 protected void Initialize()
 {
     if (Info?.Core != null)
     {
         ITextBoxCore core = Info.Core;
         core.DictBrush.TryGetValue("background_cltbox", out background_normal);
         core.DictBrush.TryGetValue("background_cltbox_selected", out background_selected);
         core.DictBrush.TryGetValue("foreground_cltbox", out foreground_normal);
         core.DictBrush.TryGetValue("foreground_cltbox_selected", out foreground_selected);
         Background = background_normal;
         Foreground = Info.IsSelected ? foreground_selected : foreground_normal;
     }
 }
Example #6
0
        protected override void Render(DrawingContext ctx)
        {
            if (Core == null || Core.IsDisposed)
            {
                return;
            }
            base.Render(ctx);
            ITextBoxCore textcore   = ViewParent.TextCore;
            double       fontsize   = textcore.FontSize;
            Brush        foreground = null;

            textcore.DictBrush.TryGetValue("foreground_linenumber", out foreground);

            Typeface      typeface = new Typeface(textcore.FontFamily, textcore.FontStyle, textcore.FontWeight, textcore.FontStretch);
            FormattedText fmttext  = new FormattedText(Core.Line.ToString(), Thread.CurrentThread.CurrentUICulture, FlowDirection.LeftToRight, typeface, fontsize, foreground);

            ctx.DrawText(fmttext, new Point(textcore.View.MarginNumberBar, 0));
        }
Example #7
0
        protected override void OnRender(DrawingContext ctx)
        {
            base.OnRender(ctx);
            if (Info == null)
            {
                return;
            }
            #region Background
            if (Info.IsSelected)
            {
                MRACltBox cltbox = Info.Core.View.UI_CltBox;
                Rect      bgrect = new Rect(Point_BgStart, new Point(Math.Max(cltbox.ActualWidth, ActualWidth), ActualHeight));
                ctx.DrawRectangle(background_selected, null, bgrect);
            }
            #endregion
            #region Icon
            {
                ImageSource icon = null;
                switch (Info.Type)
                {
                case MRACltItemTypes.Keyword: icon = Icon_Keyword; break;

                case MRACltItemTypes.Class: icon = Icon_Class; break;

                case MRACltItemTypes.Variable: icon = Icon_Variable; break;

                case MRACltItemTypes.Function: icon = Icon_Function; break;
                }
                ctx.DrawImage(icon, Rect_Icon);
            }
            #endregion
            #region Text
            {
                ITextBoxCore  core     = Info.Core;
                Typeface      typeface = new Typeface(core.FontFamily, core.FontStyle, core.FontWeight, core.FontStretch);
                FormattedText fmttext  = new FormattedText(Info.Text, Thread.CurrentThread.CurrentUICulture, FlowDirection.LeftToRight, typeface, 12, Foreground);
                foreach (MRACltBoldSegment bold in Info.Bolds)
                {
                    fmttext.SetFontWeight(FontWeights.Bold, bold.Start, bold.Count);
                }
                ctx.DrawText(fmttext, Point_Text);
            }
            #endregion
        }
Example #8
0
 public TextUndoRedoCore(ITextBoxCore _parent)
 {
     this.parent = _parent;
     this.undos  = new List <ITextAction>();
     this.redos  = new List <ITextAction>();
 }
        protected override void Render(DrawingContext ctx)
        {
            if (Core == null || Core.IsDisposed)
            {
                return;
            }
            base.Render(ctx);
            Brush        fbsNormal          = null;
            Brush        fbsInside          = null;
            Brush        bbsInside          = null;
            Brush        bbsInsideMouseOver = null;
            Brush        fbsInsideMouseOver = null;
            Brush        fbsMouseOver       = null;
            Brush        bbsMouseOver       = null;
            ITextBoxCore textcore           = ViewParent.TextCore;
            Rect         rect = new Rect(textcore.View.MarginStructBar, 0, textcore.View.MarginLeft - textcore.View.MarginStructBar, ViewParent.ActualHeight);

            textcore.DictBrush.TryGetValue("foreground_structbar_normal", out fbsNormal);
            textcore.DictBrush.TryGetValue("foreground_structbar_inside", out fbsInside);
            textcore.DictBrush.TryGetValue("background_structbar_inside_mouseover", out bbsInsideMouseOver);
            textcore.DictBrush.TryGetValue("foreground_structbar_inside_mouseover", out fbsInsideMouseOver);
            textcore.DictBrush.TryGetValue("background_structbar_inside", out bbsInside);
            textcore.DictBrush.TryGetValue("foreground_structbar_normal_mouseover", out fbsMouseOver);
            textcore.DictBrush.TryGetValue("background_structbar_normal_mouseover", out bbsMouseOver);
            Pen penNormal      = new Pen(fbsNormal, 1.0);
            Pen penNormalFocus = new Pen(fbsMouseOver, 1.2);
            Pen penInside      = new Pen(fbsInside, 1.0);
            Pen penInsideFocus = new Pen(fbsInsideMouseOver, 1.0);

            if (ViewParent.StructBarMouseOver)
            {
                fbsInside = fbsInsideMouseOver;
                bbsInside = bbsInsideMouseOver;
            }
            if (ViewParent.StructBarMouseOver && bbsMouseOver != null)
            {
                ctx.DrawRectangle(bbsMouseOver, null, rect);
            }
            if (ViewParent.IntoZone != null)
            {
                double top    = rect.Top;
                double bottom = rect.Bottom;
                if (ViewParent.IntoZone == ViewParent.OpenZone)
                {
                    top += (rect.Height - RectSize) / 2;
                }
                if (ViewParent.IntoZone == ViewParent.CloseZone)
                {
                    bottom -= rect.Height / 2;
                }
                ctx.DrawLine(Core.IntoZoneFocus ? penNormalFocus : penNormal,
                             new Point(rect.X + rect.Width / 2, top),
                             new Point(rect.X + rect.Width / 2, bottom));
                if (Core.OpenZoneFocus)
                {
                    ctx.DrawLine(penNormalFocus,
                                 new Point(rect.X + rect.Width / 2, rect.Y + rect.Height / 2),
                                 new Point(rect.X + rect.Width / 2, bottom));
                }
                if (Core.CloseZoneFocus)
                {
                    ctx.DrawLine(penNormalFocus,
                                 new Point(rect.X + rect.Width / 2, top),
                                 new Point(rect.X + rect.Width / 2, rect.Y + rect.Height / 2));
                }
            }
            if (ViewParent.CloseZone != null)
            {
                Pen pen = Core.CloseZoneFocus ? penNormalFocus : penNormal;
                if (ViewParent.IntoZone == null)
                {
                    ctx.DrawLine(pen,
                                 new Point(rect.X + rect.Width / 2, rect.Top),
                                 new Point(rect.X + rect.Width / 2, rect.Y + rect.Height / 2));
                }
                ctx.DrawLine(pen,
                             new Point(rect.X + rect.Width / 2, rect.Y + rect.Height / 2),
                             new Point(rect.X + rect.Width / 2 + RectSize / 2, rect.Y + rect.Height / 2));
            }
            if (ViewParent.SkipZone != null || ViewParent.OpenZone != null)
            {
                Pen   pen        = penNormal;
                Brush fill       = bbsInside;
                Rect  rectInside = new Rect((rect.Width - RectSize) / 2 + textcore.View.MarginStructBar, (rect.Height - RectSize) / 2, RectSize, RectSize);
                if (ViewParent.OpenZone != null && Core.OpenZoneFocus)
                {
                    pen = penNormalFocus; fill = bbsInsideMouseOver;
                }
                if (ViewParent.SkipZone != null && Core is IMRAZoneSkipInfo && ((IMRAZoneSkipInfo)Core).SkipZoneFocus)
                {
                    pen = penNormalFocus; fill = bbsInsideMouseOver;
                }
                ctx.DrawRectangle(fill, pen, rectInside);
                pen = penInside;
                if (ViewParent.OpenZone != null && Core.OpenZoneFocus)
                {
                    pen = penInsideFocus;
                }
                if (ViewParent.SkipZone != null)
                {
                    ctx.DrawLine(pen,
                                 new Point(rectInside.Left + InsideMargin, rectInside.Y + rectInside.Height / 2),
                                 new Point(rectInside.Right - InsideMargin, rectInside.Y + rectInside.Height / 2));
                    ctx.DrawLine(pen,
                                 new Point(rectInside.X + rectInside.Width / 2, rectInside.Top + InsideMargin),
                                 new Point(rectInside.X + rectInside.Width / 2, rectInside.Bottom - InsideMargin));
                }
                if (ViewParent.OpenZone != null)
                {
                    ctx.DrawLine(pen,
                                 new Point(rectInside.Left + InsideMargin, rectInside.Y + rectInside.Height / 2),
                                 new Point(rectInside.Right - InsideMargin, rectInside.Y + rectInside.Height / 2));
                }
            }
        }
        protected override void Render(DrawingContext ctx)
        {
            if (Core == null || Core.IsDisposed)
            {
                return;
            }
            base.Render(ctx);
            IMRATextItemInfo item = ViewParent?.Core;
            ITextBoxCore     core = ViewParent?.TextCore;
            WinTextLine      text = ViewParent?.TextLine;

            if (core == null)
            {
                return;
            }
            ITextPosition start = core.SelectedStart;
            ITextPosition end   = core.SelectedEnd;

            if (start.CompareTo(end) == 0)
            {
                ITextPosition pos = start.NextSeek();
                RenderBracket(ctx, pos);
                RenderDefaultMatch(ctx, pos);
                pos = pos.PrevSeek();
                RenderBracket(ctx, pos);
                RenderDefaultMatch(ctx, pos);
            }
            if (start.Line == end.Line && start.Column == end.Column)
            {
                status = start.Line == item.Line ? SelectionStatus.Caret : SelectionStatus.None;
            }
            else if (item.Line >= start.Line && item.Line <= end.Line)
            {
                status = SelectionStatus.Range;
            }
            else
            {
                status = SelectionStatus.None;
            }
            switch (status)
            {
            case SelectionStatus.None:
                break;

            case SelectionStatus.Caret:
            {
                if (!blinkshow && !forceshow)
                {
                    break;
                }
                int        index     = start.Column - 1;
                TextBounds bound     = text.GetTextBounds(index, 1).FirstOrDefault();
                Brush      brush     = null;
                double     thickness = 1.0;
                ViewParent.TextCore.DictBrush.TryGetValue("foreground_rawtext_caret", out brush);
                ViewParent.TextCore.DictValue.TryGetValue("rawtext_caret_thickness", out thickness);
                Pen   pen = new Pen(brush, thickness);
                Point p1  = bound.Rectangle.TopLeft;
                Point p2  = bound.Rectangle.BottomLeft;
                p1.Y -= 2;
                p1.X += ViewParent.TextCore.View.MarginLeft;
                p2.X += ViewParent.TextCore.View.MarginLeft;
                ctx.DrawLine(pen, p1, p2);
            }
            break;

            case SelectionStatus.Range:
            {
                //int left = start.Column - 1;
                //int right = end.Column - 1;
                if (start.Line < item.Line)
                {
                    start = Core.Start;
                }
                if (end.Line > item.Line)
                {
                    end = Core.End;
                }
                //if (right - left <= 0) break;
                //TextBounds bound = text.GetTextBounds(left, right - left).FirstOrDefault();
                Brush brush = null;
                //Rect rect = bound.Rectangle;
                ViewParent.TextCore.DictBrush.TryGetValue("background_rawtext_selected", out brush);
                //rect.X += ViewParent.TextCore.View.MarginLeft;
                //ctx.DrawRectangle(brush, null, rect);
                DrawTextRectangle(ctx, brush, null, start, end);
            }
            break;
            }
        }
 public MRATextParagraphProperties(ITextBoxCore _core, MRATextSource _textsource)
 {
     this.core       = _core;
     this.textsource = _textsource;
 }