void ISelectable.DrawSelection(GaugeGraphics g, bool designTimeSelection)
        {
            if (GetGauge() == null || GetScale() == null)
            {
                return;
            }
            Stack stack = new Stack();

            for (NamedElement namedElement = GetGauge().ParentObject; namedElement != null; namedElement = (NamedElement)((IRenderable)namedElement).GetParentRenderable())
            {
                stack.Push(namedElement);
            }
            foreach (IRenderable item in stack)
            {
                g.CreateDrawRegion(item.GetBoundRect(g));
            }
            g.CreateDrawRegion(((IRenderable)GetGauge()).GetBoundRect(g));
            using (GraphicsPath graphicsPath = GetPointerPath(g))
            {
                if (graphicsPath != null)
                {
                    RectangleF bounds = graphicsPath.GetBounds();
                    g.DrawSelection(bounds, designTimeSelection, Common.GaugeCore.SelectionBorderColor, Common.GaugeCore.SelectionMarkerColor);
                }
            }
            g.RestoreDrawRegion();
            foreach (IRenderable item2 in stack)
            {
                _ = item2;
                g.RestoreDrawRegion();
            }
        }
Esempio n. 2
0
 internal GraphicsPath GetShadowPath(GaugeGraphics g)
 {
     if (base.Visible && base.ShadowOffset != 0f && Width > 0f)
     {
         SetDrawRegion(g);
         GraphicsPath graphicsPath = new GraphicsPath();
         using (GraphicsPath addingPath = GetBarPath(Width / 2f, Width / 2f, 0f))
         {
             graphicsPath.AddPath(addingPath, connect: false);
         }
         using (Matrix matrix = new Matrix())
         {
             matrix.Translate(base.ShadowOffset, base.ShadowOffset);
             graphicsPath.Transform(matrix);
         }
         PointF pointF = new PointF(g.Graphics.Transform.OffsetX, g.Graphics.Transform.OffsetY);
         g.RestoreDrawRegion();
         PointF pointF2 = new PointF(g.Graphics.Transform.OffsetX, g.Graphics.Transform.OffsetY);
         using (Matrix matrix2 = new Matrix())
         {
             matrix2.Translate(pointF.X - pointF2.X, pointF.Y - pointF2.Y);
             graphicsPath.Transform(matrix2);
             return(graphicsPath);
         }
     }
     return(null);
 }
Esempio n. 3
0
 public GraphicsPath GetShadowPath(GaugeGraphics g)
 {
     if (base.Visible && base.ShadowOffset != 0.0 && this.Width > 0.0)
     {
         this.SetDrawRegion(g);
         GraphicsPath graphicsPath = new GraphicsPath();
         using (GraphicsPath addingPath = this.GetBarPath((float)(this.Width / 2.0), (float)(this.Width / 2.0), 0f))
         {
             graphicsPath.AddPath(addingPath, false);
         }
         using (Matrix matrix = new Matrix())
         {
             matrix.Translate(base.ShadowOffset, base.ShadowOffset);
             graphicsPath.Transform(matrix);
         }
         PointF pointF = new PointF(g.Graphics.Transform.OffsetX, g.Graphics.Transform.OffsetY);
         g.RestoreDrawRegion();
         PointF pointF2 = new PointF(g.Graphics.Transform.OffsetX, g.Graphics.Transform.OffsetY);
         using (Matrix matrix2 = new Matrix())
         {
             matrix2.Translate(pointF.X - pointF2.X, pointF.Y - pointF2.Y);
             graphicsPath.Transform(matrix2);
             return(graphicsPath);
         }
     }
     return(null);
 }
        public GraphicsPath GetPath(GaugeGraphics g, bool getShadowPath)
        {
            if (getShadowPath && (!base.Visible || base.ShadowOffset == 0.0))
            {
                return(null);
            }
            this.GetScale().SetDrawRegion(g);
            CircularScale scale              = this.GetScale();
            RectangleF    rect               = this.CalculateRangeRectangle();
            double        valueLimit         = scale.GetValueLimit(this.StartValue);
            double        valueLimit2        = scale.GetValueLimit(this.EndValue);
            float         positionFromValue  = scale.GetPositionFromValue(valueLimit);
            float         positionFromValue2 = scale.GetPositionFromValue(valueLimit2);
            float         num = positionFromValue2 - positionFromValue;

            if (Math.Round((double)num, 4) == 0.0)
            {
                g.RestoreDrawRegion();
                return(null);
            }
            GraphicsPath circularRangePath = g.GetCircularRangePath(rect, (float)(positionFromValue + 90.0), positionFromValue2 - positionFromValue, this.StartWidth, this.EndWidth, this.Placement);

            if (circularRangePath != null && getShadowPath)
            {
                using (Matrix matrix = new Matrix())
                {
                    matrix.Translate(base.ShadowOffset, base.ShadowOffset);
                    circularRangePath.Transform(matrix);
                }
            }
            PointF pointF = new PointF(g.Graphics.Transform.OffsetX, g.Graphics.Transform.OffsetY);

            g.RestoreDrawRegion();
            PointF pointF2 = new PointF(g.Graphics.Transform.OffsetX, g.Graphics.Transform.OffsetY);

            if (circularRangePath != null)
            {
                using (Matrix matrix2 = new Matrix())
                {
                    matrix2.Translate(pointF.X - pointF2.X, pointF.Y - pointF2.Y);
                    circularRangePath.Transform(matrix2);
                    return(circularRangePath);
                }
            }
            return(circularRangePath);
        }
        void ISelectable.DrawSelection(GaugeGraphics g, bool designTimeSelection)
        {
            Stack stack = new Stack();

            for (NamedElement namedElement = this.ParentObject; namedElement != null; namedElement = (NamedElement)((IRenderable)namedElement).GetParentRenderable())
            {
                stack.Push(namedElement);
            }
            foreach (IRenderable item in stack)
            {
                g.CreateDrawRegion(item.GetBoundRect(g));
            }
            g.CreateDrawRegion(((IRenderable)this).GetBoundRect(g));
            g.DrawSelection(g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f)), designTimeSelection, this.Common.GaugeCore.SelectionBorderColor, this.Common.GaugeCore.SelectionMarkerColor);
            g.RestoreDrawRegion();
            foreach (IRenderable item2 in stack)
            {
                IRenderable renderable = item2;
                g.RestoreDrawRegion();
            }
        }
