Beispiel #1
0
		/// <summary>
		/// Handles the click event by opening the text tool dialog.
		/// </summary>
		/// <param name="e">EventArgs.</param>
		/// <param name="position">Mouse position.</param>
		/// <returns>The mouse state handler for handling the next mouse events.</returns>
		public override void OnClick(PointD2D position, MouseButtonEventArgs e)
		{
			base.OnClick(position, e);

			_cachedActiveLayer = _grac.ActiveLayer;
			_cachedActiveLayerTransformation = _cachedActiveLayer.TransformationFromRootToHere();
			_cachedActiveLayerTransformationGdi = (Matrix)_cachedActiveLayerTransformation;

			// get the page coordinates (in Point (1/72") units)
			var rootLayerCoord = _grac.ConvertMouseToRootLayerCoordinates(_positionLastMouseDownInMouseCoordinates);
			// with knowledge of the current active layer, calculate the layer coordinates from them
			var layerCoord = _cachedActiveLayerTransformation.InverseTransformPoint(rootLayerCoord);

			TextGraphic tgo = new TextGraphic(_grac.Doc.GetPropertyContext());
			tgo.SetParentSize(_grac.ActiveLayer.Size, false);
			tgo.Position = layerCoord;
			tgo.ParentObject = _grac.ActiveLayer;

			// deselect the text tool
			_grac.SetGraphToolFromInternal(GraphToolType.ObjectPointer);

			object tgoo = tgo;
			if (Current.Gui.ShowDialog(ref tgoo, "Text", false))
			{
				tgo = (TextGraphic)tgoo;
				if (tgo != null && !tgo.Empty)
				{
					_grac.ActiveLayer.GraphObjects.Add(tgo);
				}
			}

			/*
			TextControlDialog dlg = new TextControlDialog(_grac.Layers[_grac.CurrentLayerNumber],tgo);
			if(DialogResult.OK==dlg.ShowDialog(_grac.View.Window))
			{
				// add the resulting textgraphobject to the layer
				if(!dlg.SimpleTextGraphics.Empty)
				{
					_grac.Layers[_grac.CurrentLayerNumber].GraphObjects.Add(dlg.SimpleTextGraphics);
					_grac.RefreshGraph();
				}
			}
			*/
			_grac.SetGraphToolFromInternal(GraphToolType.ObjectPointer);
		}