/// <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(PointD3D position, MouseButtonEventArgs e) { base.OnClick(position, e); _cachedActiveLayer = _grac.ActiveLayer; _cachedActiveLayerTransformation = _cachedActiveLayer.TransformationFromRootToHere(); GetHitPointOnActiveLayerPlaneFacingTheCamera(_grac.Doc, _grac.ActiveLayer, position, out var hitPointOnLayerPlaneInLayerCoordinates, out var rotationsRadian); var tgo = new TextGraphic(_grac.Doc.GetPropertyContext()); tgo.SetParentSize(_cachedActiveLayer.Size, false); tgo.Position = hitPointOnLayerPlaneInLayerCoordinates; tgo.RotationX = (rotationsRadian.X / Math.PI) * 180; tgo.RotationY = (rotationsRadian.Y / Math.PI) * 180; tgo.RotationZ = (rotationsRadian.Z / Math.PI) * 180; tgo.ParentObject = _grac.ActiveLayer; // deselect the text tool _grac.CurrentGraphTool = 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); } } }
public void FixupInternalDataStructures(IPlotArea layer, Func <CSLineID, CSAxisInformation> GetAxisStyleInformation) { // update the logical values of the physical axes before if (_styleID.UsePhysicalValueOtherFirst) { // then update the logical value of this identifier double logicalValue = layer.Scales[_styleID.AxisNumberOtherFirst].PhysicalVariantToNormal(_styleID.PhysicalValueOtherFirst); _styleID = _styleID.WithLogicalValueOtherFirst(logicalValue); } if (_styleID.UsePhysicalValueOtherSecond) { // then update the logical value of this identifier double logicalValue = layer.Scales[_styleID.AxisNumberOtherSecond].PhysicalVariantToNormal(_styleID.PhysicalValueOtherSecond); _styleID = _styleID.WithLogicalValueOtherSecond(logicalValue); } CachedAxisInformation = GetAxisStyleInformation(_styleID); if (null != _customTickSpacing) { CSLineID styleID = _cachedAxisInfo.Identifier; Scale scale = layer.Scales[styleID.ParallelAxisNumber]; Altaxo.Data.AltaxoVariant org = scale.OrgAsVariant, end = scale.EndAsVariant; _customTickSpacing.PreProcessScaleBoundaries(ref org, ref end, false, false); _customTickSpacing.FinalProcessScaleBoundaries(org, end, scale); } if (null != _axisTitle) { _axisTitle.SetParentSize(layer.Size, false); } }
/// <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 = _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); var 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); }
private void SetAxisTitleString(CSLineID id, string value) { AxisStyle style = _axisStyles[id]; string oldtitle = (style == null || style.Title == null) ? null : style.Title.Text; string newtitle = (value == null || value == String.Empty) ? null : value; if (newtitle != oldtitle) { if (newtitle == null) { if (style != null) style.Title = null; } else if (_axisStyles.AxisStyleEnsured(id).Title != null) { _axisStyles[id].Title.Text = newtitle; } else { TextGraphic tg = new TextGraphic(this.GetPropertyContext()); CSAxisInformation info = CoordinateSystem.GetAxisStyleInformation(id); tg.SetParentSize(this.Size, false); SetDefaultAxisTitlePositionAndOrientation(tg, id, info); tg.Text = newtitle; _axisStyles.AxisStyleEnsured(id).Title = tg; } } }