/// <summary> /// Sets the selected pivot values for X and Y. Additionally, the reference size is required. /// </summary> /// <param name="pivotX">The pivot x value.</param> /// <param name="pivotY">The pivot y value.</param> /// <param name="referenceSize">Size of the reference area.</param> public void SetSelectedPivot(RADouble pivotX, RADouble pivotY, PointD2D referenceSize) { _pivotX = pivotX; _pivotY = pivotY; _percentLayerXSizeUnit.ReferenceQuantity = new DimensionfulQuantity(referenceSize.X, Units.Length.Point.Instance); _percentLayerYSizeUnit.ReferenceQuantity = new DimensionfulQuantity(referenceSize.Y, Units.Length.Point.Instance); _xSizeEnvironment = new QuantityWithUnitGuiEnvironment(GuiLengthUnits.Collection, _percentLayerXSizeUnit); _ySizeEnvironment = new QuantityWithUnitGuiEnvironment(GuiLengthUnits.Collection, _percentLayerYSizeUnit); _guiPivotX.UnitEnvironment = _xSizeEnvironment; _guiPivotY.UnitEnvironment = _ySizeEnvironment; _guiPivotX.SelectedQuantity = _pivotX.IsAbsolute ? new Units.DimensionfulQuantity(_pivotX.Value, Units.Length.Point.Instance) : new Units.DimensionfulQuantity(_pivotX.Value * 100, _percentLayerXSizeUnit); _guiPivotY.SelectedQuantity = _pivotY.IsAbsolute ? new Units.DimensionfulQuantity(_pivotY.Value, Units.Length.Point.Instance) : new Units.DimensionfulQuantity(_pivotY.Value * 100, _percentLayerYSizeUnit); if (CanUseRadioGridView()) { SetRadioButton(); SetUseOfRadioGrid(true); } else { SetUseOfRadioGrid(false); } SetVisibilityOfSwitchButton(); }
/// <summary> /// Copy operation. /// </summary> /// <param name="obj">The AxisStyle to copy from</param> public bool CopyFrom(object obj) { if (object.ReferenceEquals(this, obj)) { return(true); } var from = obj as AxisLineStyle; if (null == from) { return(false); } using (var suspendToken = SuspendGetToken()) { ChildCopyToMember(ref _axisPen, from._axisPen); _axisPosition = from._axisPosition; _showFirstDownMajorTicks = from._showFirstDownMajorTicks; _showFirstDownMinorTicks = from._showFirstDownMinorTicks; _showFirstUpMajorTicks = from._showFirstUpMajorTicks; _showFirstUpMinorTicks = from._showFirstUpMinorTicks; _majorTickLength = from._majorTickLength; ChildCopyToMember(ref _majorTickPen, from._majorTickPen); _minorTickLength = from._minorTickLength; ChildCopyToMember(ref _minorTickPen, from._minorTickPen); _cachedAxisStyleInfo = from._cachedAxisStyleInfo; EhSelfChanged(EventArgs.Empty); suspendToken.Resume(); } return(true); }
public override bool Apply(bool disposeController) { _doc.XPartitioning.Clear(); _doc.YPartitioning.Clear(); foreach (var val in _columnCollection) { if (object.ReferenceEquals(val.Unit, _percentLayerXSizeUnit)) { _doc.XPartitioning.Add(RADouble.NewRel(val.Value / 100)); } else { _doc.XPartitioning.Add(RADouble.NewAbs(val.AsValueIn(AUL.Point.Instance))); } } foreach (var val in _rowCollection) { if (object.ReferenceEquals(val.Unit, _percentLayerYSizeUnit)) { _doc.YPartitioning.Add(RADouble.NewRel(val.Value / 100)); } else { _doc.YPartitioning.Add(RADouble.NewAbs(val.AsValueIn(AUL.Point.Instance))); } } return(ApplyEnd(true, disposeController)); }
public virtual void SetRelativeSizePositionFromAbsoluteValues(PointD2D absSize, PointD2D absPos) { var oldSizeX = SizeX; var oldSizeY = SizeY; var oldPosX = PositionX; var oldPosY = PositionY; if (_parentSize.X == 0) { throw new InvalidOperationException("ParentSize.X is zero. This would lead to an undefined relative value!"); } if (_parentSize.Y == 0) { throw new InvalidOperationException("ParentSize.Y is zero. This would lead to an undefined relative value!"); } InternalSetSizeSilent( RADouble.NewRel(absSize.X / _parentSize.X), RADouble.NewRel(absSize.Y / _parentSize.Y) ); _positionX = RADouble.NewRel(absPos.X / _parentSize.X); _positionY = RADouble.NewRel(absPos.Y / _parentSize.Y); if (oldSizeX != _sizeX || oldSizeY != _sizeY || oldPosX != _positionX || oldPosY != _positionY) { EhSelfChanged(); } }
public LineShape(PointD2D startPosition, PointD2D endPosition, Altaxo.Main.Properties.IReadOnlyPropertyBag context) : this(startPosition, context) { _location.SizeX = RADouble.NewAbs(endPosition.X - startPosition.X); _location.SizeY = RADouble.NewAbs(endPosition.Y - startPosition.Y); }
protected virtual void InternalSetAbsoluteSizeSilent(PointD2D value) { RADouble sizeX, sizeY; if (_sizeX.IsAbsolute) { sizeX = RADouble.NewAbs(value.X); } else if (_parentSize.X != 0 && !double.IsNaN(_parentSize.X)) { sizeX = RADouble.NewRel(value.X / _parentSize.X); } else { throw new InvalidOperationException("_parentSize.X is undefined or zero"); } if (_sizeY.IsAbsolute) { sizeY = RADouble.NewAbs(value.Y); } else if (_parentSize.Y != 0 && !double.IsNaN(_parentSize.Y)) { sizeY = RADouble.NewRel(value.Y / _parentSize.Y); } else { throw new InvalidOperationException("_parentSize.Y is undefined or zero"); } InternalSetSizeSilent(sizeX, sizeY); }
public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent) { TextGraphic s = null != o ? (TextGraphic)o : new TextGraphic(info); if (info.CurrentElementName == "BaseType") // that was included since 2006-06-20 { info.GetBaseValueEmbedded(s, typeof(TextGraphic).BaseType, parent); } else { info.GetBaseValueEmbedded(s, "AltaxoBase,Altaxo.Graph.GraphicsObject,0", parent); // before 2006-06-20, it was version 0 of the GraphicsObject } s._text = info.GetString("Text"); s._font = (FontX)info.GetValue("Font", s); s._textBrush = (BrushX)info.GetValue("Brush", s); if (null != s._textBrush) { s._textBrush.ParentObject = s; } s._background = (IBackgroundStyle)info.GetValue("BackgroundStyle", s); if (null != s._background) { s._background.ParentObject = s; } s._lineSpacingFactor = info.GetSingle("LineSpacing"); var xAnchorType = (XAnchorPositionType)info.GetValue("XAnchor", s); var yAnchorType = (YAnchorPositionType)info.GetValue("YAnchor", s); s._location.LocalAnchorX = RADouble.NewRel(0.5 * (int)xAnchorType); s._location.LocalAnchorY = RADouble.NewRel(0.5 * (int)yAnchorType); return(s); }
public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent) { TextGraphic s = null != o ? (TextGraphic)o : new TextGraphic(info); info.GetBaseValueEmbedded(s, "AltaxoBase,Altaxo.Graph.GraphicsObject,0", parent); // we have changed the meaning of rotation in the meantime, This is not handled in GetBaseValueEmbedded, // since the former versions did not store the version number of embedded bases //s._rotation = -s._rotation; s._text = info.GetString("Text"); s._font = (FontX)info.GetValue("Font", s); s._textBrush = (BrushX)info.GetValue("Brush", s); if (null != s._textBrush) { s._textBrush.ParentObject = s; } s.BackgroundStyleOld = (BackgroundStyle)info.GetValue("BackgroundStyle", s); s._lineSpacingFactor = info.GetSingle("LineSpacing"); info.GetSingle("ShadowLength"); var xAnchorType = (XAnchorPositionType)info.GetValue("XAnchor", s); var yAnchorType = (YAnchorPositionType)info.GetValue("YAnchor", s); s._location.LocalAnchorX = RADouble.NewRel(0.5 * (int)xAnchorType); s._location.LocalAnchorY = RADouble.NewRel(0.5 * (int)yAnchorType); return(s); }
/// <summary> /// Sets the selected pivot values for X and Y. Additionally, the reference size is required. /// </summary> /// <param name="pivotX">The pivot x value.</param> /// <param name="pivotY">The pivot y value.</param> /// <param name="referenceSize">Size of the reference area.</param> public void SetSelectedPivot(RADouble pivotX, RADouble pivotY, PointD2D referenceSize) { _pivotX = pivotX; _pivotY = pivotY; _percentLayerXSizeUnit.ReferenceQuantity = new DimensionfulQuantity(referenceSize.X, AUL.Point.Instance); _percentLayerYSizeUnit.ReferenceQuantity = new DimensionfulQuantity(referenceSize.Y, AUL.Point.Instance); _xSizeEnvironment = new QuantityWithUnitGuiEnvironment(GuiLengthUnits.Collection, _percentLayerXSizeUnit); _ySizeEnvironment = new QuantityWithUnitGuiEnvironment(GuiLengthUnits.Collection, _percentLayerYSizeUnit); _guiPivotX.UnitEnvironment = _xSizeEnvironment; _guiPivotY.UnitEnvironment = _ySizeEnvironment; _guiPivotX.SelectedQuantity = _pivotX.IsAbsolute ? new DimensionfulQuantity(_pivotX.Value, AUL.Point.Instance) : new DimensionfulQuantity(_pivotX.Value * 100, _percentLayerXSizeUnit); _guiPivotY.SelectedQuantity = _pivotY.IsAbsolute ? new DimensionfulQuantity(_pivotY.Value, AUL.Point.Instance) : new DimensionfulQuantity(_pivotY.Value * 100, _percentLayerYSizeUnit); if (CanUseRadioGridView()) { SetRadioButton(); SetUseOfRadioGrid(true); } else { SetUseOfRadioGrid(false); } SetVisibilityOfSwitchButton(); }
protected override void InternalSetSizeYSilent(RADouble value) { _sizeY = value; if (_aspectPreserving != AspectRatioPreservingMode.None) { InternalSetAbsoluteSizeXSilentHere(AbsoluteSizeY * _originalItemSize.X / _originalItemSize.Y); } }
public ItemLocationDirect() { _localAnchorX = RADouble.NewRel(0); _localAnchorY = RADouble.NewRel(0); _parentAnchorX = RADouble.NewRel(0); _parentAnchorY = RADouble.NewRel(0); _scaleX = 1; _scaleY = 1; }
public LineShape(PointD3D startPosition, PointD3D endPosition, double lineWidth, NamedColor lineColor) : this(startPosition, null) { _location.SizeX = RADouble.NewAbs(endPosition.X - startPosition.X); _location.SizeY = RADouble.NewAbs(endPosition.Y - startPosition.Y); _location.SizeZ = RADouble.NewAbs(endPosition.Z - startPosition.Z); _linePen = _linePen.WithUniformThickness(lineWidth).WithColor(lineColor); }
public LineShape(PointD2D startPosition, PointD2D endPosition, double lineWidth, NamedColor lineColor) : this(startPosition, null) { _location.SizeX = RADouble.NewAbs(endPosition.X - startPosition.X); _location.SizeY = RADouble.NewAbs(endPosition.Y - startPosition.Y); Pen.Width = (float)lineWidth; Pen.Color = lineColor; }
/// <summary> /// Creates a empty GraphDocument with no layers and a standard size of A4 landscape. /// </summary> public GraphDocument() { RootLayer = new HostLayer() { ParentObject = this }; RootLayer.Location = new ItemLocationDirect { SizeX = RADouble.NewAbs(DefaultRootLayerSizeX), SizeY = RADouble.NewAbs(DefaultRootLayerSizeY) }; }
public void ChangeRelativePositionValuesToAbsolutePositionValues() { if (_positionX.IsRelative) { _positionX = RADouble.NewAbs(AbsolutePositionX); } if (_positionY.IsRelative) { _positionY = RADouble.NewAbs(AbsolutePositionY); } }
public void ChangeRelativeSizeValuesToAbsoluteSizeValues() { if (_sizeX.IsRelative) { _sizeX = RADouble.NewAbs(AbsoluteSizeX); } if (_sizeY.IsRelative) { _sizeY = RADouble.NewAbs(AbsoluteSizeY); } }
/// <summary> /// Sets the position and size. Since this location is for autosized items, we silently ignore the size parameter here. /// </summary> /// <param name="x">The x position.</param> /// <param name="y">The y position.</param> /// <param name="width">The width (ignored).</param> /// <param name="height">The height (ignored).</param> public override void SetPositionAndSize(RADouble x, RADouble y, RADouble width, RADouble height) { bool isChanged = x != _positionX || y != _positionY; _positionX = x; _positionY = y; if (isChanged) { EhSelfChanged(); } }
/// <summary> /// If the <see cref="IsAutoSized"/> property is <c>true</c> for this instance, the graphical object has to use this function to indicate its size. /// </summary> /// <param name="autoSize">Size of the graphical object.</param> /// <param name="isChangeEventEnabled">If true, the Change event will be fired if the size has changed.</param> /// <exception cref="System.InvalidOperationException">Using SetAutoSize is not supported because IsAutoSized is false</exception> public void SetSizeInAutoSizeMode(PointD2D autoSize, bool isChangeEventEnabled) { if (_sizeX.IsRelative || _sizeY.IsRelative || _sizeX.Value != autoSize.X || _sizeY.Value != autoSize.Y) { _sizeX = RADouble.NewAbs(autoSize.X); _sizeY = RADouble.NewAbs(autoSize.Y); if (isChangeEventEnabled) { EhSelfChanged(); } } }
/// <summary> /// Sets the position and size. Since this location is for autosized items, we silently ignore the size parameter here. /// </summary> /// <param name="x">The x position.</param> /// <param name="y">The y position.</param> /// <param name="z">The z position.</param> /// <param name="sizeX">The width (ignored).</param> /// <param name="sizeY">The height (ignored).</param> /// <param name="sizeZ">The z size (ignored).</param> public override void SetPositionAndSize(RADouble x, RADouble y, RADouble z, RADouble sizeX, RADouble sizeY, RADouble sizeZ) { bool isChanged = x != _positionX || y != _positionY || z != _positionZ; _positionX = x; _positionY = y; _positionZ = z; if (isChanged) { EhSelfChanged(); } }
private void EhRadioChecked(object sender, RoutedEventArgs e) { for (int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++j) { if (object.Equals(sender, _buttons[j, i])) { _pivots[j] = RADouble.NewRel(0.5 * i); } } } }
public void ChangeParentAnchorButKeepPosition(RADouble newParentAnchorX, RADouble newParentAnchorY) { var oldRefX = _parentAnchorX.GetValueRelativeTo(_parentSize.X); var oldRefY = _parentAnchorY.GetValueRelativeTo(_parentSize.Y); var newRefX = newParentAnchorX.GetValueRelativeTo(_parentSize.X); var newRefY = newParentAnchorY.GetValueRelativeTo(_parentSize.Y); var oldPos = AbsolutePosition; InternalSetAbsolutePositionXSilent(oldPos.X + (oldRefX - newRefX)); InternalSetAbsolutePositionYSilent(oldPos.Y + (oldRefY - newRefY)); _parentAnchorX = newParentAnchorX; _parentAnchorY = newParentAnchorY; }
public IPolylineD3D ShortenedBy(RADouble marginAtStart, RADouble marginAtEnd) { double totLength = TotalLineLength; double r1 = marginAtStart.IsAbsolute ? marginAtStart.Value / totLength : marginAtStart.Value; double r2 = marginAtEnd.IsAbsolute ? marginAtEnd.Value / totLength : marginAtEnd.Value; if (!((r1 + r2) < 1)) { return(null); } return(new StraightLineAsPolylineD3D(PointD3D.Interpolate(_p0, _p1, r1), PointD3D.Interpolate(_p1, _p0, r2))); }
public GraphDocument(GraphDocument from) { using (var suppressToken = SuspendGetToken()) { _creationTime = _lastChangeTime = DateTime.UtcNow; RootLayer = new HostLayer(null, new ItemLocationDirect { SizeX = RADouble.NewAbs(814), SizeY = RADouble.NewAbs(567) }); CopyFrom(from, GraphCopyOptions.All); suppressToken.ResumeSilently(); } }
public virtual void SetPositionAndSize(RADouble x, RADouble y, RADouble width, RADouble height) { bool isChanged = x != _positionX || y != _positionY || width != _sizeX || height != _sizeY; _positionX = x; _positionY = y; InternalSetSizeSilent(width, height); if (isChanged) { EhSelfChanged(); } }
public virtual void SetPositionAndSize(RADouble x, RADouble y, RADouble z, RADouble size_x, RADouble size_y, RADouble size_z) { bool isChanged = x != _positionX || y != _positionY || size_x != _sizeX || size_y != _sizeY; _positionX = x; _positionY = y; _positionZ = z; InternalSetSizeSilent(size_x, size_y, size_z); if (isChanged) { EhSelfChanged(); } }
protected override void InternalSetSizeSilent(RADouble valueX, RADouble valueY) { _sizeX = valueX; _sizeY = valueY; switch (_aspectPreserving) { case AspectRatioPreservingMode.PreserveXPriority: InternalSetAbsoluteSizeYSilentHere(AbsoluteSizeX * _originalItemSize.Y / _originalItemSize.X); break; case AspectRatioPreservingMode.PreserveYPriority: InternalSetAbsoluteSizeXSilentHere(AbsoluteSizeY * _originalItemSize.X / _originalItemSize.Y); break; } }
private void EhNumericPivotYChanged(object sender, DependencyPropertyChangedEventArgs e) { var quant = _guiPivotY.SelectedQuantity; if (object.ReferenceEquals(quant.Unit, _percentLayerYSizeUnit)) { _pivotY = RADouble.NewRel(quant.Value / 100); } else { _pivotY = RADouble.NewAbs(quant.AsValueIn(AUL.Point.Instance)); } SetVisibilityOfSwitchButton(); }
/// <summary> /// Internal set absolute size y silent. This function is allowed to set <see cref="ItemLocationDirect._sizeY"/> directly. This is the reason why it is declared as private. /// </summary> /// <param name="value">The value.</param> /// <exception cref="System.InvalidOperationException">_parentSize.Y is undefined or zero</exception> private void InternalSetAbsoluteSizeYSilentHere(double value) { if (_sizeY.IsAbsolute) { _sizeY = RADouble.NewAbs(value); } else if (_parentSize.Y != 0 && !double.IsNaN(_parentSize.Y)) { _sizeY = RADouble.NewRel(value / _parentSize.Y); } else { throw new InvalidOperationException("_parentSize.Y is undefined or zero"); } }
protected virtual void InternalSetAbsoluteSizeYSilent(double value) { if (_sizeY.IsAbsolute) { InternalSetSizeYSilent(RADouble.NewAbs(value)); } else if (_parentSize.Y != 0 && !double.IsNaN(_parentSize.Y)) { InternalSetSizeYSilent(RADouble.NewRel(value / _parentSize.Y)); } else { throw new InvalidOperationException("_parentSize.Y is undefined or zero"); } }
/// <summary> /// Creates a empty GraphDocument with no layers and a standard size of A4 landscape. /// </summary> public GraphDocument() { _camera = new Camera.OrthographicCamera(); _lighting = new LightSettings(); RootLayer = new HostLayer() { ParentObject = this }; RootLayer.Location = new ItemLocationDirect { SizeX = RADouble.NewAbs(DefaultRootLayerSizeX), SizeY = RADouble.NewAbs(DefaultRootLayerSizeY), SizeZ = RADouble.NewAbs(DefaultRootLayerSizeZ) }; }
private void EhLocController_SizeYChanged(RADouble sizeY) { if (!_doc.IsSizeCalculationBasedOnSourceSize) { var sizeX = _docLocation.SizeX; if (_doc.AspectRatioPreserving == AspectRatioPreservingMode.PreserveYPriority || _doc.AspectRatioPreserving == AspectRatioPreservingMode.PreserveXPriority) { _docLocation.SizeX = sizeY * (_srcSize.X / _srcSize.Y); } _docLocation.SizeY = sizeY; _docScale = new PointD2D(_docLocation.AbsoluteSizeX / _srcSize.X, _docLocation.AbsoluteSizeY / _srcSize.Y); _locationController.ScaleX = _docScale.X; _locationController.ScaleY = _docScale.Y; _locationController.SizeX = _docLocation.SizeX; } }
protected virtual void InternalSetSizeSilent(RADouble valueX, RADouble valueY, RADouble valueZ) { _sizeX = valueX; _sizeY = valueY; _sizeZ = valueZ; }
protected virtual void InternalSetSizeZSilent(RADouble value) { _sizeZ = value; }
public void InitializePivot(RADouble pivotX, RADouble pivotY, RADouble pivotZ, VectorD3D sizeOfTextGraphic) { _guiLocalAnchor.SetSelectedPivot(pivotX, pivotY, pivotZ, sizeOfTextGraphic); }
public void InitializePivot(RADouble pivotX, RADouble pivotY, PointD2D sizeOfTextGraphic) { _guiLocalAnchor.SetSelectedPivot(pivotX, pivotY, sizeOfTextGraphic); }
private void EhNumericPivotXChanged(object sender, DependencyPropertyChangedEventArgs e) { var quant = _guiPivotX.SelectedQuantity; if (object.ReferenceEquals(quant.Unit, _percentLayerXSizeUnit)) _pivotX = RADouble.NewRel(quant.Value / 100); else _pivotX = RADouble.NewAbs(quant.AsValueIn(Units.Length.Point.Instance)); SetVisibilityOfSwitchButton(); }
public void ChangeRelativeSizeValuesToAbsoluteSizeValues() { if (_sizeX.IsRelative) _sizeX = RADouble.NewAbs(AbsoluteSizeX); if (_sizeY.IsRelative) _sizeY = RADouble.NewAbs(AbsoluteSizeY); if (_sizeZ.IsRelative) _sizeZ = RADouble.NewAbs(AbsoluteSizeZ); }
public virtual void SetRelativeSizePositionFromAbsoluteValues(VectorD3D absSize, PointD3D absPos) { var oldSizeX = SizeX; var oldSizeY = SizeY; var oldSizeZ = SizeZ; var oldPosX = PositionX; var oldPosY = PositionY; var oldPosZ = PositionZ; if (_parentSize.X == 0) throw new InvalidOperationException("ParentSize.X is zero. This would lead to an undefined relative value!"); if (_parentSize.Y == 0) throw new InvalidOperationException("ParentSize.Y is zero. This would lead to an undefined relative value!"); if (_parentSize.Z == 0) throw new InvalidOperationException("ParentSize.Z is zero. This would lead to an undefined relative value!"); InternalSetSizeSilent( RADouble.NewRel(absSize.X / _parentSize.X), RADouble.NewRel(absSize.Y / _parentSize.Y), RADouble.NewRel(absSize.Z / _parentSize.Z) ); _positionX = RADouble.NewRel(absPos.X / _parentSize.X); _positionY = RADouble.NewRel(absPos.Y / _parentSize.Y); _positionZ = RADouble.NewRel(absPos.Z / _parentSize.Z); if (oldSizeX != _sizeX || oldSizeY != _sizeY || oldSizeZ != _sizeZ || oldPosX != _positionX || oldPosY != _positionY || oldPosZ != _positionZ) EhSelfChanged(); }
private void InternalSetAbsolutePivotPositionYSilent(double value) { var mySizeY = _sizeY.GetValueRelativeTo(_parentSize.Y); if (_positionY.IsAbsolute) _positionY = RADouble.NewAbs(value - _parentAnchorY.GetValueRelativeTo(_parentSize.Y)); else if (0 != _parentSize.Y && _parentSize.Y.IsFinite()) _positionY = RADouble.NewRel((value - _parentAnchorY.GetValueRelativeTo(_parentSize.Y)) / _parentSize.Y); else throw new InvalidOperationException("_parentSize.Y is undefined or zero"); }
public IPolylineD3D ShortenedBy(RADouble marginAtStart, RADouble marginAtEnd) { throw new NotImplementedException(); }
/// <summary> /// Copy operation. /// </summary> /// <param name="obj">The AxisStyle to copy from</param> public bool CopyFrom(object obj) { if (object.ReferenceEquals(this, obj)) return true; var from = obj as AxisLineStyle; if (null == from) return false; using (var suspendToken = SuspendGetToken()) { ChildCopyToMember(ref _axisPen, from._axisPen); this._axisPosition = from._axisPosition; this._showFirstDownMajorTicks = from._showFirstDownMajorTicks; this._showFirstDownMinorTicks = from._showFirstDownMinorTicks; this._showFirstUpMajorTicks = from._showFirstUpMajorTicks; this._showFirstUpMinorTicks = from._showFirstUpMinorTicks; this._majorTickLength = from._majorTickLength; ChildCopyToMember(ref _majorTickPen, from._majorTickPen); this._minorTickLength = from._minorTickLength; ChildCopyToMember(ref _minorTickPen, from._minorTickPen); this._cachedAxisStyleInfo = from._cachedAxisStyleInfo; EhSelfChanged(EventArgs.Empty); suspendToken.Resume(); } return true; }
/// <summary> /// Sets the position and size. Since this location is for autosized items, we silently ignore the size parameter here. /// </summary> /// <param name="x">The x position.</param> /// <param name="y">The y position.</param> /// <param name="z">The z position.</param> /// <param name="sizeX">The width (ignored).</param> /// <param name="sizeY">The height (ignored).</param> /// <param name="sizeZ">The z size (ignored).</param> public override void SetPositionAndSize(RADouble x, RADouble y, RADouble z, RADouble sizeX, RADouble sizeY, RADouble sizeZ) { bool isChanged = x != _positionX || y != _positionY || z != _positionZ; _positionX = x; _positionY = y; _positionZ = z; if (isChanged) EhSelfChanged(); }
private void InternalSetAbsolutePositionZSilent(double value) { var mySizeZ = _sizeZ.GetValueRelativeTo(_parentSize.Z); if (_positionZ.IsAbsolute) _positionZ = RADouble.NewAbs(value - _parentAnchorZ.GetValueRelativeTo(_parentSize.Z) + _localAnchorZ.GetValueRelativeTo(mySizeZ)); else if (0 != _parentSize.Z && _parentSize.Z.IsFinite()) _positionZ = RADouble.NewRel((value - _parentAnchorZ.GetValueRelativeTo(_parentSize.Z) + _localAnchorZ.GetValueRelativeTo(mySizeZ)) / _parentSize.Z); else throw new InvalidOperationException("_parentSize.Z is undefined or zero"); }
private void EhRadioChecked(object sender, RoutedEventArgs e) { for (int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++j) { if (object.Equals(sender, _buttons[j, i])) { _pivotX = RADouble.NewRel(0.5 * i); _pivotY = RADouble.NewRel(0.5 * j); } } } }
public void ChangeRelativePositionValuesToAbsolutePositionValues() { if (this._positionX.IsRelative) _positionX = RADouble.NewAbs(AbsolutePositionX); if (_positionY.IsRelative) _positionY = RADouble.NewAbs(AbsolutePositionY); if (_positionZ.IsRelative) _positionZ = RADouble.NewAbs(AbsolutePositionZ); }
public virtual void SetPositionAndSize(RADouble x, RADouble y, RADouble width, RADouble height) { bool isChanged = x != _positionX || y != _positionY || width != _sizeX || height != _sizeY; _positionX = x; _positionY = y; InternalSetSizeSilent(width, height); if (isChanged) EhSelfChanged(); }
/// <summary> /// Returns a new, shortened polyline. If the shortened line would have zero or negative length, <c>null</c> is returned. /// </summary> /// <param name="polyline">The points of the polyline. Only points starting from <paramref name="startIdx"/> with the number of points = <paramref name="count"/> are considered to be part of the polyline.</param> /// <param name="startIdx">Index of the first point of the polyline in array <paramref name="polyline"/>.</param> /// <param name="count">The number of points of the polyline. An exception is thrown if this argument is less than 2.</param> /// <param name="marginAtStart">The margin at start. Either an absolute value, or relative to the total length of the polyline.</param> /// <param name="marginAtEnd">The margin at end. Either an absolute value, or relative to the total length of the polyline.</param> /// <returns>A new, shortened polyline. If the shortened line would have zero or negative length, <c>null</c> is returned.</returns> public static PointF[] ShortenedBy(this PointF[] polyline, int startIdx, int count, RADouble marginAtStart, RADouble marginAtEnd) { if (null == polyline) throw new ArgumentNullException(nameof(polyline)); if (count < 2) throw new ArgumentException("Polyline must have at least 2 points", nameof(polyline)); int nextIdx = startIdx + count; double totLength = TotalLineLength(polyline, startIdx, count); double a1 = marginAtStart.IsAbsolute ? marginAtStart.Value : marginAtStart.Value * totLength; double a2 = marginAtEnd.IsAbsolute ? marginAtEnd.Value : marginAtEnd.Value * totLength; if (!((a1 + a2) < totLength)) return null; PointF? p0 = null; PointF? p1 = null; int i0 = 0; int i1 = 0; if (a1 <= 0) { p0 = Interpolate(polyline[startIdx], polyline[startIdx + 1], a1 / totLength); i0 = startIdx + 1; } else { double sum = 0, prevSum = 0; for (int i = startIdx + 1; i < nextIdx; ++i) { sum += LengthBetween(polyline[i], polyline[i - 1]); if (!(sum < a1)) { p0 = Interpolate(polyline[i - 1], polyline[i], (a1 - prevSum) / (sum - prevSum)); i0 = p0 != polyline[i] ? i : i + 1; break; } prevSum = sum; } } if (a2 <= 0) { p1 = Interpolate(polyline[nextIdx - 2], polyline[nextIdx - 1], 1 - a2 / totLength); i1 = nextIdx - 2; } else { double sum = 0, prevSum = 0; for (int i = nextIdx - 2; i >= startIdx; --i) { sum += LengthBetween(polyline[i], polyline[i + 1]); if (!(sum < a2)) { p1 = Interpolate(polyline[i + 1], polyline[i], (a2 - prevSum) / (sum - prevSum)); i1 = p1 != polyline[i] ? i : i - 1; break; } prevSum = sum; } } if (p0.HasValue && p1.HasValue) { var plist = new List<PointF>(); plist.Add(p0.Value); for (int i = i0; i <= i1; ++i) plist.Add(polyline[i]); plist.Add(p1.Value); return plist.ToArray(); } else { return null; } }
public void InitializeReference(RADouble pivotX, RADouble pivotY, PointD2D sizeOfTextGraphic) { _guiParentAnchor.SetSelectedPivot(pivotX, pivotY, sizeOfTextGraphic); }
/// <summary> /// Sets the position and size. Since this location is for autosized items, we silently ignore the size parameter here. /// </summary> /// <param name="x">The x position.</param> /// <param name="y">The y position.</param> /// <param name="width">The width (ignored).</param> /// <param name="height">The height (ignored).</param> public override void SetPositionAndSize(RADouble x, RADouble y, RADouble width, RADouble height) { bool isChanged = x != _positionX || y != _positionY; _positionX = x; _positionY = y; if (isChanged) EhSelfChanged(); }
protected override void InternalSetSizeSilent(RADouble valueX, RADouble valueY) { throw new InvalidOperationException("Setting the size is not supported in AutoSize mode. (internally the function SetSizeInAutoSizeMode should be used)"); }
public virtual void SetPositionAndSize(RADouble x, RADouble y, RADouble z, RADouble size_x, RADouble size_y, RADouble size_z) { bool isChanged = x != _positionX || y != _positionY || size_x != _sizeX || size_y != _sizeY; _positionX = x; _positionY = y; _positionZ = z; InternalSetSizeSilent(size_x, size_y, size_z); if (isChanged) EhSelfChanged(); }
public void ChangeParentAnchorButKeepPosition(RADouble newParentAnchorX, RADouble newParentAnchorY, RADouble newParentAnchorZ) { var oldRefX = _parentAnchorX.GetValueRelativeTo(_parentSize.X); var oldRefY = _parentAnchorY.GetValueRelativeTo(_parentSize.Y); var oldRefZ = _parentAnchorZ.GetValueRelativeTo(_parentSize.Z); var newRefX = newParentAnchorX.GetValueRelativeTo(_parentSize.X); var newRefY = newParentAnchorY.GetValueRelativeTo(_parentSize.Y); var newRefZ = newParentAnchorZ.GetValueRelativeTo(_parentSize.Z); var oldPos = this.AbsolutePosition; this.InternalSetAbsolutePositionXSilent(oldPos.X + (oldRefX - newRefX)); this.InternalSetAbsolutePositionYSilent(oldPos.Y + (oldRefY - newRefY)); this.InternalSetAbsolutePositionZSilent(oldPos.Z + (oldRefZ - newRefZ)); _parentAnchorX = newParentAnchorX; _parentAnchorY = newParentAnchorY; _parentAnchorZ = newParentAnchorZ; }
protected override void InternalSetSizeYSilent(RADouble value) { _sizeY = value; if (_aspectPreserving != AspectRatioPreservingMode.None) InternalSetAbsoluteSizeXSilentHere(AbsoluteSizeY * _originalItemSize.X / _originalItemSize.Y); }
public IPolylineD3D ShortenedBy(RADouble marginAtStart, RADouble marginAtEnd) { if (_points.Length < 2) return null; double totLength = TotalLineLength; double a1 = marginAtStart.IsAbsolute ? marginAtStart.Value : marginAtStart.Value * totLength; double a2 = marginAtEnd.IsAbsolute ? marginAtEnd.Value : marginAtEnd.Value * totLength; if (!((a1 + a2) < totLength)) return null; PointD3D? p0 = null; PointD3D? p1 = null; int i0 = 0; int i1 = 0; if (a1 <= 0) { p0 = PointD3D.Interpolate(_points[0], _points[1], a1 / totLength); i0 = 1; } else { double sum = 0, prevSum = 0; for (int i = 1; i < _points.Length; ++i) { sum += (_points[i] - _points[i - 1]).Length; if (!(sum < a1)) { p0 = PointD3D.Interpolate(_points[i - 1], _points[i], (a1 - prevSum) / (sum - prevSum)); i0 = p0 != _points[i] ? i : i + 1; break; } prevSum = sum; } } if (a2 <= 0) { p1 = PointD3D.Interpolate(_points[_points.Length - 2], _points[_points.Length - 1], 1 - a2 / totLength); i1 = _points.Length - 2; } else { double sum = 0, prevSum = 0; for (int i = _points.Length - 2; i >= 0; --i) { sum += (_points[i] - _points[i + 1]).Length; if (!(sum < a2)) { p1 = PointD3D.Interpolate(_points[i + 1], _points[i], (a2 - prevSum) / (sum - prevSum)); i1 = p1 != _points[i] ? i : i - 1; break; } prevSum = sum; } } if (p0.HasValue && p1.HasValue) { var plist = new List<PointD3D>(); plist.Add(p0.Value); for (int i = i0; i <= i1; ++i) plist.Add(_points[i]); plist.Add(p1.Value); return new SharpPolylineD3D(plist.ToArray()); } else { return null; } }
public ItemLocationDirect() { _localAnchorX = RADouble.NewRel(0); _localAnchorY = RADouble.NewRel(0); _localAnchorZ = RADouble.NewRel(0); _parentAnchorX = RADouble.NewRel(0); _parentAnchorY = RADouble.NewRel(0); _parentAnchorZ = RADouble.NewRel(0); _scaleX = 1; _scaleY = 1; _scaleZ = 1; }
protected override void InternalSetSizeSilent(RADouble valueX, RADouble valueY, RADouble valueZ) { _sizeX = valueX; _sizeY = valueY; _sizeZ = valueZ; switch (_aspectPreserving) { case AspectRatioPreservingMode.PreserveXPriority: InternalSetAbsoluteSizeYSilentHere(AbsoluteSizeX * _originalItemSize.Y / _originalItemSize.X); break; case AspectRatioPreservingMode.PreserveYPriority: InternalSetAbsoluteSizeXSilentHere(AbsoluteSizeY * _originalItemSize.X / _originalItemSize.Y); break; } }
public virtual bool CopyFrom(object obj) { if (object.ReferenceEquals(this, obj)) return true; if (obj is ItemLocationDirect) { var from = (ItemLocationDirect)obj; this._parentSize = from._parentSize; this._positionX = from._positionX; this._positionY = from._positionY; this._positionZ = from._positionZ; this._sizeX = from._sizeX; this._sizeY = from._sizeY; this._sizeZ = from._sizeZ; this._localAnchorX = from._localAnchorX; this._localAnchorY = from._localAnchorY; this._localAnchorZ = from._localAnchorZ; this._parentAnchorX = from._parentAnchorX; this._parentAnchorY = from._parentAnchorY; this._parentAnchorZ = from._parentAnchorZ; this._rotationX = from._rotationX; this._rotationY = from._rotationY; this._rotationZ = from._rotationZ; this._scaleX = from._scaleX; this._scaleY = from._scaleY; this._scaleZ = from._scaleZ; this._shearX = from._shearX; this._shearY = from._shearY; this._shearZ = from._shearZ; EhSelfChanged(); return true; } else if (obj is IItemLocation) { var from = (IItemLocation)obj; this._rotationX = from.RotationX; this._rotationY = from.RotationY; this._rotationZ = from.RotationZ; this._shearX = from.ShearX; this._shearY = from.ShearY; this._shearZ = from.ShearZ; this._scaleX = from.ScaleX; this._scaleY = from.ScaleY; this._scaleY = from.ScaleZ; EhSelfChanged(); return true; } return false; }