protected override void ApplyScale(Vector scale, Point center)
        {
            Dictionary <SceneElement, Size> dictionary = this.CalculateClampedSizes(ref scale);
            Vector          vector1 = new Vector(scale.X < 0.0 ? -1.0 : 1.0, scale.Y < 0.0 ? -1.0 : 1.0);
            Matrix          startSharedTransform = this.StartSharedTransform;
            Matrix          inverseMatrix        = ElementUtilities.GetInverseMatrix(startSharedTransform);
            ILayoutDesigner designerForChild     = this.ActiveSceneViewModel.GetLayoutDesignerForChild(this.EditingElementSet.PrimaryElement, true);

            foreach (SceneElement index in this.EditingElementSet.Elements)
            {
                double width  = dictionary[index].Width;
                double height = dictionary[index].Height;
                Rect   rect1  = this.StartBoundsDictionary[index];
                Point  renderTransformOrigin = ((Base2DElement)index).RenderTransformOrigin;
                Point  point1  = new Point(rect1.X + rect1.Width * renderTransformOrigin.X, rect1.Y + rect1.Height * renderTransformOrigin.Y);
                Matrix matrix1 = this.ElementToElementsTransformDictionary[index];
                Matrix matrix2 = new Matrix();
                matrix2.Translate(-center.X, -center.Y);
                matrix1 *= matrix2;
                Point  point2  = matrix1.Transform(point1);
                Vector vector2 = new Point(point2.X * scale.X, point2.Y * scale.Y) - point2;
                Vector vector3 = new Vector((width - rect1.Width) * renderTransformOrigin.X, (height - rect1.Height) * renderTransformOrigin.Y);
                Vector vector4 = vector2 * startSharedTransform - vector3;
                Matrix matrix3 = this.StartTransformsDictionary[index];
                Matrix m       = new Matrix();
                m.Scale(scale.X, scale.Y);
                Matrix matrix4 = ElementUtilities.GetInverseMatrix(m) * matrix3 * inverseMatrix;
                Vector vector5 = new Vector(matrix3.OffsetX, matrix3.OffsetY) * inverseMatrix;
                matrix4.ScaleAt(scale.X, scale.Y, vector5.X, vector5.Y);
                CanonicalDecomposition newTransform = new CanonicalDecomposition(matrix4 * startSharedTransform);
                newTransform.ScaleX      *= vector1.X;
                newTransform.ScaleY      *= vector1.Y;
                newTransform.Translation += vector4;
                AdornedToolBehavior.UpdateElementTransform(index, newTransform, AdornedToolBehavior.TransformPropertyFlags.Scale | AdornedToolBehavior.TransformPropertyFlags.Skew | AdornedToolBehavior.TransformPropertyFlags.RotatationAngle);
                Rect rect2 = this.initialRects[index];
                rect2.Offset(newTransform.TranslationX - this.initialTransforms[index].TranslationX, newTransform.TranslationY - this.initialTransforms[index].TranslationY);
                rect2.Width  = width;
                rect2.Height = height;
                BaseFrameworkElement child             = (BaseFrameworkElement)index;
                LayoutOverrides      overridesToIgnore = (LayoutOverrides)(0 | (!object.Equals((object)width, (object)rect1.Width) ? 16 : 0) | (!object.Equals((object)height, (object)rect1.Height) ? 32 : 0));
                designerForChild.SetChildRect(child, rect2, this.initialOverrides[index], overridesToIgnore, LayoutOverrides.None);
                if (!object.Equals((object)width, (object)rect1.Width) || !object.Equals((object)height, (object)rect1.Height))
                {
                    PathElement.EnsureStretchIsFill((SceneNode)index);
                }
                PathElement.PathTransformHelper pathTransformHelper;
                if (this.pathTransformHelpers.TryGetValue(index, out pathTransformHelper))
                {
                    pathTransformHelper.Update(scale.X * vector1.X, scale.Y * vector1.Y);
                }
            }
        }
Esempio n. 2
0
 public override void SetChildRect(BaseFrameworkElement child, Rect rect, LayoutOverrides layoutOverrides, LayoutOverrides overridesToIgnore, LayoutOverrides nonExplicitOverrides, SetRectMode setRectMode)
 {
     if (child == null)
     {
         throw new ArgumentNullException("child");
     }
     if (!child.IsAttached)
     {
         overridesToIgnore = LayoutOverrides.All;
     }
     overridesToIgnore |= LayoutOverrides.GridBox;
     base.SetChildRect(child, this.PrepareLayoutRect(rect), layoutOverrides, overridesToIgnore, nonExplicitOverrides, setRectMode);
 }
