コード例 #1
0
        public void SetResultViewing(string fileName, string langdef, string data, int row, int col)
        {
            Title += fileName;
            TaggingHighlight hl = null;

            if (langdef != null)
            {
                hl = new TaggingHighlight();
                new Highlight.Highlighter(hl).Highlight(langdef, data);
            }

            var reprp   = 0;
            var lineid  = 0;
            var lastcfg = 0;
            var locelem = -1;
            var inlcoll = hltextblk.Inlines;

            for (; ;)
            {
                lineid++;
                if (lineid == row)
                {
                    locelem = inlcoll.Count;
                }

                var nextlf = data.IndexOf('\n', reprp);
                if (nextlf > 0)
                {
                    lastcfg = MatchFile.AddInlineWithHL(lastcfg, inlcoll, data.Substring(reprp, nextlf - reprp), reprp, nextlf, hl, null);
                    inlcoll.Add(new LineBreak());
                    reprp = nextlf + 1;
                }
                else
                {
                    lastcfg = MatchFile.AddInlineWithHL(lastcfg, inlcoll, data.Substring(reprp), data.Length, nextlf, hl, null);
                    break;
                }
            }

            (((System.Collections.IList)inlcoll)[locelem] as Inline).BringIntoView();
        }
コード例 #2
0
        public MatchFile AddFile(string fileName, string highlighter)
        {
            if (fileName == lastextra)
            {
                return(null);
            }
            if (filec > MAXFILECNT)
            {
                lastextra = fileName;
                extracnt++;
                if (extrafiles == null)
                {
                    var tb = new TextBlock()
                    {
                        Margin     = new Thickness(16, 0, 0, 0),
                        Foreground = new SolidColorBrush(Color.FromRgb(0x48, 0x97, 0x48))
                    };
                    tb.Inlines.Add(new Run("And:    "));
                    tb.Inlines.Add(extrafiles = new Run(""));
                    tb.Inlines.Add(" more files");
                    LargePanel.Children.Add(LargePanel);
                }
                extrafiles.Text = extracnt.ToString();
                return(null);
            }
            if (lastfile != null && lastfile.fileName.Text == fileName)
            {
                return(lastfile);
            }

            MatchFile filem = new MatchFile();

            filem.SetFilename(fileName, highlighter);
            filem.HorizontalAlignment = HorizontalAlignment.Stretch;
            filem.SetPreviewLines(envapply);
            LargePanel.Children.Add(filem);
            FileCntAdd();
            lastfile = filem;
            return(filem);
        }