Esempio n. 1
0
        private DocumentCompositeNode GenerateDataTemplateIfNeeded(SceneNode targetNode, ITypeId dataTemplateType)
        {
            if (this.DragModel.RelativeDropSchemaPath.IsProperty)
            {
                return((DocumentCompositeNode)null);
            }
            IList <DataSchemaNodePath> relativeSchemaPaths = this.GetRelativeSchemaPaths();

            if (relativeSchemaPaths.Count == 0)
            {
                return((DocumentCompositeNode)null);
            }
            DocumentCompositeNode dataTemplateNode = (DocumentCompositeNode)null;

            using (SceneEditTransaction editTransaction = this.DragModel.Document.CreateEditTransaction(StringTable.UndoUnitCreateTemplate))
            {
                DataSchemaNode node           = this.DragModel.RelativeDropSchemaPath.Node;
                DataSchemaNode dataSchemaNode = node.CollectionItem ?? node;
                string         str            = ((dataSchemaNode.Type != (Type)null ? dataSchemaNode.Type.Name : dataSchemaNode.PathName) + "Template").TrimStart('@', '/');
                if (!SceneNodeIDHelper.IsCSharpID(str))
                {
                    str = "DataTemplate";
                }
                dataTemplateNode = DataViewFactory.CreateDataTemplateResource(targetNode, ItemsControlElement.ItemTemplateProperty, str, relativeSchemaPaths, DataViewCategory.DataTemplate, dataTemplateType);
                editTransaction.Update();
                this.ApplyActiveUserThemeStyleToDataTemplate(dataTemplateNode);
                editTransaction.Commit();
            }
            return(dataTemplateNode);
        }
Esempio n. 2
0
        private ISchema GetRelativeSchema()
        {
            ISchema        schema             = this.DragModel.RelativeDropSchemaPath.Schema;
            DataSchemaNode collectionItemNode = this.DragModel.RelativeDropSchemaPath.EffectiveCollectionItemNode;

            if (collectionItemNode != null)
            {
                schema = schema.MakeRelativeToNode(collectionItemNode);
            }
            return(schema);
        }
Esempio n. 3
0
 private static string GetColumnName(DataSchemaNodePath schemaPath)
 {
     for (DataSchemaNode dataSchemaNode = schemaPath.Node; dataSchemaNode != null; dataSchemaNode = dataSchemaNode.Parent)
     {
         if (dataSchemaNode.PathName != DataSchemaNode.IndexNodePath)
         {
             return(dataSchemaNode.PathName);
         }
     }
     return("_");
 }
        private bool UpdateCallMethodAction(SceneNode actionNode)
        {
            if (!ProjectNeutralTypes.CallMethodAction.IsAssignableFrom((ITypeId)actionNode.Type))
            {
                return(false);
            }
            DataSchemaNodePath primaryAbsolutePath = this.DragModel.DataSource.PrimaryAbsolutePath;
            DataSchemaNode     node             = primaryAbsolutePath.Node;
            DataSchemaNodePath bindingPath      = new DataSchemaNodePath(primaryAbsolutePath.Schema, node.Parent);
            BindingSceneNode   bindingSceneNode = this.DragModel.ViewModel.BindingEditor.CreateAndSetBindingOrData(actionNode, DataBindingDragDropAddTriggerHandler.TargetObjectProperty, bindingPath) as BindingSceneNode;

            if (bindingSceneNode == null)
            {
                return(false);
            }
            bindingSceneNode.ClearLocalValue(BindingSceneNode.ModeProperty);
            actionNode.SetValue(DataBindingDragDropAddTriggerHandler.MethodNameProperty, (object)node.PathName);
            return(true);
        }
