protected void FillDataSource(BindingContext bindingManager, object component)
        {
            if (component is IListSource || component is IList || component is Array)
            {
                CurrencyManager listManager             = (CurrencyManager)bindingManager[component];
                PropertyDescriptorCollection properties = listManager.GetItemProperties();
                if (properties.Count > 0)
                {
                    TreeNodeCollection nodes = this.Nodes;

                    if (multipleDataSources)
                    {
                        TreeNode dataSourceNode = new DataSourceNode((IComponent)component);
                        Nodes.Add(dataSourceNode);
                        if (selectedItem != null && selectedItem.Equals(component, ""))
                        {
                            selectedNode = dataSourceNode;
                        }
                        nodes = dataSourceNode.Nodes;
                    }

                    for (int j = 0; j < properties.Count; j++)
                    {
                        FillDataMembers(bindingManager, component, properties[j].Name, properties[j].Name, typeof(IList).IsAssignableFrom(properties[j].PropertyType), nodes, 0);
                    }
                }
            }
        }
示例#2
0
        private bool EnsureDataSourceReachable(SceneNode targetNode, DataSourceNode dataSource)
        {
            if (!targetNode.ViewModel.Document.HasOpenTransaction || new ExpressionEvaluator(targetNode.ViewModel.DocumentRootResolver).EvaluateResource(targetNode.DocumentNodePath, ResourceReferenceType.Static, dataSource.ResourceKey) != null)
            {
                return(true);
            }
            IProjectDocument projectDocument = targetNode.ProjectContext.OpenDocument(dataSource.DocumentNode.Context.DocumentUrl);

            if (projectDocument == null || projectDocument.DocumentType != ProjectDocumentType.ResourceDictionary)
            {
                return(false);
            }
            SceneDocument   resourceDictionary1 = projectDocument.Document as SceneDocument;
            ResourceManager resourceManager     = targetNode.ViewModel.DesignerContext.ResourceManager;
            ResourceDictionaryContentProvider resourceDictionary2 = resourceManager.FindContentProviderForResourceDictionary(resourceDictionary1);
            ResourceContainer resourceContainer = resourceManager.FindResourceContainer(targetNode.DocumentContext.DocumentUrl);

            return(resourceDictionary2.EnsureLinked(targetNode.ViewModel, resourceContainer));
        }