Esempio n. 3
0
            public DelayedElementTranslationInfo(BaseFrameworkElement element)
            {
                Rect            rect        = (Rect)element.GetLocalOrDefaultValueAsWpf(DesignTimeProperties.LayoutRectProperty);
                LayoutOverrides overrides   = (LayoutOverrides)element.GetLocalOrDefaultValue(DesignTimeProperties.LayoutOverridesProperty);
                bool            overlapping = element.IsSet(DesignTimeProperties.SlotOriginProperty) != PropertyState.Set;
                Point           slotOrigin  = overlapping ? new Point() : (Point)element.GetLocalOrDefaultValueAsWpf(DesignTimeProperties.SlotOriginProperty);

                this.element = element;
                this.cache   = new LayoutCacheRecord(rect, slotOrigin, overrides, overlapping);
                this.element.ClearValue(DesignTimeProperties.LayoutRectProperty);
                this.element.ClearValue(DesignTimeProperties.LayoutOverridesProperty);
                this.element.ClearValue(DesignTimeProperties.SlotOriginProperty);
            }
        public override void SetChildRect(BaseFrameworkElement child, Rect rect, LayoutOverrides layoutOverrides, LayoutOverrides overridesToIgnore, LayoutOverrides nonExplicitOverrides, SetRectMode setRectMode)
        {
            if (child == null)
            {
                throw new ArgumentNullException("child");
            }
            CanonicalTransform canonicalTransform = new CanonicalTransform((Transform)child.GetComputedValueAsWpf(Base2DElement.RenderTransformProperty));
            Vector             translation        = canonicalTransform.Translation;

            canonicalTransform.TranslationX  = 0.0;
            canonicalTransform.TranslationY  = 0.0;
            canonicalTransform.SkewX         = 0.0;
            canonicalTransform.SkewY         = 0.0;
            canonicalTransform.RotationAngle = 0.0;
            Rect   computedTightBounds = child.GetComputedTightBounds();
            double num1 = computedTightBounds.Width == 0.0 ? 0.0 : rect.Width / computedTightBounds.Width;
            double num2 = computedTightBounds.Height == 0.0 ? 0.0 : rect.Height / computedTightBounds.Height;
            double num3 = RoundingHelper.RoundScale(num1);
            double num4 = RoundingHelper.RoundScale(num2);

            if ((overridesToIgnore & LayoutOverrides.Width) != LayoutOverrides.None && !object.Equals((object)canonicalTransform.ScaleX, (object)num3))
            {
                child.SetValueAsWpf(child.Platform.Metadata.CommonProperties.RenderTransformScaleX, (object)num3);
            }
            if ((overridesToIgnore & LayoutOverrides.Height) != LayoutOverrides.None && !object.Equals((object)canonicalTransform.ScaleY, (object)num4))
            {
                child.SetValueAsWpf(child.Platform.Metadata.CommonProperties.RenderTransformScaleY, (object)num4);
            }
            canonicalTransform.ScaleX = num3;
            canonicalTransform.ScaleY = num4;
            canonicalTransform.Center = child.RenderTransformOriginInElementCoordinates;
            computedTightBounds.Transform(canonicalTransform.TransformGroup.Value);
            double num5 = rect.Left - computedTightBounds.Left + translation.X;
            double num6 = rect.Top - computedTightBounds.Top + translation.Y;
            double num7 = RoundingHelper.RoundLength(num5);
            double num8 = RoundingHelper.RoundLength(num6);

            if (!object.Equals((object)translation.X, (object)num7))
            {
                child.SetValueAsWpf(child.Platform.Metadata.CommonProperties.RenderTransformTranslationX, (object)num7);
            }
            if (object.Equals((object)translation.Y, (object)num8))
            {
                return;
            }
            child.SetValueAsWpf(child.Platform.Metadata.CommonProperties.RenderTransformTranslationY, (object)num8);
        }
Esempio n. 5
0
        public static void DetectLayoutOverrides(SceneElement element, PropertyReference propertyReference)
        {
            if (!element.IsAttached || LayoutUtilities.InLayoutMode)
            {
                return;
            }
            ReferenceStep   referenceStep    = propertyReference[0];
            LayoutOverrides layoutOverrides1 = LayoutOverrides.None;

            if (referenceStep.Equals((object)BaseFrameworkElement.HorizontalAlignmentProperty))
            {
                layoutOverrides1 |= LayoutOverrides.HorizontalAlignment;
            }
            else if (referenceStep.Equals((object)BaseFrameworkElement.VerticalAlignmentProperty))
            {
                layoutOverrides1 |= LayoutOverrides.VerticalAlignment;
            }
            else if (referenceStep.Equals((object)BaseFrameworkElement.MarginProperty))
            {
                layoutOverrides1 |= LayoutOverrides.Margin;
            }
            else if (referenceStep.Equals((object)BaseFrameworkElement.WidthProperty))
            {
                layoutOverrides1 |= LayoutOverrides.Width;
            }
            else if (referenceStep.Equals((object)BaseFrameworkElement.HeightProperty))
            {
                layoutOverrides1 |= LayoutOverrides.Height;
            }
            if (layoutOverrides1 == LayoutOverrides.None)
            {
                return;
            }
            LayoutOverrides layoutOverrides2 = LayoutUtilities.GetLayoutOverrides(element);
            LayoutOverrides flags            = layoutOverrides2 & ~layoutOverrides1;

            if (layoutOverrides2 == flags)
            {
                return;
            }
            LayoutUtilities.SetLayoutOverrides(element, flags);
        }