Esempio n. 5
0
        private List <DataSchemaNode> GetNodesToCreateElements()
        {
            IPlatform             platform = this.DragModel.Platform;
            List <DataSchemaNode> list     = new List <DataSchemaNode>();
            bool             flag          = DataBindingModeModel.Instance.NormalizedMode == DataBindingMode.Default;
            DataViewCategory category      = flag ? DataViewCategory.Master : DataViewCategory.Details;

            if (flag && this.DragModel.DataSource.Count == 1 && this.DragModel.DataSource.PrimarySchemaNodePath.IsCollection)
            {
                DataSchemaNode collectionItemNode = this.DragModel.DataSource.PrimarySchemaNodePath.EffectiveCollectionItemNode;
                IType          type = collectionItemNode.ResolveType(this.DragModel.TargetNode.DocumentNode.TypeResolver);
                if (PlatformTypes.IConvertible.IsAssignableFrom((ITypeId)type) || PlatformTypes.ImageSource.IsAssignableFrom((ITypeId)type))
                {
                    list.Add(collectionItemNode);
                }
                else
                {
                    foreach (DataSchemaNode dataSchemaNode in collectionItemNode.Children)
                    {
                        IType dataType = dataSchemaNode.ResolveType(this.DragModel.TargetNode.DocumentNode.TypeResolver);
                        if (DataViewFactory.GetDataViewTemplateEntry(platform, dataType, category) != null)
                        {
                            list.Add(dataSchemaNode);
                        }
                    }
                }
            }
            else
            {
                for (int index = 0; index < this.DragModel.DataSource.Count; ++index)
                {
                    DataSchemaNodePath dataSchemaNodePath = this.DragModel.DataSource[index];
                    if (DataViewFactory.GetDataViewTemplateEntry(platform, dataSchemaNodePath.Type, category) != null)
                    {
                        list.Add(dataSchemaNodePath.Node);
                    }
                }
            }
            list.Sort((Comparison <DataSchemaNode>)((a, b) => StringLogicalComparer.Instance.Compare(a.PathName, b.PathName)));
            return(list);
        }
Esempio n. 6
0
        private bool UpdateDragModelDefault()
        {
            int collectionDepth = this.DragModel.RelativeDropSchemaPath.CollectionDepth;

            if (collectionDepth > 1 || collectionDepth > 0 && this.DragModel.RelativeDropSchemaPath.IsMethod)
            {
                return(false);
            }
            DataBindingDragDropFlags dragFlags = this.DragModel.DragFlags;

            if (this.DragModel.DataSource.Count == 1 && (collectionDepth == 0 || this.DragModel.RelativeDropSchemaPath.IsCollection))
            {
                this.DragModel.DropFlags |= DataBindingDragDropFlags.SetBinding;
            }
            else if (this.DragModel.DataSource.Count > 1 && collectionDepth == 0)
            {
                dragFlags &= ~(DataBindingDragDropFlags.SetBinding | DataBindingDragDropFlags.AutoPickProperty);
            }
            DataSchemaNode effectiveCollectionNode = this.DragModel.RelativeDropSchemaPath.EffectiveCollectionNode;
            bool           flag = effectiveCollectionNode != null && effectiveCollectionNode != this.DragModel.RelativeDropSchemaPath.Node;

            if (flag)
            {
                this.DragModel.RelativeDropSchemaPath = new DataSchemaNodePath(this.DragModel.RelativeDropSchemaPath.Schema, effectiveCollectionNode);
            }
            this.ApplyRules(dragFlags);
            if (this.DragModel.TargetPropertySpecialDataContext != null)
            {
                this.DragModel.RelativeDropSchemaPath = this.DragModel.TargetPropertySpecialDataContext;
            }
            else if (flag && this.DragModel.CheckDropFlags(DataBindingDragDropFlags.SetBinding) && !this.ShouldGenerateDetails(this.DragModel.TargetProperty))
            {
                this.DragModel.TargetProperty = (IProperty)null;
                this.DragModel.DropFlags     &= ~DataBindingDragDropFlags.SetBinding;
            }
            return(true);
        }
Esempio n. 7
0
        public static bool CanBindToSchemaNode(SceneNode targetElement, IPropertyId targetPropertyId, DataSchemaNode schemaNode)
        {
            ReferenceStep referenceStep = targetElement.ProjectContext.ResolveProperty(targetPropertyId) as ReferenceStep;

            if (!BindingPropertyHelper.IsPropertyBindable(targetElement, referenceStep))
            {
                return(false);
            }
            IType dataType = schemaNode.ResolveType((ITypeResolver)targetElement.ProjectContext);

            if (dataType == null)
            {
                return(true);
            }
            return(BindingPropertyHelper.GetPropertyCompatibility((IProperty)referenceStep, dataType, (ITypeResolver)targetElement.ProjectContext) != BindingPropertyCompatibility.None);
        }