Example #1
0
		/// <summary>
		/// Draws an <see cref="InvariantTextPrimitive"/>.  Must be overridden and implemented.
		/// </summary>
		protected abstract void DrawTextPrimitive(InvariantTextPrimitive textPrimitive);
Example #2
0
		/// <summary>
		/// Draws a text primitive to the specified destination buffer.
		/// </summary>
		/// <param name="buffer">The destination buffer.</param>
		/// <param name="brush">A GDI brush to use for drawing.</param>
		/// <param name="fontFactory">A GDI font factory to use for drawing.</param>
		/// <param name="text">The text primitive to be drawn.</param>
		/// <param name="dpi">The intended output DPI.</param>
		public static void DrawTextPrimitive(IGdiBuffer buffer, SolidBrush brush, FontFactory fontFactory, InvariantTextPrimitive text, float dpi = _nominalScreenDpi)
		{
			text.CoordinateSystem = CoordinateSystem.Destination;
			try
			{
				// We adjust the font size depending on the scale so that it's the same size
				// irrespective of the zoom
				var fontSize = CalculateScaledFontPoints(text.SizeInPoints, dpi);
				var font = fontFactory.GetFont(text.Font, fontSize, FontStyle.Regular, GraphicsUnit.Point, FontFactory.GenericSansSerif);

				// Calculate how big the text will be so we can set the bounding box
				text.Dimensions = buffer.Graphics.MeasureString(text.Text, font);

				// Draw drop shadow
				brush.Color = Color.Black;

				var dropShadowOffset = new SizeF(1, 1);
				var boundingBoxTopLeft = new PointF(text.BoundingBox.Left, text.BoundingBox.Top);

				buffer.Graphics.DrawString(
					text.Text,
					font,
					brush,
					boundingBoxTopLeft + dropShadowOffset);

				// Draw text
				brush.Color = text.Color;

				buffer.Graphics.DrawString(
					text.Text,
					font,
					brush,
					boundingBoxTopLeft);
			}
			finally
			{
				text.ResetCoordinateSystem();
			}
		}
Example #3
0
		/// <summary>
		/// Draws an <see cref="InvariantTextPrimitive"/>.
		/// </summary>
		protected override void DrawTextPrimitive(InvariantTextPrimitive textPrimitive)
		{
			textPrimitive.CoordinateSystem = CoordinateSystem.Destination;

			// We adjust the font size depending on the scale so that it's the same size
			// irrespective of the zoom
			var fontSize = CalculateScaledFontPoints(textPrimitive.SizeInPoints, Dpi);
			Font font = CreateFont(textPrimitive.Font, fontSize, FontStyle.Regular, GraphicsUnit.Point, _defaultFont);

			// Calculate how big the text will be so we can set the bounding box
			textPrimitive.Dimensions = Surface.FinalBuffer.Graphics.MeasureString(textPrimitive.Text, font);

			// Draw drop shadow
			_brush.Color = Color.Black;

			SizeF dropShadowOffset = new SizeF(1, 1);
			PointF boundingBoxTopLeft = new PointF(textPrimitive.BoundingBox.Left, textPrimitive.BoundingBox.Top);

			Surface.FinalBuffer.Graphics.DrawString(
				textPrimitive.Text,
				font,
				_brush,
				boundingBoxTopLeft + dropShadowOffset);

			// Draw text
			_brush.Color = textPrimitive.Color;

			Surface.FinalBuffer.Graphics.DrawString(
				textPrimitive.Text,
				font,
				_brush,
				boundingBoxTopLeft);

			font.Dispose();

			textPrimitive.ResetCoordinateSystem();
		}
Example #4
0
		private static IControlGraphic CreateTextAreaGraphic()
		{
			InvariantTextPrimitive textArea = new InvariantTextPrimitive();
			TextEditControlGraphic controlGraphic = new TextEditControlGraphic(new MoveControlGraphic(textArea));
			controlGraphic.DeleteOnEmpty = true;

			StandardStatefulGraphic statefulGraphic = new StandardStatefulGraphic(controlGraphic);
			statefulGraphic.State = statefulGraphic.CreateInactiveState();

			ContextMenuControlGraphic contextGraphic = new ContextMenuControlGraphic(typeof (TextCalloutTool).FullName, "basicgraphic-menu", null, statefulGraphic);
			contextGraphic.Actions = new ToolSet(new GraphicToolExtensionPoint(), new GraphicToolContext(contextGraphic)).Actions;

			return contextGraphic;
		}
