Ejemplo n.º 1
0
        internal float GetCustomLabelOffset(GaugeGraphics g, CustomLabel customLabel)
        {
            float num  = (customLabel.FontUnit != 0) ? (g.GetRelativeSize(new SizeF(customLabel.Font.Size * 1.3f, 0f)).Width *(100f / Radius)) : customLabel.Font.Size;
            float num2 = 0f;

            num2 = ((customLabel.Placement == Placement.Inside) ? (0f - Width / 2f - customLabel.DistanceFromScale) : ((customLabel.Placement != Placement.Cross) ? (customLabel.DistanceFromScale + num) : (0f - customLabel.DistanceFromScale + num / 2f)));
            float val = (customLabel.TickMarkStyle.Placement == Placement.Inside) ? (0f - Width / 2f - customLabel.TickMarkStyle.DistanceFromScale) : ((customLabel.TickMarkStyle.Placement != Placement.Cross) ? (customLabel.TickMarkStyle.DistanceFromScale + customLabel.TickMarkStyle.Length) : (0f - customLabel.TickMarkStyle.DistanceFromScale + customLabel.TickMarkStyle.Length / 2f));

            return(Math.Max(num2, val));
        }
Ejemplo n.º 2
0
        public float GetCustomLabelOffset(GaugeGraphics g, CustomLabel customLabel)
        {
            float num  = (float)((customLabel.FontUnit != 0) ? (g.GetRelativeSize(new SizeF((float)(customLabel.Font.Size * 1.2999999523162842), 0f)).Width *(100.0 / this.Radius)) : customLabel.Font.Size);
            float num2 = 0f;

            num2 = (float)((customLabel.Placement != 0) ? ((customLabel.Placement != Placement.Cross) ? (customLabel.DistanceFromScale + num) : (0.0 - customLabel.DistanceFromScale + num / 2.0)) : (0.0 - this.Width / 2.0 - customLabel.DistanceFromScale));
            float val = (float)((customLabel.TickMarkStyle.Placement != 0) ? ((customLabel.TickMarkStyle.Placement != Placement.Cross) ? (customLabel.TickMarkStyle.DistanceFromScale + customLabel.TickMarkStyle.Length) : (0.0 - customLabel.TickMarkStyle.DistanceFromScale + customLabel.TickMarkStyle.Length / 2.0)) : (0.0 - this.Width / 2.0 - customLabel.TickMarkStyle.DistanceFromScale));

            return(Math.Max(num2, val));
        }
Ejemplo n.º 3
0
        internal float GetLabelsOffset(GaugeGraphics g)
        {
            float num  = 0f;
            float num2 = (LabelStyle.FontUnit != 0) ? (g.GetRelativeSize(new SizeF(LabelStyle.Font.Size * 1.3f, 0f)).Width *(100f / Radius)) : LabelStyle.Font.Size;

            if (LabelStyle.Placement == Placement.Inside)
            {
                return(0f - Width / 2f - LabelStyle.DistanceFromScale);
            }
            if (LabelStyle.Placement == Placement.Cross)
            {
                return(0f - LabelStyle.DistanceFromScale + num2 / 2f);
            }
            return(LabelStyle.DistanceFromScale + num2);
        }
Ejemplo n.º 4
0
        public float GetLabelsOffset(GaugeGraphics g)
        {
            float num  = 0f;
            float num2 = (float)((this.LabelStyle.FontUnit != 0) ? (g.GetRelativeSize(new SizeF((float)(this.LabelStyle.Font.Size * 1.2999999523162842), 0f)).Width *(100.0 / this.Radius)) : this.LabelStyle.Font.Size);

            if (this.LabelStyle.Placement == Placement.Inside)
            {
                return((float)(0.0 - this.Width / 2.0 - this.LabelStyle.DistanceFromScale));
            }
            if (this.LabelStyle.Placement == Placement.Cross)
            {
                return((float)(0.0 - this.LabelStyle.DistanceFromScale + num2 / 2.0));
            }
            return(this.LabelStyle.DistanceFromScale + num2);
        }