Esempio n. 6
0
        protected override void ApplyScale(Vector scale, Point center)
        {
            Vector             scale1             = new Vector(Math.Abs(scale.X), Math.Abs(scale.Y));
            Vector             scale2             = new Vector(scale.X < 0.0 ? -1.0 : 1.0, scale.Y < 0.0 ? -1.0 : 1.0);
            Vector             vector1            = new Vector(this.StartCenter.X, this.StartCenter.Y);
            Size               newSize            = this.ComputeNewSize(scale1);
            Point              topLeft            = this.StartBounds.TopLeft;
            CanonicalTransform canonicalTransform = new CanonicalTransform(this.StartTransform);

            canonicalTransform.ApplyScale(scale, this.StartCenter, center);
            Point point1 = (topLeft - vector1) * canonicalTransform.TransformGroup.Value + vector1;
            Point renderTransformOrigin = this.BaseEditingElement.RenderTransformOrigin;

            renderTransformOrigin.X *= newSize.Width;
            renderTransformOrigin.Y *= newSize.Height;
            CanonicalTransform newTransform = new CanonicalTransform(this.StartTransform);

            newTransform.ApplyScale(scale2, renderTransformOrigin, center);
            Vector vector2 = (Vector)renderTransformOrigin;
            Point  point2  = (topLeft - vector2) * newTransform.TransformGroup.Value + vector2;

            newTransform.Translation += point1 - point2;
            AdornedToolBehavior.UpdateElementTransform(this.EditingElement, newTransform, AdornedToolBehavior.TransformPropertyFlags.Scale);
            ILayoutDesigner designerForChild = this.ActiveSceneViewModel.GetLayoutDesignerForChild(this.EditingElement, true);
            Rect            rect             = this.initialRect;

            rect.Offset(newTransform.TranslationX - this.StartTransform.TranslationX, newTransform.TranslationY - this.StartTransform.TranslationY);
            rect.Width  = newSize.Width;
            rect.Height = newSize.Height;
            LayoutOverrides overridesToIgnore = (LayoutOverrides)(0 | (!object.Equals((object)rect.Width, (object)this.StartSize.Width) ? 16 : 0) | (!object.Equals((object)rect.Height, (object)this.StartSize.Height) ? 32 : 0));

            designerForChild.SetChildRect(this.BaseEditingElement, rect, this.initialOverrides, overridesToIgnore, LayoutOverrides.None);
            if (!object.Equals((object)rect.Width, (object)this.StartSize.Width) || !object.Equals((object)rect.Height, (object)this.StartSize.Height))
            {
                PathElement.EnsureStretchIsFill((SceneNode)this.EditingElement);
            }
            if (this.transformHelper == null)
            {
                return;
            }
            this.transformHelper.Update(scale1.X, scale1.Y);
        }
Esempio n. 7
0
 public virtual void SetChildRect(BaseFrameworkElement child, Rect rect, LayoutOverrides layoutOverrides, LayoutOverrides overridesToIgnore, LayoutOverrides nonExplicitOverrides, SetRectMode setRectMode)
 {
     overridesToIgnore = this.AdjustOverrideToIgnore(child, overridesToIgnore);
     if (this.suppressLayoutRoundingCount == 0 && (LayoutRoundingHelper.GetLayoutRoundingStatus((SceneElement)child) & LayoutRoundingStatus.ShouldSnapToPixel) != LayoutRoundingStatus.Off)
     {
         rect = LayoutRoundingHelper.RoundRect(child.Platform.GeometryHelper, rect);
     }
     using (child.ViewModel.ScopeViewObjectCache())
     {
         using (GridLayoutDesigner.TryCanvasDesignMode(child, rect.Size, true, true))
         {
             LayoutUtilities.EnterLayoutMode();
             LayoutOperation layoutOperation = this.CreateLayoutOperation(child);
             if (layoutOverrides == LayoutOverrides.RecomputeDefault)
             {
                 layoutOverrides = this.InternalComputeOverrides(child, layoutOperation);
             }
             layoutOperation.SetRect(rect, layoutOverrides, overridesToIgnore, nonExplicitOverrides, setRectMode);
             LayoutUtilities.ExitLayoutMode();
         }
     }
 }