Esempio n. 6
0
        internal GraphicsPath GetShadowPath(GaugeGraphics g)
        {
            if (base.ShadowOffset == 0f || GetScale() == null)
            {
                return(null);
            }
            GetScale().SetDrawRegion(g);
            if (Image != "")
            {
                DrawImage(g, primary: true, drawShadow: true);
            }
            if (CapImage != "")
            {
                DrawImage(g, primary: false, drawShadow: true);
            }
            GraphicsPath pointerPath = GetPointerPath(g);

            if (pointerPath == null || pointerPath.PointCount == 0)
            {
                g.RestoreDrawRegion();
                return(null);
            }
            using (Matrix matrix = new Matrix())
            {
                matrix.Translate(base.ShadowOffset, base.ShadowOffset);
                pointerPath.Transform(matrix);
            }
            PointF pointF = new PointF(g.Graphics.Transform.OffsetX, g.Graphics.Transform.OffsetY);

            g.RestoreDrawRegion();
            PointF pointF2 = new PointF(g.Graphics.Transform.OffsetX, g.Graphics.Transform.OffsetY);

            using (Matrix matrix2 = new Matrix())
            {
                matrix2.Translate(pointF.X - pointF2.X, pointF.Y - pointF2.Y);
                pointerPath.Transform(matrix2);
                return(pointerPath);
            }
        }
Esempio n. 7
0
        void ISelectable.DrawSelection(GaugeGraphics g, bool designTimeSelection)
        {
            Stack stack = new Stack();

            for (NamedElement namedElement = base.ParentObject; namedElement != null; namedElement = (NamedElement)((IRenderable)namedElement).GetParentRenderable())
            {
                stack.Push(namedElement);
            }
            foreach (IRenderable item in stack)
            {
                g.CreateDrawRegion(item.GetBoundRect(g));
            }
            g.CreateDrawRegion(((IRenderable)this).GetBoundRect(g));
            RectangleF frameRectangle = base.Frame.GetFrameRectangle(g);

            g.DrawSelection(frameRectangle, (float)(-3.0 / g.Graphics.PageScale), designTimeSelection, this.Common.GaugeCore.SelectionBorderColor, this.Common.GaugeCore.SelectionMarkerColor);
            g.RestoreDrawRegion();
            foreach (IRenderable item2 in stack)
            {
                IRenderable renderable = item2;
                g.RestoreDrawRegion();
            }
        }
