Esempio n. 1
0
		public SolidText(string text, FontX3D font)
		{
			_text = text;
			_fontSize = font.Size;
			_depth = font.Depth;
			_font = font;
		}
Esempio n. 2
0
			public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
			{
				var font = (FontX)info.GetValue("Font", null);
				var depth = info.GetDouble("Depth");
				var s = new FontX3D(font, depth);
				return s;
			}
Esempio n. 3
0
 public SolidText(string text, FontX3D font)
 {
     _text     = text;
     _fontSize = font.Size;
     _depth    = font.Depth;
     _font     = font;
 }
Esempio n. 4
0
        public virtual VectorD3D MeasureString(string text, FontX3D font)
        {
            EnsureGraphicsCreated();
            var size = _graphics.MeasureString(text, Altaxo.Graph.Gdi.GdiFontManager.ToGdi(font.Font), new System.Drawing.PointF(0, 0), _stringFormat);

            return(new VectorD3D(size.Width, size.Height, font.Depth));
        }
Esempio n. 5
0
            public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                var font  = (FontX)info.GetValue("Font", null);
                var depth = info.GetDouble("Depth");
                var s     = new FontX3D(font, depth);

                return(s);
            }
Esempio n. 6
0
        public virtual FontInfo GetFontInformation(FontX3D font)
        {
            // get some properties of the font
            EnsureGraphicsCreated();
            var    gdiFont      = Altaxo.Graph.Gdi.GdiFontManager.ToGdi(font.Font);
            double size         = gdiFont.Size;
            double cyLineSpace  = gdiFont.GetHeight(_graphics); // space between two lines
            int    iCellSpace   = gdiFont.FontFamily.GetLineSpacing(gdiFont.Style);
            int    iCellAscent  = gdiFont.FontFamily.GetCellAscent(gdiFont.Style);
            int    iCellDescent = gdiFont.FontFamily.GetCellDescent(gdiFont.Style);
            double cyAscent     = cyLineSpace * iCellAscent / iCellSpace;
            double cyDescent    = cyLineSpace * iCellDescent / iCellSpace;

            return(new FontInfo(cyLineSpace, cyAscent, cyDescent, size));
        }
Esempio n. 7
0
		public virtual FontInfo GetFontInformation(FontX3D font)
		{
			// get some properties of the font
			EnsureGraphicsCreated();
			var gdiFont = Altaxo.Graph.Gdi.GdiFontManager.ToGdi(font.Font);
			double size = gdiFont.Size;
			double cyLineSpace = gdiFont.GetHeight(_graphics); // space between two lines
			int iCellSpace = gdiFont.FontFamily.GetLineSpacing(gdiFont.Style);
			int iCellAscent = gdiFont.FontFamily.GetCellAscent(gdiFont.Style);
			int iCellDescent = gdiFont.FontFamily.GetCellDescent(gdiFont.Style);
			double cyAscent = cyLineSpace * iCellAscent / iCellSpace;
			double cyDescent = cyLineSpace * iCellDescent / iCellSpace;

			return new FontInfo(cyLineSpace, cyAscent, cyDescent, size);
		}
