Exemplo n.º 1
0
        private DocumentCompositeNode GenerateHierarchicalDataTemplateIfNeeded(SceneNode targetNode)
        {
            DocumentCompositeNode documentCompositeNode = this.GenerateDataTemplateIfNeeded(targetNode, ProjectNeutralTypes.HierarchicalDataTemplate);

            if (documentCompositeNode == null)
            {
                return((DocumentCompositeNode)null);
            }
            IType type   = this.DragModel.RelativeDropSchemaPath.Type;
            IType typeId = type != null ? type.ItemType : (IType)null;

            if (typeId == null)
            {
                return(documentCompositeNode);
            }
            string path;

            if (PlatformTypes.IEnumerable.IsAssignableFrom((ITypeId)typeId) && !PlatformTypes.String.IsAssignableFrom((ITypeId)typeId))
            {
                path = string.Empty;
            }
            else
            {
                IProperty         property1             = (IProperty)null;
                MemberAccessTypes allowableMemberAccess = TypeHelper.GetAllowableMemberAccess((ITypeResolver)this.ProjectContext, typeId);
                List <IProperty>  list = new List <IProperty>(typeId.GetProperties(allowableMemberAccess));
                list.Sort((Comparison <IProperty>)((a, b) => StringLogicalComparer.Instance.Compare(a.Name, b.Name)));
                foreach (IProperty property2 in list)
                {
                    IType propertyType = property2.PropertyType;
                    if (propertyType == type)
                    {
                        property1 = property2;
                        break;
                    }
                    if (property1 == null && PlatformTypes.IEnumerable.IsAssignableFrom((ITypeId)propertyType) && !PlatformTypes.String.IsAssignableFrom((ITypeId)propertyType))
                    {
                        property1 = property2;
                    }
                }
                if (property1 == null)
                {
                    return(documentCompositeNode);
                }
                path = property1.Name;
            }
            BindingSceneNode bindingSceneNode = (BindingSceneNode)this.DragModel.ViewModel.CreateSceneNode(PlatformTypes.Binding);

            if (!string.IsNullOrEmpty(path))
            {
                bindingSceneNode.SetPath(path);
            }
            documentCompositeNode.Properties[DataBindingDragDropDefaultHandler.HierarchicalItemsSourceProperty] = bindingSceneNode.DocumentNode;
            return(documentCompositeNode);
        }
Exemplo n.º 2
0
        public BindingSceneNode CreateElementNameBinding(SceneNode targetNode)
        {
            BindingSceneNode binding = (BindingSceneNode)this.ViewModel.CreateSceneNode(PlatformTypes.Binding);
            ReferenceStep    selectedBindingField = this.SelectedBindingField;

            targetNode.EnsureNamed();
            binding.ElementName = targetNode.Name;
            binding.SetPath(selectedBindingField.Name);
            this.SetAdvancedPropertiesIfNeeded(binding);
            return(binding);
        }
Exemplo n.º 3
0
        public SceneNode CreateBindingOrData(SceneViewModel viewModel, string bindingPath, SceneNode targetNode, IProperty targetProperty)
        {
            BindingSceneNode bindingSceneNode = BindingSceneNode.Factory.Instantiate(viewModel);

            if (bindingPath.Length > 0)
            {
                if (this.Schema is ClrObjectSchema)
                {
                    bindingSceneNode = bindingSceneNode.SetPath(bindingPath);
                }
                else if (this.Schema is XmlSchema)
                {
                    bindingSceneNode.XPath = bindingPath;
                }
                else
                {
                    bindingSceneNode = bindingSceneNode.SetPath(bindingPath);
                }
            }
            return((SceneNode)bindingSceneNode);
        }
            public override void ApplyChange(SceneViewModel viewModel)
            {
                if (this.Change.BreakingChange)
                {
                    return;
                }
                BindingSceneNode bindingSceneNode = viewModel.GetSceneNode((DocumentNode)this.DocumentNode) as BindingSceneNode;

                if (bindingSceneNode == null)
                {
                    return;
                }
                bindingSceneNode.SetPath(this.Change.NewPath);
            }
Exemplo n.º 5
0
        protected void LinkDetailsWithMasterControl(SceneElement detailsContainerElement)
        {
            BaseFrameworkElement masterControl = this.FindMasterControl(detailsContainerElement);

            if (masterControl == null)
            {
                return;
            }
            masterControl.EnsureNamed();
            BindingSceneNode binding = (BindingSceneNode)this.DragModel.ViewModel.CreateSceneNode(PlatformTypes.Binding);

            binding.ElementName = masterControl.Name;
            binding.SetPath("SelectedItem");
            detailsContainerElement.SetBinding(BaseFrameworkElement.DataContextProperty, binding);
        }