示例#3
0
        public virtual void Execute(XmlNode node)
        {
            var DataSourceNodes = node.SelectNodes("./DataSource");

            foreach (XmlNode DataSourceNode in DataSourceNodes)
            {
                var name = DataSourceNode.Attributes["Name"].Value;

                var path = DataSourceNode.SelectSingleNode("./Path")?.InnerXml;
                path = path ?? $"{Root.NamingConvention.Apply(name)}";
                if (!Path.IsPathRooted(path))
                {
                    path = Path.Combine(RootPath ?? string.Empty, path);
                }

                var overwrite = bool.Parse(DataSourceNode.Attributes["overwrite"]?.Value ?? bool.TrueString);

                DataSourceService.Create(name, ParentPath, path, overwrite);
                Root.DataSources.Add(name, $"{ParentPath}/{name}");
            }
        }
 private void LoadAvailableColumnsTree()
 {
     if (this.currentDataSource != null)
     {
         this.selectedDataSourceNode = new DataSourceNode();
         this.availableColumnsTree.Nodes.Add(this.selectedDataSourceNode);
     }
     ButtonNode node = new ButtonNode();
     this.availableColumnsTree.Nodes.Add(node);
     ButtonNode node2 = new ButtonNode("Select", System.Design.SR.GetString("DGCol_SelectButton"), System.Design.SR.GetString("DGCol_Node_Select"));
     node.Nodes.Add(node2);
     EditCommandNode node3 = new EditCommandNode();
     node.Nodes.Add(node3);
     ButtonNode node4 = new ButtonNode("Delete", System.Design.SR.GetString("DGCol_DeleteButton"), System.Design.SR.GetString("DGCol_Node_Delete"));
     node.Nodes.Add(node4);
     HyperLinkNode node5 = new HyperLinkNode();
     this.availableColumnsTree.Nodes.Add(node5);
     TemplateNode node6 = new TemplateNode();
     this.availableColumnsTree.Nodes.Add(node6);
 }
 private void InitPage()
 {
     this.currentDataSource = null;
     this.autoColumnCheck.Checked = false;
     this.selectedDataSourceNode = null;
     this.availableColumnsTree.Nodes.Clear();
     this.selColumnsList.Items.Clear();
     this.currentColumnItem = null;
     this.columnSortExprCombo.Items.Clear();
     this.currentColumnEditor = null;
     this.boundColumnEditor.ClearDataFields();
     this.buttonColumnEditor.ClearDataFields();
     this.hyperLinkColumnEditor.ClearDataFields();
     this.editCommandColumnEditor.ClearDataFields();
     this.propChangesPending = false;
     this.headerTextChanged = false;
 }
 private void AddProjectDataSourceContents(TreeNodeCollection nodes, DataSourceNode projectDataSourceNode)
 {
     DataSourceDescriptor dataSource = projectDataSourceNode.DataSource as DataSourceDescriptor;
     if (dataSource != null)
     {
         System.Type type = this.GetType(dataSource.TypeName, false, false);
         if (type != null)
         {
             object list = type;
             try
             {
                 list = Activator.CreateInstance(type);
             }
             catch (Exception exception)
             {
                 if (System.Windows.Forms.ClientUtils.IsCriticalException(exception))
                 {
                     throw;
                 }
             }
             bool flag = (list is IListSource) && (list as IListSource).ContainsListCollection;
             if (!flag || !(this.context.Instance is BindingSource))
             {
                 PropertyDescriptorCollection listItemProperties = ListBindingHelper.GetListItemProperties(list);
                 if (listItemProperties != null)
                 {
                     foreach (PropertyDescriptor descriptor2 in listItemProperties)
                     {
                         if (this.IsBindableDataMember(descriptor2) && descriptor2.IsBrowsable)
                         {
                             bool isList = this.IsListMember(descriptor2);
                             if ((!this.selectListMembers || isList) && (flag || !isList))
                             {
                                 this.AddProjectDataMember(nodes, dataSource, descriptor2, list, isList);
                             }
                         }
                     }
                 }
             }
         }
     }
 }
 private void AddProjectDataSourceContents(DataSourceNode projectDataSourceNode)
 {
     this.AddProjectDataSourceContents(projectDataSourceNode.Nodes, projectDataSourceNode);
 }
 private void AddDataSource(TreeNodeCollection nodes, IComponent dataSource, string dataMember)
 {
     if (this.showDataSources && this.IsBindableDataSource(dataSource))
     {
         string message = null;
         PropertyDescriptorCollection properties = null;
         try
         {
             properties = this.GetItemProperties(dataSource, dataMember);
             if (properties == null)
             {
                 return;
             }
         }
         catch (ArgumentException exception)
         {
             message = exception.Message;
         }
         if (!this.showDataMembers || (properties.Count != 0))
         {
             DataSourceNode node = new DataSourceNode(this, dataSource, dataSource.Site.Name);
             nodes.Add(node);
             if ((this.selectedItem != null) && this.selectedItem.Equals(dataSource, ""))
             {
                 this.selectedNode = node;
             }
             if (message == null)
             {
                 this.AddDataSourceContents(node.Nodes, dataSource, dataMember, properties);
                 node.SubNodesFilled = true;
             }
             else
             {
                 node.Error = message;
                 node.ForeColor = SystemColors.GrayText;
             }
         }
     }
 }
 private void LoadCustomFields()
 {
     if (this._customFieldDesigners == null)
     {
         this._customFieldDesigners = DataControlFieldHelper.GetCustomFieldDesigners(this, this.Control);
     }
     IDataSourceFieldSchema[] fieldSchemas = this.GetFieldSchemas();
     bool flag = (fieldSchemas != null) && (fieldSchemas.Length > 0);
     foreach (KeyValuePair<System.Type, DataControlFieldDesigner> pair in this._customFieldDesigners)
     {
         DataControlFieldDesigner fieldDesigner = pair.Value;
         if (fieldDesigner.UsesSchema && flag)
         {
             DataSourceNode node = new DataSourceNode(pair.Key.Name);
             this._availableFieldsTree.Nodes.Add(node);
             foreach (IDataSourceFieldSchema schema in fieldSchemas)
             {
                 node.Nodes.Add(new DataControlFieldDesignerNode(fieldDesigner, schema));
             }
             node.Expand();
         }
         else
         {
             this._availableFieldsTree.Nodes.Add(new DataControlFieldDesignerNode(fieldDesigner));
         }
     }
 }
 private void LoadAvailableFieldsTree()
 {
     IDataSourceFieldSchema[] fieldSchemas = this.GetFieldSchemas();
     if ((fieldSchemas != null) && (fieldSchemas.Length > 0))
     {
         this._selectedDataSourceNode = new DataSourceNode();
         this._availableFieldsTree.Nodes.Add(this._selectedDataSourceNode);
         this._selectedCheckBoxDataSourceNode = new BoolDataSourceNode();
         this._availableFieldsTree.Nodes.Add(this._selectedCheckBoxDataSourceNode);
     }
     HyperLinkNode node = new HyperLinkNode(this);
     this._availableFieldsTree.Nodes.Add(node);
     ImageNode node2 = new ImageNode(this);
     this._availableFieldsTree.Nodes.Add(node2);
     ButtonNode node3 = new ButtonNode(this);
     this._availableFieldsTree.Nodes.Add(node3);
     CommandNode node4 = new CommandNode(this);
     this._availableFieldsTree.Nodes.Add(node4);
     CommandNode node5 = new CommandNode(this, 0, System.Design.SR.GetString("DCFEditor_Node_Edit"), 6);
     node4.Nodes.Add(node5);
     if (this.Control is GridView)
     {
         CommandNode node6 = new CommandNode(this, 2, System.Design.SR.GetString("DCFEditor_Node_Select"), 5);
         node4.Nodes.Add(node6);
     }
     CommandNode node7 = new CommandNode(this, 3, System.Design.SR.GetString("DCFEditor_Node_Delete"), 7);
     node4.Nodes.Add(node7);
     if (this.Control is DetailsView)
     {
         CommandNode node8 = new CommandNode(this, 1, System.Design.SR.GetString("DCFEditor_Node_Insert"), 11);
         node4.Nodes.Add(node8);
     }
     TemplateNode node9 = new TemplateNode(this);
     this._availableFieldsTree.Nodes.Add(node9);
 }
 private void InitPage()
 {
     this._autoFieldCheck.Checked = false;
     this._selectedDataSourceNode = null;
     this._selectedCheckBoxDataSourceNode = null;
     this._availableFieldsTree.Nodes.Clear();
     this._selFieldsList.Items.Clear();
     this._currentFieldItem = null;
     this._propChangesPending = false;
 }