public bool Apply() { // read axis title _doc.TitleText = m_View.AxisTitle; if (null != _axisLineStyleController) { if (!_axisLineStyleController.Apply()) return false; else _doc.AxisLineStyle = (AxisLineStyle)_axisLineStyleController.ModelObject; } _doc.ShowMajorLabels = m_View.ShowMajorLabels; _doc.ShowMinorLabels = m_View.ShowMinorLabels; // if we have offset applying, create a brand new AxisStyle instance double offset = m_View.PositionOffset/100; if (0 != offset) { AxisStyle newDoc = new AxisStyle(CSLineID.FromIDandFirstLogicalOffset(_doc.StyleID, offset)); newDoc.CopyWithoutIdFrom(_doc); _doc = newDoc; } return true; // all ok }
public override void Paint(Graphics g, IPaintContext paintContext) { var layer = Altaxo.Main.AbsoluteDocumentPath.GetRootNodeImplementing<XYPlotLayer>(this); if (null == layer) { PaintErrorInvalidLayerType(g, paintContext); return; } Logical3D rBegin; layer.CoordinateSystem.LayerToLogicalCoordinates(X, Y, out rBegin); Logical3D rEnd = rBegin; switch (_scaleSpanType) { case FloatingScaleSpanType.IsLogicalValue: rEnd[_scaleNumber] = rBegin[_scaleNumber] + _scaleSpanValue; break; case FloatingScaleSpanType.IsPhysicalEndOrgDifference: { var physValue = layer.Scales[_scaleNumber].NormalToPhysicalVariant(rBegin[this._scaleNumber]); physValue += _scaleSpanValue; // to be replaced by the scale span var logValue = layer.Scales[_scaleNumber].PhysicalVariantToNormal(physValue); rEnd[_scaleNumber] = logValue; } break; case FloatingScaleSpanType.IsPhysicalEndOrgRatio: { var physValue = layer.Scales[_scaleNumber].NormalToPhysicalVariant(rBegin[this._scaleNumber]); physValue *= _scaleSpanValue; // to be replaced by the scale span var logValue = layer.Scales[_scaleNumber].PhysicalVariantToNormal(physValue); rEnd[_scaleNumber] = logValue; } break; } // axis style var csLineId = new CSLineID(_scaleNumber, rBegin); if (_axisStyle.StyleID != csLineId) { var propertyContext = this.GetPropertyContext(); var axStyle = new AxisStyle(new CSLineID(_scaleNumber, rBegin), false, false, false, null, propertyContext); axStyle.CopyWithoutIdFrom(_axisStyle); _axisStyle = axStyle; } var privScale = new ScaleSegment(layer.Scales[_scaleNumber], rBegin[_scaleNumber], rEnd[_scaleNumber], _scaleSegmentType); _tickSpacing.FinalProcessScaleBoundaries(privScale.OrgAsVariant, privScale.EndAsVariant, privScale); privScale.TickSpacing = _tickSpacing; var privLayer = new LayerSegment(layer, privScale, rBegin, rEnd, _scaleNumber); if (_background == null) { _axisStyle.Paint(g, paintContext, privLayer, privLayer.GetAxisStyleInformation); } else { // if we have a background, we paint in a dummy bitmap in order to measure all items // the real painting is done later on after painting the background. using (var bmp = new Bitmap(4, 4)) { using (Graphics gg = Graphics.FromImage(bmp)) { _axisStyle.Paint(gg, paintContext, privLayer, privLayer.GetAxisStyleInformation); } } } _cachedPath = _axisStyle.AxisLineStyle.GetObjectPath(privLayer, true); // calculate size information RectangleD2D bounds1 = _cachedPath.GetBounds(); if (_axisStyle.AreMinorLabelsEnabled) { var path = _axisStyle.MinorLabelStyle.GetSelectionPath(); if (path.PointCount > 0) { _cachedPath.AddPath(path, false); RectangleD2D bounds2 = path.GetBounds(); bounds1.ExpandToInclude(bounds2); } } if (_axisStyle.AreMajorLabelsEnabled) { var path = _axisStyle.MajorLabelStyle.GetSelectionPath(); if (path.PointCount > 0) { _cachedPath.AddPath(path, false); RectangleD2D bounds2 = path.GetBounds(); bounds1.ExpandToInclude(bounds2); } } ((ItemLocationDirectAutoSize)_location).SetSizeInAutoSizeMode(bounds1.Size); //this._leftTop = bounds1.Location - this.GetPosition(); //throw new NotImplementedException("debug the previous statement"); if (_background != null) { bounds1.Expand(_backgroundPadding); _background.Draw(g, bounds1); _axisStyle.Paint(g, paintContext, privLayer, privLayer.GetAxisStyleInformation); } }