Пример #1
0
		/// <summary>
		/// Updates the internal MindFusion.FlowChartX.Text.Text
		/// obejct when styled characteristics of
		/// a table's text have changed.
		/// </summary>
		private void updateText()
		{
			if (useStyledText)
			{
				Graphics graphics = flowChart.CreateGraphics();
				flowChart.setTransforms(graphics);

				// Create and setup styled text
				fcaption = new Text.StyledText();
				fcaption.Setup(caption, graphics, Font);

				graphics.Dispose();
			}
			else
			{
				// Text won't be used
				fcaption = null;
			}
		}
Пример #2
0
		private bool DoLayout(Text text, Polygon polygon, LayoutOptions options)
		{
			// Initialize internal variables
			_text = text;
			_polygon = polygon;
			_options = options;
			_bounds = _polygon.Bounds;

			_fits = false;

			// Build the h-lines according to the layout settings
			BuildLines();

			// Find out the starting line and the total number
			// of lines needed to layout the text.
			_totalLines = 1;
			_startLine = FirstLine(_totalLines);
			if (GetHLines(_totalLines).Count == 0)
				return false;

			do
			{
				// Check if the text fits within the h-lines
				// in the range [_startLine, _startLine + _totalLines)
				int iword = 0;
				PointList hLine = null;

				for (int i = _startLine; i < _startLine + _totalLines; i++)
				{
					hLine = GetHLines(_totalLines)[i] as PointList;
					for (int j = 0; j < hLine.Count; j += 2)
					{
						PointF pt1 = hLine[j];
						PointF pt2 = hLine[j + 1];
						RectangleF rc = new RectangleF(
							pt1.X, pt1.Y, pt2.X - pt1.X, pt2.Y - pt1.Y);

						bool newLine = false;
						iword = FitTextInRect(iword, rc, ref newLine);

						if (newLine)
							break;
						if (iword >= _text.Words.Count)
						{
							_fits = true;
							return true;
						}
					}
				}

				// If the text does not fit, increase the total
				// number of lines and recalculate the starting
				// line depending on v-alignment.
				_totalLines++;
				if (_totalLines > GetHLines(_totalLines).Count)
				{
					_totalLines--;
					return false;
				}
				_startLine = FirstLine(_totalLines);

				ArrayList hLines = GetHLines(_totalLines);
				if (_startLine + _totalLines > hLines.Count)
				{
					ArrayList hLines2 = GetHLines(_totalLines + 1);
					if (_totalLines > hLines2.Count)
					{
						// The text would not fit in the
						// polygon, so use all of the available
						// space to layout as much text as possible
						_totalLines = Math.Max(hLines.Count, hLines2.Count);
						_startLine = 0;
						return false;
					}
				}
			}
			while ((_startLine = FirstLine(_totalLines)) != -1);

			return false;
		}
Пример #3
0
		/// <summary>
		/// Layouts text inside polygonal area.
		/// </summary>
		public bool LayoutInPolygon(Text text,
			PointF[] polygon, LayoutOptions options)
		{
			if (polygon == null)
				return false;
			if (polygon.Length < 3)
				return false;
			if (text == null || text.RawText.Length == 0)
				return true;

			return DoLayout(text, new Polygon(new PointList(polygon)), options);
		}
Пример #4
0
		public bool LayoutInEllipse(Text text,
			RectangleF bounds, LayoutOptions options)
		{
			return DoLayout(text, new Polygon(bounds, 25), options);
		}
Пример #5
0
		public bool LayoutInRectangle(Text text,
			RectangleF rectangle, LayoutOptions options)
		{
			return DoLayout(text, new Polygon(rectangle), options);
		}
Пример #6
0
		/// <summary>
		/// Updates the internal MindFusion.FlowChartX.Text.Text
		/// obejct when styled / laid-out characteristics of
		/// the box' text have changed.
		/// </summary>
		private void updateText()
		{
			Graphics graphics = flowChart.CreateGraphics();
			flowChart.setTransforms(graphics);

			if (useStyledText)
			{
				// Create and setup styled text
				ftext = new Text.StyledText();
				ftext.Setup(text, graphics, Font);
			}
			else
			{
				if (useTextLayout)
				{
					// Create and setup plain text
					ftext = new Text.PlainText();
					ftext.Setup(text, graphics, Font);
				}
				else
				{
					// Text won't be used
					ftext = null;
				}
			}

			graphics.Dispose();
		}