コード例 #1
0
        internal static ReferenceStep FilterProperty(SceneNode node, ReferenceStep referenceStep)
        {
            if (node is RichTextBoxRangeElement)
            {
                return(referenceStep);
            }
            RichTextBoxElement richTextBoxElement = node as RichTextBoxElement;

            if (richTextBoxElement != null)
            {
                foreach (IPropertyId propertyId in !node.ProjectContext.IsCapabilitySet(PlatformCapability.IsWpf) ? RichTextBoxParagraphsRangeElement.SilverlightTextParagraphProperties : RichTextBoxParagraphsRangeElement.WpfTextParagraphProperties)
                {
                    if (referenceStep.Equals((object)richTextBoxElement.ProjectContext.ResolveProperty(propertyId)))
                    {
                        return(referenceStep);
                    }
                }
            }
            StyleNode styleNode   = node as StyleNode;
            IType     typeId      = styleNode == null || styleNode.Platform.Metadata.IsNullType((ITypeId)styleNode.StyleTargetTypeId) ? node.Type : styleNode.StyleTargetTypeId;
            Type      runtimeType = typeId.NearestResolvedType.RuntimeType;

            if (referenceStep.TargetType.IsAssignableFrom(runtimeType) && (PlatformTypeHelper.GetDeclaringType((IMember)referenceStep) == runtimeType || referenceStep.MemberType == MemberType.DesignTimeProperty))
            {
                return(referenceStep);
            }
            ReferenceStep referenceStep1;

            if (typeId == SceneNodeObjectSet.FilteredPropertiesType)
            {
                if (SceneNodeObjectSet.FilteredProperties.TryGetValue(referenceStep, out referenceStep1))
                {
                    return(referenceStep1);
                }
            }
            else
            {
                SceneNodeObjectSet.FilteredPropertiesType = (ITypeId)typeId;
                SceneNodeObjectSet.FilteredProperties.Clear();
            }
            referenceStep1 = SceneNodeObjectSet.FilterPropertyInternal((ITypeResolver)node.ProjectContext, typeId, referenceStep);
            SceneNodeObjectSet.FilteredProperties.Add(referenceStep, referenceStep1);
            return(referenceStep1);
        }
コード例 #2
0
ファイル: StyleNode.cs プロジェクト: radtek/Shopdrawing
        protected override object GetRawComputedValueInternal(PropertyReference propertyReference)
        {
            if (this.IsStyleProperty(propertyReference))
            {
                return(base.GetRawComputedValueInternal(propertyReference));
            }
            IViewObject viewTargetElement = this.ViewTargetElement;

            if (viewTargetElement == null || !PlatformTypes.FrameworkElement.IsAssignableFrom((ITypeId)viewTargetElement.GetIType((ITypeResolver)this.ProjectContext)))
            {
                ReferenceStep referenceStep = propertyReference[propertyReference.Count - 1];
                return(referenceStep.GetDefaultValue(PlatformTypeHelper.GetDeclaringType((IMember)referenceStep)));
            }
            PropertyReference propertyReference1 = DesignTimeProperties.GetAppliedShadowPropertyReference(propertyReference, (ITypeId)this.Type);

            if (propertyReference1 != propertyReference && !DesignTimeProperties.UseShadowPropertyForInstanceBuilding(this.DocumentContext.TypeResolver, (IPropertyId)propertyReference[0]))
            {
                return(SceneNode.GetComputedValueWithShadowCoercion(propertyReference, propertyReference, viewTargetElement.PlatformSpecificObject));
            }
            return(this.GetCurrentValueFromPropertyReference(propertyReference1, viewTargetElement.PlatformSpecificObject));
        }