Esempio n. 8
0
 public GraphicsPath GetShadowPath(GaugeGraphics g)
 {
     if (base.ShadowOffset != 0.0 && this.GetScale() != null)
     {
         this.GetScale().SetDrawRegion(g);
         if (this.Image != "")
         {
             this.DrawImage(g, true, true);
         }
         if (this.CapImage != "")
         {
             this.DrawImage(g, false, true);
         }
         GraphicsPath pointerPath = this.GetPointerPath(g);
         if (pointerPath != null && pointerPath.PointCount != 0)
         {
             using (Matrix matrix = new Matrix())
             {
                 matrix.Translate(base.ShadowOffset, base.ShadowOffset);
                 pointerPath.Transform(matrix);
             }
             PointF pointF = new PointF(g.Graphics.Transform.OffsetX, g.Graphics.Transform.OffsetY);
             g.RestoreDrawRegion();
             PointF pointF2 = new PointF(g.Graphics.Transform.OffsetX, g.Graphics.Transform.OffsetY);
             using (Matrix matrix2 = new Matrix())
             {
                 matrix2.Translate(pointF.X - pointF2.X, pointF.Y - pointF2.Y);
                 pointerPath.Transform(matrix2);
                 return(pointerPath);
             }
         }
         g.RestoreDrawRegion();
         return(null);
     }
     return(null);
 }
Esempio n. 9
0
        internal void RenderStaticElements(GaugeGraphics g)
        {
            if (!base.Visible)
            {
                return;
            }
            Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceStartRendering(Name));
            g.StartHotRegion(this);
            GraphicsState gstate = g.Save();

            SetDrawRegion(g);
            try
            {
                staticRendering = true;
                if (!base.TickMarksOnTop)
                {
                    markers.Clear();
                }
                labels.Clear();
                RenderBar(g);
                RenderCustomLabels(g);
                if (!base.TickMarksOnTop)
                {
                    RenderGrid(g);
                }
                RenderLabels(g);
                RenderPins(g);
                SetScaleHitTestPath(g);
                if (!base.TickMarksOnTop)
                {
                    markers.Sort();
                }
            }
            finally
            {
                g.RestoreDrawRegion();
                g.Restore(gstate);
                g.EndHotRegion();
            }
            Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceRenderingComplete(Name));
        }