Ejemplo n.º 5
0
        private void DrawLabel(Placement placement, string labelStr, double position, float labelPos, float rotateLabelAngle, Font font, Color color, bool rotateLabels, bool allowUpsideDown, FontUnit fontUnit)
        {
            float num = GetPositionFromValueNormalized(position);

            if (rotateLabels)
            {
                rotateLabelAngle += num + 180f;
                rotateLabelAngle %= 360f;
                if (!allowUpsideDown && rotateLabelAngle > 90f && rotateLabelAngle < 270f)
                {
                    rotateLabelAngle += 180f;
                    rotateLabelAngle %= 360f;
                }
            }
            MarkerPosition markerPosition = new MarkerPosition((float)Math.Round(num), position, placement);

            if (MarkerPosition.IsExistsInArray(labels, markerPosition))
            {
                return;
            }
            if (labelStr.Length > 0)
            {
                labels.Add(markerPosition);
            }
            GaugeGraphics graph        = Common.Graph;
            StringFormat  stringFormat = new StringFormat();

            stringFormat.Alignment     = StringAlignment.Center;
            stringFormat.LineAlignment = StringAlignment.Center;
            using (Brush brush2 = new SolidBrush(color))
            {
                Font resizedFont = GetResizedFont(font, fontUnit);
                try
                {
                    SizeF relativeSize = graph.GetRelativeSize(graph.MeasureString(labelStr, resizedFont));
                    relativeSize.Height -= relativeSize.Height / 8f;
                    float contactPointOffset = Utils.GetContactPointOffset(relativeSize, num - rotateLabelAngle);
                    float offset             = labelPos;
                    switch (placement)
                    {
                    case Placement.Inside:
                        offset = labelPos - Math.Max(0f, contactPointOffset);
                        break;

                    case Placement.Outside:
                        offset = labelPos + Math.Max(0f, contactPointOffset);
                        break;
                    }
                    PointF absolutePoint = graph.GetAbsolutePoint(GetPoint(num, offset));
                    relativeSize = graph.GetAbsoluteSize(relativeSize);
                    RectangleF layoutRectangle = new RectangleF(absolutePoint, new SizeF(0f, 0f));
                    layoutRectangle.Inflate(relativeSize.Width / 2f, relativeSize.Height / 2f);
                    Matrix transform = graph.Transform;
                    Matrix matrix    = graph.Transform.Clone();
                    try
                    {
                        TextRenderingHint textRenderingHint = graph.TextRenderingHint;
                        try
                        {
                            if (textRenderingHint == TextRenderingHint.ClearTypeGridFit)
                            {
                                graph.TextRenderingHint = TextRenderingHint.AntiAlias;
                            }
                            if (base.ShadowOffset != 0f)
                            {
                                using (Brush brush = graph.GetShadowBrush())
                                {
                                    using (Matrix matrix2 = matrix.Clone())
                                    {
                                        matrix2.Translate(base.ShadowOffset, base.ShadowOffset);
                                        matrix2.RotateAt(rotateLabelAngle, absolutePoint);
                                        graph.Transform = matrix2;
                                        graph.DrawString(labelStr, resizedFont, brush, layoutRectangle, stringFormat);
                                    }
                                }
                            }
                            matrix.RotateAt(rotateLabelAngle, absolutePoint);
                            graph.Transform = matrix;
                            graph.DrawString(labelStr, resizedFont, brush2, layoutRectangle, stringFormat);
                        }
                        finally
                        {
                            graph.TextRenderingHint = textRenderingHint;
                        }
                    }
                    finally
                    {
                        matrix.Dispose();
                        graph.Transform = transform;
                    }
                }
                finally
                {
                    if (resizedFont != font)
                    {
                        resizedFont.Dispose();
                    }
                }
            }
        }