Exemplo n.º 6
0
        private SceneNode CreateDataGridBoundColumn(DataSchemaNodePath schemaPath, ITypeId columnType)
        {
            DataGridColumnNode dataGridColumnNode = (DataGridColumnNode)this.DragModel.ViewModel.CreateSceneNode(columnType);
            string             columnName         = DataBindingDragDropDefaultHandler.GetColumnName(schemaPath);

            dataGridColumnNode.SetLocalValue(DataGridColumnNode.ColumnHeaderProperty, (object)columnName);
            BindingSceneNode bindingSceneNode = (BindingSceneNode)this.DragModel.ViewModel.CreateSceneNode(PlatformTypes.Binding);

            bindingSceneNode.SetPath(schemaPath.Path);
            BindingModeInfo defaultBindingMode = BindingPropertyHelper.GetDefaultBindingMode(dataGridColumnNode.DocumentNode, DataGridColumnNode.BoundColumnBindingProperty, schemaPath);

            if (!defaultBindingMode.IsOptional)
            {
                bindingSceneNode.Mode = defaultBindingMode.Mode;
            }
            dataGridColumnNode.SetValueAsSceneNode(DataGridColumnNode.BoundColumnBindingProperty, (SceneNode)bindingSceneNode);
            return((SceneNode)dataGridColumnNode);
        }
Exemplo n.º 7
0
        private BindingSceneNode CreateFallbackBind(SceneViewModel viewModel, string bindingPath, SceneNode targetNode, IProperty targetProperty)
        {
            if (this.ResourceKey == null)
            {
                return((BindingSceneNode)null);
            }
            BindingSceneNode binding = BindingSceneNode.Factory.Instantiate(viewModel);
            DocumentNode     keyNode = this.ResourceKey.Clone(viewModel.Document.DocumentContext);

            binding.Source = (DocumentNode)DocumentNodeUtilities.NewStaticResourceNode(viewModel.Document.DocumentContext, keyNode);
            if (bindingPath.Length > 0)
            {
                binding = binding.SetPath(bindingPath);
            }
            using (targetNode.ViewModel.AnimationEditor.DeferKeyFraming())
                targetNode.SetBinding((IPropertyId)targetProperty, binding);
            return(binding);
        }
Exemplo n.º 8
0
        private SceneNode CreateBindingOrDataInternal(bool bindingNeededForVerification)
        {
            SceneNode        sceneNode         = (SceneNode)null;
            BindingSceneNode bindingSceneNode1 = (BindingSceneNode)null;

            if (this.CurrentBindingSource != null)
            {
                if (bindingNeededForVerification)
                {
                    sceneNode = this.CurrentBindingSource.CreateBindingOrData(this.TargetElement.ViewModel, this.TargetElement, (IProperty)this.TargetProperty);
                }
                else if (this.useCustomBindingExpression)
                {
                    sceneNode = this.CurrentBindingSource.CreateBindingOrData(this.TargetElement.ViewModel, this.customBindingExpression, this.TargetElement, (IProperty)this.TargetProperty);
                    BindingSceneNode bindingSceneNode2 = sceneNode as BindingSceneNode;
                    if (bindingSceneNode2 != null)
                    {
                        if (this.customBindingExpression.StartsWith("Path=", StringComparison.Ordinal))
                        {
                            bindingSceneNode2.ClearValue(BindingSceneNode.XPathProperty);
                            bindingSceneNode1 = bindingSceneNode2.SetPath(this.customBindingExpression.Substring("Path=".Length));
                        }
                        else if (this.customBindingExpression.StartsWith("XPath=", StringComparison.Ordinal) && bindingSceneNode2.SupportsXPath)
                        {
                            bindingSceneNode2.XPath = this.customBindingExpression.Substring("XPath=".Length);
                            bindingSceneNode2.ClearValue(BindingSceneNode.PathProperty);
                        }
                    }
                }
                else
                {
                    sceneNode = this.CurrentBindingSource.CreateBindingOrData(this.TargetElement.ViewModel, this.TargetElement, (IProperty)this.TargetProperty);
                }
                BindingSceneNode binding = sceneNode as BindingSceneNode;
                if (binding != null)
                {
                    this.SetCommonBindingValues(binding);
                }
            }
            return(sceneNode);
        }
Exemplo n.º 9
0
        private BindingSceneNode CreateBinding(SceneViewModel viewModel, string bindingPath)
        {
            BindingSceneNode bindingSceneNode = (BindingSceneNode)null;

            if (this.SelectedNode != null)
            {
                bindingSceneNode = BindingSceneNode.Factory.Instantiate(viewModel);
                if (!string.IsNullOrEmpty(this.Source))
                {
                    bindingSceneNode.ElementName = this.Source;
                }
                else
                {
                    bindingSceneNode.ElementBindingTarget = (SceneNode)this.SelectedNode.Element;
                }
                if (bindingPath.Length > 0)
                {
                    bindingSceneNode = bindingSceneNode.SetPath(bindingPath);
                }
            }
            return(bindingSceneNode);
        }