Esempio n. 8
0
        public void SetRect(Rect rect, LayoutOverrides layoutOverrides, LayoutOverrides overridesToIgnore, LayoutOverrides nonExplicitOverrides, SetRectMode setRectMode)
        {
            if (this.Child.Visual == null)
            {
                return;
            }
            this.LayoutOverrides      = layoutOverrides;
            this.OverridesToIgnore    = overridesToIgnore;
            this.NonExplicitOverrides = nonExplicitOverrides;
            this.SetRectMode          = setRectMode;
            LayoutOverrides explicitOverrides = this.ExplicitOverrides;

            if (this.RoundBeforeSettingChildRect)
            {
                double num1 = (this.LayoutOverrides & LayoutOverrides.Width) == LayoutOverrides.None || (this.OverridesToIgnore & LayoutOverrides.Width) != LayoutOverrides.None ? 0.0 : 0.00045;
                double num2 = (this.LayoutOverrides & LayoutOverrides.Height) == LayoutOverrides.None || (this.OverridesToIgnore & LayoutOverrides.Height) != LayoutOverrides.None ? 0.0 : 0.00045;
                double x    = RoundingHelper.RoundLength(rect.Left - num1);
                double y    = RoundingHelper.RoundLength(rect.Top - num2);
                double num3 = RoundingHelper.RoundLength(rect.Right + num1);
                double num4 = RoundingHelper.RoundLength(rect.Bottom + num2);
                rect = new Rect(x, y, RoundingHelper.RoundLength(num3 - x), RoundingHelper.RoundLength(num4 - y));
            }
            this.ChildRect = rect;
            this.ComputeIdealSlotRect();
            this.SetSlotRectChanges();
            this.UpdateChildRectWithinSlot();
            this.ComputeIdealAlignment();
            this.SetAlignmentChanges();
            this.ComputeIdealSize();
            this.SetSizeChanges();
            this.ComputeIdealMargin();
            this.SetMarginChanges();
            this.ExplicitOverrides &= ~this.NonExplicitOverrides;
            if (this.ExplicitOverrides == explicitOverrides)
            {
                return;
            }
            LayoutUtilities.SetLayoutOverrides((SceneElement)this.Child, this.ExplicitOverrides);
        }
        public override void Execute(object arg)
        {
            DesignerContext designerContext      = this.DesignerContext;
            SceneViewModel  activeSceneViewModel = designerContext.ActiveSceneViewModel;
            ITypeId         type = this.Type;

            if (type is ProjectNeutralTypeId)
            {
                bool flag = activeSceneViewModel.ProjectContext.PlatformMetadata.IsSupported((ITypeResolver)this.DesignerContext.ActiveSceneViewModel.ProjectContext, type);
                if (!flag && this.IsDragDropContainer)
                {
                    IMessageDisplayService messageDisplayService = activeSceneViewModel.DesignerContext.MessageDisplayService;
                    flag = ToolkitHelper.EnsureSilverlightToolkitTypeAvailable((ITypeResolver)activeSceneViewModel.ProjectContext, type, messageDisplayService, StringTable.SilverlightToolkitDragDropNotInstalled, StringTable.SilverlightToolkitDragDropIncorrectVersion);
                }
                if (!flag)
                {
                    return;
                }
            }
            using (SceneEditTransaction editTransaction = designerContext.ActiveDocument.CreateEditTransaction(string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.UndoUnitGroupIntoLayoutType, new object[1]
            {
                (object)this.Type.Name
            })))
            {
                List <SceneElement> list1    = new List <SceneElement>();
                List <SceneNode>    elements = new List <SceneNode>();
                list1.AddRange((IEnumerable <SceneElement>)designerContext.SelectionManager.ElementSelectionSet.Selection);
                GroupIntoLayoutTypeCommand.OrientationHelper orientationHelper = new GroupIntoLayoutTypeCommand.OrientationHelper();
                list1.Sort((IComparer <SceneElement>) new ZOrderComparer <SceneElement>(this.SceneViewModel.RootNode));
                List <LayoutCacheRecord> list2 = new List <LayoutCacheRecord>(list1.Count);
                Rect empty = Rect.Empty;
                for (int index = 0; index < list1.Count; ++index)
                {
                    list2.Add((LayoutCacheRecord)null);
                    BaseFrameworkElement element = list1[index] as BaseFrameworkElement;
                    if (element != null)
                    {
                        ILayoutDesigner designerForChild   = element.ViewModel.GetLayoutDesignerForChild((SceneElement)element, true);
                        Rect            roundedUpChildRect = LayoutRoundingHelper.GetRoundedUpChildRect(designerForChild, element);
                        empty.Union(roundedUpChildRect);
                        orientationHelper.AddChildRect((SceneNode)element, roundedUpChildRect);
                        LayoutCacheRecord layoutCacheRecord = designerForChild.CacheLayout(element);
                        list2[index] = layoutCacheRecord;
                        elements.Add((SceneNode)element);
                    }
                }
                Dictionary <IPropertyId, SceneNode> properties = (Dictionary <IPropertyId, SceneNode>)null;
                using (this.SceneViewModel.ForceBaseValue())
                {
                    using (this.SceneViewModel.DisableDrawIntoState())
                    {
                        SceneElement sceneElement1 = (SceneElement)null;
                        SceneElement sceneElement2 = (SceneElement)activeSceneViewModel.CreateSceneNode(type);
                        Orientation? nullable      = orientationHelper.ApplyOrientation(sceneElement2);
                        if (nullable.HasValue)
                        {
                            orientationHelper.SortElements(elements, nullable.Value);
                        }
                        int num;
                        if (list1.Count == 1 && list1[0] is BaseFrameworkElement)
                        {
                            int?fixedCapacity = sceneElement2.DefaultContent.FixedCapacity;
                            num = fixedCapacity.GetValueOrDefault() != 1 ? 0 : (fixedCapacity.HasValue ? true : false);
                        }
                        else
                        {
                            num = 0;
                        }
                        bool flag = num != 0;
                        if (sceneElement2 != null)
                        {
                            activeSceneViewModel.GetLayoutDesignerForParent(sceneElement2, true);
                        }
                        foreach (SceneElement sceneElement3 in list1)
                        {
                            if (sceneElement3 != null)
                            {
                                BaseFrameworkElement frameworkElement = sceneElement3 as BaseFrameworkElement;
                                ILayoutDesigner      layoutDesigner   = frameworkElement == null ? (ILayoutDesigner)null : sceneElement3.ViewModel.GetLayoutDesignerForChild((SceneElement)frameworkElement, true);
                                if (flag)
                                {
                                    properties = SceneElementHelper.StoreProperties((SceneNode)sceneElement3, layoutDesigner.GetLayoutProperties(), true);
                                }
                                if (this.SceneViewModel.LockedInsertionPoint != null && this.SceneViewModel.LockedInsertionPoint.SceneElement == sceneElement3)
                                {
                                    sceneElement1 = sceneElement3;
                                }
                            }
                        }
                        if (list1.Count == 1)
                        {
                            VisualStateManagerSceneNode.MoveStates(list1[0], sceneElement2);
                        }
                        using (activeSceneViewModel.DisableUpdateChildrenOnAddAndRemove())
                        {
                            SceneElement primarySelection = designerContext.SelectionManager.ElementSelectionSet.PrimarySelection;
                            designerContext.SelectionManager.ElementSelectionSet.Clear();
                            Dictionary <IPropertyId, List <SceneNode> > storedChildren = new Dictionary <IPropertyId, List <SceneNode> >();
                            storedChildren.Add((IPropertyId)sceneElement2.DefaultContentProperty, elements);
                            ISceneNodeCollection <SceneNode> collectionContainer = primarySelection.GetCollectionContainer();
                            foreach (SceneElement sceneElement3 in list1)
                            {
                                if (sceneElement3 != primarySelection)
                                {
                                    sceneElement3.Remove();
                                }
                            }
                            int index1 = collectionContainer.IndexOf((SceneNode)primarySelection);
                            primarySelection.Remove();
                            collectionContainer.Insert(index1, (SceneNode)sceneElement2);
                            ChangeLayoutTypeCommand.ApplyChildren(sceneElement2, storedChildren, empty.Size);
                            if (flag)
                            {
                                SceneElementHelper.FixElementNameBindingsInStoredProperties((SceneNode)list1[0], (SceneNode)sceneElement2, properties);
                                SceneElementHelper.ApplyProperties((SceneNode)sceneElement2, properties);
                            }
                            else
                            {
                                ILayoutDesigner designerForChild = sceneElement2.ViewModel.GetLayoutDesignerForChild(sceneElement2, true);
                                if (sceneElement2.IsViewObjectValid)
                                {
                                    LayoutOverrides layoutOverrides   = LayoutOverrides.None;
                                    LayoutOverrides overridesToIgnore = LayoutOverrides.None;
                                    if (nullable.HasValue && nullable.Value == Orientation.Horizontal)
                                    {
                                        layoutOverrides |= LayoutOverrides.Width;
                                    }
                                    else
                                    {
                                        overridesToIgnore |= LayoutOverrides.Width;
                                    }
                                    if (nullable.HasValue && nullable.Value == Orientation.Vertical)
                                    {
                                        layoutOverrides |= LayoutOverrides.Height;
                                    }
                                    else
                                    {
                                        overridesToIgnore |= LayoutOverrides.Height;
                                    }
                                    designerForChild.SetChildRect((BaseFrameworkElement)sceneElement2, empty, layoutOverrides, overridesToIgnore, LayoutOverrides.None);
                                }
                            }
                            editTransaction.Update();
                            if (sceneElement2.IsViewObjectValid)
                            {
                                this.SceneViewModel.DefaultView.UpdateLayout();
                                SceneElement    parentElement     = primarySelection.ParentElement;
                                ILayoutDesigner designerForParent = activeSceneViewModel.GetLayoutDesignerForParent(parentElement, true);
                                for (int index2 = 0; index2 < list1.Count; ++index2)
                                {
                                    SceneElement         sceneElement3    = list1[index2];
                                    BaseFrameworkElement frameworkElement = sceneElement3 as BaseFrameworkElement;
                                    if (frameworkElement != null)
                                    {
                                        LayoutCacheRecord layoutCacheRecord = list2[index2];
                                        Rect rect = LayoutRoundingHelper.RoundUpLayoutRect(frameworkElement, layoutCacheRecord.Rect);
                                        rect.Location = (Point)(rect.Location - empty.Location);
                                        designerForParent.ClearUnusedLayoutProperties(frameworkElement);
                                        designerForParent.SetChildRect(frameworkElement, rect, flag ? LayoutOverrides.None : layoutCacheRecord.Overrides, LayoutOverrides.Margin | LayoutOverrides.GridBox, LayoutOverrides.None);
                                        if (this.IsDragDropContainer)
                                        {
                                            sceneElement3.SetValue(Base2DElement.AllowDropProperty, (object)true);
                                        }
                                    }
                                }
                            }
                            if (sceneElement1 != null)
                            {
                                this.SceneViewModel.SetLockedInsertionPoint(sceneElement1);
                            }
                        }
                        designerContext.SelectionManager.ElementSelectionSet.SetSelection(sceneElement2);
                        editTransaction.Commit();
                    }
                }
            }
        }
