public static double RoundDouble(IProjectContext projectContext, double d) { if (projectContext.IsCapabilitySet(PlatformCapability.UsesFloatsInternally)) { return(RoundingHelper.RoundToDoublePrecision(d, 6)); } return(d); }
private void ChangeRegistrationPoint(RegistrationPointFlags registrationPoint) { if (this.objectSet.ViewModel == null) { return; } bool flag1 = false; using (SceneEditTransaction editTransaction = this.objectSet.ViewModel.CreateEditTransaction(StringTable.UndoUnitTransformPaneCenterPoint)) { Point point1 = this.CenterFromRegistrationPoint(registrationPoint); foreach (SceneElement sceneElement in this.objectSet.Objects) { BaseFrameworkElement frameworkElement = sceneElement as BaseFrameworkElement; if (frameworkElement != null) { flag1 = true; CanonicalTransform canonicalTransform1 = new CanonicalTransform((Transform)frameworkElement.GetComputedValueAsWpf(this.PropertyReference)); CanonicalTransform canonicalTransform2 = new CanonicalTransform(canonicalTransform1); if (this.IsRenderTransform) { Point point2 = (Point)frameworkElement.GetComputedValueAsWpf(Base2DElement.RenderTransformOriginProperty); Rect computedTightBounds = frameworkElement.GetComputedTightBounds(); Point oldOrigin = new Point(point2.X * computedTightBounds.Width + computedTightBounds.Left, point2.Y * computedTightBounds.Height + computedTightBounds.Top); Point newOrigin = new Point(point1.X * computedTightBounds.Width + computedTightBounds.Left, point1.Y * computedTightBounds.Height + computedTightBounds.Top); canonicalTransform2.UpdateForNewOrigin(oldOrigin, newOrigin); bool flag2 = false; if (!double.IsNaN(point1.X) && !object.Equals((object)point1.X, (object)point2.X)) { point2.X = point1.X; flag2 = true; } if (!double.IsNaN(point1.Y) && !object.Equals((object)point1.Y, (object)point2.Y)) { point2.Y = point1.Y; flag2 = true; } if (flag2) { frameworkElement.SetValueAsWpf(Base2DElement.RenderTransformOriginProperty, (object)point2); } } double num1 = RoundingHelper.RoundToDoublePrecision(canonicalTransform2.TranslationX, 6); double num2 = RoundingHelper.RoundToDoublePrecision(canonicalTransform2.TranslationY, 6); if (canonicalTransform1.TranslationX != num1) { frameworkElement.SetValue(this.TranslationXPropertyReference, (object)num1); } if (canonicalTransform1.TranslationY != num2) { frameworkElement.SetValue(this.TranslationYPropertyReference, (object)num2); } } } if (flag1) { editTransaction.Commit(); } else { editTransaction.Cancel(); } } }