internal void SetValue( Source[] sources, Hashtable sourceIndex, ValueFormatter vFormat ) { try { double val = sources[ (int) sourceIndex[sourceName] ].GetAggregate( aggregate ); double oldBase = vFormat.Base; if (baseValue != -1) vFormat.SetBase(baseValue); vFormat.SetFormat( val, numDec, strLen ); vFormat.SetScaling( normalScale, uniformScale ); string valueStr = vFormat.FormattedValue; string prefix = vFormat.Prefix; // Replace all values for (int i = 0; i < oList.Count; i += 2 ) { string str = (string) oList[i]; str = VALUE_PATTERN.Replace(str, valueStr); str = str.Replace(VALUE_MARKER, valueStr); if ( normalScale ) str = str.Replace(SCALE_MARKER, prefix); if ( uniformScale ) str = str.Replace(UNIFORM_SCALE_MARKER, prefix); oList[i] = str ; } if (baseValue != -1) vFormat.SetBase(oldBase); } catch (Exception) { throw new RrdException( "Could not find datasource: " + sourceName ); } }
internal Grapher( RrdGraphDef graphDef, RrdGraph rrdGraph ) { this.graphDef = graphDef; this.rrdGraph = rrdGraph; // Set font dimension specifics if ( graphDef.DefaultFont != null ) normal_font = graphDef.DefaultFont; if ( graphDef.TitleFont != null ) title_font = graphDef.TitleFont; normalFontColor = graphDef.DefaultFontColor; nfont_height = (int) normal_font.GetHeight(); // MONO FIX: Font.GetHeight() always returns 0 on mono 1.0 if (nfont_height == 0) nfont_height = (int)normal_font.Size; nfont_width = nfont_height / 2+1 ; sf = StringFormat.GenericDefault; sf.FormatFlags = StringFormatFlags.MeasureTrailingSpaces; // Bold font is higher tfont_height = (int) title_font.GetHeight(); // MONO FIX: Font.GetHeight() always returns 0 on mono 1.0 if (tfont_height == 0) tfont_height = (int)title_font.Size; tfont_width = tfont_height / 2 +1; // Create the shared valueformatter valueFormat = new ValueFormatter( graphDef.BaseValue, graphDef.ScaleIndex ); // Set default graph stroke defaultPen = new Pen(Color.Black); dashPen = new Pen(Color.Black, 1); defaultBrush = new SolidBrush(Color.White); }