Example #1
0
        protected override void Draw(PaintArgs p)
        {
            base.I_Fill.Draw(p, base.BoundsAlignment);
            PlotChannelImage channel = this.Channel;

            if (channel != null)
            {
                Rectangle r = base.BoundsAlignment;
                r.Inflate(-this.m_MarginOuterPixels, -this.m_MarginOuterPixels);
                bool dockVertical;
                if (!(dockVertical = base.DockVertical))
                {
                    r.Inflate(0, -this.m_EndsMargin);
                }
                else
                {
                    r.Inflate(-this.m_EndsMargin, 0);
                }
                int num  = 0;
                int num2 = 0;
                dockVertical = base.DockVertical;
                int    left         = r.Left;
                int    right        = r.Right;
                int    top          = r.Top;
                int    bottom       = r.Bottom;
                int    width        = r.Width;
                int    height       = r.Height;
                bool   stepsEnabled = channel.IntensityGradient.StepsEnabled;
                int    num3         = dockVertical ? width : height;
                Bitmap image        = (!stepsEnabled) ? this.GetGradientBitmap(num3, dockVertical) : this.GetStepBitmap(num3, dockVertical);
                if (base.DockRight)
                {
                    p.Graphics.DrawImage(image, left, top);
                }
                else if (base.DockLeft)
                {
                    p.Graphics.DrawImage(image, right - this.GradientWidth, top);
                }
                else if (base.DockTop)
                {
                    p.Graphics.DrawImage(image, left, bottom - this.GradientWidth);
                }
                else if (base.DockBottom)
                {
                    p.Graphics.DrawImage(image, left, top);
                }
                if (this.TicksVisible)
                {
                    if (base.DockRight)
                    {
                        num = left + this.GradientWidth + this.TicksMargin;
                    }
                    else if (base.DockLeft)
                    {
                        num = right - this.GradientWidth - this.TicksMargin;
                    }
                    else if (base.DockTop)
                    {
                        num = bottom - this.GradientWidth - this.TicksMargin;
                    }
                    else if (base.DockBottom)
                    {
                        num = top + this.GradientWidth + this.TicksMargin;
                    }
                    if (base.DockRight)
                    {
                        num2 = num + this.TicksLength + this.m_TicksLabelMarginPixels;
                    }
                    else if (base.DockLeft)
                    {
                        num2 = num - this.TicksLength - this.m_TicksLabelMarginPixels;
                    }
                    else if (base.DockTop)
                    {
                        num2 = num - this.TicksLength - this.m_TicksLabelMarginPixels;
                    }
                    else if (base.DockBottom)
                    {
                        num2 = num + this.TicksLength + this.m_TicksLabelMarginPixels;
                    }
                    Size             maxSizeTickLabels  = this.m_MaxSizeTickLabels;
                    DrawStringFormat genericTypographic = DrawStringFormat.GenericTypographic;
                    genericTypographic.LineAlignment = StringAlignment.Center;
                    genericTypographic.Alignment     = StringAlignment.Far;
                    Pen pen = p.Graphics.Pen(base.ForeColor);
                    for (int i = 0; i < this.m_Positions.Length; i++)
                    {
                        string s    = (string)this.m_Ticks[i];
                        int    num4 = dockVertical ? (left + (int)(this.m_Positions[i] * (float)num3)) : (top + (int)(this.m_Positions[i] * (float)num3));
                        if (base.DockRight)
                        {
                            p.Graphics.DrawLine(pen, num, num4, num + this.TicksLength, num4);
                        }
                        else if (base.DockLeft)
                        {
                            p.Graphics.DrawLine(pen, num, num4, num - this.TicksLength, num4);
                        }
                        else if (base.DockTop)
                        {
                            p.Graphics.DrawLine(pen, num4, num, num4, num - this.TicksLength);
                        }
                        else if (base.DockBottom)
                        {
                            p.Graphics.DrawLine(pen, num4, num, num4, num + this.TicksLength);
                        }
                        if (base.DockRight)
                        {
                            r = new Rectangle(num2, num4 - maxSizeTickLabels.Height / 2, maxSizeTickLabels.Width, maxSizeTickLabels.Height);
                        }
                        else if (base.DockLeft)
                        {
                            r = new Rectangle(num2 - maxSizeTickLabels.Width, num4 - maxSizeTickLabels.Height / 2, maxSizeTickLabels.Width, maxSizeTickLabels.Height);
                        }
                        else if (base.DockTop)
                        {
                            r = new Rectangle(num4 - maxSizeTickLabels.Height / 2, num2 - maxSizeTickLabels.Width, maxSizeTickLabels.Height, maxSizeTickLabels.Width);
                        }
                        else if (base.DockBottom)
                        {
                            r = new Rectangle(num4 - maxSizeTickLabels.Height / 2, num2, maxSizeTickLabels.Height, maxSizeTickLabels.Width);
                        }
                        if (base.DockRight)
                        {
                            p.Graphics.DrawRotatedText(s, base.Font, base.ForeColor, r, TextRotation.X000, genericTypographic);
                        }
                        else if (base.DockLeft)
                        {
                            p.Graphics.DrawRotatedText(s, base.Font, base.ForeColor, r, TextRotation.X000, genericTypographic);
                        }
                        else if (base.DockTop)
                        {
                            p.Graphics.DrawRotatedText(s, base.Font, base.ForeColor, r, TextRotation.X090, genericTypographic);
                        }
                        else if (base.DockBottom)
                        {
                            p.Graphics.DrawRotatedText(s, base.Font, base.ForeColor, r, TextRotation.X090, genericTypographic);
                        }
                        if (this.TicksShowFirstAndLastOnly && i == 0)
                        {
                            i = this.m_Positions.Length - 2;
                        }
                    }
                }
            }
        }
