Exemplo n.º 1
0
        private void CreateFieldElement(DataViewBuilderContext context, DataViewTemplateEntry templateEntry)
        {
            context.CurrentFieldNode = (DocumentCompositeNode)templateEntry.FieldNode.Clone(context.DocumentContext);
            DocumentCompositeNode documentCompositeNode = (DocumentCompositeNode)context.CurrentFieldNode.Properties[(IPropertyId)templateEntry.FieldValueProperty];
            string path = context.CurrentSchemaPath.Path;

            if (context.CurrentSchemaPath.Schema is XmlSchema)
            {
                string str = path ?? string.Empty;
                documentCompositeNode.Properties[BindingSceneNode.XPathProperty] = (DocumentNode)context.DocumentContext.CreateNode(str);
            }
            else if (!string.IsNullOrEmpty(path))
            {
                object obj = this.Platform.Metadata.MakePropertyPath(path);
                documentCompositeNode.Properties[BindingSceneNode.PathProperty] = context.DocumentContext.CreateNode(obj.GetType(), obj);
            }
            BindingModeInfo defaultBindingMode = BindingPropertyHelper.GetDefaultBindingMode((DocumentNode)templateEntry.FieldNode, (IPropertyId)templateEntry.FieldValueProperty, context.CurrentSchemaPath);

            if (defaultBindingMode.IsOptional)
            {
                return;
            }
            DocumentPrimitiveNode node = context.DocumentContext.CreateNode(PlatformTypes.BindingMode, (IDocumentNodeValue) new DocumentNodeStringValue(defaultBindingMode.Mode.ToString()));

            documentCompositeNode.Properties[BindingSceneNode.ModeProperty] = (DocumentNode)node;
        }
 public override void SetElementLayout(DataViewBuilderContext context)
 {
     if (!this.shouldCreateLabels)
     {
         context.CurrentLabelNode = (DocumentCompositeNode)null;
     }
     this.records.Add(new CanvasLikeDataViewLayoutBuilder.LabelField((DocumentNode)context.CurrentLabelNode, (DocumentNode)context.CurrentFieldNode));
     base.SetElementLayout(context);
 }
Exemplo n.º 3
0
        private void CreateLabelElement(DataViewBuilderContext context, DataViewTemplateEntry templateEntry)
        {
            if (templateEntry.LabelNode == null)
            {
                return;
            }
            context.CurrentLabelNode = (DocumentCompositeNode)templateEntry.LabelNode.Clone(context.DocumentContext);
            string str = context.CurrentSchemaPath.Node.PathName.TrimStart('@', '/');

            context.CurrentLabelNode.Properties[(IPropertyId)templateEntry.LabelValueProperty] = (DocumentNode)context.DocumentContext.CreateNode(str);
        }
Exemplo n.º 4
0
        private void ProcessSingleSchemaPath(DataViewBuilderContext context, DataSchemaNodePath schemaPath, DataViewTemplate dataViewTemplate)
        {
            DataViewTemplateEntry templateEntryInternal = this.GetDataViewTemplateEntryInternal(schemaPath.Type, dataViewTemplate);

            if (templateEntryInternal == null)
            {
                return;
            }
            context.CurrentSchemaPath = schemaPath;
            context.CurrentLabelNode  = (DocumentCompositeNode)null;
            context.CurrentFieldNode  = (DocumentCompositeNode)null;
            this.CreateLabelElement(context, templateEntryInternal);
            this.CreateFieldElement(context, templateEntryInternal);
            this.layoutBuilder.SetElementLayout(context);
        }
        public virtual void SetElementLayout(DataViewBuilderContext context)
        {
            IProperty             defaultContentProperty = context.RootNode.Type.Metadata.DefaultContentProperty;
            DocumentCompositeNode contentNode            = (DocumentCompositeNode)context.RootNode.Properties[(IPropertyId)defaultContentProperty];

            if (contentNode == null)
            {
                contentNode = context.RootNode.Context.CreateNode((ITypeId)defaultContentProperty.PropertyType);
                context.RootNode.Properties[PanelElement.ChildrenProperty] = (DocumentNode)contentNode;
            }
            if (context.CurrentLabelNode != null)
            {
                this.AddChildToContent(contentNode, context.CurrentLabelNode);
            }
            this.AddChildToContent(contentNode, context.CurrentFieldNode);
        }
Exemplo n.º 6
0
 public DocumentCompositeNode GenerateDataView(IDocumentContext documentContext, IList <DataSchemaNodePath> entries, DataViewCategory category, DocumentCompositeNode containerNode, IDataViewLayoutBuilder layoutBuilder)
 {
     try
     {
         DataViewTemplate dataViewTemplate = this.GetDataViewTemplate(category);
         if (containerNode == null)
         {
             containerNode = (DocumentCompositeNode)dataViewTemplate.RootNode.Clone(documentContext);
         }
         this.layoutBuilder = layoutBuilder != null ? layoutBuilder : (!PlatformTypes.Grid.IsAssignableFrom((ITypeId)containerNode.Type) ? (IDataViewLayoutBuilder) new PanelDataViewLayoutBuilder() : (IDataViewLayoutBuilder) new GridDataViewLayoutBuilder());
         DataViewBuilderContext context = new DataViewBuilderContext(containerNode, category);
         for (int index = 0; index < entries.Count; ++index)
         {
             this.ProcessSingleSchemaPath(context, entries[index], dataViewTemplate);
         }
     }
     catch (Exception ex)
     {
     }
     return(containerNode);
 }
Exemplo n.º 7
0
 public void SetElementLayout(DataViewBuilderContext context)
 {
     if (this.row == -1)
     {
         this.contentNode = (DocumentCompositeNode)context.RootNode.Properties[PanelElement.ChildrenProperty];
     }
     ++this.row;
     if (this.row == 0)
     {
         if (context.CurrentLabelNode != null)
         {
             this.firstLabel = context.CurrentLabelNode;
             this.contentNode.Children.Add((DocumentNode)this.firstLabel);
         }
         this.firstField = context.CurrentFieldNode;
         this.contentNode.Children.Add((DocumentNode)this.firstField);
     }
     else
     {
         if (this.row == 1)
         {
             this.rowDefinitionsNode = context.DocumentContext.CreateNode(PlatformTypes.RowDefinitionCollection);
             context.RootNode.Properties[GridElement.RowDefinitionsProperty] = (DocumentNode)this.rowDefinitionsNode;
             this.AddRowDefinition();
             if (this.firstLabel != null)
             {
                 this.firstLabel.Properties[GridElement.RowProperty] = context.RootNode.Context.CreateNode(typeof(int), (object)0);
             }
             this.firstField.Properties[GridElement.RowProperty] = context.RootNode.Context.CreateNode(typeof(int), (object)0);
         }
         this.AddRowDefinition();
         if (context.CurrentLabelNode != null)
         {
             context.CurrentLabelNode.Properties[GridElement.RowProperty] = context.RootNode.Context.CreateNode(typeof(int), (object)this.row);
             this.contentNode.Children.Add((DocumentNode)context.CurrentLabelNode);
         }
         context.CurrentFieldNode.Properties[GridElement.RowProperty] = context.RootNode.Context.CreateNode(typeof(int), (object)this.row);
         this.contentNode.Children.Add((DocumentNode)context.CurrentFieldNode);
     }
 }