Exemplo n.º 1
0
 public PathDiff(Base2DElement targetElement, IPropertyId pathProperty, PathDiffChangeList changeList)
 {
     this.targetElement    = targetElement;
     this.platformMetadata = targetElement.Platform.Metadata;
     this.pathProperty     = this.platformMetadata.ResolveProperty(pathProperty) as ReferenceStep;
     this.changeList       = changeList;
 }
        private static object InstantiateConstructorArgument(IInstanceBuilderContext context, ViewNode viewNode, IParameter constructorArgument, IProperty constructorArgumentProperty, DocumentNode constructorArgumentNode)
        {
            object defaultValue;

            if (constructorArgumentProperty != null)
            {
                return(InstanceBuilderOperations.UpdatePropertyWithoutApply(context, viewNode, constructorArgumentProperty, constructorArgumentNode).Instance);
            }
            if (constructorArgumentNode != null)
            {
                ViewNode viewNode1 = InstanceBuilderOperations.UpdateChildWithoutApply(context, viewNode, viewNode.Children.Count, DocumentNodeChangeAction.Add, constructorArgumentNode);
                return(viewNode1.Instance);
            }
            IDocumentContext documentContext = viewNode.DocumentNode.Context;
            Type             targetType      = viewNode.TargetType;
            Type             runtimeType     = constructorArgument.ParameterType.RuntimeType;
            ReferenceStep    referenceStep   = constructorArgumentProperty as ReferenceStep;

            if (referenceStep == null || !referenceStep.HasDefaultValue(targetType))
            {
                bool flag = documentContext.TypeResolver.InTargetAssembly(constructorArgument.ParameterType);
                defaultValue = InstanceBuilderOperations.InstantiateType(runtimeType, flag);
            }
            else
            {
                defaultValue = referenceStep.GetDefaultValue(targetType);
            }
            if (context.IsSerializationScope)
            {
                defaultValue = documentContext.CreateNode(runtimeType, defaultValue);
            }
            return(defaultValue);
        }
Exemplo n.º 3
0
        private void UpdateFromDataContext()
        {
            this.editingValue = this.DataContext as Microsoft.Windows.Design.PropertyEditing.PropertyValue;
            this.UnhookEditingProperty();
            if (this.editingValue != null)
            {
                this.editingProperty = (SceneNodeProperty)this.editingValue.ParentProperty;
            }
            if (this.editingProperty == null)
            {
                return;
            }
            SceneNodeObjectSet sceneNodeObjectSet = this.editingProperty.SceneNodeObjectSet;
            ReferenceStep      singleStep1        = (ReferenceStep)sceneNodeObjectSet.ProjectContext.ResolveProperty(BehaviorEventTriggerBaseNode.BehaviorSourceNameProperty);

            if (singleStep1 != null)
            {
                this.sourceNameProperty = sceneNodeObjectSet.CreateSceneNodeProperty(new PropertyReference(singleStep1), (AttributeCollection)null);
                this.sourceNameProperty.PropertyReferenceChanged += new Microsoft.Expression.DesignSurface.Documents.PropertyReferenceChangedEventHandler(this.OnSourceNameOrSourceObjectPropertyPropertyReferenceChanged);
            }
            ReferenceStep singleStep2 = (ReferenceStep)sceneNodeObjectSet.ProjectContext.ResolveProperty(BehaviorEventTriggerBaseNode.BehaviorSourceObjectProperty);

            if (singleStep2 != null)
            {
                this.sourceObjectProperty = sceneNodeObjectSet.CreateSceneNodeProperty(new PropertyReference(singleStep2), (AttributeCollection)null);
                this.sourceObjectProperty.PropertyReferenceChanged += new Microsoft.Expression.DesignSurface.Documents.PropertyReferenceChangedEventHandler(this.OnSourceNameOrSourceObjectPropertyPropertyReferenceChanged);
            }
            this.editingProperty.PropertyReferenceChanged += new Microsoft.Expression.DesignSurface.Documents.PropertyReferenceChangedEventHandler(this.OnEditingPropertyChanged);
            this.Rebuild();
        }
 public WrapperObjectSet(SceneNodeObjectSet baseSet, ReferenceStep targetStep, IPropertyInformation redirectedProperty)
     : base(baseSet.DesignerContext, baseSet.TransactionContext)
 {
     this.baseSet            = baseSet;
     this.targetStep         = targetStep;
     this.redirectedProperty = redirectedProperty;
 }
