public override void DrawItem(Graphics g, BrushX brush, FontX font, StringFormat strfmt, Altaxo.Data.AltaxoVariant item, PointF morg) { SplitInFirstPartAndExponent(item, out var firstpart, out var mant, out var middelpart, out var exponent); var gdiFont = GdiFontManager.ToGdi(font); SizeF size1 = g.MeasureString(_prefix + firstpart + middelpart, gdiFont, morg, strfmt); g.DrawString(_prefix + firstpart + middelpart, gdiFont, brush, morg, strfmt); var orginalY = morg.Y; morg.X += size1.Width; morg.Y += size1.Height / 3; FontX font2 = font.WithSize(font.Size * 2 / 3.0); var gdiFont2 = GdiFontManager.ToGdi(font2); g.DrawString(exponent, gdiFont2, brush, morg); if (!string.IsNullOrEmpty(_suffix)) { morg.X += g.MeasureString(exponent, gdiFont2, morg, strfmt).Width; morg.Y = orginalY; } if (!string.IsNullOrEmpty(_suffix)) { g.DrawString(_suffix, gdiFont, brush, morg, strfmt); } }
private void EhFontSize_SelectionChangeCommitted(object sender, System.Windows.DependencyPropertyChangedEventArgs e) { if (FontX != null) { FontX = FontX.WithSize(_cbFontSize.SelectedQuantityAsValueInPoints); OnSelectedFontChanged(); } }
public IEnumerable <(string PropertyName, object PropertyValue, Action <object> PropertySetter)> GetRoutedProperties(string propertyName) { switch (propertyName) { case "FontSize": yield return(propertyName, _font.Size, (value) => Font = _font.WithSize((double)value)); break; case "FontFamily": yield return(propertyName, _font.FontFamilyName, (value) => Font = _font.WithFamily((string)value)); break; } yield break; }
public override IMeasuredLabelItem[] GetMeasuredItems(Graphics g, FontX font, StringFormat strfmt, Altaxo.Data.AltaxoVariant[] items) { var litems = new MeasuredLabelItem[items.Length]; FontX localfont1 = font; FontX localfont2 = font.WithSize(font.Size * 2 / 3); var localstrfmt = (StringFormat)strfmt.Clone(); string[] firstp = new string[items.Length]; string[] middel = new string[items.Length]; string[] expos = new string[items.Length]; double[] mants = new double[items.Length]; float maxexposize = 0; int firstpartmin = int.MaxValue; int firstpartmax = int.MinValue; for (int i = 0; i < items.Length; ++i) { string firstpart, exponent; if (items[i].IsType(Altaxo.Data.AltaxoVariant.Content.VDouble)) { SplitInFirstPartAndExponent(items[i], out firstpart, out mants[i], out middel[i], out exponent); if (exponent.Length > 0) { firstpartmin = Math.Min(firstpartmin, firstpart.Length); firstpartmax = Math.Max(firstpartmax, firstpart.Length); } } else { firstpart = items[i].ToString(); middel[i] = string.Empty; exponent = string.Empty; } firstp[i] = firstpart; expos[i] = exponent; maxexposize = Math.Max(maxexposize, g.MeasureString(exponent, GdiFontManager.ToGdi(localfont2), new PointF(0, 0), strfmt).Width); } if (firstpartmax > 0 && firstpartmax > firstpartmin) // then we must use special measures to equilibrate the mantissa { firstp = NumericLabelFormattingAuto.FormatItems(mants); } for (int i = 0; i < items.Length; ++i) { string mid = string.Empty; if (!string.IsNullOrEmpty(expos[i])) { if (string.IsNullOrEmpty(firstp[i])) { mid = "10"; } else { mid = "\u00D710"; } } litems[i] = new MeasuredLabelItem(g, localfont1, localfont2, localstrfmt, _prefix + firstp[i] + mid, expos[i], _suffix, maxexposize); } return(litems); }
public FontX3D WithSize(double newSize) { return(new FontX3D(_font.WithSize(newSize), _depth)); }