Esempio n. 10
0
 public override void SetChildRect(BaseFrameworkElement child, Rect rect, LayoutOverrides layoutOverrides, LayoutOverrides overridesToIgnore, LayoutOverrides nonExplicitOverrides, SetRectMode setRectMode)
 {
     overridesToIgnore |= LayoutOverrides.Margin;
     base.SetChildRect(child, rect, layoutOverrides, overridesToIgnore, nonExplicitOverrides, setRectMode);
 }
Esempio n. 11
0
 public void SetChildRect(BaseFrameworkElement child, Rect rect, LayoutOverrides layoutOverrides, LayoutOverrides overridesToIgnore, LayoutOverrides nonExplicitOverrides)
 {
     this.SetChildRect(child, rect, layoutOverrides, overridesToIgnore, nonExplicitOverrides, SetRectMode.Default);
 }
Esempio n. 12
0
        public void SetChildRect(BaseFrameworkElement child, Rect rect, bool setWidth, bool setHeight)
        {
            LayoutOverrides overridesToIgnore = (LayoutOverrides)(0 | (setWidth ? 16 : 0) | (setHeight ? 32 : 0));

            this.SetChildRect(child, this.PrepareLayoutRect(rect), LayoutOverrides.RecomputeDefault, overridesToIgnore, LayoutOverrides.None, SetRectMode.Default);
        }
