示例#1
0
        protected virtual void UpdateCenterPoint(Point centerPoint)
        {
            CanonicalTransform canonicalTransform = new CanonicalTransform((Transform)this.EditingElement.GetComputedValueAsWpf(Base2DElement.RenderTransformProperty));
            Point  elementCoordinates             = this.BaseEditingElement.RenderTransformOriginInElementCoordinates;
            Vector translation           = canonicalTransform.Translation;
            Rect   computedTightBounds   = ((Base2DElement)this.EditingElement).GetComputedTightBounds();
            Point  renderTransformOrigin = this.BaseEditingElement.RenderTransformOrigin;
            Point  point2 = new Point((centerPoint.X - computedTightBounds.Left) / (computedTightBounds.Width == 0.0 ? 1.0 : computedTightBounds.Width), (centerPoint.Y - computedTightBounds.Top) / (computedTightBounds.Height == 0.0 ? 1.0 : computedTightBounds.Height));

            point2 = RoundingHelper.RoundPosition(point2);
            Point newOrigin = new Point(computedTightBounds.Left + point2.X * computedTightBounds.Width, computedTightBounds.Top + point2.Y * computedTightBounds.Height);

            canonicalTransform.UpdateForNewOrigin(elementCoordinates, newOrigin);
            canonicalTransform.TranslationX = RoundingHelper.RoundLength(canonicalTransform.TranslationX);
            canonicalTransform.TranslationY = RoundingHelper.RoundLength(canonicalTransform.TranslationY);
            if (!Point.Equals(renderTransformOrigin, point2))
            {
                this.BaseEditingElement.RenderTransformOrigin = point2;
            }
            if (!object.Equals((object)translation.X, (object)canonicalTransform.TranslationX))
            {
                this.EditingElement.SetValue(this.EditingElement.Platform.Metadata.CommonProperties.RenderTransformTranslationX, (object)canonicalTransform.TranslationX);
            }
            if (object.Equals((object)translation.Y, (object)canonicalTransform.TranslationY))
            {
                return;
            }
            this.EditingElement.SetValue(this.EditingElement.Platform.Metadata.CommonProperties.RenderTransformTranslationY, (object)canonicalTransform.TranslationY);
        }
示例#2
0
        private void UpdateCenterPoint(Point centerPoint)
        {
            CanonicalTransform canonicalTransform = new CanonicalTransform(this.pathElement.RenderTransform);
            Point elementCoordinates = this.pathElement.RenderTransformOriginInElementCoordinates;
            Rect  computedBounds     = this.pathElement.GetComputedBounds((Base2DElement)this.pathElement);
            Point newOrigin          = new Point(computedBounds.Left + centerPoint.X * computedBounds.Width, computedBounds.Top + centerPoint.Y * computedBounds.Height);

            canonicalTransform.UpdateForNewOrigin(elementCoordinates, newOrigin);
            this.pathElement.RenderTransformOriginInElementCoordinates = newOrigin;
            this.pathElement.SetValue(this.pathElement.Platform.Metadata.CommonProperties.RenderTransformTranslationX, (object)canonicalTransform.TranslationX);
            this.pathElement.SetValue(this.pathElement.Platform.Metadata.CommonProperties.RenderTransformTranslationY, (object)canonicalTransform.TranslationY);
        }
示例#3
0
        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();
                }
            }
        }