Esempio n. 10
0
 internal void RenderDynamicElements(GaugeGraphics g)
 {
     if (base.Visible && base.TickMarksOnTop)
     {
         GraphicsState gstate = g.Save();
         SetDrawRegion(g);
         try
         {
             staticRendering = false;
             markers.Clear();
             RenderCustomLabels(g);
             RenderGrid(g);
             RenderPins(g);
             markers.Sort();
         }
         finally
         {
             g.RestoreDrawRegion();
             g.Restore(gstate);
         }
     }
 }
 void ISelectable.DrawSelection(GaugeGraphics g, bool designTimeSelection)
 {
     if (this.GetGauge() != null)
     {
         Stack stack = new Stack();
         for (NamedElement namedElement = this.GetGauge().ParentObject; namedElement != null; namedElement = (NamedElement)((IRenderable)namedElement).GetParentRenderable())
         {
             stack.Push(namedElement);
         }
         foreach (IRenderable item in stack)
         {
             g.CreateDrawRegion(item.GetBoundRect(g));
         }
         g.CreateDrawRegion(((IRenderable)this.GetGauge()).GetBoundRect(g));
         Gap gap = new Gap(this.Position);
         gap.SetOffset(Placement.Cross, this.Width);
         gap.SetBase();
         if (this.MajorTickMark.Visible)
         {
             gap.SetOffsetBase(this.MajorTickMark.Placement, this.MajorTickMark.Length);
             if (this.MajorTickMark.Placement == Placement.Outside)
             {
                 gap.Outside = Math.Max(gap.Outside, (float)(this.MajorTickMark.DistanceFromScale + this.MajorTickMark.Length + this.Width / 2.0));
                 gap.Inside  = Math.Max(gap.Inside, (float)(0.0 - this.MajorTickMark.DistanceFromScale));
             }
             else if (this.MajorTickMark.Placement == Placement.Cross)
             {
                 gap.Outside = Math.Max(gap.Outside, (float)(0.0 - this.MajorTickMark.DistanceFromScale + this.MajorTickMark.Length / 2.0));
                 gap.Inside  = Math.Max(gap.Inside, (float)(this.MajorTickMark.DistanceFromScale + this.MajorTickMark.Length / 2.0));
             }
             else
             {
                 gap.Outside = Math.Max(gap.Outside, (float)(0.0 - this.MajorTickMark.DistanceFromScale));
                 gap.Inside  = Math.Max(gap.Inside, (float)(this.MajorTickMark.DistanceFromScale + this.MajorTickMark.Length + this.Width / 2.0));
             }
         }
         if (this.MinorTickMark.Visible)
         {
             gap.SetOffsetBase(this.MinorTickMark.Placement, this.MinorTickMark.Length);
             if (this.MinorTickMark.Placement == Placement.Outside)
             {
                 gap.Outside = Math.Max(gap.Outside, (float)(this.MinorTickMark.DistanceFromScale + this.MinorTickMark.Length + this.Width / 2.0));
                 gap.Inside  = Math.Max(gap.Inside, (float)(0.0 - this.MinorTickMark.DistanceFromScale));
             }
             else if (this.MinorTickMark.Placement == Placement.Cross)
             {
                 gap.Outside = Math.Max(gap.Outside, (float)(0.0 - this.MinorTickMark.DistanceFromScale + this.MinorTickMark.Length / 2.0));
                 gap.Inside  = Math.Max(gap.Inside, (float)(this.MinorTickMark.DistanceFromScale + this.MinorTickMark.Length / 2.0));
             }
             else
             {
                 gap.Outside = Math.Max(gap.Outside, (float)(0.0 - this.MinorTickMark.DistanceFromScale));
                 gap.Inside  = Math.Max(gap.Inside, (float)(this.MinorTickMark.DistanceFromScale + this.MinorTickMark.Length + this.Width / 2.0));
             }
         }
         if (this.LabelStyle.Visible)
         {
             if (this.LabelStyle.Placement == Placement.Outside)
             {
                 gap.Outside = Math.Max(gap.Outside, (float)(this.LabelStyle.DistanceFromScale + (float)this.LabelStyle.Font.Height + this.Width / 2.0));
                 gap.Inside  = Math.Max(gap.Inside, (float)(0.0 - this.LabelStyle.DistanceFromScale));
             }
             else if (this.LabelStyle.Placement == Placement.Cross)
             {
                 gap.Outside = Math.Max(gap.Outside, (float)(0.0 - this.LabelStyle.DistanceFromScale + (float)this.LabelStyle.Font.Height / 2.0));
                 gap.Inside  = Math.Max(gap.Inside, (float)(this.LabelStyle.DistanceFromScale + (float)this.LabelStyle.Font.Height / 2.0));
             }
             else
             {
                 gap.Outside = Math.Max(gap.Outside, (float)(0.0 - this.LabelStyle.DistanceFromScale));
                 gap.Inside  = Math.Max(gap.Inside, (float)(this.LabelStyle.DistanceFromScale + (float)this.LabelStyle.Font.Height + this.Width / 2.0));
             }
         }
         using (GraphicsPath graphicsPath = this.GetBarPath(gap.Inside, gap.Outside))
         {
             if (graphicsPath != null)
             {
                 RectangleF bounds = graphicsPath.GetBounds();
                 g.DrawSelection(bounds, designTimeSelection, this.Common.GaugeCore.SelectionBorderColor, this.Common.GaugeCore.SelectionMarkerColor);
             }
         }
         g.RestoreDrawRegion();
         foreach (IRenderable item2 in stack)
         {
             IRenderable renderable = item2;
             g.RestoreDrawRegion();
         }
     }
 }