Esempio n. 13
0
        private void SetLayout(ISceneInsertionPoint insertionPoint, Rect rect, SceneNode node, SceneNode layoutTarget, SceneEditTransaction undo)
        {
            if (!PlatformTypes.UIElement.IsAssignableFrom((ITypeId)node.Type))
            {
                return;
            }
            bool flag1 = false;
            bool flag2 = false;

            if (node.IsSet(BaseFrameworkElement.WidthProperty) == PropertyState.Set && double.IsNaN(rect.Width))
            {
                rect.Width = (double)node.GetLocalOrDefaultValueAsWpf(BaseFrameworkElement.WidthProperty);
                flag1      = true;
            }
            if (node.IsSet(BaseFrameworkElement.HeightProperty) == PropertyState.Set && double.IsNaN(rect.Height))
            {
                rect.Height = (double)node.GetLocalOrDefaultValueAsWpf(BaseFrameworkElement.HeightProperty);
                flag2       = true;
            }
            using (this.ViewModel.ForceBaseValue())
            {
                BaseFrameworkElement child = layoutTarget as BaseFrameworkElement;
                if (child == null)
                {
                    return;
                }
                SetRectMode     setRectMode      = SetRectMode.Default;
                ILayoutDesigner designerForChild = child.ViewModel.GetLayoutDesignerForChild((SceneElement)child, true);
                if (double.IsNaN(rect.Width) || double.IsNaN(rect.Height))
                {
                    setRectMode = SetRectMode.CreateDefault;
                    bool flag3 = PlatformTypes.Control.IsAssignableFrom((ITypeId)node.Type) || PlatformTypes.TextBlock.IsAssignableFrom((ITypeId)node.Type);
                    for (int index = 0; index < DefaultTypeInstantiator.SizeNonExceptions.Length; ++index)
                    {
                        if (DefaultTypeInstantiator.SizeNonExceptions[index].Equals((object)node.Type))
                        {
                            flag3 = false;
                        }
                    }
                    if (!flag3)
                    {
                        BaseFrameworkElement frameworkElement = insertionPoint.SceneNode as BaseFrameworkElement;
                        if (frameworkElement != null)
                        {
                            Rect   computedTightBounds = frameworkElement.GetComputedTightBounds();
                            double val1_1 = 100.0;
                            double val1_2 = 100.0;
                            if (ProjectNeutralTypes.GridSplitter.IsAssignableFrom((ITypeId)node.Type))
                            {
                                val1_1 = 5.0;
                            }
                            else if (PlatformTypes.Button.IsAssignableFrom((ITypeId)node.Type))
                            {
                                val1_1 = 75.0;
                            }
                            else if (PlatformTypes.ComboBox.IsAssignableFrom((ITypeId)node.Type))
                            {
                                val1_1 = 120.0;
                            }
                            if (PlatformTypes.ProgressBar.IsAssignableFrom((ITypeId)node.Type))
                            {
                                val1_2 = 10.0;
                            }
                            else if (PlatformTypes.Button.IsAssignableFrom((ITypeId)node.Type) || PlatformTypes.ComboBox.IsAssignableFrom((ITypeId)node.Type))
                            {
                                val1_2 = double.NaN;
                            }
                            if ((designerForChild.GetWidthConstraintMode(child) & LayoutConstraintMode.CanvasLike) == LayoutConstraintMode.NonOverlappingGridlike)
                            {
                                val1_1 = Math.Min(val1_1, computedTightBounds.Width);
                            }
                            if ((designerForChild.GetHeightConstraintMode(child) & LayoutConstraintMode.CanvasLike) == LayoutConstraintMode.NonOverlappingGridlike)
                            {
                                val1_2 = Math.Min(val1_2, computedTightBounds.Height);
                            }
                            rect = new Rect(rect.Left, rect.Top, double.IsNaN(rect.Width) ? val1_1 : rect.Width, double.IsNaN(rect.Height) ? val1_2 : rect.Height);
                        }
                    }
                }
                LayoutOverrides layoutOverrides   = LayoutOverrides.None;
                LayoutOverrides overridesToIgnore = LayoutOverrides.None;
                Rect            rect1             = rect;
                if (double.IsNaN(rect.Width))
                {
                    layoutOverrides |= LayoutOverrides.Width;
                    rect1.Width      = 0.0;
                }
                else
                {
                    overridesToIgnore |= LayoutOverrides.Width;
                }
                if (double.IsNaN(rect.Height))
                {
                    layoutOverrides |= LayoutOverrides.Height;
                    rect1.Height     = 0.0;
                }
                else
                {
                    overridesToIgnore |= LayoutOverrides.Height;
                }
                designerForChild.SetChildRect(child, rect1, layoutOverrides, overridesToIgnore, LayoutOverrides.None, setRectMode);
                undo.Update();
                IViewVisual viewVisual = child.ViewObject as IViewVisual;
                if (viewVisual == null || !double.IsNaN(rect.Width) && !double.IsNaN(rect.Height))
                {
                    return;
                }
                viewVisual.UpdateLayout();
                Rect childRect = designerForChild.GetChildRect(child);
                if (double.IsNaN(rect.Width) && !flag1)
                {
                    if (viewVisual.RenderSize.Width < 5.0)
                    {
                        rect1.Width        = 100.0;
                        layoutOverrides   &= ~LayoutOverrides.Width;
                        overridesToIgnore |= LayoutOverrides.Width;
                    }
                    else
                    {
                        rect1.Width = childRect.Width;
                    }
                }
                if (double.IsNaN(rect.Height) && !flag2)
                {
                    if (viewVisual.RenderSize.Height < 5.0)
                    {
                        rect1.Height       = 100.0;
                        layoutOverrides   &= ~LayoutOverrides.Height;
                        overridesToIgnore |= LayoutOverrides.Height;
                    }
                    else
                    {
                        rect1.Height = childRect.Height;
                    }
                }
                LayoutOverrides nonExplicitOverrides = LayoutOverrides.None;
                if (PlatformTypes.FlowDocumentScrollViewer.IsAssignableFrom((ITypeId)child.Type) || PlatformTypes.RichTextBox.IsAssignableFrom((ITypeId)child.Type))
                {
                    nonExplicitOverrides = LayoutOverrides.Width;
                }
                designerForChild.SetChildRect(child, rect1, layoutOverrides, overridesToIgnore, nonExplicitOverrides, setRectMode);
            }
        }
 public override void SetChildRect(BaseFrameworkElement child, Rect rect, LayoutOverrides layoutOverrides, LayoutOverrides overridesToIgnore, LayoutOverrides nonExplicitOverrides, SetRectMode setRectMode)
 {
 }