Exemplo n.º 5
0
        private static void RunDesignModeValueProvider(object target, IPlatform platform, ValueTranslationService valueTranslationService, IType type, Type runtimeType, PropertyIdentifier property, ReferenceStep referenceStep, bool isFirstTime)
        {
            if (!runtimeType.IsAssignableFrom(target.GetType()))
            {
                return;
            }
            ModelItem modelItemForObject = DesignModeValueProviderService.GetModelItemForObject(platform, target);

            if (modelItemForObject == null)
            {
                return;
            }
            ReferenceStep referenceStep1 = (ReferenceStep)DesignTimeProperties.GetShadowProperty((IProperty)referenceStep, (ITypeId)type);

            try
            {
                object valueToSet;
                if (isFirstTime && !referenceStep1.IsSet(target))
                {
                    valueToSet = referenceStep.GetValue(target);
                    referenceStep1.SetValue(target, valueToSet);
                }
                else
                {
                    valueToSet = referenceStep1.GetValue(target);
                }
                referenceStep.SetValue(target, valueTranslationService.TranslatePropertyValue(runtimeType, modelItemForObject, property, valueToSet));
            }
            catch (Exception ex)
            {
            }
        }
            public IEnumerable <IProperty> GetProperties(MemberAccessTypes access)
            {
                ReadOnlyCollection <IProperty> readOnlyCollection1;

                if (this.designPropertySets.TryGetValue(access, out readOnlyCollection1))
                {
                    return((IEnumerable <IProperty>)readOnlyCollection1);
                }
                IEnumerable <IProperty> properties = this.designType.GetProperties(access);
                List <IProperty>        list       = new List <IProperty>();

                foreach (IProperty property in properties)
                {
                    ReferenceStep actualReferenceStep = property as ReferenceStep;
                    if (actualReferenceStep != null)
                    {
                        TypeReflectingProjectContext.DesignTypeProperty createDesignProperty = this.GetOrCreateDesignProperty(actualReferenceStep);
                        list.Add((IProperty)createDesignProperty);
                    }
                }
                ReadOnlyCollection <IProperty> readOnlyCollection2 = new ReadOnlyCollection <IProperty>((IList <IProperty>)list);

                this.designPropertySets[access] = readOnlyCollection2;
                return((IEnumerable <IProperty>)readOnlyCollection2);
            }
Exemplo n.º 7
0
        private void UpdateFromDataContext()
        {
            this.UnhookEditingProperty();
            Microsoft.Windows.Design.PropertyEditing.PropertyValue propertyValue = this.hostControl.DataContext as Microsoft.Windows.Design.PropertyEditing.PropertyValue;
            if (propertyValue != null)
            {
                this.editingProperty = (PropertyReferenceProperty)propertyValue.ParentProperty;
            }
            if (this.editingProperty == null)
            {
                return;
            }
            this.editingProperty.PropertyReferenceChanged += new Microsoft.Expression.DesignSurface.Documents.PropertyReferenceChangedEventHandler(this.OnEditingPropertyChanged);
            SceneNodeObjectSetBase nodeObjectSetBase = (SceneNodeObjectSetBase)this.editingProperty.ObjectSet;
            ReferenceStep          singleStep1       = (ReferenceStep)nodeObjectSetBase.ProjectContext.ResolveProperty(BehaviorTargetedTriggerActionNode.BehaviorTargetNameProperty);

            if (singleStep1 != null)
            {
                this.targetNameProperty = (SceneNodeProperty)nodeObjectSetBase.CreateProperty(new PropertyReference(singleStep1), (AttributeCollection)null);
                this.targetNameProperty.PropertyReferenceChanged += new Microsoft.Expression.DesignSurface.Documents.PropertyReferenceChangedEventHandler(this.OnEditingPropertyChanged);
            }
            ReferenceStep singleStep2 = (ReferenceStep)nodeObjectSetBase.ProjectContext.ResolveProperty(BehaviorTargetedTriggerActionNode.BehaviorTargetObjectProperty);

            if (singleStep2 != null)
            {
                this.targetObjectProperty = (SceneNodeProperty)nodeObjectSetBase.CreateProperty(new PropertyReference(singleStep2), (AttributeCollection)null);
                this.targetObjectProperty.PropertyReferenceChanged += new Microsoft.Expression.DesignSurface.Documents.PropertyReferenceChangedEventHandler(this.OnEditingPropertyChanged);
            }
            this.Rebuild();
        }
Exemplo n.º 8
0
        private void ApplyEyedropperTextElement(BaseTextElement textElement)
        {
            PropertyManager   propertyManager   = (PropertyManager)this.ToolBehaviorContext.PropertyManager;
            IPlatform         platform          = this.ActiveDocument.ProjectContext.Platform;
            IPlatformMetadata platformMetadata  = (IPlatformMetadata)platform.Metadata;
            Artboard          artboard          = this.ActiveView.Artboard;
            Matrix            matrix            = artboard.CalculateTransformFromArtboardToContent().Value;
            Matrix            transformFromRoot = this.ActiveView.GetComputedTransformFromRoot((SceneElement)textElement);
            Point             position          = this.MouseDevice.GetPosition((IInputElement)artboard);
            Point             point1            = matrix.Transform(position);
            Point             point2            = transformFromRoot.Transform(point1);

            this.EnsureEditTransaction();
            foreach (IPropertyId propertyId in PropertyToolBehavior.PropertyList)
            {
                ReferenceStep singleStep = platformMetadata.ResolveProperty(propertyId) as ReferenceStep;
                if (singleStep != null && singleStep.PropertyType.PlatformMetadata == platform.Metadata)
                {
                    PropertyReference propertyReference1 = new PropertyReference(singleStep);
                    PropertyReference propertyReference2 = propertyManager.FilterProperty((SceneNode)textElement, propertyReference1);
                    if (propertyReference2 != null)
                    {
                        object textValueAtPoint = textElement.GetTextValueAtPoint(point2, true, propertyReference2);
                        propertyManager.SetValue(propertyReference2, textValueAtPoint);
                    }
                }
            }
            this.UpdateEditTransaction();
        }