Example #5
0
		/// <summary>
		/// Draws an <see cref="InvariantTextPrimitive"/>.
		/// </summary>
		protected override void DrawTextPrimitive(InvariantTextPrimitive textPrimitive)
		{
			DrawTextPrimitive(Surface.FinalBuffer, _brush, _fontFactory, textPrimitive, Dpi);
		}
Example #6
0
				protected override void Dispose(bool disposing)
				{
					base.DecoratedGraphic.VisualStateChanged -= DecoratedGraphic_VisualStateChanged;

					if (_textGraphic != null)
					{
						_textGraphic.BoundingBoxChanged -= TextGraphic_BoundingBoxChanged;
						_textGraphic = null;
					}

					_topParent = null;

					base.Dispose(disposing);
				}
Example #7
0
				public SliceControlGraphic(IGraphic subject, ResliceToolGraphic topParent) : base(subject)
				{
					_topParent = topParent;
					_textGraphic = new InvariantTextPrimitive();
					_textGraphic.BoundingBoxChanged += TextGraphic_BoundingBoxChanged;
					base.Graphics.Add(_textGraphic);
					base.DecoratedGraphic.VisualStateChanged += DecoratedGraphic_VisualStateChanged;
				}
        private static IGraphic TextAnnotationToGraphic(aim_dotnet.TextAnnotation textAnnotation, string shapeLabel)
        {
            Platform.CheckForNullReference(textAnnotation.ConnectorPoints, "ConnectorPoints");
            Platform.CheckForNullReference(textAnnotation.ConnectorPoints.SpatialCoordinateCollection, "SpatialCoordinateCollection");
            Platform.CheckArgumentRange(textAnnotation.ConnectorPoints.SpatialCoordinateCollection.Count, 1, 2, "SpatialCoordinateCollection");

            if (textAnnotation.ConnectorPoints == null || textAnnotation.ConnectorPoints.SpatialCoordinateCollection == null)
                return null;

            var graphicText = shapeLabel.Trim();
            graphicText = string.IsNullOrEmpty(graphicText)
                          	? textAnnotation.Text.Trim()
                          	: string.Format("{0}:\r\n{1}", graphicText, textAnnotation.Text.Trim());
            switch (textAnnotation.ConnectorPoints.SpatialCoordinateCollection.Count)
            {
                case 1:
                    {
                        var textPrimitive = new InvariantTextPrimitive(graphicText);
                        textPrimitive.Location = AsPointF(textAnnotation.ConnectorPoints.SpatialCoordinateCollection[0]);
                        var statefulGraphic = new StandardStatefulGraphic(textPrimitive);
                        statefulGraphic.State = statefulGraphic.CreateInactiveState();
                        return statefulGraphic;
                    }
                    break;
                case 2:
                    {
                        var callout = new CalloutGraphic(graphicText);
                        callout.LineStyle = LineStyle.Solid;
                        callout.ShowArrowhead = true;
                        callout.AnchorPoint = AsPointF(textAnnotation.ConnectorPoints.SpatialCoordinateCollection[0]);
                        callout.TextLocation = AsPointF(textAnnotation.ConnectorPoints.SpatialCoordinateCollection[1]);
                        var statefulGraphic = new StandardStatefulGraphic(callout);
                        statefulGraphic.State = statefulGraphic.CreateInactiveState();
                        return statefulGraphic;
                    }
                    break;
                default:
                    break;
            }
            return null;
        }
		public ReferenceLineGraphic()
		{
			base.Graphics.Add(_text = new InvariantTextPrimitive());
			base.Graphics.Add(_line = new LinePrimitive());

			_text.BoundingBoxChanged += OnTextBoundingBoxChanged;
		}
Example #10
0
        public static void DrawTextPrimitive(IGdiBuffer buffer, SolidBrush brush, IFontFactory fontFactory, InvariantTextPrimitive text, float dpi = _nominalScreenDpi)
	    {
            var fakeFactory = new LegacyGdiObjectFactory(fontFactory, brush);
            DrawTextPrimitive(buffer, fakeFactory, text, dpi);
	    }