Esempio n. 1
0
		/// <summary>
		/// Sets the instance of <see cref="GdiFontManager"/> here in this class (used by the static methods of this class).
		/// </summary>
		/// <param name="newInstance">The new instance.</param>
		public static void SetInstance(GdiFontManager newInstance)
		{
			var oldInstance = _instance;

			if (!object.ReferenceEquals(oldInstance, newInstance))
			{
				_instance = newInstance;

				oldInstance?.Dispose();
			}
		}
Esempio n. 2
0
        }     // end of function DoPaint

        public static FontX GetDefaultFont(Altaxo.Main.Properties.IReadOnlyPropertyBag context)
        {
            if (null != context)
            {
                return(context.GetValue(PropertyKeyDefaultFont));
            }
            else
            {
                return(GdiFontManager.GetFontX(GdiFontManager.GenericSansSerifFontFamilyName, 18, FontXStyle.Regular));
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Gets the default major tick length for all graphics in this graph, using the provided property context.
        /// </summary>
        /// <param name="context">The property context.</param>
        /// <returns>Default major tick length in points (1/72 inch).</returns>
        public static double GetDefaultMajorTickLength(Altaxo.Main.Properties.IReadOnlyPropertyBag context)
        {
            double result = 8;

            if (null != context)
            {
                var font = context.GetValue(PropertyKeyDefaultFont);
                using (var path = new GraphicsPath())
                {
                    path.AddString("0", GdiFontManager.ToGdi(font).FontFamily, (int)font.Style, (float)font.Size, new PointF(0, 0), StringFormat.GenericTypographic);
                    var bounds = path.GetBounds();

                    if (bounds.Width > 0)
                    {
                        result = 2 * Calc.Rounding.RoundToNumberOfSignificantDigits(bounds.Width / 2, 2, MidpointRounding.ToEven);
                    }
                }
            }
            return(result);
        }