Exemplo n.º 9
0
        private void ApplyEyedropperSceneElement(SceneElement hitElement)
        {
            PropertyManager   propertyManager  = (PropertyManager)this.ToolBehaviorContext.PropertyManager;
            IPlatform         platform         = this.ActiveDocument.ProjectContext.Platform;
            IPlatformMetadata platformMetadata = (IPlatformMetadata)platform.Metadata;

            this.EnsureEditTransaction();
            foreach (IPropertyId propertyId in PropertyToolBehavior.PropertyList)
            {
                ReferenceStep singleStep = platformMetadata.ResolveProperty(propertyId) as ReferenceStep;
                if (singleStep != null && singleStep.PropertyType.PlatformMetadata == platform.Metadata)
                {
                    PropertyReference propertyReference1 = new PropertyReference(singleStep);
                    PropertyReference propertyReference2 = propertyManager.FilterProperty((SceneNode)hitElement, propertyReference1);
                    if (propertyReference2 != null)
                    {
                        object second        = propertyManager.GetValue(propertyReference2);
                        object computedValue = hitElement.GetComputedValue(propertyReference2);
                        if (computedValue != MixedProperty.Mixed && !PropertyUtilities.Compare(computedValue, second, hitElement.ViewModel.DefaultView))
                        {
                            propertyManager.SetValue(propertyReference2, computedValue);
                        }
                    }
                }
            }
            this.UpdateEditTransaction();
        }
Exemplo n.º 10
0
        private static bool IsPropertyBindableAsTarget(SceneNode sceneNode, ReferenceStep referenceStep, bool isDeclaringTypeBindable)
        {
            if (referenceStep.Equals((object)referenceStep.DeclaringType.Metadata.NameProperty) || (referenceStep.WriteAccess & (MemberAccessType)14) == MemberAccessType.None)
            {
                return(false);
            }
            SceneNode[] selection = new SceneNode[1]
            {
                sceneNode
            };
            TargetedReferenceStep targetedReferenceStep = new TargetedReferenceStep(referenceStep, sceneNode.Type);

            if ((!PropertyInspectorModel.IsPropertyBrowsable(selection, targetedReferenceStep) || !PropertyInspectorModel.IsAttachedPropertyBrowsable(selection, sceneNode.Type, targetedReferenceStep, (ITypeResolver)sceneNode.ProjectContext)) && !referenceStep.Equals((object)ContentControlElement.ContentProperty))
            {
                return(false);
            }
            if (referenceStep.PropertyType.IsBinding)
            {
                return(true);
            }
            object[] customAttributes = referenceStep.GetCustomAttributes(typeof(BindableAttribute), false);
            if (customAttributes != null && customAttributes.Length > 0)
            {
                return(((BindableAttribute)customAttributes[0]).Bindable);
            }
            return(isDeclaringTypeBindable && referenceStep is DependencyPropertyReferenceStep);
        }
        protected object ResolveCurrentStyle(SceneElement targetElement, PropertyReference propertyReference, bool allowDefaultStyle)
        {
            ReferenceStep referenceStep = propertyReference[0];
            object        computedValue = targetElement.GetComputedValue(propertyReference);
            StyleNode     styleNode     = targetElement.GetLocalOrDefaultValue(propertyReference) as StyleNode;
            bool          flag          = computedValue == null || styleNode != null && styleNode.IsDefaultStyle;

            if (!allowDefaultStyle && flag && referenceStep.Equals((object)BaseFrameworkElement.StyleProperty))
            {
                return((object)null);
            }
            if (computedValue != null)
            {
                Style style = computedValue as Style;
                if (style != null)
                {
                    foreach (SetterBase setterBase in (Collection <SetterBase>)style.Setters)
                    {
                        Setter            setter = setterBase as Setter;
                        FrameworkTemplate frameworkTemplate;
                        if (setter != null && (frameworkTemplate = setter.Value as FrameworkTemplate) != null && frameworkTemplate.VisualTree != null)
                        {
                            return((object)null);
                        }
                    }
                }
            }
            return(computedValue);
        }