Esempio n. 12
0
        public GraphicsPath GetTextPath(GaugeGraphics g)
        {
            if (!this.Visible)
            {
                return(null);
            }
            if (this.Text.Length == 0)
            {
                return(null);
            }
            RectangleF   absoluteRectangle = g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f));
            GraphicsPath graphicsPath      = new GraphicsPath();
            string       text = this.Text;
            Font         font = this.Font;

            text = text.Replace("\\n", "\n");
            float emSize;

            if (this.ResizeMode == ResizeMode.AutoFit)
            {
                SizeF sizeF        = g.MeasureString(text, font);
                SizeF absoluteSize = g.GetAbsoluteSize(new SizeF(100f, 100f));
                float num          = absoluteSize.Width / sizeF.Width;
                float num2         = absoluteSize.Height / sizeF.Height;
                emSize = (float)((!(num < num2)) ? (font.SizeInPoints * num2 * 1.2999999523162842 * g.Graphics.DpiY / 96.0) : (font.SizeInPoints * num * 1.2999999523162842 * g.Graphics.DpiY / 96.0));
            }
            else
            {
                if (this.FontUnit == FontUnit.Percent)
                {
                    g.RestoreDrawRegion();
                    emSize = g.GetAbsoluteDimension(font.Size);
                    RectangleF boundRect = ((IRenderable)this).GetBoundRect(g);
                    g.CreateDrawRegion(boundRect);
                }
                else
                {
                    emSize = (float)(font.SizeInPoints * g.Graphics.DpiY / 96.0);
                }
                emSize = (float)(emSize * 1.2999999523162842);
            }
            StringFormat stringFormat = new StringFormat();

            if (this.TextAlignment == ContentAlignment.TopLeft)
            {
                stringFormat.Alignment     = StringAlignment.Near;
                stringFormat.LineAlignment = StringAlignment.Near;
            }
            else if (this.TextAlignment == ContentAlignment.TopCenter)
            {
                stringFormat.Alignment     = StringAlignment.Center;
                stringFormat.LineAlignment = StringAlignment.Near;
            }
            else if (this.TextAlignment == ContentAlignment.TopRight)
            {
                stringFormat.Alignment     = StringAlignment.Far;
                stringFormat.LineAlignment = StringAlignment.Near;
            }
            else if (this.TextAlignment == ContentAlignment.MiddleLeft)
            {
                stringFormat.Alignment     = StringAlignment.Near;
                stringFormat.LineAlignment = StringAlignment.Center;
            }
            else if (this.TextAlignment == ContentAlignment.MiddleCenter)
            {
                stringFormat.Alignment     = StringAlignment.Center;
                stringFormat.LineAlignment = StringAlignment.Center;
            }
            else if (this.TextAlignment == ContentAlignment.MiddleRight)
            {
                stringFormat.Alignment     = StringAlignment.Far;
                stringFormat.LineAlignment = StringAlignment.Center;
            }
            else if (this.TextAlignment == ContentAlignment.BottomLeft)
            {
                stringFormat.Alignment     = StringAlignment.Near;
                stringFormat.LineAlignment = StringAlignment.Far;
            }
            else if (this.TextAlignment == ContentAlignment.BottomCenter)
            {
                stringFormat.Alignment     = StringAlignment.Center;
                stringFormat.LineAlignment = StringAlignment.Far;
            }
            else
            {
                stringFormat.Alignment     = StringAlignment.Far;
                stringFormat.LineAlignment = StringAlignment.Far;
            }
            graphicsPath.AddString(text, font.FontFamily, (int)font.Style, emSize, absoluteRectangle, stringFormat);
            if (this.Angle != 0.0)
            {
                PointF point = new PointF((float)(absoluteRectangle.X + absoluteRectangle.Width / 2.0), (float)(absoluteRectangle.Y + absoluteRectangle.Height / 2.0));
                using (Matrix matrix = new Matrix())
                {
                    matrix.RotateAt(this.Angle, point);
                    graphicsPath.Transform(matrix);
                    return(graphicsPath);
                }
            }
            return(graphicsPath);
        }
 public override void Render(GaugeGraphics g)
 {
     if (this.Common != null && base.Visible && this.GetScale() != null)
     {
         this.Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceStartRendering(this.Name));
         g.StartHotRegion(this);
         this.GetScale().SetDrawRegion(g);
         RectangleF    rectangleF         = this.CalculateRangeRectangle();
         CircularScale scale              = this.GetScale();
         double        valueLimit         = scale.GetValueLimit(this.StartValue);
         double        valueLimit2        = scale.GetValueLimit(this.EndValue);
         float         positionFromValue  = scale.GetPositionFromValue(valueLimit);
         float         positionFromValue2 = scale.GetPositionFromValue(valueLimit2);
         float         num = positionFromValue2 - positionFromValue;
         if (Math.Round((double)num, 4) == 0.0)
         {
             g.RestoreDrawRegion();
             g.EndHotRegion();
             this.Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceRenderingComplete(this.Name));
         }
         else
         {
             Pen          pen          = null;
             Brush        brush        = null;
             GraphicsPath graphicsPath = null;
             try
             {
                 graphicsPath = g.GetCircularRangePath(rectangleF, (float)(positionFromValue + 90.0), num, this.StartWidth, this.EndWidth, this.Placement);
                 if (graphicsPath == null)
                 {
                     g.RestoreDrawRegion();
                     g.EndHotRegion();
                     this.Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceRenderingComplete(this.Name));
                     return;
                 }
                 RectangleF rect = rectangleF;
                 if (this.Placement != 0)
                 {
                     float num2 = this.StartWidth;
                     if (num2 < this.EndWidth)
                     {
                         num2 = this.EndWidth;
                     }
                     if (this.Placement == Placement.Outside)
                     {
                         rect.Inflate(num2, num2);
                     }
                     else
                     {
                         rect.Inflate((float)(num2 / 2.0), (float)(num2 / 2.0));
                     }
                 }
                 RangeGradientType fillGradientType = base.FillGradientType;
                 brush         = g.GetCircularRangeBrush(rect, (float)(positionFromValue + 90.0), num, base.FillColor, base.FillHatchStyle, "", GaugeImageWrapMode.Unscaled, Color.Empty, GaugeImageAlign.TopLeft, fillGradientType, base.FillGradientEndColor);
                 pen           = new Pen(base.BorderColor, (float)base.BorderWidth);
                 pen.DashStyle = g.GetPenStyle(base.BorderStyle);
                 g.FillPath(brush, graphicsPath);
                 if (base.BorderStyle != 0 && base.BorderWidth > 0)
                 {
                     g.DrawPath(pen, graphicsPath);
                 }
             }
             catch (Exception)
             {
                 if (graphicsPath != null)
                 {
                     graphicsPath.Dispose();
                 }
                 if (pen != null)
                 {
                     pen.Dispose();
                 }
                 if (brush != null)
                 {
                     brush.Dispose();
                 }
                 g.RestoreDrawRegion();
                 throw;
             }
             this.Common.GaugeCore.HotRegionList.SetHotRegion(this, g.GetAbsolutePoint(this.GetScale().GetPivotPoint()), graphicsPath);
             g.RestoreDrawRegion();
             g.EndHotRegion();
             this.Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceRenderingComplete(this.Name));
         }
     }
 }