Example #2
0
        public void DrawRotatedText(string s, Font font, Color foreColor, Rectangle r, TextRotation rotation, DrawStringFormat format)
        {
            if (font != null)
            {
                PointF pointF;
                switch (rotation)
                {
                case TextRotation.X000:
                    this.DrawString(s, font, this.Brush(foreColor), r, format);
                    break;

                case TextRotation.X090:
                {
                    r      = new Rectangle(r.Left, r.Top, r.Height, r.Width);
                    pointF = new PointF((float)(r.Left + r.Height / 2), (float)((r.Top + r.Bottom) / 2));
                    GraphicsState gstate = this.Save();
                    this.TranslateTransform(pointF.X, pointF.Y);
                    this.RotateTransform(90f);
                    this.TranslateTransform(0f - pointF.X, 0f - pointF.Y);
                    this.DrawString(s, font, this.Brush(foreColor), r, format);
                    this.Restore(gstate);
                    break;
                }

                case TextRotation.X180:
                {
                    pointF = new PointF((float)((r.Left + r.Right) / 2), (float)((r.Top + r.Bottom) / 2));
                    GraphicsState gstate = this.Save();
                    this.TranslateTransform(pointF.X, pointF.Y);
                    this.RotateTransform(180f);
                    this.TranslateTransform(0f - pointF.X, 0f - pointF.Y);
                    this.DrawString(s, font, this.Brush(foreColor), r, format);
                    this.Restore(gstate);
                    break;
                }

                case TextRotation.X270:
                {
                    r      = new Rectangle(r.Left, r.Top, r.Height, r.Width);
                    pointF = new PointF((float)((r.Left + r.Right) / 2), (float)(r.Top + r.Width / 2));
                    GraphicsState gstate = this.Save();
                    this.TranslateTransform(pointF.X, pointF.Y);
                    this.RotateTransform(270f);
                    this.TranslateTransform(0f - pointF.X, 0f - pointF.Y);
                    this.DrawString(s, font, this.Brush(foreColor), r, format);
                    this.Restore(gstate);
                    break;
                }
                }
            }
        }
Example #3
0
        protected override void DrawCustom(PaintArgs p, PlotXAxis xAxis, PlotYAxis yAxis)
        {
            float num7;

            if (!this.FixedSize)
            {
                float num;
                float num2;
                if (!base.XYSwapped)
                {
                    num  = (float)base.WidthPixels;
                    num2 = (float)base.HeightPixels;
                }
                else
                {
                    num  = (float)base.HeightPixels;
                    num2 = (float)base.WidthPixels;
                }
                float num3 = (float)p.Graphics.MeasureString(this.Text, this.Font).Width;
                float num4 = (float)this.Font.Height;
                float num5 = num / num3;
                float num6 = num2 / num4;
                num7 = ((!(num6 < num5)) ? (num / num3 * this.Font.Size) : (num2 / num4 * this.Font.Size));
            }
            else
            {
                num7 = this.Font.Size;
            }
            if (!(num7 <= 0f))
            {
                Font font;
                if (this.Font.Size != num7)
                {
                    if (this.m_DrawFont == null || this.m_DrawFont.Size != num7)
                    {
                        this.m_DrawFont = new Font(this.Font.Name, num7, this.Font.Style);
                    }
                    font = this.m_DrawFont;
                }
                else
                {
                    font = this.Font;
                }
                Point     point      = base.XYSwapped ? new Point(base.YPixels, base.XPixels) : new Point(base.XPixels, base.YPixels);
                Size      size       = p.Graphics.MeasureString(this.Text, font, true);
                Rectangle rectangle  = new Rectangle(point.X - size.Width / 2, point.Y - size.Height / 2, size.Width, size.Height);
                int       num8       = (int)Math.Round((double)p.Graphics.MeasureString("0", font, true).Width *this.OuterMargin);
                Rectangle rectangle2 = rectangle;
                rectangle2.Inflate(num8, num8);
                if (!base.BoundsClip.IntersectsWith(rectangle2))
                {
                    base.ClickRegion = null;
                }
                else
                {
                    base.I_Fill.Draw(p, rectangle2);
                    DrawStringFormat genericTypographic = DrawStringFormat.GenericTypographic;
                    genericTypographic.Alignment     = StringAlignment.Center;
                    genericTypographic.LineAlignment = StringAlignment.Center;
                    p.Graphics.DrawString(this.Text, font, p.Graphics.Brush(this.ForeColor), rectangle, genericTypographic);
                    base.ClickRegion = this.ToClickRegion(rectangle2);
                    base.UpdateGrabHandles(rectangle2);
                }
            }
        }
Example #4
0
 public void DrawString(string s, Font font, Brush brush, float x, float y, DrawStringFormat format)
 {
     this.m_GraphicsMS.DrawString(s, font, brush, x, y, format.StringFormat);
 }
Example #5
0
 public void DrawString(string s, Font font, Brush brush, Rectangle r, DrawStringFormat format)
 {
     this.m_GraphicsMS.DrawString(s, font, brush, r, format.StringFormat);
 }
Example #6
0
 public void DrawString(string s, Font font, Brush brush, Point point, DrawStringFormat format)
 {
     this.m_GraphicsMS.DrawString(s, font, brush, point, format.StringFormat);
 }
Example #7
0
 protected abstract void Draw(PaintArgs p, DrawStringFormat format, int majorLength);
Example #8
0
 void IScaleTickBase.Draw(PaintArgs p, DrawStringFormat format, int majorLength)
 {
     this.Draw(p, format, majorLength);
 }