Exemplo n.º 12
0
        private void UpdateTranslation(bool scrollNow)
        {
            SceneView      activeView = this.ActiveView;
            SceneViewModel viewModel  = activeView.ViewModel;
            Vector         delta      = this.dragCurrentPosition - this.dragStartPosition;

            if (this.isConstraining)
            {
                delta = this.ConstrainDeltaToAxis(delta);
            }
            if (delta == this.lastMove || this.IsAltDown)
            {
                return;
            }
            this.EnsureEditTransaction();
            Vector       vector1          = delta - this.lastMove;
            SceneElement primarySelection = viewModel.ElementSelectionSet.PrimarySelection;

            if (primarySelection == null)
            {
                return;
            }
            PropertyReference propertyReference = this.GetBrushPropertyReference((SceneNode)primarySelection);

            if (propertyReference == null)
            {
                return;
            }
            object computedValue = primarySelection.GetComputedValue(propertyReference);

            if (computedValue != null && !PlatformTypes.IsInstance(computedValue, PlatformTypes.SolidColorBrush, (ITypeResolver)primarySelection.ProjectContext))
            {
                Vector vector2 = vector1 * activeView.GetComputedTransformFromRoot(primarySelection) * BrushAdorner.GetCompleteInverseBrushTransformMatrix((Base2DElement)primarySelection, computedValue, true);
                if (PlatformTypes.IsInstance(computedValue, PlatformTypes.LinearGradientBrush, (ITypeResolver)primarySelection.ProjectContext) && this.Tool is GradientBrushTool)
                {
                    ReferenceStep referenceStep1 = (ReferenceStep)viewModel.ProjectContext.ResolveProperty(LinearGradientBrushNode.StartPointProperty);
                    ReferenceStep referenceStep2 = (ReferenceStep)viewModel.ProjectContext.ResolveProperty(LinearGradientBrushNode.EndPointProperty);
                    Point         point1         = RoundingHelper.RoundPosition((Point)viewModel.DefaultView.ConvertToWpfValue(referenceStep1.GetCurrentValue(computedValue)) + vector2);
                    Point         point2         = RoundingHelper.RoundPosition((Point)viewModel.DefaultView.ConvertToWpfValue(referenceStep2.GetCurrentValue(computedValue)) + vector2);
                    this.SetBrushValue(LinearGradientBrushNode.StartPointProperty, (object)point1);
                    this.SetBrushValue(LinearGradientBrushNode.EndPointProperty, (object)point2);
                }
                else if (PlatformTypes.IsInstance(computedValue, PlatformTypes.RadialGradientBrush, (ITypeResolver)primarySelection.ProjectContext) && this.Tool is GradientBrushTool)
                {
                    ReferenceStep referenceStep1 = (ReferenceStep)viewModel.ProjectContext.ResolveProperty(RadialGradientBrushNode.CenterProperty);
                    ReferenceStep referenceStep2 = (ReferenceStep)viewModel.ProjectContext.ResolveProperty(RadialGradientBrushNode.GradientOriginProperty);
                    Point         point1         = RoundingHelper.RoundPosition((Point)viewModel.DefaultView.ConvertToWpfValue(referenceStep1.GetCurrentValue(computedValue)) + vector2);
                    Point         point2         = RoundingHelper.RoundPosition((Point)viewModel.DefaultView.ConvertToWpfValue(referenceStep2.GetCurrentValue(computedValue)) + vector2);
                    this.SetBrushValue(RadialGradientBrushNode.CenterProperty, (object)point1);
                    this.SetBrushValue(RadialGradientBrushNode.GradientOriginProperty, (object)point2);
                }
                else
                {
                    this.TranslateBrushPosition(vector1 * activeView.GetComputedTransformFromRoot(primarySelection) * BrushAdorner.GetCompleteInverseBrushTransformMatrix((Base2DElement)primarySelection, computedValue, false), primarySelection);
                }
            }
            activeView.EnsureVisible(this.dragStartPosition + delta, scrollNow);
            this.lastMove = delta;
            this.UpdateEditTransaction();
        }
Exemplo n.º 13
0
        public void TranslateBrushPosition(Vector elementDelta, SceneElement element)
        {
            PropertyReference propertyReference = this.GetBrushPropertyReference((SceneNode)element);

            if (propertyReference == null)
            {
                return;
            }
            object computedValue = element.GetComputedValue(propertyReference);

            if (computedValue == null || PlatformTypes.IsInstance(computedValue, PlatformTypes.SolidColorBrush, (ITypeResolver)element.ProjectContext))
            {
                return;
            }
            ReferenceStep      referenceStep      = (ReferenceStep)element.Platform.Metadata.ResolveProperty(BrushNode.RelativeTransformProperty);
            object             obj                = element.ViewModel.DefaultView.ConvertToWpfValue(referenceStep.GetCurrentValue(computedValue));
            CanonicalTransform canonicalTransform = !(obj is Transform) ? new CanonicalTransform(Matrix.Identity) : new CanonicalTransform((Transform)obj);

            elementDelta *= canonicalTransform.TransformGroup.Value;
            double valueToSet1 = RoundingHelper.RoundLength(canonicalTransform.TranslationX + elementDelta.X);
            double valueToSet2 = RoundingHelper.RoundLength(canonicalTransform.TranslationY + elementDelta.Y);

            this.SetBrushTransformValue(element.Platform.Metadata.CommonProperties.BrushTranslationXReference, valueToSet1);
            this.SetBrushTransformValue(element.Platform.Metadata.CommonProperties.BrushTranslationYReference, valueToSet2);
        }
Exemplo n.º 14
0
 public ReferenceStepQuery.Step.MatchType Matches(ReferenceStep otherStep)
 {
     if (this.wildcard != ReferenceStepQuery.WildcardType.None)
     {
         if (this.wildcard == ReferenceStepQuery.WildcardType.Descendant)
         {
             return(ReferenceStepQuery.Step.MatchType.ContinueMatch);
         }
         if (this.wildcard != ReferenceStepQuery.WildcardType.Indexer)
         {
             return(ReferenceStepQuery.Step.MatchType.NoMatch);
         }
         if (otherStep.GetType() != typeof(IndexedClrPropertyReferenceStep))
         {
             return(ReferenceStepQuery.Step.MatchType.NoMatch);
         }
         return(ReferenceStepQuery.Step.MatchType.YesMatch);
     }
     if (this.referenceStep == null)
     {
         if (!otherStep.Name.Contains(this.nameContains))
         {
             return(ReferenceStepQuery.Step.MatchType.NoMatch);
         }
         return(ReferenceStepQuery.Step.MatchType.YesMatch);
     }
     if (this.referenceStep.SortValue == otherStep.SortValue && this.referenceStep.GetType() == otherStep.GetType())
     {
         return(ReferenceStepQuery.Step.MatchType.YesMatch);
     }
     return(ReferenceStepQuery.Step.MatchType.NoMatch);
 }