Esempio n. 8
0
		public virtual VectorD3D MeasureString(string text, FontX3D font)
		{
			EnsureGraphicsCreated();
			var size = _graphics.MeasureString(text, Altaxo.Graph.Gdi.GdiFontManager.ToGdi(font.Font), new System.Drawing.PointF(0, 0), _stringFormat);
			return new VectorD3D(size.Width, size.Height, font.Depth);
		}
			public MeasuredLabelItem(IGraphicsContext3D g, FontX3D font, string itemtext, double lineSpacing, Alignment horizontalAlignment, Alignment verticalAlignment, Alignment textBlockAligment)
			{
				_text = itemtext.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
				_stringSize = new VectorD3D[_text.Length];
				_font = font;
				_horizontalAlignment = horizontalAlignment;
				_verticalAlignment = verticalAlignment;
				_textBlockAligment = textBlockAligment;
				_lineSpacing = lineSpacing;
				_size = VectorD3D.Empty;
				var bounds = RectangleD3D.Empty;
				var position = PointD3D.Empty;
				for (int i = 0; i < _text.Length; ++i)
				{
					_stringSize[i] = g.MeasureString(_text[i], _font, PointD3D.Empty);
					bounds = bounds.WithRectangleIncluded(new RectangleD3D(position, _stringSize[i]));
					position = position.WithYPlus(-_stringSize[i].Y * _lineSpacing);
				}
				_size = bounds.Size;
			}
		/// <summary>
		/// Measures a couple of items and prepares them for being drawn.
		/// </summary>
		/// <param name="g">Graphics context.</param>
		/// <param name="font">Font used.</param>
		/// <param name="strfmt">String format used.</param>
		/// <param name="items">Array of items to be drawn.</param>
		/// <returns>An array of <see cref="IMeasuredLabelItem" /> that can be used to determine the size of each item and to draw it.</returns>
		public override IMeasuredLabelItem[] GetMeasuredItems(IGraphicsContext3D g, FontX3D font, AltaxoVariant[] items)
		{
			string[] titems = FormatItems(items);
			if (!string.IsNullOrEmpty(_prefix) || !string.IsNullOrEmpty(_suffix))
			{
				for (int i = 0; i < titems.Length; ++i)
					titems[i] = _prefix + titems[i] + _suffix;
			}

			MeasuredLabelItem[] litems = new MeasuredLabelItem[titems.Length];

			FontX3D localfont = font;

			for (int i = 0; i < titems.Length; ++i)
			{
				litems[i] = new MeasuredLabelItem(g, localfont, titems[i], _relativeLineSpacing, Alignment.Near, Alignment.Near, _textBlockAlignment);
			}

			return litems;
		}
			public MeasuredLabelItem(IGraphicsContext3D g, FontX3D font1, FontX3D font2, string firstpart, string exponent, string lastpart, double maxexposize)
			{
				_firstpart = firstpart;
				_exponent = exponent;
				_lastpart = lastpart;
				_font1 = font1;
				_font2 = font2;
				_size1 = g.MeasureString(_firstpart, _font1, PointD3D.Empty);
				_size2 = g.MeasureString(_exponent, _font2, new PointD3D(_size1.X, 0, 0));
				_size3 = g.MeasureString(_lastpart, _font1, PointD3D.Empty);
				_rightPadding = maxexposize - _size2.X;
			}
		public override IMeasuredLabelItem[] GetMeasuredItems(IGraphicsContext3D g, FontX3D font, AltaxoVariant[] items)
		{
			MeasuredLabelItem[] litems = new MeasuredLabelItem[items.Length];

			var localfont1 = font;
			var localfont2 = font.WithSize(font.Size * 2 / 3);

			string[] firstp = new string[items.Length];
			string[] middel = new string[items.Length];
			string[] expos = new string[items.Length];
			double[] mants = new double[items.Length];

			double 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((double)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, localfont2, PointD3D.Empty).X);
			}

			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, _prefix + firstp[i] + mid, expos[i], _suffix, maxexposize);
			}

			return litems;
		}
		public override void DrawItem(IGraphicsContext3D g, IMaterial brush, FontX3D font, Altaxo.Data.AltaxoVariant item, PointD3D morg)
		{
			string firstpart, middelpart, exponent;
			double mant;
			SplitInFirstPartAndExponent((double)item, out firstpart, out mant, out middelpart, out exponent);

			var size1 = g.MeasureString(_prefix + firstpart + middelpart, font, morg);
			g.DrawString(_prefix + firstpart + middelpart, font, brush, morg);
			var orginalY = morg.Y;
			morg = morg + new VectorD3D(size1.X, size1.Y, 0);
			var font2 = font.WithSize(font.Size * 2 / 3.0);
			g.DrawString(exponent, font2, brush, morg);
			if (!string.IsNullOrEmpty(_suffix))
			{
				var shiftX = g.MeasureString(exponent, font2, morg).X;
				morg = new PointD3D(morg.X + shiftX, orginalY, morg.Z);
			}

			if (!string.IsNullOrEmpty(_suffix))
			{
				g.DrawString(_suffix, font, brush, morg);
			}
		}
		public override VectorD3D MeasureItem(IGraphicsContext3D g, FontX3D font, Altaxo.Data.AltaxoVariant mtick, PointD3D morg)
		{
			string firstpart, middelpart, exponent;
			double mant;
			SplitInFirstPartAndExponent((double)mtick, out firstpart, out mant, out middelpart, out exponent);

			var size1 = g.MeasureString(_prefix + firstpart + middelpart, font, PointD3D.Empty);
			var size2 = g.MeasureString(exponent, font, PointD3D.Empty);
			var size3 = g.MeasureString(_suffix, font, PointD3D.Empty);

			return new VectorD3D(size1.X + size2.X + size3.X, size1.Y, font.Depth);
		}