DrawClientPipeMap

// Timeline.Timeline
// Token: 0x06000014 RID: 20 RVA: 0x00003BA4 File Offset: 0x00001DA4
private Bitmap DrawClientPipeMap(bool bFixedScale, long iMaxMS, ref int iImageWidth, out int iImageHeight)
{
    if (this.listEntries == null || this.listEntries.Count < 1)
    {
        iImageWidth = (iImageHeight = 1);
        return null;
    }
    Dictionary<string, List<ChartEntry>> dictionary = new Dictionary<string, List<ChartEntry>>();
    foreach (ChartEntry chartEntry in this.listEntries)
    {
        if (dictionary.ContainsKey(chartEntry.sClientPipeKey))
        {
            dictionary[chartEntry.sClientPipeKey].Add(chartEntry);
        }
        else
        {
            dictionary[chartEntry.sClientPipeKey] = new List<ChartEntry>();
            dictionary[chartEntry.sClientPipeKey].Add(chartEntry);
        }
    }
    iImageHeight = dictionary.Keys.Count * MAGICS.RowHeight + MAGICS.TitleRowHeight + MAGICS.TimerRowHeight + MAGICS.FooterRowHeight;
    float num = 0.06f;
    if (bFixedScale)
    {
        int num2 = Math.Max(iImageWidth, MAGICS.URIWidth + MAGICS.LeftMarginWidth + MAGICS.RightMarginWidth + (int)((float)iMaxMS * num));
        if (num2 > 16000)
        {
            bFixedScale = false;
        }
        else
        {
            iImageWidth = num2;
        }
    }
    if (!bFixedScale)
    {
        num = (float)(iImageWidth - MAGICS.URIWidth - MAGICS.LeftMarginWidth - MAGICS.RightMarginWidth) / (float)iMaxMS;
        if (num > 100f)
        {
            num = 100f;
        }
    }
    Bitmap bitmap;
    Graphics graphics;
    try
    {
        bitmap = new Bitmap(iImageWidth, iImageHeight);
        graphics = Graphics.FromImage(bitmap);
    }
    catch (Exception ex)
    {
        MessageBox.Show(string.Format("Failed to create {0}x{1} chart.\n{2}", iImageWidth, iImageHeight, ex.ToString()), "Failed to create chart");
        iImageWidth = (iImageHeight = 1);
        return null;
    }
    graphics.FillRectangle(Brushes.White, -1, -1, iImageWidth + 1, iImageHeight + 1);
    graphics.DrawLine(MAGICS.PenGrid, MAGICS.URIWidth + 2, MAGICS.TitleRowHeight + MAGICS.TimerRowHeight, iImageWidth, MAGICS.TitleRowHeight + MAGICS.TimerRowHeight);
    graphics.DrawLine(MAGICS.PenGrid, MAGICS.URIWidth + 2, iImageHeight - MAGICS.FooterRowHeight, iImageWidth, iImageHeight - MAGICS.FooterRowHeight);
    graphics.DrawLine(MAGICS.PenGrid, MAGICS.URIWidth + 2, MAGICS.TitleRowHeight + MAGICS.TimerRowHeight, MAGICS.URIWidth + 2, iImageHeight - MAGICS.FooterRowHeight);
    StringFormat stringFormat = new StringFormat(StringFormatFlags.FitBlackBox | StringFormatFlags.NoWrap);
    stringFormat.Alignment = StringAlignment.Center;
    stringFormat.LineAlignment = StringAlignment.Far;
    float num3 = (float)iImageWidth / num;
    int num4 = 1000;
    while ((float)num4 <= num3)
    {
        long num5 = (long)((float)num4 * num) + (long)MAGICS.URIWidth + (long)MAGICS.LeftMarginWidth;
        if (num3 < 30000f || num4 % 5000 == 0)
        {
            Rectangle r = new Rectangle((int)num5 - 20, MAGICS.TitleRowHeight, 40, MAGICS.TimerRowHeight);
            graphics.DrawString(((double)num4 * 0.001).ToString() + "s", this.fontURI, Brushes.Gray, r, stringFormat);
        }
        graphics.DrawLine(Pens.LightGray, (float)num5, (float)(MAGICS.TitleRowHeight + MAGICS.TimerRowHeight), (float)num5, (float)(iImageHeight - MAGICS.FooterRowHeight));
        num4 += 1000;
    }
    stringFormat.Dispose();
    StringFormat stringFormat2 = new StringFormat(StringFormatFlags.FitBlackBox | StringFormatFlags.NoWrap);
    stringFormat2.Alignment = StringAlignment.Far;
    stringFormat2.LineAlignment = StringAlignment.Center;
    Rectangle r2 = new Rectangle(2, 2 + MAGICS.TitleRowHeight + MAGICS.TimerRowHeight, MAGICS.URIWidth, MAGICS.RowHeight);
    int num6 = 2 + MAGICS.TitleRowHeight + MAGICS.TimerRowHeight;
    Pen pen = new Pen(Color.PowderBlue);
    pen.DashStyle = DashStyle.Dash;
    Pen pen2 = new Pen(Color.DarkKhaki);
    pen2.DashStyle = DashStyle.Dot;
    bool flag = false;
    foreach (string text in dictionary.Keys)
    {
        graphics.DrawString(text, this.fontURI, Brushes.Black, r2, stringFormat2);
        foreach (ChartEntry chartEntry2 in dictionary[text])
        {
            long num7 = (long)((float)chartEntry2.iStartMS * num) + (long)MAGICS.URIWidth + (long)MAGICS.LeftMarginWidth;
            long num8 = (chartEntry2.iTTFBMS > 0L) ? ((long)((float)chartEntry2.iTTFBMS * num) + (long)MAGICS.URIWidth + (long)MAGICS.LeftMarginWidth) : 0L;
            long num9 = (long)((float)chartEntry2.iFinishMS * num) + (long)MAGICS.URIWidth + (long)MAGICS.LeftMarginWidth;
            if (num9 < num7)
            {
                num9 = num7;
            }
            Pen penTransfer = MAGICS.PenTransfer;
            Brush brush = Timeline.ChooseTransferBrush(chartEntry2);
            graphics.DrawLine(flag ? pen2 : pen, new Point(MAGICS.URIWidth + MAGICS.LeftMarginWidth, num6 + 8), new Point((int)num7, num6 + 8));
            chartEntry2.oDisplayRect = new Rectangle((int)num7, r2.Top, (int)(1L + num9 - num7), r2.Height);
            graphics.FillRectangle(brush, (float)num7, (float)(num6 + 4), (float)(1L + num9 - num7), 9f);
            if (num8 > 0L)
            {
                graphics.DrawLine(Pens.Black, (float)num8, (float)(num6 + 1), (float)num8, (float)(num6 + 15));
            }
            if (chartEntry2.bWasClosed)
            {
                graphics.DrawLine(Pens.Red, new Point((int)num9 + 3, num6 + 6), new Point((int)num9 + 7, num6 + 10));
                graphics.DrawLine(Pens.Red, new Point((int)num9 + 3, num6 + 10), new Point((int)num9 + 7, num6 + 6));
            }
        }
        num6 += MAGICS.RowHeight;
        r2.Y += MAGICS.RowHeight;
        flag = !flag;
    }
    graphics.DrawString("Client PipeMap", this.fontTitle, Brushes.Blue, (float)(iImageWidth / 2 - 80), 2f);
    if (!bFixedScale && iMaxMS < 1000L)
    {
        string text2 = iMaxMS.ToString() + " ms";
        graphics.DrawString(text2, this.fontURI, Brushes.Gray, (float)(iImageWidth - MAGICS.RightMarginWidth) - graphics.MeasureString(text2, this.fontURI).Width, (float)MAGICS.TitleRowHeight);
    }
    graphics.Dispose();
    return bitmap;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值