コード例 #3
0
ファイル: TextEditProxy.cs プロジェクト: radtek/Shopdrawing
        protected virtual void CopyProperty(IPropertyId propertyId)
        {
            DependencyPropertyReferenceStep propertyReferenceStep = this.TextSource.DesignerContext.DesignerDefaultPlatformService.DefaultPlatform.Metadata.ResolveProperty(propertyId) as DependencyPropertyReferenceStep;
            ReferenceStep referenceStep1 = PlatformTypes.IsExpressionInteractiveType(PlatformTypeHelper.GetDeclaringType((IMember)propertyReferenceStep)) ? (ReferenceStep)propertyReferenceStep : PlatformTypeHelper.GetProperty((ITypeResolver)this.TextSource.ProjectContext, (ITypeId)this.TextSource.Type, MemberType.LocalProperty, propertyReferenceStep.Name);

            if (referenceStep1 == null)
            {
                return;
            }
            object computedValueAsWpf = this.TextSource.GetComputedValueAsWpf((IPropertyId)referenceStep1);

            if (!this.TextSource.ProjectContext.IsCapabilitySet(PlatformCapability.IsWpf))
            {
                if (DesignTimeProperties.GetShadowProperty((IProperty)referenceStep1, (ITypeId)this.TextSource.Type) != null)
                {
                    for (SceneNode sceneNode = (SceneNode)this.TextSource; sceneNode != null; sceneNode = sceneNode.Parent)
                    {
                        IProperty property = PlatformTypes.IsExpressionInteractiveType(PlatformTypeHelper.GetDeclaringType((IMember)referenceStep1)) ? (IProperty)referenceStep1 : (IProperty)PlatformTypeHelper.GetProperty((ITypeResolver)this.TextSource.ProjectContext, (ITypeId)sceneNode.Type, MemberType.LocalProperty, referenceStep1.Name);
                        if (property != null && sceneNode.IsSet((IPropertyId)property) == PropertyState.Set)
                        {
                            computedValueAsWpf = sceneNode.GetComputedValueAsWpf((IPropertyId)property);
                            break;
                        }
                    }
                }
            }
            try
            {
                ReferenceStep referenceStep2 = referenceStep1;
                if (!this.TextSource.ProjectContext.IsCapabilitySet(PlatformCapability.IsWpf))
                {
                    referenceStep2 = (ReferenceStep)propertyReferenceStep;
                }
                referenceStep2.SetValue(this.EditingElement.PlatformSpecificObject, computedValueAsWpf);
            }
            catch
            {
            }
        }