Esempio n. 14
0
        void ISelectable.DrawSelection(GaugeGraphics g, bool designTimeSelection)
        {
            if (GetGauge() == null)
            {
                return;
            }
            Stack stack = new Stack();

            for (NamedElement namedElement = GetGauge().ParentObject; namedElement != null; namedElement = (NamedElement)((IRenderable)namedElement).GetParentRenderable())
            {
                stack.Push(namedElement);
            }
            foreach (IRenderable item in stack)
            {
                g.CreateDrawRegion(item.GetBoundRect(g));
            }
            g.CreateDrawRegion(((IRenderable)GetGauge()).GetBoundRect(g));
            SetDrawRegion(g);
            Gap gap = new Gap(GetRadius());

            gap.SetOffset(Placement.Cross, Width);
            gap.SetBase();
            if (MajorTickMark.Visible)
            {
                gap.SetOffsetBase(MajorTickMark.Placement, MajorTickMark.Length);
                if (MajorTickMark.Placement == Placement.Outside)
                {
                    gap.Outside = Math.Max(gap.Outside, MajorTickMark.DistanceFromScale + MajorTickMark.Length + Width / 2f);
                    gap.Inside  = Math.Max(gap.Inside, 0f - MajorTickMark.DistanceFromScale);
                }
                else if (MajorTickMark.Placement == Placement.Cross)
                {
                    gap.Outside = Math.Max(gap.Outside, 0f - MajorTickMark.DistanceFromScale + MajorTickMark.Length / 2f);
                    gap.Inside  = Math.Max(gap.Inside, MajorTickMark.DistanceFromScale + MajorTickMark.Length / 2f);
                }
                else
                {
                    gap.Outside = Math.Max(gap.Outside, 0f - MajorTickMark.DistanceFromScale);
                    gap.Inside  = Math.Max(gap.Inside, MajorTickMark.DistanceFromScale + MajorTickMark.Length + Width / 2f);
                }
            }
            if (MinorTickMark.Visible)
            {
                gap.SetOffsetBase(MinorTickMark.Placement, MinorTickMark.Length);
                if (MinorTickMark.Placement == Placement.Outside)
                {
                    gap.Outside = Math.Max(gap.Outside, MinorTickMark.DistanceFromScale + MinorTickMark.Length + Width / 2f);
                    gap.Inside  = Math.Max(gap.Inside, 0f - MinorTickMark.DistanceFromScale);
                }
                else if (MinorTickMark.Placement == Placement.Cross)
                {
                    gap.Outside = Math.Max(gap.Outside, 0f - MinorTickMark.DistanceFromScale + MinorTickMark.Length / 2f);
                    gap.Inside  = Math.Max(gap.Inside, MinorTickMark.DistanceFromScale + MinorTickMark.Length / 2f);
                }
                else
                {
                    gap.Outside = Math.Max(gap.Outside, 0f - MinorTickMark.DistanceFromScale);
                    gap.Inside  = Math.Max(gap.Inside, MinorTickMark.DistanceFromScale + MinorTickMark.Length + Width / 2f);
                }
            }
            if (LabelStyle.Visible)
            {
                if (LabelStyle.Placement == Placement.Outside)
                {
                    gap.Outside = Math.Max(gap.Outside, LabelStyle.DistanceFromScale + (float)LabelStyle.Font.Height + Width / 2f);
                    gap.Inside  = Math.Max(gap.Inside, 0f - LabelStyle.DistanceFromScale);
                }
                else if (LabelStyle.Placement == Placement.Cross)
                {
                    gap.Outside = Math.Max(gap.Outside, 0f - LabelStyle.DistanceFromScale + (float)LabelStyle.Font.Height / 2f);
                    gap.Inside  = Math.Max(gap.Inside, LabelStyle.DistanceFromScale + (float)LabelStyle.Font.Height / 2f);
                }
                else
                {
                    gap.Outside = Math.Max(gap.Outside, 0f - LabelStyle.DistanceFromScale);
                    gap.Inside  = Math.Max(gap.Inside, LabelStyle.DistanceFromScale + (float)LabelStyle.Font.Height + Width / 2f);
                }
            }
            float angularMargin = 4f;
            float num           = 5f;

            using (GraphicsPath graphicsPath = GetBarPath(gap.Inside + num, gap.Outside + num, angularMargin))
            {
                if (graphicsPath != null)
                {
                    PointF[] selectionMarkers = GetSelectionMarkers(g, gap.Inside + num, gap.Outside + num, angularMargin);
                    g.DrawRadialSelection(g, graphicsPath, selectionMarkers, designTimeSelection, Common.GaugeCore.SelectionBorderColor, Common.GaugeCore.SelectionMarkerColor);
                }
            }
            g.RestoreDrawRegion();
            g.RestoreDrawRegion();
            foreach (IRenderable item2 in stack)
            {
                _ = item2;
                g.RestoreDrawRegion();
            }
        }
