예제 #1
0
        internal void SetResults(ProcessedDataPackage package, int index)
        {
            lastRenderTimestamp = 0;
            if (package == null)
            {
                //  Clear();
                return;
            }

            lock (setResultsLock)
            {
                this.currentResultsIndex = index;

                if (lastPackageHashNumber != package.GetHashCode())
                {
                    this.currentResults        = null;
                    this.package               = package;
                    this.lastPackageHashNumber = package.GetHashCode();

                    if (package.ContainsKey(typeof(BrokenSourceData)) != false &&
                        String.IsNullOrEmpty(((BrokenSourceData)package[typeof(BrokenSourceData)]).PageSource) == false &&
                        ((BrokenSourceData)package[typeof(BrokenSourceData)]).InjectionBreaks != null)
                    {
                        BrokenSourceData brokenSourceData = ((BrokenSourceData)package[typeof(BrokenSourceData)]);

                        SourcePiece[] sp = new SourcePiece[brokenSourceData.InjectionBreaks.Count];
                        int           i  = 0;
                        foreach (SourcePiece s in brokenSourceData.InjectionBreaks)
                        {
                            sp[i] = s;
                            i++;
                        }
                        this.currentResults = sp;
                        SetBuffer(brokenSourceData.PageSource);
                    }
                    if (package.ContainsKey(typeof(RenderData)) != false)
                    {
                        RenderData rd = (RenderData)package[typeof(RenderData)];
                        foreach (RenderedSegment rs in rd.Values)
                        {
                            lastRenderTimestamp = Math.Max(lastRenderTimestamp, rs.EndTime);
                        }
                    }
                }

                RedrawResultsNextPrev();
            }
        }
예제 #2
0
        private void RedrawResultsNextPrev()
        {
            this.sourceTextBox.SelectionBackColor = Color.White;
            this.sourceTextBox.SelectionColor     = Color.FromArgb(0xCACACA);

            this.sourceTextBox.SelectionStart  = 0;
            this.sourceTextBox.SelectionLength = Math.Max(0, this.sourceTextBox.Text.Length - 1);

            this.sourceTextBox.SelectionBackColor = Color.White;
            this.sourceTextBox.SelectionColor     = Color.FromArgb(0xCACACA);

            this.sourceTextBox.ScrollToCaret();

            if (currentResults == null || currentResults.Length == 0)
            {
                this.nextBtn.Enabled = false;
                this.prevBtn.Enabled = false;
            }
            else
            {
                this.nextBtn.Enabled = (currentResultsIndex < currentResults.Length - 1);
                this.prevBtn.Enabled = (currentResultsIndex > 0);
            }

            if (currentResults != null)
            {
                if (currentResultsIndex < currentResults.Length)
                {
                    SourcePiece bvf = currentResults[currentResultsIndex];
                    int         l   = 0;
                    int         s   = 0;
                    int         c   = 0;
                    try
                    {
                        c = CountCaretReturs(bvf.SourceData.PageSource, bvf.StartIndex, bvf.Length);
                        l = bvf.Length - c;
                        s = bvf.StartIndex - CountCaretReturs(bvf.SourceData.PageSource, 0, bvf.StartIndex);

                        if (s < sourceTextBox.Text.Length)
                        {
                            this.sourceTextBox.SelectionStart     = s;
                            this.sourceTextBox.SelectionLength    = Math.Max(0, Math.Min(sourceTextBox.Text.Length - s, l));
                            this.sourceTextBox.SelectionBackColor = Color.FromArgb(0xFFFFCC);
                            this.sourceTextBox.SelectionColor     = Color.FromArgb(0x000000);

                            if (c > 0)
                            {
                                this.sourceTextBox.SelectionStart = s;
                            }
                            else
                            {
                                this.sourceTextBox.SelectionStart = s + (Math.Min(sourceTextBox.Text.Length - s, l));
                            }

                            this.sourceTextBox.ScrollToCaret();

                            this.sourceTextBox.SelectionLength = 0;
                        }
                    }
                    catch
                    {
                    }
                }
            }
            SetThumbnailsAndData();
        }
예제 #3
0
        private void AddRenderTimesData(XmlDocument xml, XmlElement results)
        {
            if (this.ContainsKey(typeof(RenderData)) == false)
            {
                return;
            }

            RenderData r = (RenderData)this[typeof(RenderData)];

            XmlElement b = xml.CreateElement("render");

            b.SetAttribute("un", r.ReadyStateUninitialized.ToString());
            b.SetAttribute("li", r.ReadyStateLoading.ToString());
            b.SetAttribute("lo", r.ReadyStateLoaded.ToString());
            b.SetAttribute("in", r.ReadyStateInteractive.ToString());
            b.SetAttribute("co", r.ReadyStateComplete.ToString());
            b.SetAttribute("ol", r.OnLoad.ToString());

            results.AppendChild(b);

            XmlElement t  = null;
            int        ss = 0;
            int        sl = 0;

            SourcePiece[] ib = null;
            if (this.ContainsKey(typeof(BrokenSourceData)))
            {
                BrokenSourceData bs = (BrokenSourceData)this[typeof(BrokenSourceData)];
                if (bs.InjectionBreaks != null)
                {
                    ib = new SourcePiece[bs.InjectionBreaks.Count];
                    int i = 0;

                    foreach (SourcePiece sp in bs.InjectionBreaks)
                    {
                        ib[i] = sp;
                        i++;
                    }
                }
            }
            foreach (RenderedSegment rp in r.Values)
            {
                ss = 0;
                sl = 0;

                t = xml.CreateElement("r");
                t.SetAttribute("s", rp.StartTime.ToString());
                t.SetAttribute("e", rp.EndTime.ToString());
                t.SetAttribute("i", rp.InjectionID.ToString());
                t.SetAttribute("st", rp.SegmentType.ToString());

                if (ib != null && ib.Length > rp.InjectionID)
                {
                    ss = ib[rp.InjectionID].StartIndex;
                    sl = ib[rp.InjectionID].Length;
                }

                t.SetAttribute("ss", ss.ToString());
                t.SetAttribute("sl", sl.ToString());

                b.AppendChild(t);
            }
        }