Exemplo n.º 15
0
        private static bool ShouldUseRelativeSourceTemplateBinding(DocumentNode targetNode, PropertyReference targetProperty)
        {
            bool flag;

            if (!targetNode.PlatformMetadata.IsCapabilitySet(PlatformCapability.UseRelativeSourceTemplateBinding))
            {
                return(false);
            }
            if (!PlatformTypes.FrameworkElement.IsAssignableFrom(targetNode.Type) && !PlatformTypes.FrameworkContentElement.IsAssignableFrom(targetNode.Type))
            {
                return(true);
            }
            if (targetProperty != null)
            {
                using (IEnumerator <ReferenceStep> enumerator = targetProperty.ReferenceSteps.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        ReferenceStep current = enumerator.Current;
                        if (!PlatformTypes.Freezable.IsAssignableFrom(current.DeclaringType) || PlatformTypes.FrameworkElement.IsAssignableFrom(current.DeclaringType) || PlatformTypes.FrameworkContentElement.IsAssignableFrom(current.DeclaringType))
                        {
                            continue;
                        }
                        flag = true;
                        return(flag);
                    }
                    return(false);
                }
                return(flag);
            }
            return(false);
        }
Exemplo n.º 16
0
        private static IEnumerable <ReferenceStep> GetPropertiesForSceneNode(SceneNode node)
        {
            TextRangeElement textRange = node as TextRangeElement;

            if (textRange != null)
            {
                foreach (IPropertyId propertyId in textRange.RangeProperties)
                {
                    DependencyPropertyReferenceStep dp = node.ProjectContext.ResolveProperty(propertyId) as DependencyPropertyReferenceStep;
                    if (dp != null)
                    {
                        yield return((ReferenceStep)dp);
                    }
                }
            }
            else
            {
                foreach (IProperty property in ITypeExtensions.GetProperties(PropertyMerger.GetTypeFromSceneNode(node), MemberAccessTypes.Public, true))
                {
                    ReferenceStep referenceStep = property as ReferenceStep;
                    if (referenceStep != null)
                    {
                        DependencyPropertyReferenceStep dependencyPropertyReferenceStep = referenceStep as DependencyPropertyReferenceStep;
                        if (dependencyPropertyReferenceStep == null || !dependencyPropertyReferenceStep.IsAttachable)
                        {
                            yield return(referenceStep);
                        }
                    }
                }
            }
        }
Exemplo n.º 17
0
 public static bool DoesPropertyApply(SceneNode sceneNode, ReferenceStep referenceStep, SceneNode valueNode, out ReferenceStep appliedReferenceStep)
 {
     appliedReferenceStep = sceneNode.DesignerContext.PropertyManager.FilterProperty(sceneNode, referenceStep);
     if (appliedReferenceStep == null)
     {
         return(false);
     }
     if (DocumentNodeUtilities.IsStyleOrTemplate(appliedReferenceStep.PropertyType))
     {
         DocumentNode node = valueNode.DocumentNode;
         if (node.Type.IsExpression)
         {
             node = new ExpressionEvaluator(sceneNode.ViewModel.DocumentRootResolver).EvaluateExpression(sceneNode.DocumentNodePath, valueNode.DocumentNode);
         }
         if (node == null || !DocumentNodeUtilities.IsStyleOrTemplate(node.Type) || !appliedReferenceStep.PropertyType.IsAssignableFrom((ITypeId)node.Type))
         {
             return(false);
         }
         IType templateTargetType = DocumentNodeUtilities.GetStyleOrTemplateTargetType(node);
         Type  propertyTargetType = sceneNode.Metadata.GetStylePropertyTargetType((IPropertyId)appliedReferenceStep);
         if (templateTargetType != null && propertyTargetType != (Type)null && !templateTargetType.RuntimeType.IsAssignableFrom(propertyTargetType))
         {
             return(false);
         }
     }
     return(true);
 }
Exemplo n.º 18
0
 public ApplyResourceCommand(ResourceToolBehavior behavior, SceneElement targetElement, ReferenceStep targetProperty, ResourceEntryItem resource)
 {
     this.behavior       = behavior;
     this.targetElement  = targetElement;
     this.resource       = resource;
     this.targetProperty = targetProperty;
 }
Exemplo n.º 19
0
        private static object CreateXmlDataContext(DataSourceInfo dataSource, SceneViewModel viewModel)
        {
            DocumentNode sourceNode = dataSource.SourceNode;
            object       obj        = (object)null;

            using (StandaloneInstanceBuilderContext instanceBuilderContext = new StandaloneInstanceBuilderContext(viewModel.Document.DocumentContext, viewModel.DesignerContext))
            {
                try
                {
                    IInstanceBuilder builder  = instanceBuilderContext.InstanceBuilderFactory.GetBuilder(sourceNode.TargetType);
                    ViewNode         viewNode = builder.GetViewNode((IInstanceBuilderContext)instanceBuilderContext, sourceNode);
                    obj = (object)(bool)(builder.Instantiate((IInstanceBuilderContext)instanceBuilderContext, viewNode) ? true : false);
                }
                catch
                {
                }
            }
            ReferenceStep referenceStep  = (ReferenceStep)viewModel.ProjectContext.ResolveProperty(XmlDataProviderSceneNode.XPathProperty);
            string        inheritedXPath = referenceStep.GetValue(obj) as string;

            if (string.IsNullOrEmpty(inheritedXPath))
            {
                inheritedXPath = dataSource.Path;
            }
            else if (!string.IsNullOrEmpty(dataSource.Path))
            {
                inheritedXPath = XmlSchema.CombineXPaths(inheritedXPath, dataSource.Path);
            }
            if (!string.IsNullOrEmpty(inheritedXPath))
            {
                referenceStep.SetValue(obj, (object)inheritedXPath);
            }
            return(obj);
        }
