Exemple #1
0
 protected override void CreateObjects()
 {
     base.CreateObjects();
     this.m_ChannelList = new PlotObjectCollection();
 }
        private void Draw(PaintArgs p, PlotObjectCollection channels, Rectangle r)
        {
            Rectangle r2 = new Rectangle(r.Left, r.Top, r.Width, this.m_DrawPixelsHeightTitle + 2 * this.m_DrawPixelsMarginOuter);
            Rectangle r3 = new Rectangle(r.Left, r2.Bottom, r.Width, r.Height - r2.Height);

            this.I_TitleFill.Draw(p, r2);
            this.I_DataFill.Draw(p, r3);
            string s     = "";
            int    num   = 0;
            int    x     = r3.Left + this.m_DrawPixelsMarginOuter;
            int    num2  = this.m_DrawPixelsHeightData + 2 * this.m_DrawPixelsMarginOuter;
            int    width = r3.Width - 2 * this.m_DrawPixelsMarginOuter;

            if (this.TitleVisible)
            {
                Rectangle r4 = new Rectangle(x, r2.Top + this.m_DrawPixelsMarginOuter, width, this.m_DrawPixelsHeightTitle);
                this.I_TitleLayout.Draw(p.Graphics, this.m_DrawTitleFont, p.Graphics.Brush(this.TitleForeColor), this.TitleText, r4);
            }
            foreach (PlotChannelBase channel in channels)
            {
                Rectangle r4 = new Rectangle(x, r3.Top + num * num2 + this.m_DrawPixelsMarginOuter, width, this.m_DrawPixelsHeightData);
                if (this.DataType == PlotLegendMultiColumnItemType.Marker)
                {
                    ((IPlotChannelBase)channel).DrawLegendMarker(p, r4);
                    num++;
                }
                else
                {
                    if (this.DataType == PlotLegendMultiColumnItemType.ChannelTitle)
                    {
                        s = channel.DisplayDescription;
                    }
                    else if (this.DataType == PlotLegendMultiColumnItemType.DataPointCount)
                    {
                        s = channel.Count.ToString();
                    }
                    else if (this.DataType == PlotLegendMultiColumnItemType.DataCursorX)
                    {
                        s = channel.GetXValueText(channel.DataCursorX);
                    }
                    else if (this.DataType == PlotLegendMultiColumnItemType.DataCursorY)
                    {
                        s = channel.GetYValueText(channel.DataCursorY);
                    }
                    else if (this.DataType == PlotLegendMultiColumnItemType.XFirst)
                    {
                        s = channel.GetXValueText(channel.XFirst);
                    }
                    else if (this.DataType == PlotLegendMultiColumnItemType.XLast)
                    {
                        s = channel.GetXValueText(channel.XLast);
                    }
                    else if (this.DataType == PlotLegendMultiColumnItemType.XMax)
                    {
                        s = channel.GetXValueText(channel.XMax);
                    }
                    else if (this.DataType == PlotLegendMultiColumnItemType.XMean)
                    {
                        s = channel.GetXValueText(channel.XMean);
                    }
                    else if (this.DataType == PlotLegendMultiColumnItemType.XMin)
                    {
                        s = channel.GetXValueText(channel.XMin);
                    }
                    else if (this.DataType == PlotLegendMultiColumnItemType.XStandardDeviation)
                    {
                        s = channel.GetXValueText(channel.XStandardDeviation);
                    }
                    else if (this.DataType == PlotLegendMultiColumnItemType.YFirst)
                    {
                        s = channel.GetYValueText(channel.YFirst);
                    }
                    else if (this.DataType == PlotLegendMultiColumnItemType.YLast)
                    {
                        s = channel.GetYValueText(channel.YLast);
                    }
                    else if (this.DataType == PlotLegendMultiColumnItemType.YMax)
                    {
                        s = channel.GetYValueText(channel.YMax);
                    }
                    else if (this.DataType == PlotLegendMultiColumnItemType.YMean)
                    {
                        s = channel.GetYValueText(channel.YMean);
                    }
                    else if (this.DataType == PlotLegendMultiColumnItemType.YMin)
                    {
                        s = channel.GetYValueText(channel.YMin);
                    }
                    else if (this.DataType == PlotLegendMultiColumnItemType.YStandardDeviation)
                    {
                        s = channel.GetYValueText(channel.YStandardDeviation);
                    }
                    this.I_DataLayout.Draw(p.Graphics, this.m_DrawDataFont, p.Graphics.Brush(this.DataForeColor), s, r4);
                    if (this.DataType == PlotLegendMultiColumnItemType.ChannelTitle)
                    {
                        channel.LegendRectangle = r4;
                        if (channel.Focused && !channel.LegendRectangle.IsEmpty)
                        {
                            p.Graphics.DrawFocusRectangle(r4, base.BackColor);
                        }
                    }
                    num++;
                }
            }
        }
 void IPlotLegendMultiColumnItem.Draw(PaintArgs p, PlotObjectCollection channels, Rectangle r)
 {
     this.Draw(p, channels, r);
 }
        private void Calculate(PaintArgs p, PlotObjectCollection channels)
        {
            this.m_DrawPixelsTextWidth   = 0;
            this.m_DrawPixelsHeightTitle = 0;
            this.m_DrawPixelsHeightData  = 0;
            if (this.TitleVisible)
            {
                this.m_DrawPixelsHeightTitle = p.Graphics.MeasureString(this.TitleText, this.m_DrawDataFont).Height;
            }
            if (this.m_WidthStyle == SizeStyle.FixedCharacters)
            {
                this.m_DrawPixelsTextWidth = (int)Math.Ceiling((double)p.Graphics.MeasureString(this.m_DrawTitleFont).Width *this.Width);
            }
            else if (this.m_WidthStyle == SizeStyle.FixedPixels)
            {
                this.m_DrawPixelsTextWidth = (int)Math.Ceiling(this.Width);
            }
            else if (this.m_WidthStyle == SizeStyle.Auto)
            {
                this.m_DrawPixelsTextWidth = (int)Math.Ceiling((double)p.Graphics.MeasureString(this.m_DrawTitleFont).Width *this.Width);
                if (this.TitleVisible)
                {
                    this.m_DrawPixelsTextWidth = Math.Max(this.m_DrawPixelsTextWidth, this.I_TitleLayout.GetRequiredSize(this.TitleText, this.m_DrawTitleFont, p.Graphics).Width);
                }
            }
            string s = "";

            foreach (PlotChannelBase channel in channels)
            {
                if (this.DataType != 0)
                {
                    if (this.DataType == PlotLegendMultiColumnItemType.ChannelTitle)
                    {
                        s = channel.DisplayDescription;
                    }
                    else if (this.DataType == PlotLegendMultiColumnItemType.DataPointCount)
                    {
                        s = channel.Count.ToString();
                    }
                    else if (this.DataType == PlotLegendMultiColumnItemType.DataCursorX)
                    {
                        s = channel.GetXValueText(channel.DataCursorX);
                    }
                    else if (this.DataType == PlotLegendMultiColumnItemType.DataCursorY)
                    {
                        s = channel.GetYValueText(channel.DataCursorY);
                    }
                    else if (this.DataType == PlotLegendMultiColumnItemType.XFirst)
                    {
                        s = channel.GetXValueText(channel.XFirst);
                    }
                    else if (this.DataType == PlotLegendMultiColumnItemType.XLast)
                    {
                        s = channel.GetXValueText(channel.XLast);
                    }
                    else if (this.DataType == PlotLegendMultiColumnItemType.XMax)
                    {
                        s = channel.GetXValueText(channel.XMax);
                    }
                    else if (this.DataType == PlotLegendMultiColumnItemType.XMean)
                    {
                        s = channel.GetXValueText(channel.XMean);
                    }
                    else if (this.DataType == PlotLegendMultiColumnItemType.XMin)
                    {
                        s = channel.GetXValueText(channel.XMin);
                    }
                    else if (this.DataType == PlotLegendMultiColumnItemType.XStandardDeviation)
                    {
                        s = channel.GetXValueText(channel.XStandardDeviation);
                    }
                    else if (this.DataType == PlotLegendMultiColumnItemType.YFirst)
                    {
                        s = channel.GetYValueText(channel.YFirst);
                    }
                    else if (this.DataType == PlotLegendMultiColumnItemType.YLast)
                    {
                        s = channel.GetYValueText(channel.YLast);
                    }
                    else if (this.DataType == PlotLegendMultiColumnItemType.YMax)
                    {
                        s = channel.GetYValueText(channel.YMax);
                    }
                    else if (this.DataType == PlotLegendMultiColumnItemType.YMean)
                    {
                        s = channel.GetYValueText(channel.YMean);
                    }
                    else if (this.DataType == PlotLegendMultiColumnItemType.YMin)
                    {
                        s = channel.GetYValueText(channel.YMin);
                    }
                    else if (this.DataType == PlotLegendMultiColumnItemType.YStandardDeviation)
                    {
                        s = channel.GetYValueText(channel.YStandardDeviation);
                    }
                    Size requiredSize = this.I_DataLayout.GetRequiredSize(s, this.m_DrawDataFont, p.Graphics);
                    if (this.m_WidthStyle == SizeStyle.Auto)
                    {
                        this.m_DrawPixelsTextWidth = Math.Max(this.m_DrawPixelsTextWidth, requiredSize.Width);
                    }
                    this.m_DrawPixelsHeightData = requiredSize.Height;
                    continue;
                }
                this.m_DrawPixelsTextWidth  = Math.Max(this.m_DrawPixelsTextWidth, this.m_DrawPixelsMarkerMinWidth);
                this.m_DrawPixelsHeightData = this.m_DrawPixelsMarkerMinWidth;
                break;
            }
        }
 void IPlotLegendMultiColumnItem.Calculate(PaintArgs p, PlotObjectCollection channels)
 {
     this.Calculate(p, channels);
 }