Esempio n. 15
0
        internal override void Render(GaugeGraphics g)
        {
            if (Common == null || !Visible || GetScale() == null)
            {
                return;
            }
            g.StartHotRegion(this);
            GetScale().SetDrawRegion(g);
            if (Image != "" && CapImage != "")
            {
                DrawImage(g, primary: true, drawShadow: false);
                DrawImage(g, primary: false, drawShadow: false);
                SetAllHotRegions(g);
                g.RestoreDrawRegion();
                g.EndHotRegion();
                return;
            }
            if (Image != "")
            {
                DrawImage(g, primary: true, drawShadow: false);
            }
            float  positionFromValue = GetScale().GetPositionFromValue(base.Position);
            PointF absolutePoint     = g.GetAbsolutePoint(GetScale().GetPivotPoint());
            Pen    pen = new Pen(base.BorderColor, base.BorderWidth);

            pen.DashStyle = g.GetPenStyle(base.BorderStyle);
            if (pen.DashStyle != 0)
            {
                pen.Alignment = PenAlignment.Center;
            }
            KnobStyleAttrib knobStyleAttrib = GetKnobStyleAttrib(g, absolutePoint, positionFromValue);

            try
            {
                if (knobStyleAttrib.paths != null)
                {
                    for (int i = 0; i < knobStyleAttrib.paths.Length; i++)
                    {
                        if (knobStyleAttrib.brushes[i] != null && knobStyleAttrib.paths[i] != null)
                        {
                            g.FillPath(knobStyleAttrib.brushes[i], knobStyleAttrib.paths[i]);
                        }
                    }
                    if (base.BorderWidth > 0 && knobStyleAttrib.paths[0] != null)
                    {
                        g.DrawPath(pen, knobStyleAttrib.paths[0]);
                    }
                    if (knobStyleAttrib.paths[0] != null)
                    {
                        AddHotRegion((GraphicsPath)knobStyleAttrib.paths[0].Clone(), primary: true);
                    }
                }
            }
            finally
            {
                knobStyleAttrib.Dispose();
            }
            if (CapImage != "")
            {
                DrawImage(g, primary: false, drawShadow: false);
            }
            SetAllHotRegions(g);
            g.RestoreDrawRegion();
            g.EndHotRegion();
        }