Exemplo n.º 20
0
        protected override DocumentNode CreateValue(BaseFrameworkElement source)
        {
            object tileBrush = this.CreateTileBrush(source);

            if (tileBrush == null)
            {
                return((DocumentNode)null);
            }
            ITypeResolver typeResolver = (ITypeResolver)source.ProjectContext;
            IViewObject   visual       = source.Visual;

            if (visual != null)
            {
                object platformSpecificObject = visual.PlatformSpecificObject;
                if (platformSpecificObject != null && PlatformTypes.Image.IsAssignableFrom((ITypeId)visual.GetIType((ITypeResolver)this.SceneViewModel.ProjectContext)))
                {
                    ReferenceStep referenceStep = typeResolver.ResolveProperty(TileBrushNode.StretchProperty) as ReferenceStep;
                    object        obj           = referenceStep.GetValue(tileBrush);
                    object        valueToSet    = (typeResolver.ResolveProperty(ImageElement.StretchProperty) as ReferenceStep).GetValue(platformSpecificObject);
                    if (!obj.Equals(valueToSet))
                    {
                        referenceStep.SetValue(tileBrush, valueToSet);
                    }
                }
            }
            return(this.SceneViewModel.Document.DocumentContext.CreateNode(typeResolver.ResolveType(PlatformTypes.TileBrush).RuntimeType, tileBrush));
        }
Exemplo n.º 21
0
 public ControlStylingCommandBase(ISceneViewHost viewHost, SceneViewModel viewModel, IPropertyId targetProperty, bool useRootTemplateProperty)
     : base(viewModel)
 {
     this.viewHost                = viewHost;
     this.targetProperty          = viewModel.ProjectContext.ResolveProperty(targetProperty) as ReferenceStep;
     this.useRootTemplateProperty = useRootTemplateProperty;
 }
Exemplo n.º 22
0
        public void Setup()
        {
            flowIdentifier1 = new FlowIdentifier(FlowType.Basic, 0);
            flowIdentifier2 = new FlowIdentifier(FlowType.BoundedAlternative, 1);

            referenceStep1 = new ReferenceStep(flowIdentifier1, 0);
            referenceStep2 = new ReferenceStep(flowIdentifier2, 1);

            List <Node> nodes = new List <Node>();

            nodes.Add(new Node("A node", flowIdentifier1));
            nodeList1 = nodes.AsReadOnly();

            nodes = new List <Node>();
            nodes.Add(new Node("Another node", flowIdentifier2));
            nodeList2 = nodes.AsReadOnly();

            List <ReferenceStep> referenceSteps = new List <ReferenceStep>();

            referenceSteps.Add(referenceStep1);
            referenceStepList1 = referenceSteps.AsReadOnly();

            referenceSteps = new List <ReferenceStep>();
            referenceSteps.Add(referenceStep2);
            referenceStepList2 = referenceSteps.AsReadOnly();
        }
 private void Rebuild(object sender, EventArgs args)
 {
     if (this.targetPropertyEntry != null)
     {
         this.targetPropertyEntry.OnRemoveFromCategory();
         this.targetPropertyEntry = (SceneNodeProperty)null;
     }
     if (this.contextHelper.EditingProperty != null && this.contextHelper.CurrentProperty != null)
     {
         SceneNodeObjectSetBase nodeObjectSetBase = (SceneNodeObjectSetBase)this.contextHelper.EditingProperty.ObjectSet;
         ReferenceStep          referenceStep     = (ReferenceStep)nodeObjectSetBase.ProjectContext.ResolveProperty(ChangePropertyActionNode.ValueProperty);
         PropertyPickerExtendedEditor.WrapperObjectSet wrapperObjectSet = new PropertyPickerExtendedEditor.WrapperObjectSet((SceneNodeObjectSet)nodeObjectSetBase, referenceStep, this.contextHelper.CurrentProperty);
         this.targetPropertyEntry = (SceneNodeProperty) new PropertyPickerExtendedEditor.WrapperTypedSceneNodeProperty((SceneNodeObjectSet)wrapperObjectSet, new PropertyReference(referenceStep), this.contextHelper.CurrentProperty.Name, this.contextHelper.CurrentProperty.Attributes, this.contextHelper.CurrentProperty.PropertyType.RuntimeType, (ITypeResolver)nodeObjectSetBase.ProjectContext);
         this.targetPropertyEntry.Recache();
         wrapperObjectSet.TargetProperty      = this.targetPropertyEntry;
         this.propertyContainer.PropertyEntry = (PropertyEntry)this.targetPropertyEntry;
         if (this.propertyContainer.ExtendedEditorTemplate == null)
         {
             return;
         }
         this.propertyContainer.ActiveEditMode = PropertyContainerEditMode.ExtendedPinned;
     }
     else
     {
         this.propertyContainer.PropertyEntry = (PropertyEntry)null;
     }
 }
