private void ClearVelocityGauge() { GaugeCircularScale oScale = gaugeControl1.CircularScales[0]; GaugePointer GPointer = oScale.Pointers[0]; GPointer.Value = 0; }
private void CalcCircularMarkerPoint(GaugeCircularScale scale) { int radius = Radius; switch (GaugePointer.Placement) { case DisplayPlacement.Near: radius -= (Width / 2); break; case DisplayPlacement.Far: radius += (Width / 2); break; } _Bounds.Size = new Size(radius * 2, radius * 2); _Bounds.Location = new Point(scale.Center.X - radius, scale.Center.Y - radius); Dpt = scale.SweepAngle / scale.Spread; _Origin = GetOriginInterval() - scale.MinValue; _Marker = GetInterval(Value) - scale.MinValue; if (scale.Reversed == true) { IntervalAngle = (float)(scale.StartAngle + scale.SweepAngle - (_Marker * Dpt)); _StartAngle = (float)(scale.StartAngle + scale.SweepAngle - (_Origin * Dpt)); } else { IntervalAngle = (float)(scale.StartAngle + _Marker * Dpt); _StartAngle = (float)(scale.StartAngle + _Origin * Dpt); } IntervalPoint = scale.GetPoint(radius, IntervalAngle); _SweepAngle = IntervalAngle - _StartAngle; if (GaugePointer.BarStyle != BarPointerStyle.Square) { _RoundAngle = 0; if (_SweepAngle != 0) { float x = (float)((360 * Width / 2) / (radius * 2 * Math.PI)); _RoundAngle = (_SweepAngle > 0) ? Math.Min(x, _SweepAngle) : Math.Max(-x, _SweepAngle); _SweepAngle -= _RoundAngle; } } }
private void CalcCircularTickPoint(GaugeCircularScale scale) { double spread = Scale.MaxValue - Scale.MinValue; double dpt = scale.SweepAngle / spread; if (_Interval >= 0 && _Interval <= spread) { _TickPoint = new TickPoint(this); if (scale.Reversed == true) _TickPoint.Angle = (float)(scale.StartAngle + scale.SweepAngle - (_Interval * dpt)); else _TickPoint.Angle = (float)(scale.StartAngle + _Interval * dpt); _TickPoint.Point = scale.GetPoint(Radius, _TickPoint.Angle); _TickPoint.Interval = _Interval; } }
private double Set_GaugeControl() { double velocity = 0.0; velocity = dblInputVelocity.Value; // gaugeControl1.SetParameters(0, 500, velocity, 100); GaugeCircularScale oScale = gaugeControl1.CircularScales[0]; oScale.Labels.Interval = 50; oScale.MinValue = 0; oScale.MaxValue = 500; GaugePointer GPointer = oScale.Pointers[0]; GPointer.Value = velocity; return(velocity); }
private void CalcCircularMarkerPoint(GaugeCircularScale scale) { Dpt = scale.SweepAngle / scale.Spread; double marker = GetInterval(Value) - scale.MinValue; IntervalAngle = (float)(scale.Reversed ? scale.StartAngle + scale.SweepAngle - (marker * Dpt) : scale.StartAngle + (marker * Dpt)); IntervalPoint = scale.GetPoint(Radius, IntervalAngle); _CapWidth = (int)(scale.AbsRadius * GaugePointer.CapWidth); if (_CapWidth % 2 != 0) _CapWidth++; int n = _CapWidth / 2; _CapBounds = new Rectangle( scale.Center.X - n, scale.Center.Y - n, _CapWidth, _CapWidth); }
private GraphicsPath GetCircularBarPath(GaugeCircularScale scale) { GraphicsPath path = new GraphicsPath(); Rectangle r = _Bounds; r.Inflate(Width / 2, Width / 2); path.AddArc(r, _StartAngle, _SweepAngle); if (_RoundAngle != 0) { if (GaugePointer.BarStyle != BarPointerStyle.Square) { Point pt = scale.GetPoint(_Bounds.Width/2, _StartAngle + _SweepAngle); Point pt2 = scale.GetPoint(_Bounds.Width/2, _StartAngle + _SweepAngle + _RoundAngle); int dx = pt2.X - pt.X; int dy = pt2.Y - pt.Y; double n = Math.Max(1, Math.Sqrt((dx * dx) + (dy * dy))); float angle = (_StartAngle + _SweepAngle) % 360; using (GraphicsPath path2 = new GraphicsPath()) { Matrix matrix = new Matrix(); matrix.RotateAt(angle, pt); r.X = pt.X - Width/2 + 1; r.Y = pt.Y - (int) n; r.Width = Width - 1; r.Height = (int) (n*2); if (GaugePointer.BarStyle == BarPointerStyle.Rounded) { path2.AddArc(r, 0, _SweepAngle + _RoundAngle > 0 ? 180 : -180); } else { path2.AddLine(new Point(r.Right, r.Y + r.Height/2), new Point(r.X + Width/2, _SweepAngle + _RoundAngle > 0 ? r.Bottom : r.Y)); } path2.Transform(matrix); path.AddPath(path2, true); } } } r = _Bounds; r.Inflate(-Width / 2, -Width / 2); path.AddArc(r, _StartAngle + _SweepAngle, -_SweepAngle); path.CloseFigure(); return (path); }
private string GetScaleName(GaugeCircularScale scale) { for (int i = 1; i < 100; i++) { string s = "Scale" + i.ToString(); if (scale.GaugeControl.CircularScales[s] == null) return (s); } return (null); }
private void CalcCircularLabelPoint(GaugeCircularScale scale) { if (Radius > 0) { _LabelPoint = new LabelPoint(); _LabelPoint.Angle = _GaugePin.Angle; _LabelPoint.Point = scale.GetPoint(Radius, _LabelPoint.Angle); } }
private void CopyCircularScale(GaugeCircularScale scale) { if (_AddButton != null) { _AddButton.PerformClick(); GaugeCircularScaleCollection css = scale.GaugeControl.CircularScales; GaugeCircularScale clone = css[css.Count - 1]; scale.CopyToItem(clone); } }
private void InitializeNewCircularScale(GaugeCircularScale scale) { scale.Name = GetScaleName(scale); GaugeSection section = new GaugeSection(scale); section.Name = GetSectionName(scale); section.FillColor = new GradientFillColor(Color.CornflowerBlue); scale.Sections.Add(section); }
private void SetCBottomMeterDesignTimeDefaults() { _GaugeControl.Frame.Style = GaugeFrameStyle.Rectangular; _GaugeControl.Frame.BackColor = new GradientFillColor(Color.Gainsboro, Color.DarkGray); _GaugeControl.Frame.FrameColor = new GradientFillColor(Color.White, Color.DimGray); _GaugeControl.Frame.FrameColor.BorderColor = Color.Gainsboro; _GaugeControl.Frame.FrameColor.BorderWidth = 1; _GaugeControl.Size = new Size(_GaugeControl.Size.Width, _GaugeControl.Size.Width / 3); GaugeCircularScale scale = new GaugeCircularScale(_GaugeControl); scale.Name = "Scale1"; scale.Radius = 2.5F; scale.StartAngle = 240F; scale.SweepAngle = 60F; scale.Width = 0.011F; scale.MajorTickMarks.Interval = 50; scale.MajorTickMarks.Layout.Length = 0.063F; scale.MajorTickMarks.Layout.Width = 0.033F; scale.MaxPin.EndOffset = 0.01F; scale.MaxPin.Length = 0.026F; scale.MaxPin.ScaleOffset = -0.06F; scale.MaxPin.Width = 0.026F; GradientFillColor fillColor = new GradientFillColor(Color.LightYellow); fillColor.BorderColor = Color.DimGray; fillColor.BorderWidth = 1; scale.MinorTickMarks.Interval = 10; scale.MinorTickMarks.Layout.FillColor = fillColor; scale.MinorTickMarks.Layout.Length = 0.042F; scale.MinorTickMarks.Layout.Width = 0.013F; scale.MinPin.EndOffset = 0.01F; scale.MinPin.Length = 0.026F; scale.MinPin.ScaleOffset = -0.06F; scale.MinPin.Width = 0.026F; scale.PivotPoint = new PointF(.5f, 2.7f); scale.Labels.Layout.Font = new Font("Microsoft Sans Serif", 4F); scale.Labels.Layout.ScaleOffset = 0.075F; GaugeRange range = new GaugeRange(scale); range.Name = "Range1"; range.ScaleOffset = 0.033F; range.StartValue = 0; range.StartWidth = 0.07F; range.EndValue = 100; range.EndWidth = 0.07F; range.FillColor.BorderColor = Color.Gray; range.FillColor.BorderWidth = 1; range.FillColor.Color1 = Color.Yellow; range.FillColor.Color2 = Color.Lime; scale.Ranges.Add(range); GaugePointer pointer = new GaugePointer(scale); pointer.Name = "Pointer1"; pointer.Style = PointerStyle.Needle; pointer.ScaleOffset = -0.057F; pointer.Width = 0.032F; pointer.CapFillColor.BorderColor = Color.DimGray; pointer.CapFillColor.BorderWidth = 1; pointer.CapFillColor.Color1 = Color.Gainsboro; pointer.CapFillColor.Color2 = Color.Silver; pointer.FillColor.BorderColor = Color.DimGray; pointer.FillColor.BorderWidth = 1; pointer.FillColor.Color1 = Color.Black; scale.Pointers.Add(pointer); _GaugeControl.CircularScales.Add(scale); }
private void CalcCircularTickPoints( GaugeCircularScale scale, double ticks, int n) { double dpt = scale.SweepAngle / ticks; double theta = _Interval * dpt; double startAngle = scale.StartAngle; if (scale.Reversed == true) startAngle += scale.SweepAngle; int dir = scale.Reversed ? -1 : 1; startAngle += (dpt * _IntervalOffset * dir); _TickPoints = new TickPoint[n]; double interval = _IntervalOffset; for (int i = 0; i < n; i++) { _TickPoints[i] = new TickPoint(this); _TickPoints[i].Angle = (float)(startAngle + (i * theta * dir)); _TickPoints[i].Point = scale.GetPoint(Radius, _TickPoints[i].Angle); _TickPoints[i].Interval = interval; interval += _Interval; } }
private void CalcCircularMetrics(GaugeCircularScale scale) { _Radius = scale.AbsRadius; _Bounds = new Rectangle(0, 0, (int)(_Radius * _Width), (int)(_Radius * _Length)); int m = scale.AbsScaleWidth; int offset = (int)(scale.AbsRadius * _ScaleOffset); switch (_Placement) { case DisplayPlacement.Near: _Radius -= ((_Bounds.Height + m) / 2 + offset); break; case DisplayPlacement.Center: _Radius += (offset); break; case DisplayPlacement.Far: _Radius += ((_Bounds.Height + m) / 2 + offset); break; } float angle = _EndOffset * 360; if (_IsMaxPin != scale.Reversed) _Angle = scale.StartAngle + scale.SweepAngle + angle; else _Angle = scale.StartAngle - angle; Point pt = scale.GetPoint(_Radius, _Angle); _Bounds.Location = new Point(pt.X - _Bounds.Width / 2, pt.Y - _Bounds.Height / 2); }
private void SetCInsetScaleDesignTimeDefaults() { _GaugeControl.Frame.Style = GaugeFrameStyle.Circular; SetBaseGuageColor(); GaugeCircularScale scale1 = new GaugeCircularScale(_GaugeControl); scale1.Name = "Scale1"; scale1.Radius = 0.092F; scale1.Width = 0.139F; scale1.MaxValue = 10; scale1.Labels.Layout.RotateLabel = false; scale1.Labels.Layout.Font = new Font("Microsoft Sans Serif", 18F); GradientFillColor fillColor = new GradientFillColor(Color.White); fillColor.BorderColor = Color.DimGray; fillColor.BorderWidth = 1; scale1.MajorTickMarks.Interval = 1; scale1.MajorTickMarks.Layout.FillColor = fillColor; scale1.MajorTickMarks.Layout.Length = 0.263F; scale1.MajorTickMarks.Layout.Style = GaugeMarkerStyle.Circle; scale1.MajorTickMarks.Layout.Width = 0.263F; scale1.MinorTickMarks.Interval = 0.5; scale1.MinorTickMarks.Layout.FillColor = new GradientFillColor(Color.Black); scale1.MinorTickMarks.Layout.Length = 0.2F; scale1.PivotPoint = new PointF(.50f, .68f); GaugePointer pointer = new GaugePointer(scale1); pointer.Name = "Pointer1"; pointer.Style = PointerStyle.Needle; pointer.Length = 0.54F; pointer.Width = 0.2F; pointer.Placement = DisplayPlacement.Near; pointer.NeedleStyle = NeedlePointerStyle.Style6; pointer.CapFillColor.BorderColor = Color.DimGray; pointer.CapFillColor.BorderWidth = 1; pointer.CapFillColor.Color1 = Color.WhiteSmoke; pointer.CapFillColor.Color2 = Color.Brown; pointer.CapFillColor.GradientFillType = GradientFillType.Center; pointer.CapStyle = NeedlePointerCapStyle.Style1; pointer.CapWidth = 0.4F; pointer.FillColor.BorderColor = Color.DarkSlateGray; pointer.FillColor.BorderWidth = 1; pointer.FillColor.Color1 = Color.Turquoise; scale1.Pointers.Add(pointer); GaugeSection section = new GaugeSection(scale1); section.FillColor.Color1 = Color.CornflowerBlue; section.Name = "Section1"; scale1.Sections.Add(section); _GaugeControl.CircularScales.Add(scale1); GaugeCircularScale scale2 = new GaugeCircularScale(_GaugeControl); scale2.Name = "Scale2"; scale2.Radius = .38f; section = new GaugeSection(scale2); section.Name = "Section1"; section.FillColor = new GradientFillColor(Color.CornflowerBlue, Color.Purple); scale2.Sections.Add(section); pointer = new GaugePointer(scale2); pointer.Name = "Pointer1"; pointer.Style = PointerStyle.Needle; pointer.Length = 0.358F; pointer.FillColor = new GradientFillColor(Color.WhiteSmoke, Color.Red); pointer.FillColor.BorderColor = Color.DimGray; pointer.FillColor.BorderWidth = 1; pointer.CapFillColor = new GradientFillColor(Color.WhiteSmoke, Color.DimGray, 90); pointer.CapFillColor.BorderColor = Color.DimGray; pointer.CapFillColor.BorderWidth = 1; scale2.Pointers.Add(pointer); _GaugeControl.CircularScales.Add(scale2); }
private void GetCPointerPath(GaugeCircularScale scale) { if (Radius > 0 && (_SweepAngle != 0 || _RoundAngle != 0)) PointerPath = GetCircularBarPath(scale); }
private void CalcCircularLabelPoints(GaugeCircularScale scale) { double labelInterval = (_Interval.Equals(double.NaN) ? scale.MajorTickMarks.Interval : _Interval); double labelIntervalOffset = (_IntervalOffset.Equals(double.NaN) ? scale.MajorTickMarks.IntervalOffset : _IntervalOffset); double spread = scale.MaxValue - scale.MinValue; double dpt = scale.SweepAngle / spread; int n = GetPointCount(spread, labelInterval, labelIntervalOffset); if (n > 0) { double startAngle = scale.StartAngle; double interval = (_ShowMinLabel == true ? 0 : labelIntervalOffset > 0 ? labelIntervalOffset : labelInterval); int dir = (scale.Reversed ? -1 : 1); if (scale.Reversed == true) startAngle += scale.SweepAngle; _LabelPoints = new LabelPoint[n]; for (int i = 0; i < n; i++) { _LabelPoints[i] = new LabelPoint(); if (interval + scale.MinValue > scale.MaxValue) interval = scale.MaxValue - scale.MinValue; _LabelPoints[i].Angle = (float)(startAngle + (interval * dpt) * dir); _LabelPoints[i].Point = scale.GetPoint(Radius, _LabelPoints[i].Angle); _LabelPoints[i].Interval = interval; if (interval >= labelIntervalOffset) interval += labelInterval; else interval = labelIntervalOffset; } } else { _LabelPoints = null; } }
private void CalcCircularMetrics(GaugeCircularScale scale) { _Radius = scale.AbsRadius; if (_Radius > 0) { int offset = (int)(_Radius * _Layout.ScaleOffset); switch (_Layout.Placement) { case DisplayPlacement.Near: _Radius = scale.GetNearLabelRadius() - offset; break; case DisplayPlacement.Center: _Radius += offset; break; case DisplayPlacement.Far: _Radius = scale.GetFarLabelRadius() + offset; break; } } }
private Font GetAbsFont(GaugeCircularScale scale) { float emSize = _Layout.Font.SizeInPoints; emSize = (emSize / 120) * scale.AbsRadius; if (emSize <= 0) emSize = 1; return (new Font(_Layout.Font.FontFamily, emSize, _Layout.Font.Style)); }
private double GetCValueFromPoint(GaugeCircularScale scale, Point pt) { double minValue = scale.MinValue; double maxValue = scale.MaxValue; double startAngle = scale.StartAngle; double sweepAngle = scale.SweepAngle; double radians = GetPointRadians(pt); double spread = scale.MaxValue - scale.MinValue; double dpt = spread / scale.SweepAngle; if (minValue <= scale.AbsMinLimit) minValue -= GetCMinPinOffset(dpt, ref startAngle, ref sweepAngle); if (maxValue >= scale.AbsMaxLimit) maxValue += GetCMaxPinOffset(dpt, ref startAngle, ref sweepAngle); double angle = (GaugePointer.MouseDownAngle + scale.GetDegrees(radians - GaugePointer.MouseDownRadians) - startAngle) % 360; if (angle < 0) angle += 360; if (scale.Reversed == true) { angle = sweepAngle - angle; if (angle < 0) angle += 360; } if (angle < sweepAngle) { double value = angle * dpt + minValue; if (GaugePointer.SnapInterval > 0) value = (int)(value / GaugePointer.SnapInterval) * GaugePointer.SnapInterval; return (value); } if (angle > sweepAngle + (360 - sweepAngle) / 2) { double limit = minValue; if (limit > scale.AbsMinLimit) limit = Math.Max(limit - 1, scale.AbsMinLimit); return (limit); } double limit2 = maxValue; if (limit2 < scale.AbsMaxLimit) limit2 = Math.Min(limit2 + 1, scale.AbsMaxLimit); return (limit2); }
private void CalcCircularMetrics(GaugeCircularScale scale) { _Width = (int)(scale.AbsRadius * GaugePointer.Width); _Length = (int)(scale.AbsRadius * GaugePointer.Length); if (_Width % 2 != 0) _Width++; }
private void CalcCircularMetrics(GaugeCircularScale scale) { float spread = (float)Math.Abs(scale.MaxValue - scale.MinValue); if (spread == 0) spread = 1; float dv = scale.SweepAngle / spread; _StartAngle = (float)(dv * _MinValue) + scale.StartAngle; _SweepAngle = (float)(dv * (_MaxValue - _MinValue)); if (scale.Reversed == true) { _StartAngle = (scale.StartAngle + scale.SweepAngle) - (_StartAngle - scale.StartAngle); _SweepAngle = -_SweepAngle; } }
private void SetCircularDesignTimeDefaults() { _GaugeControl.Frame.Style = GaugeFrameStyle.Circular; SetBaseGuageColor(); GaugeCircularScale scale = new GaugeCircularScale(_GaugeControl); scale.Name = "Scale1"; scale.Radius = .38f; _GaugeControl.CircularScales.Add(scale); GaugeSection section = new GaugeSection(scale); section.Name = "Section1"; section.FillColor = new GradientFillColor(Color.CornflowerBlue, Color.Purple); scale.Sections.Add(section); GaugeRange range = new GaugeRange(scale); range.Name = "Range1"; range.FillColor = new GradientFillColor(Color.Lime, Color.Red); range.FillColor.BorderColor = Color.DimGray; range.FillColor.BorderWidth = 1; range.ScaleOffset = .28f; range.StartValue = 70; scale.Ranges.Add(range); GaugePointer pointer = new GaugePointer(scale); pointer.Name = "Pointer1"; pointer.Style = PointerStyle.Needle; pointer.Length = 0.358F; pointer.FillColor = new GradientFillColor(Color.WhiteSmoke, Color.Red); pointer.FillColor.BorderColor = Color.DimGray; pointer.FillColor.BorderWidth = 1; pointer.CapFillColor = new GradientFillColor(Color.WhiteSmoke, Color.DimGray, 90); pointer.CapFillColor.BorderColor = Color.DimGray; pointer.CapFillColor.BorderWidth = 1; scale.Pointers.Add(pointer); }
private void SetC2ScalesDesignTimeDefaults() { _GaugeControl.Frame.Style = GaugeFrameStyle.Circular; SetBaseGuageColor(); GaugeCircularScale scale1 = new GaugeCircularScale(_GaugeControl); scale1.Name = "Scale1"; scale1.Radius = .38f; _GaugeControl.CircularScales.Add(scale1); GaugeSection section = new GaugeSection(scale1); section.Name = "Section1"; section.FillColor = new GradientFillColor(Color.CornflowerBlue, Color.Purple); scale1.Sections.Add(section); GaugePointer pointer = new GaugePointer(scale1); pointer.Name = "Pointer1"; pointer.Style = PointerStyle.Needle; pointer.Length = 0.358F; pointer.FillColor = new GradientFillColor(Color.WhiteSmoke, Color.Red); pointer.FillColor.BorderColor = Color.DimGray; pointer.FillColor.BorderWidth = 1; pointer.CapFillColor = new GradientFillColor(Color.WhiteSmoke, Color.DimGray, 90); pointer.CapFillColor.BorderColor = Color.DimGray; pointer.CapFillColor.BorderWidth = 1; scale1.Pointers.Add(pointer); GaugeCircularScale scale2 = new GaugeCircularScale(_GaugeControl); scale2.Name = "Scale2"; scale2.Radius = .24f; scale2.MaxValue = 200; scale2.MajorTickMarks.Interval = 20; scale2.MaxValue = 200; scale2.MinorTickMarks.Interval = 4; scale2.Name = "Scale2"; scale2.Radius = 0.24F; _GaugeControl.CircularScales.Add(scale2); section = new GaugeSection(scale2); section.Name = "Section1"; section.FillColor.Color1 = Color.CornflowerBlue; section.Name = "Section1"; scale2.Sections.Add(section); }
private void CalcCircularMetrics(GaugeCircularScale scale) { _Radius = scale.AbsRadius; _Length = (int)(_Radius * _Layout.Length); _Width = (int)(_Radius * _Layout.Width); int m = scale.AbsScaleWidth; int offset = (int)(scale.AbsRadius * _Layout.ScaleOffset); switch (_Layout.Placement) { case DisplayPlacement.Near: _Radius -= ((_Length + m / 2) + offset); break; case DisplayPlacement.Center: _Radius += ((_Length / 2) + offset + 1); break; case DisplayPlacement.Far: _Radius += ((_Length + m / 2) + offset); break; } }
private GaugeCircularScale NewCircularScale() { GaugeCircularScale scale = new GaugeCircularScale(_GaugeControl); scale.Name = GetScaleName(scale); GaugeSection section = new GaugeSection(scale); section.Name = GetSectionName(scale); section.FillColor = new GradientFillColor(Color.CornflowerBlue); scale.Sections.Add(section); return (scale); }