コード例 #4
0
        public static PathElement ConvertToPath(BaseFrameworkElement element)
        {
            SceneViewModel  viewModel        = element.ViewModel;
            PathGeometry    pathGeometry     = PathConversionHelper.ConvertToPathGeometry((SceneElement)element);
            PathElement     pathElement      = (PathElement)viewModel.CreateSceneNode(PlatformTypes.Path);
            ILayoutDesigner designerForChild = viewModel.GetLayoutDesignerForChild((SceneElement)element, true);
            Rect            childRect        = designerForChild.GetChildRect(element);
            Transform       transform1       = Transform.Identity;

            if (element.IsSet(Base2DElement.RenderTransformProperty) == PropertyState.Set)
            {
                transform1 = (Transform)element.GetComputedValueAsWpf(Base2DElement.RenderTransformProperty);
            }
            Point point1 = new Point(0.5, 0.5);

            if (element.IsSet(Base2DElement.RenderTransformOriginProperty) == PropertyState.Set)
            {
                point1 = (Point)element.GetComputedValueAsWpf(Base2DElement.RenderTransformOriginProperty);
            }
            bool flag = false;

            using (SceneEditTransaction editTransaction = viewModel.CreateEditTransaction(StringTable.UndoUnitConvertToPath, true))
            {
                using (viewModel.ForceBaseValue())
                {
                    pathElement.PathGeometry = pathGeometry;
                    pathElement.SetValueAsWpf(ShapeElement.StretchProperty, (object)Stretch.Fill);
                    Brush textForeground = PathCommandHelper.GetTextForeground(element);
                    if (textForeground != null)
                    {
                        flag = true;
                        pathElement.SetValueAsWpf(ShapeElement.FillProperty, (object)textForeground);
                    }
                    viewModel.AnimationEditor.DeleteAllAnimations((SceneNode)element);
                    Dictionary <IPropertyId, SceneNode> properties         = SceneElementHelper.StoreProperties((SceneNode)element);
                    ISceneNodeCollection <SceneNode>    collectionForChild = element.Parent.GetCollectionForChild((SceneNode)element);
                    int index = collectionForChild.IndexOf((SceneNode)element);
                    collectionForChild[index] = (SceneNode)pathElement;
                    if (flag)
                    {
                        List <IPropertyId> list = new List <IPropertyId>();
                        foreach (KeyValuePair <IPropertyId, SceneNode> keyValuePair in properties)
                        {
                            IPropertyId key = keyValuePair.Key;
                            DependencyPropertyReferenceStep propertyReferenceStep = key as DependencyPropertyReferenceStep;
                            if (propertyReferenceStep != null && !propertyReferenceStep.IsAttachable && (propertyReferenceStep.MemberType != MemberType.DesignTimeProperty && !PlatformTypeHelper.GetDeclaringType((IMember)propertyReferenceStep).IsAssignableFrom(typeof(Path))))
                            {
                                list.Add(key);
                            }
                        }
                        foreach (IPropertyId key in list)
                        {
                            properties.Remove(key);
                        }
                    }
                    SceneElementHelper.ApplyProperties((SceneNode)pathElement, properties);
                }
                if (ProjectNeutralTypes.PrimitiveShape.IsAssignableFrom((ITypeId)element.Type))
                {
                    using (viewModel.ForceBaseValue())
                    {
                        Rect   bounds          = pathGeometry.Bounds;
                        double halfStrokeWidth = PathCommandHelper.GetHalfStrokeWidth(pathElement);
                        bounds.Inflate(halfStrokeWidth / 2.0, halfStrokeWidth / 2.0);
                        if (transform1 != Transform.Identity && bounds.Size != childRect.Size)
                        {
                            Point point2 = (Point)pathElement.GetComputedValueAsWpf(Base2DElement.RenderTransformOriginProperty);
                            Point point3 = new Point(point2.X * childRect.Width, point2.Y * childRect.Height);
                            Point point4 = new Point((point3.X - bounds.X) / bounds.Width, (point3.Y - bounds.Y) / bounds.Height);
                            pathElement.SetValueAsWpf(Base2DElement.RenderTransformOriginProperty, (object)point4);
                        }
                        bounds.Offset(childRect.Left, childRect.Top);
                        editTransaction.Update();
                        designerForChild.SetChildRect((BaseFrameworkElement)pathElement, bounds);
                    }
                }
                if (flag && !pathGeometry.IsEmpty())
                {
                    using (viewModel.ForceBaseValue())
                    {
                        Rect bounds = pathGeometry.Bounds;
                        bounds.Offset(childRect.Left, childRect.Top);
                        Point point2 = new Point(bounds.Left + point1.X * bounds.Width, bounds.Top + point1.Y * bounds.Height);
                        Point point3 = new Point(childRect.Left + childRect.Width * point1.X, childRect.Top + childRect.Height * point1.Y);
                        Point point4 = new TransformGroup()
                        {
                            Children =
                            {
                                (Transform) new TranslateTransform(-point3.X, -point3.Y),
                                transform1,
                                (Transform) new TranslateTransform(point3.X,  point3.Y)
                            }
                        }.Transform(point2);
                        Transform transform2 = (Transform) new CanonicalTransform(transform1)
                        {
                            TranslationX = 0.0,
                            TranslationY = 0.0
                        }.TransformGroup;
                        Rect rect = new Rect(point4.X - bounds.Width * point1.X, point4.Y - bounds.Height * point1.Y, bounds.Width, bounds.Height);
                        pathElement.SetValueAsWpf(Base2DElement.RenderTransformOriginProperty, (object)point1);
                        editTransaction.Update();
                        designerForChild.SetChildRect((BaseFrameworkElement)pathElement, rect);
                        pathElement.RenderTransform = transform2;
                    }
                }
                editTransaction.Commit();
            }
            return(pathElement);
        }