Exemplo n.º 24
0
        private bool SetBinding(SceneNode targetNode, ref IProperty targetProperty)
        {
            ReferenceStep targetProperty1 = (ReferenceStep)null;

            if (targetProperty != null)
            {
                targetProperty1 = this.DragModel.DocumentContext.TypeResolver.ResolveProperty((IPropertyId)targetProperty) as ReferenceStep;
            }
            DataSchemaNodePath bindingPath = new DataSchemaNodePath(this.DragModel.DataSource.PrimaryAbsoluteSchema, this.DragModel.RelativeDropSchemaPath.Node);
            SceneNode          setBindingOrData;

            if (targetProperty1 == null)
            {
                bool useDesignDataContext = DataBindingModeModel.Instance.NormalizedMode == DataBindingMode.Details;
                setBindingOrData = MiniBindingDialog.CreateAndSetBindingOrData(bindingPath, targetNode, useDesignDataContext, ref targetProperty1);
            }
            else
            {
                setBindingOrData = this.DragModel.ViewModel.BindingEditor.CreateAndSetBindingOrData(targetNode, (IPropertyId)targetProperty1, bindingPath);
            }
            if (setBindingOrData == null)
            {
                return(false);
            }
            if (targetProperty != null)
            {
                this.GenerateDetailsIfNeeded(targetNode, (IProperty)targetProperty1);
            }
            targetProperty = (IProperty)targetProperty1;
            return(true);
        }
Exemplo n.º 25
0
            private DataContextMetadata.AncestorPropertyPath ParseInternal()
            {
                List <string> list = new List <string>();

                while (this.parsePosition < this.ancestorPath.Length)
                {
                    string str = this.ParseNextStep();
                    if (str == null)
                    {
                        return((DataContextMetadata.AncestorPropertyPath)null);
                    }
                    list.Add(str);
                }
                List <ReferenceStep> steps = new List <ReferenceStep>(list.Count);

                for (int index = list.Count - 1; index >= 0; --index)
                {
                    this.ancestorNode = this.ancestorNode.Parent;
                    if (this.ancestorNode == null)
                    {
                        return((DataContextMetadata.AncestorPropertyPath)null);
                    }
                    ReferenceStep property = this.GetProperty(list[index]);
                    if (property == null)
                    {
                        return((DataContextMetadata.AncestorPropertyPath)null);
                    }
                    steps.Add(property);
                }
                steps.Reverse();
                return(new DataContextMetadata.AncestorPropertyPath(this.ancestorNode, new PropertyReference(steps)));
            }
        private MenuItem BuildMenuItem(SceneElement element, ReferenceStep referenceStep)
        {
            MenuItem        menuItem = (MenuItem)null;
            IList <Control> list     = this.GeneratePropertyItems(element, referenceStep);

            if (list.Count > 0)
            {
                menuItem = new MenuItem();
                menuItem.SetValue(AutomationElement.IdProperty, (object)referenceStep.Name);
                foreach (Control control in (IEnumerable <Control>)list)
                {
                    menuItem.Items.Add((object)control);
                }
                string displayName = this.GetDisplayName((IPropertyId)referenceStep);
                if (displayName != null)
                {
                    menuItem.Header = (object)string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.EditPropertyItemWithDisplayNameFormat, new object[2]
                    {
                        (object)displayName,
                        (object)referenceStep.Name
                    });
                }
                else
                {
                    menuItem.Header = (object)string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.EditPropertyItemFormat, new object[1]
                    {
                        (object)referenceStep.Name
                    });
                }
            }
            return(menuItem);
        }
Exemplo n.º 27
0
        private void Rebuild()
        {
            this.X1Property = this.CreateProperty("KeySpline.ControlPoint1/X");
            this.Y1Property = this.CreateProperty("KeySpline.ControlPoint1/Y");
            this.X2Property = this.CreateProperty("KeySpline.ControlPoint2/X");
            this.Y2Property = this.CreateProperty("KeySpline.ControlPoint2/Y");
            if (this.keySplineProperty == null || this.keySplineProperty.IsEmpty)
            {
                return;
            }
            KeyFrameSceneNode keyFrameSceneNode = this.keySplineProperty.SceneNodeObjectSet.RepresentativeSceneNode as KeyFrameSceneNode;

            if (keyFrameSceneNode == null)
            {
                return;
            }
            ReferenceStep singleStep = (IProperty)keyFrameSceneNode.Type.GetMember(MemberType.LocalProperty, "KeyTime", MemberAccessTypes.Public) as ReferenceStep;

            if (singleStep != null)
            {
                this.keyTimeProperty = new PropertyReference(singleStep);
                this.keySplineProperty.SceneNodeObjectSet.RegisterPropertyChangedHandler(this.keyTimeProperty, new Microsoft.Expression.DesignSurface.Documents.PropertyReferenceChangedEventHandler(this.KeyTimePropertyChanged));
            }
            this.UpdateTime0KeyFrameStatus();
        }