Esempio n. 15
0
        public virtual bool AddToDocument(IProjectItem projectItem, IView view, ISceneInsertionPoint insertionPoint, Rect rect)
        {
            SceneView sceneView = view as SceneView;

            if (sceneView != null && sceneView.IsDesignSurfaceEnabled && insertionPoint != null)
            {
                SceneViewModel viewModel = sceneView.ViewModel;
                string         str       = insertionPoint.SceneNode.DocumentNode.Context.MakeResourceReference(projectItem.DocumentReference.Path);
                if (!string.IsNullOrEmpty(str))
                {
                    SceneElement element = this.CreateElement(viewModel, insertionPoint, str);
                    if (element != null)
                    {
                        try
                        {
                            using (SceneEditTransaction editTransaction = viewModel.CreateEditTransaction(StringTable.AssetAddAssetUndo))
                            {
                                IList <SceneElement> list = this.AddToDocumentInternal(str, element, insertionPoint, viewModel, editTransaction);
                                editTransaction.Update();
                                if (sceneView.IsValid && list.Count > 0)
                                {
                                    element = list[0];
                                    if (element != null && element.IsViewObjectValid && (this.designerContext.ActiveView == sceneView && sceneView.ViewRoot != null) && element.Visual != null)
                                    {
                                        sceneView.EnsureVisible(element.Visual);
                                    }
                                    BaseFrameworkElement child = element as BaseFrameworkElement;
                                    if (child != null)
                                    {
                                        SetRectMode setRectMode = SetRectMode.CreateAtPosition;
                                        if (rect.IsEmpty)
                                        {
                                            rect        = new Rect(0.0, 0.0, double.PositiveInfinity, double.PositiveInfinity);
                                            setRectMode = SetRectMode.CreateDefault;
                                        }
                                        if (double.IsPositiveInfinity(rect.Width))
                                        {
                                            rect.Width = this.GetNativeWidth((SceneElement)child);
                                        }
                                        if (double.IsPositiveInfinity(rect.Height))
                                        {
                                            rect.Height = this.GetNativeHeight((SceneElement)child);
                                        }
                                        using (viewModel.ForceBaseValue())
                                        {
                                            ILayoutDesigner designerForChild = viewModel.GetLayoutDesignerForChild((SceneElement)child, true);
                                            LayoutOverrides layoutOverrides  = LayoutOverrides.HorizontalAlignment | LayoutOverrides.VerticalAlignment;
                                            designerForChild.SetChildRect(child, rect, LayoutOverrides.None, layoutOverrides, layoutOverrides, setRectMode);
                                        }
                                    }
                                    viewModel.ElementSelectionSet.SetSelection((ICollection <SceneElement>)list, (SceneElement)null);
                                }
                                editTransaction.Commit();
                            }
                            return(true);
                        }
                        catch (InvalidOperationException ex)
                        {
                            this.DesignerContext.MessageDisplayService.ShowError(string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.AssetElementInsertionFailedDialogMessage, new object[2]
                            {
                                (object)element.Name,
                                (object)ex.Message
                            }));
                        }
                    }
                }
            }
            return(false);
        }
Esempio n. 16
0
 protected T SetPropertyChanges <T>(T settingsValue, T settingsFromElementValue, LayoutOverrides layoutOverride, IPropertyId property)
 {
     if (!settingsFromElementValue.Equals((object)settingsValue))
     {
         if ((this.LayoutOverrides & layoutOverride) != LayoutOverrides.None && (this.OverridesToIgnore & layoutOverride) == LayoutOverrides.None)
         {
             settingsValue = settingsFromElementValue;
         }
         else
         {
             this.Child.SetValueAsWpf(property, (object)settingsValue);
         }
         this.ExplicitOverrides &= ~layoutOverride;
     }
     else if ((this.LayoutOverrides & layoutOverride) != LayoutOverrides.None && (this.SettingsFromElement.LayoutOverrides & layoutOverride) == LayoutOverrides.None)
     {
         this.ExplicitOverrides |= layoutOverride;
     }
     return(settingsValue);
 }