Esempio n. 16
0
 public override void Render(GaugeGraphics g)
 {
     if (this.Common != null && this.Visible && this.GetScale() != null)
     {
         g.StartHotRegion(this);
         this.GetScale().SetDrawRegion(g);
         if (this.Image != "" && this.CapImage != "")
         {
             this.DrawImage(g, true, false);
             this.DrawImage(g, false, false);
             this.SetAllHotRegions(g);
             g.RestoreDrawRegion();
             g.EndHotRegion();
         }
         else
         {
             if (this.Image != "")
             {
                 this.DrawImage(g, true, false);
             }
             float  positionFromValue = this.GetScale().GetPositionFromValue(base.Position);
             PointF absolutePoint     = g.GetAbsolutePoint(this.GetScale().GetPivotPoint());
             Pen    pen = new Pen(base.BorderColor, (float)base.BorderWidth);
             pen.DashStyle = g.GetPenStyle(base.BorderStyle);
             if (pen.DashStyle != 0)
             {
                 pen.Alignment = PenAlignment.Center;
             }
             KnobStyleAttrib knobStyleAttrib = this.GetKnobStyleAttrib(g, absolutePoint, positionFromValue);
             try
             {
                 if (knobStyleAttrib.paths != null)
                 {
                     for (int i = 0; i < knobStyleAttrib.paths.Length; i++)
                     {
                         if (knobStyleAttrib.brushes[i] != null && knobStyleAttrib.paths[i] != null)
                         {
                             g.FillPath(knobStyleAttrib.brushes[i], knobStyleAttrib.paths[i]);
                         }
                     }
                     if (base.BorderWidth > 0 && knobStyleAttrib.paths[0] != null)
                     {
                         g.DrawPath(pen, knobStyleAttrib.paths[0]);
                     }
                     if (knobStyleAttrib.paths[0] != null)
                     {
                         this.AddHotRegion((GraphicsPath)knobStyleAttrib.paths[0].Clone(), true);
                     }
                 }
             }
             finally
             {
                 knobStyleAttrib.Dispose();
             }
             if (this.CapImage != "")
             {
                 this.DrawImage(g, false, false);
             }
             this.SetAllHotRegions(g);
             g.RestoreDrawRegion();
             g.EndHotRegion();
         }
     }
 }
        internal override void Render(GaugeGraphics g)
        {
            if (Common == null || !base.Visible || GetScale() == null)
            {
                return;
            }
            Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceStartRendering(Name));
            g.StartHotRegion(this);
            GetScale().SetDrawRegion(g);
            RectangleF    rectangleF        = CalculateRangeRectangle();
            CircularScale scale             = GetScale();
            double        valueLimit        = scale.GetValueLimit(StartValue);
            double        valueLimit2       = scale.GetValueLimit(EndValue);
            float         positionFromValue = scale.GetPositionFromValue(valueLimit);
            float         num = scale.GetPositionFromValue(valueLimit2) - positionFromValue;

            if (Math.Round(num, 4) == 0.0)
            {
                g.RestoreDrawRegion();
                g.EndHotRegion();
                Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceRenderingComplete(Name));
                return;
            }
            Pen          pen          = null;
            Brush        brush        = null;
            GraphicsPath graphicsPath = null;

            try
            {
                graphicsPath = g.GetCircularRangePath(rectangleF, positionFromValue + 90f, num, StartWidth, EndWidth, Placement);
                if (graphicsPath == null)
                {
                    g.RestoreDrawRegion();
                    g.EndHotRegion();
                    Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceRenderingComplete(Name));
                    return;
                }
                RectangleF rect = rectangleF;
                if (Placement != 0)
                {
                    float num2 = StartWidth;
                    if (num2 < EndWidth)
                    {
                        num2 = EndWidth;
                    }
                    if (Placement == Placement.Outside)
                    {
                        rect.Inflate(num2, num2);
                    }
                    else
                    {
                        rect.Inflate(num2 / 2f, num2 / 2f);
                    }
                }
                RangeGradientType fillGradientType = base.FillGradientType;
                brush         = g.GetCircularRangeBrush(rect, positionFromValue + 90f, num, base.FillColor, base.FillHatchStyle, "", GaugeImageWrapMode.Unscaled, Color.Empty, GaugeImageAlign.TopLeft, fillGradientType, base.FillGradientEndColor);
                pen           = new Pen(base.BorderColor, base.BorderWidth);
                pen.DashStyle = g.GetPenStyle(base.BorderStyle);
                g.FillPath(brush, graphicsPath);
                if (base.BorderStyle != 0 && base.BorderWidth > 0)
                {
                    g.DrawPath(pen, graphicsPath);
                }
            }
            catch (Exception)
            {
                graphicsPath?.Dispose();
                pen?.Dispose();
                brush?.Dispose();
                g.RestoreDrawRegion();
                throw;
            }
            Common.GaugeCore.HotRegionList.SetHotRegion(this, g.GetAbsolutePoint(GetScale().GetPivotPoint()), graphicsPath);
            g.RestoreDrawRegion();
            g.EndHotRegion();
            Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceRenderingComplete(Name));
        }