Exemplo n.º 28
0
        public DataBindingDialogModel(DataPanelModel model, SceneNode targetElement, ReferenceStep targetProperty)
            : base(targetElement, targetProperty)
        {
            this.isBinding = true;
            this.addXmlDataSourceCommand        = model.AddXmlDataSourceCommand;
            this.createSampleDataCommand        = model.CreateSampleDataCommand;
            this.createSampleDataFromXmlCommand = model.CreateSampleDataFromXmlCommand;
            this.addClrObjectDataSourceCommand  = model.AddClrObjectDataSourceCommand;
            DataContextInfo dataContextInfo = new DataContextEvaluator().Evaluate(targetElement, (IPropertyId)targetProperty, true);

            if (dataContextInfo.DataSource.IsValidWithSource)
            {
                ISchema schemaForDataSource = SchemaManager.GetSchemaForDataSource(dataContextInfo.DataSource.SourceNode);
                if (schemaForDataSource != null && !(schemaForDataSource is EmptySchema))
                {
                    this.dataContext = schemaForDataSource.GetNodePathFromPath(dataContextInfo.DataSource.Path);
                }
            }
            this.bindsTwoWayByDefault = this.BindsTwoWayByDefault(targetElement, targetProperty);
            this.bindingFilterModes   = new ObservableCollection <BindingFilterMode>();
            this.bindingFilterModes.Add(BindingFilterMode.None);
            this.bindingFilterModes.Add(BindingFilterMode.FilterByType);
            ICollectionView defaultView = CollectionViewSource.GetDefaultView((object)this.bindingFilterModes);

            defaultView.MoveCurrentTo((object)BindingFilterMode.FilterByType);
            this.bindingSources  = new ObservableCollection <IBindingSourceModel>();
            this.dataSourceModel = new DataSourceBindingSourceModel(model, new DataSchemaItemFilter(this.BindingFilter));
            this.AddBindingSource((IBindingSourceModel)this.dataSourceModel);
            if (targetElement.ViewModel.ActiveEditingContainer is SceneElement)
            {
                this.elementPropertyModel = new ElementPropertyBindingSourceModel(targetElement, new DataSchemaItemFilter(this.BindingFilter));
                this.AddBindingSource((IBindingSourceModel)this.elementPropertyModel);
            }
            this.explicitDataContextModel = new ExplicitDataContextBindingSourceModel(targetElement, targetProperty, new DataSchemaItemFilter(this.BindingFilter));
            this.AddBindingSource((IBindingSourceModel)this.explicitDataContextModel);
            this.bindingSourcesProxy = new BindingProxy <IBindingSourceModel>();
            this.bindingSourcesProxy.PropertyChanged += new PropertyChangedEventHandler(this.BindingSourcesProxy_PropertyChanged);
            this.bindingSourcesView = (CollectionView) new DataBindingProxyCollectionView <IBindingSourceModel>(this.bindingSources, (IDataBindingProxy <IBindingSourceModel>) this.bindingSourcesProxy);
            BindingSceneNode binding = targetElement.GetBinding((IPropertyId)targetProperty);

            if (binding != null)
            {
                this.SetExistingBindingValues(binding);
            }
            else if (!(this.explicitDataContextModel.Schema is EmptySchema))
            {
                this.bindingSourcesView.MoveCurrentTo((object)this.explicitDataContextModel);
            }
            else
            {
                this.bindingSourcesView.MoveCurrentTo((object)this.dataSourceModel);
            }
            if (binding == null || !binding.IsModeSet)
            {
                this.CurrentBindingMode = BindingPropertyHelper.GetDefaultBindingMode(this.TargetElement.DocumentNode, (IPropertyId)this.TargetProperty, this.CurrentDataPath).Mode;
            }
            this.bindingSourcesView.CurrentChanging += new CurrentChangingEventHandler(this.BindingSourcesView_CurrentChanging);
            defaultView.CurrentChanged += new EventHandler(this.BindingFilterModesView_CurrentChanged);
            this.PropertyChanged       += new PropertyChangedEventHandler(this.DataBindingDialogModel_PropertyChanged);
        }
Exemplo n.º 29
0
        public static PropertyReference ConvertTransformPropertyToComposite(PropertyReference propertyReference)
        {
            if (propertyReference == null)
            {
                return((PropertyReference)null);
            }
            int num = -1;

            for (int index = 0; index < propertyReference.Count; ++index)
            {
                if (PlatformTypes.Transform.IsAssignableFrom((ITypeId)propertyReference[index].PropertyType))
                {
                    num = index;
                    break;
                }
            }
            if (num == -1)
            {
                return((PropertyReference)null);
            }
            ReferenceStep compositeProperty = TransformPropertyLookup.GetCorrespondingCompositeProperty(propertyReference);

            if (compositeProperty == null)
            {
                return((PropertyReference)null);
            }
            ReferenceStep[] steps = new ReferenceStep[num + 2];
            for (int index = 0; index <= num; ++index)
            {
                steps[index] = propertyReference.ReferenceSteps[index];
            }
            steps[num + 1] = compositeProperty;
            return(PropertyReference.CreateNewPropertyReferenceFromStepsWithoutCopy(steps));
        }
Exemplo n.º 30
0
        internal static PropertyReference FilterProperty(ITypeResolver typeResolver, IType type, PropertyReference propertyReference)
        {
            ReferenceStep referenceStep = propertyReference[0];
            ReferenceStep filteredStep  = SceneNodeObjectSet.FilterProperty(typeResolver, type, referenceStep);

            return(SceneNodeObjectSet.UpdatePropertyReference(propertyReference, referenceStep, filteredStep));
        }