/// <summary> /// Calculate the values needed to properly display this <see cref="GasGaugeNeedle"/>. /// </summary> /// <param name="pane"> /// A graphic device object to be drawn into. This is normally e.Graphics from the /// PaintEventArgs argument to the Paint() method. /// </param> public static void CalculateGasGaugeParameters(GraphPane pane) { //loop thru slices and get total value and maxDisplacement double minVal = double.MaxValue; double maxVal = double.MinValue; foreach (CurveItem curve in pane.CurveList) { if (curve is GasGaugeRegion) { GasGaugeRegion ggr = (GasGaugeRegion)curve; if (maxVal < ggr.MaxValue) { maxVal = ggr.MaxValue; } if (minVal > ggr.MinValue) { minVal = ggr.MinValue; } } } //Set Needle Sweep angle values here based on the min and max values of the GasGuage foreach (CurveItem curve in pane.CurveList) { if (curve is GasGaugeNeedle) { GasGaugeNeedle ggn = (GasGaugeNeedle)curve; float sweep = ((float)ggn.NeedleValue - (float)minVal) / ((float)maxVal - (float)minVal) * 180.0f; ggn.SweepAngle = sweep; } } }
/// <summary> /// Calculate the values needed to properly display this <see cref="GasGaugeRegion"/>. /// </summary> /// <param name="pane"> /// A graphic device object to be drawn into. This is normally e.Graphics from the /// PaintEventArgs argument to the Paint() method. /// </param> public static void CalculateGasGuageParameters( GraphPane pane ) { //loop thru slices and get total value and maxDisplacement double minVal = double.MaxValue; double maxVal = double.MinValue; foreach ( CurveItem curve in pane.CurveList ) if ( curve is GasGaugeRegion ) { GasGaugeRegion ggr = (GasGaugeRegion)curve; if ( maxVal < ggr.MaxValue ) maxVal = ggr.MaxValue; if ( minVal > ggr.MinValue ) minVal = ggr.MinValue; } //Calculate start and sweep angles for each of the GasGaugeRegion based on teh min and max value foreach ( CurveItem curve in pane.CurveList ) { if ( curve is GasGaugeRegion ) { GasGaugeRegion ggr = (GasGaugeRegion)curve; float start = ( (float)ggr.MinValue - (float)minVal ) / ( (float)maxVal - (float)minVal ) * 180.0f; float sweep = ( (float)ggr.MaxValue - (float)minVal ) / ( (float)maxVal - (float)minVal ) * 180.0f; sweep = sweep - start; Fill f = new Fill( Color.White, ggr.RegionColor, -( sweep / 2f ) ); ggr.Fill = f; ggr.StartAngle = start; ggr.SweepAngle = sweep; } } }
/// <summary> /// Calculate the <see cref="RectangleF"/> that will be used to define the bounding rectangle of /// the GasGaugeNeedle. /// </summary> /// <remarks>This rectangle always lies inside of the <see cref="Chart.Rect"/>, and it is /// normally a square so that the pie itself is not oval-shaped.</remarks> /// <param name="g"> /// A graphic device object to be drawn into. This is normally e.Graphics from the /// PaintEventArgs argument to the Paint() method. /// </param> /// <param name="pane"> /// A reference to the <see cref="ZedGraph.GraphPane"/> object that is the parent or /// owner of this object. /// </param> /// <param name="scaleFactor"> /// The scaling factor to be used for rendering objects. This is calculated and /// passed down by the parent <see cref="ZedGraph.GraphPane"/> object using the /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust /// font sizes, etc. according to the actual size of the graph. /// </param> /// <param name="chartRect">The <see cref="RectangleF"/> (normally the <see cref="Chart.Rect"/>) /// that bounds this pie.</param> /// <returns></returns> public static RectangleF CalcRectangle(Graphics g, GraphPane pane, float scaleFactor, RectangleF chartRect) { RectangleF nonExpRect = chartRect; nonExpRect.Height -= pane.GasGaugeRegionWidth / 2; nonExpRect.Width -= pane.GasGaugeRegionWidth; float width = nonExpRect.Width; float height; double sineVal = Math.Sin((Math.PI / 180) * ((pane.Angle - 180) / 2)); //take at least half a circle if (pane.Angle <= 180) { height = (width / 2); } else { height = (float)((width / 2) + ((width / 2) * sineVal)); nonExpRect.Height -= (float)(pane.GasGaugeRegionWidth / 2 * sineVal); } height *= 1.05f; float ratio = width / height; if ((ratio * nonExpRect.Height) > nonExpRect.Width) { //Scale based on width nonExpRect.Height = nonExpRect.Width; } else { //Scale based on heights nonExpRect.Width = nonExpRect.Height * ratio; nonExpRect.Height = nonExpRect.Width; } //define the place on the pane nonExpRect.X = (pane.Rect.Width - nonExpRect.Width) / 2; nonExpRect.Y = pane.Chart.Rect.Top + pane.GasGaugeRegionWidth / 2; GasGaugeRegion.CalculateGasGuageParameters(pane); foreach (CurveItem curve in pane.CurveList) { if (curve is GasGaugeRegion) { GasGaugeRegion gg = (GasGaugeRegion)curve; gg._boundingRectangle = nonExpRect; } } return(nonExpRect); }
/// <summary> /// The Copy Constructor /// </summary> /// <param name="ggr">The <see cref="GasGaugeRegion"/> object from which to copy</param> public GasGaugeRegion(GasGaugeRegion ggr) : base(ggr) { _minValue = ggr._minValue; _maxValue = ggr._maxValue; _color = ggr._color; _startAngle = ggr._startAngle; _sweepAngle = ggr._sweepAngle; _border = ggr._border.Clone(); _labelDetail = ggr._labelDetail.Clone(); }
/// <summary> /// Calculate the values needed to properly display this <see cref="GasGaugeRegion"/>. /// </summary> /// <param name="pane"> /// A graphic device object to be drawn into. This is normally e.Graphics from the /// PaintEventArgs argument to the Paint() method. /// </param> public static void CalculateGasGuageParameters(GraphPane pane) { //loop thru slices and get total value and maxDisplacement double minVal = double.MaxValue; double maxVal = double.MinValue; foreach (CurveItem curve in pane.CurveList) { if (curve is GasGaugeRegion) { GasGaugeRegion ggr = (GasGaugeRegion)curve; if (maxVal < ggr.MaxValue) { maxVal = ggr.MaxValue; } if (minVal > ggr.MinValue) { minVal = ggr.MinValue; } } } //Calculate start and sweep angles for each of the GasGaugeRegion based on the min and max value foreach (CurveItem curve in pane.CurveList) { if (curve is GasGaugeRegion) { GasGaugeRegion ggr = (GasGaugeRegion)curve; float start; float sweep; if (pane.Clockwise) { start = ((float)ggr.MaxValue - (float)maxVal) / ((float)minVal - (float)maxVal) * pane.Angle; sweep = ((float)ggr.MinValue - (float)maxVal) / ((float)minVal - (float)maxVal) * pane.Angle; sweep = sweep - start; } else { start = ((float)ggr.MinValue - (float)minVal) / ((float)maxVal - (float)minVal) * pane.Angle; sweep = ((float)ggr.MaxValue - (float)minVal) / ((float)maxVal - (float)minVal) * pane.Angle; sweep = sweep - start; } Fill f = new Fill(ggr.RegionColorStart, ggr.RegionColorEnd, -(sweep / 2f)); ggr.Fill = f; ggr.StartAngle = start - (pane.Angle - 180) / 2; ggr.SweepAngle = sweep; } } }
/// <summary> /// Calculate the <see cref="RectangleF"/> that will be used to define the bounding rectangle of /// the GasGaugeNeedle. /// </summary> /// <remarks>This rectangle always lies inside of the <see cref="Chart.Rect"/>, and it is /// normally a square so that the pie itself is not oval-shaped.</remarks> /// <param name="g"> /// A graphic device object to be drawn into. This is normally e.Graphics from the /// PaintEventArgs argument to the Paint() method. /// </param> /// <param name="pane"> /// A reference to the <see cref="ZedGraph.GraphPane"/> object that is the parent or /// owner of this object. /// </param> /// <param name="scaleFactor"> /// The scaling factor to be used for rendering objects. This is calculated and /// passed down by the parent <see cref="ZedGraph.GraphPane"/> object using the /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust /// font sizes, etc. according to the actual size of the graph. /// </param> /// <param name="chartRect">The <see cref="RectangleF"/> (normally the <see cref="Chart.Rect"/>) /// that bounds this pie.</param> /// <returns></returns> public static RectangleF CalcRectangle(Graphics g, GraphPane pane, float scaleFactor, RectangleF chartRect) { RectangleF nonExpRect = chartRect; if ((2 * nonExpRect.Height) > nonExpRect.Width) { //Scale based on width float percentS = ((nonExpRect.Height * 2) - nonExpRect.Width) / (nonExpRect.Height * 2); nonExpRect.Height = ((nonExpRect.Height * 2) - ((nonExpRect.Height * 2) * percentS)); } else { nonExpRect.Height = nonExpRect.Height * 2; } nonExpRect.Width = nonExpRect.Height; float xDelta = (chartRect.Width / 2) - (nonExpRect.Width / 2); //Align Horizontally nonExpRect.X += xDelta; //nonExpRect.Y += -(float)0.025F * nonExpRect.Height; //nonExpRect.Y += ((chartRect.Height) - (nonExpRect.Height / 2)) - 10.0f; nonExpRect.Inflate(-(float)0.05F * nonExpRect.Height, -(float)0.05 * nonExpRect.Width); GasGaugeRegion.CalculateGasGuageParameters(pane); foreach (CurveItem curve in pane.CurveList) { if (curve is GasGaugeRegion) { GasGaugeRegion gg = (GasGaugeRegion)curve; gg._boundingRectangle = nonExpRect; } } return(nonExpRect); }
private void CreateGraph_GasGauge( ZedGraphControl zgc ) { GraphPane myPane = zgc.GraphPane; // Define the title myPane.Title.Text = "Gas Gauge Demo"; // Fill the pane with gray myPane.Fill = new Fill( Color.LightGray, Color.White, 45.0f ); // Fill the chart rect with blue myPane.Chart.Fill = new Fill( Color.White, Color.SkyBlue, 45.0f ); // Don't show any axes for the gas gauge myPane.XAxis.IsVisible = false; myPane.Y2Axis.IsVisible = false; myPane.YAxis.IsVisible = false; //Define needles; can add more than one GasGaugeNeedle gg1 = new GasGaugeNeedle( "Cereal", 30.0f, Color.Black ); GasGaugeNeedle gg2 = new GasGaugeNeedle( "Milk", 80.0f, Color.DarkGreen ); myPane.CurveList.Add( gg1 ); myPane.CurveList.Add( gg2 ); //Define all regions GasGaugeRegion ggr1 = new GasGaugeRegion( "Red", 20f, 33.0f, Color.Red ); GasGaugeRegion ggr2 = new GasGaugeRegion( "Yellow", 33.0f, 66.0f, Color.Yellow ); GasGaugeRegion ggr3 = new GasGaugeRegion( "Green", 66.0f, 100.0f, Color.Green ); // Add the curves myPane.CurveList.Add( ggr1 ); myPane.CurveList.Add( ggr2 ); myPane.CurveList.Add( ggr3 ); zgc.AxisChange(); }
public override void Draw(Graphics g, GraphPane pane, int pos, float scaleFactor) { if (pane.Chart._rect.Width <= 0 && pane.Chart._rect.Height <= 0) { _slicePath = null; } else { CalcRectangle(g, pane, scaleFactor, pane.Chart._rect); _slicePath = new GraphicsPath(); if (!_isVisible) { return; } RectangleF tRect = _boundingRectangle; if (tRect.Width >= 1 && tRect.Height >= 1) { SmoothingMode sMode = g.SmoothingMode; g.SmoothingMode = SmoothingMode.AntiAlias; RectangleF r = new RectangleF((tRect.X + (tRect.Width / 2)) - 1.0f, (tRect.Y + (tRect.Height / 2)) - 1.0f, 1.0f, 1.0f); using (LinearGradientBrush borderGradient = new LinearGradientBrush(tRect, Color.LightGray, Color.DarkGray, (360 - pane.Angle) / 2, true)) { float offset = 0f; using (Pen borderPen = new Pen(Color.Black, 3.0f)) { //draw a full black circle around the gauge offset = pane.GasGaugeRegionWidth - borderPen.Width; if (pane.GasGaugeBorder) { g.DrawArc(borderPen, (tRect.X - offset / 2), (tRect.Y - offset / 2), (tRect.Width + offset), (tRect.Height + offset), 0, 360); } } PointF[] pts = new PointF[2]; using (Matrix matrix = new Matrix()) { matrix.Translate(tRect.X + (tRect.Width / 2), tRect.Y + (tRect.Height / 2), MatrixOrder.Prepend); pts[0] = new PointF(((tRect.Height * -.40f) / 2.0f) * (float)Math.Cos(-SweepAngle * Math.PI / 180.0f), ((tRect.Height * -.40f) / 2.0f) * (float)Math.Sin(-SweepAngle * Math.PI / 180.0f)); pts[1] = new PointF((tRect.Width / 2.0f) * (float)Math.Cos(-SweepAngle * Math.PI / 180.0f), (tRect.Width / 2.0f) * (float)Math.Sin(-SweepAngle * Math.PI / 180.0f)); matrix.TransformPoints(pts); } //check which region is being pointed and take its color for the needle if (_dynamicColor) { foreach (CurveItem curve in pane.CurveList) { if (curve is GasGaugeRegion) { GasGaugeRegion gg = (GasGaugeRegion)curve; if (NeedleValue >= gg.MinValue && NeedleValue <= gg.MaxValue) { NeedleColor = gg.RegionColorStart; } } } } //draw a black needle behind the needle //to simulate a border using (Pen pEdge = new Pen(Color.Black, ((tRect.Height * .10f) / 2.0f))) { pEdge.EndCap = LineCap; pEdge.Width = NeedleWidth + 2; using (Pen p = new Pen(NeedleColor, ((tRect.Height * .10f) / 2.0f))) { p.EndCap = LineCap; p.Width = NeedleWidth; g.DrawLine(pEdge, pts[0].X, pts[0].Y, pts[1].X, pts[1].Y); g.DrawLine(p, pts[0].X, pts[0].Y, pts[1].X, pts[1].Y); } } //Fill center 10% with a gray gradient dot with a border; using (Fill f = new Fill(Color.White, Color.Gray)) { r.Inflate((tRect.Height * .10f), (tRect.Height * .10f)); using (LinearGradientBrush fillBrush = new LinearGradientBrush(r, Color.Gray, Color.White, (360 - pane.Angle) / 2, true)) { using (Pen borderPen = new Pen(borderGradient, 10)) { g.DrawPie(borderPen, r.X, r.Y, r.Width, r.Height, 90.0f, 360.0f); g.FillPie(fillBrush, r.X, r.Y, r.Width, r.Height, 90.0f, 360.0f); } //draw the label of the value in the middle of the dot //take a big fontsize but reduce if the text doesn't fit the dot if (pane.ShowGasGaugeValueLabel) { TextObj valueLabel = new TextObj(NeedleValue.ToString(), 0.5, (r.Top + (r.Bottom - r.Top) / 2) / pane.Rect.Bottom, ZedGraph.CoordType.PaneFraction); valueLabel.FontSpec.Size = 40; SizeF textsize = valueLabel.FontSpec.MeasureString(g, NeedleValue.ToString(), scaleFactor); while (textsize.Height > r.Width || textsize.Width > r.Height) { valueLabel.FontSpec.Size--; textsize = valueLabel.FontSpec.MeasureString(g, NeedleValue.ToString(), scaleFactor); } valueLabel.FontSpec.Border.IsVisible = false; valueLabel.FontSpec.Fill.IsVisible = false; foreach (Object o in pane.GraphObjList) { if (o is TextObj) { TextObj to = (TextObj)o; if (to.Location.TopLeft == valueLabel.Location.TopLeft) { pane.GraphObjList.Remove(to); break; } } } pane.GraphObjList.Add(valueLabel); } } } } g.SmoothingMode = sMode; } } }
private void tabPowerChannel_Enter(object sender, EventArgs e) { if (m_graphPowerChannel == null) { m_graphPowerChannel = new ZedGraphControl(); m_panelPowerChannel.Controls.Add(m_graphPowerChannel); m_graphPowerChannel.EditButtons = System.Windows.Forms.MouseButtons.Left; m_graphPowerChannel.IsAntiAlias = true; m_graphPowerChannel.IsEnableSelection = false; m_graphPowerChannel.Location = new System.Drawing.Point(5, 5); m_graphPowerChannel.Name = "zedPowerChannel"; m_graphPowerChannel.ScrollGrace = 0D; m_graphPowerChannel.ScrollMaxX = 0D; m_graphPowerChannel.ScrollMaxY = 0D; m_graphPowerChannel.ScrollMaxY2 = 0D; m_graphPowerChannel.ScrollMinX = 0D; m_graphPowerChannel.ScrollMinY = 0D; m_graphPowerChannel.ScrollMinY2 = 0D; m_graphPowerChannel.Size = new System.Drawing.Size(600, 300); m_graphPowerChannel.TabIndex = 49; m_graphPowerChannel.TabStop = false; m_graphPowerChannel.UseExtendedPrintDialog = true; m_graphPowerChannel.Visible = true; m_graphPowerChannel.GraphPane.Title.Text = "RF Explorer Channel Power Meter"; m_graphPowerChannel.GraphPane.Title.FontSpec.Size = 18f; m_graphPowerChannel.GraphPane.TitleGap = 6; m_graphPowerChannel.Dock = DockStyle.Fill; m_graphPowerChannel.ContextMenuBuilder += new ZedGraph.ZedGraphControl.ContextMenuBuilderEventHandler(this.objGraphPowerChannel_ContextMenuBuilder); //m_graphSpectrumAnalyzer.ZoomEvent += new ZedGraph.ZedGraphControl.ZoomEventHandler(this.zedSpectrumAnalyzer_ZoomEvent); m_graphPowerChannel.GraphPane.XAxis.IsVisible = false; m_graphPowerChannel.GraphPane.Y2Axis.IsVisible = false; m_graphPowerChannel.GraphPane.YAxis.IsVisible = false; m_graphPowerChannel.GraphPane.Border.IsVisible = false; //Define needles; can add more than one m_PowerChannelNeedle = new GasGaugeNeedle("Realtime", -30.0f, Color.Blue); m_PowerChannelNeedle.NeedleWidth = 10f; m_PowerChannelNeedle.NeedleColor = Color.Blue; m_PowerChannelNeedle.Label.IsVisible = false; m_PowerChannelNeedle.LineCap = LineCap.ArrowAnchor; m_graphPowerChannel.GraphPane.CurveList.Add(m_PowerChannelNeedle); //Define all regions m_PowerChannelRegion_Low = new GasGaugeRegion("Low", -120.0f, -90.0f, Color.Blue); m_PowerChannelRegion_Low.HasLabel = true; m_PowerChannelRegion_Medium = new GasGaugeRegion("Medium", -90.0f, -30.0f, Color.LightBlue); m_PowerChannelRegion_High = new GasGaugeRegion("High", -30.0f, 0.0f, Color.Red); m_PowerChannelRegion_High.HasLabel = true; m_PowerChannelRegion_Low.Label.IsVisible = false; m_PowerChannelRegion_Medium.Label.IsVisible = false; m_PowerChannelRegion_High.Label.IsVisible = false; //not working as intended //m_PowerChannelRegion_Low.RegionColorStart = Color.LightGreen; //m_PowerChannelRegion_Low.RegionColorEnd = Color.LightBlue; //m_PowerChannelRegion_Medium.RegionColorStart = Color.LightBlue; //m_PowerChannelRegion_Medium.RegionColorEnd = Color.Blue; //m_PowerChannelRegion_High.RegionColorStart = Color.Blue; //m_PowerChannelRegion_High.RegionColorEnd = Color.Red; m_PowerChannelText = new TextObj("No data available", 0.5, 0.25, CoordType.PaneFraction); m_PowerChannelText.IsClippedToChartRect = false; m_PowerChannelText.FontSpec.FontColor = Color.DarkBlue; m_PowerChannelText.Location.AlignH = AlignH.Center; m_PowerChannelText.Location.AlignV = AlignV.Center; m_PowerChannelText.FontSpec.IsBold = false; m_PowerChannelText.FontSpec.Size = 16f; m_PowerChannelText.FontSpec.Border.IsVisible = false; m_PowerChannelText.FontSpec.Fill.IsVisible = false; m_PowerChannelText.FontSpec.StringAlignment = StringAlignment.Center; m_PowerChannelText.FontSpec.Family = "Arial"; m_graphPowerChannel.GraphPane.GraphObjList.Add(m_PowerChannelText); // Add the curves m_graphPowerChannel.GraphPane.CurveList.Add(m_PowerChannelRegion_Low); m_graphPowerChannel.GraphPane.CurveList.Add(m_PowerChannelRegion_Medium); m_graphPowerChannel.GraphPane.CurveList.Add(m_PowerChannelRegion_High); m_graphPowerChannel.GraphPane.Angle = 150; m_graphPowerChannel.GraphPane.GasGaugeRegionWidth = 25; m_graphPowerChannel.GraphPane.GasGaugeBorder = false; m_graphPowerChannel.GraphPane.ShowGasGaugeValueLabel = false; //needs better code to paint value + unit m_graphPowerChannel.GraphPane.HasLabel = false; //needs better code to paint values m_graphPowerChannel.GraphPane.Border.IsVisible = false; m_graphPowerChannel.GraphPane.Chart.Border.IsVisible = false; m_graphPowerChannel.GraphPane.Clockwise = true; m_graphPowerChannel.AxisChange(); } DisplayGroups(); m_tabPowerChannel.Invalidate(); }
/// <summary> /// Gas gauge chart. /// </summary> /// <param name="query">The query.</param> /// <param name="_options">GraphOptions.</param> /// <param name="binaryOutput">if set to <c>true</c> the image will output in the response stream.</param> /// <returns></returns> public static System.Drawing.Bitmap GasGauge( string query, Dictionary<string, object> _options, bool binaryOutput ) { ( "FUNCTION /w binaryStream gasGauge" ).Debug( 10 ); JToken jtOpt = JToken.FromObject( _options ); JsonSerializer serializer = new JsonSerializer(); GraphOptions options = null; using( JTokenReader jtr = new JTokenReader( jtOpt ) ) { options = ( GraphOptions )serializer.Deserialize( jtr, typeof( GraphOptions ) ); } GraphPane myPane = new GraphPane( new System.Drawing.Rectangle( 0, 0, options.Width, options.Height ), options.Title, "", "" ); myPane.Title.Text = options.Title; // Define the title myPane.Title.Text = "Gas Gauge Demo"; // Fill the pane with gray myPane.Fill = new Fill( System.Drawing.Color.LightGray, System.Drawing.Color.White, 45.0f ); // Fill the chart rect with blue myPane.Chart.Fill = new Fill( System.Drawing.Color.White, System.Drawing.Color.SkyBlue, 45.0f ); // Don't show any axes for the gas gauge myPane.XAxis.IsVisible = false; myPane.Y2Axis.IsVisible = false; myPane.YAxis.IsVisible = false; //Define needles; can add more than one GasGaugeNeedle gg1 = new GasGaugeNeedle( "Cereal", 30.0f, System.Drawing.Color.Black ); GasGaugeNeedle gg2 = new GasGaugeNeedle( "Milk", 80.0f, System.Drawing.Color.DarkGreen ); myPane.CurveList.Add( gg1 ); myPane.CurveList.Add( gg2 ); //Define all regions GasGaugeRegion ggr1 = new GasGaugeRegion( "Red", 0.0f, 33.0f, System.Drawing.Color.Red ); GasGaugeRegion ggr2 = new GasGaugeRegion( "Yellow", 33.0f, 66.0f, System.Drawing.Color.Yellow ); GasGaugeRegion ggr3 = new GasGaugeRegion( "Green", 66.0f, 100.0f, System.Drawing.Color.Green ); // Add the curves myPane.CurveList.Add( ggr1 ); myPane.CurveList.Add( ggr2 ); myPane.CurveList.Add( ggr3 ); System.Drawing.Bitmap image = myPane.GetImage( true ); if( binaryOutput ) { using( MemoryStream ms = new MemoryStream() ) { image.Save( ms, System.Drawing.Imaging.ImageFormat.Png ); if(HttpContext.Current!=null){ HttpContext.Current.Response.Clear(); HttpContext.Current.Response.ContentType = "image/png"; HttpContext.Current.Response.AddHeader( "Expires", "0" );/* RFC 2616 14.21 Content has already expired */ HttpContext.Current.Response.AddHeader( "Cache-Control", "no-store" );/* RFC 2616 14.9.2 Don't ever cache */ HttpContext.Current.Response.AddHeader( "Pragma", "no-store" );/* RFC 2616 14.32 Pragma - same as cache control */ ms.WriteTo( HttpContext.Current.Response.OutputStream ); } } image.Dispose(); } return image; }
public override void Draw(Graphics g, GraphPane pane, int pos, float scaleFactor) { if (pane.Chart._rect.Width <= 0 && pane.Chart._rect.Height <= 0) { _slicePath = null; } else { CalcRectangle(g, pane, scaleFactor, pane.Chart._rect); _slicePath = new GraphicsPath(); if (!_isVisible) { return; } RectangleF tRect = _boundingRectangle; if (tRect.Width >= 1 && tRect.Height >= 1) { SmoothingMode sMode = g.SmoothingMode; g.SmoothingMode = SmoothingMode.AntiAlias; _slicePath.AddPie(tRect.X, tRect.Y, tRect.Width, tRect.Height, -StartAngle, -SweepAngle); float avgAngle = 90 - ((SweepAngle / 2) + StartAngle); RectangleF gradientrect = new RectangleF(tRect.X - 10, tRect.Y - 10, tRect.Width + 20, tRect.Height + 20); using (LinearGradientBrush linearBrush = new LinearGradientBrush(gradientrect, RegionColorStart, RegionColorEnd, avgAngle)) { using (Pen regionPen = new Pen(linearBrush, pane.GasGaugeRegionWidth)) { g.DrawArc(regionPen, tRect.X, tRect.Y, tRect.Width, tRect.Height, -StartAngle, -SweepAngle); } } if (this.Border.IsVisible) { using (Pen borderPen = _border.GetPen(pane, scaleFactor)) { g.DrawPie(borderPen, tRect.X, tRect.Y, tRect.Width, tRect.Height, -StartAngle, -SweepAngle); } } //draw labels for the region limits if (pane.HasLabel || HasLabel) { double absmax = 0; double absmin = MinValue; foreach (object gg in pane.CurveList) { if (gg is GasGaugeRegion) { GasGaugeRegion ggr = (GasGaugeRegion)gg; if (absmax < ggr.MaxValue) { absmax = ggr.MaxValue; } if (absmin > ggr.MinValue) { absmin = ggr.MinValue; } } } DrawLabelValue(pane, (StartAngle + SweepAngle), ref m_LabelMin, MinValue); DrawLabelValue(pane, StartAngle, ref m_LabelMax, MaxValue); } else { if (m_LabelMin != null) { m_LabelMin.IsVisible = false; } if (m_LabelMax != null) { m_LabelMax.IsVisible = false; } } g.SmoothingMode = sMode; } } }