/// <summary>
        ///     Create a new branch.
        /// </summary>
        protected TreeGridDesignerBranch(object component, TreeGridDesignerColumnDescriptor[] columns)
        {
            if (columns == null)
            {
                throw new ArgumentNullException("columns");
            }

            _component = component;
            _columns = columns;
        }
        /// <summary>
        ///     Derived classes may override this to perform initialization.
        /// </summary>
        /// <param name="component">Selected component that this branch may act on.</param>
        /// <param name="columns">columns to act on.</param>
        public virtual bool /* ITreeGridDesignerInitializeBranch */ Initialize(object component, TreeGridDesignerColumnDescriptor[] columns)
        {
            if (columns == null)
            {
                throw new ArgumentNullException("columns");
            }

            _component = component;
            _columns = columns;
            return true;
        }
        public override bool Initialize(object component, TreeGridDesignerColumnDescriptor[] columns)
        {
            if (!base.Initialize(component, columns))
            {
                return false;
            }

            var mappingAssociationSet = component as MappingAssociationSet;
            if (mappingAssociationSet != null)
            {
                _mappingAssociationSet = mappingAssociationSet;
            }

            return true;
        }
        public override bool Initialize(object component, TreeGridDesignerColumnDescriptor[] columns)
        {
            if (!base.Initialize(component, columns))
            {
                return false;
            }

            _mappingFunctionImport = component as MappingFunctionImport;
            if (_mappingFunctionImport != null)
            {
                return true;
            }

            return false;
        }
        public override bool Initialize(object component, TreeGridDesignerColumnDescriptor[] columns)
        {
            if (!base.Initialize(component, columns))
            {
                return false;
            }

            var mappingResultBindings = component as MappingResultBindings;
            if (mappingResultBindings != null)
            {
                _mappingResultBindings = mappingResultBindings;
            }

            return true;
        }
Пример #6
0
        public override bool Initialize(object component, TreeGridDesignerColumnDescriptor[] columns)
        {
            if (!base.Initialize(component, columns))
            {
                return false;
            }

            var mappingModificationFunctionMapping = component as MappingModificationFunctionMapping;
            if (mappingModificationFunctionMapping != null)
            {
                _mappingModificationFunctionMapping = mappingModificationFunctionMapping;
            }

            return true;
        }
Пример #7
0
        public override bool Initialize(object component, TreeGridDesignerColumnDescriptor[] columns)
        {
            if (!base.Initialize(component, columns))
            {
                return false;
            }

            var mappingFunctionScalarProperties = component as MappingFunctionScalarProperties;
            if (mappingFunctionScalarProperties != null)
            {
                _mappingFunctionScalarProperties = mappingFunctionScalarProperties;
            }

            return true;
        }
Пример #8
0
        public override bool Initialize(object component, TreeGridDesignerColumnDescriptor[] columns)
        {
            if (!base.Initialize(component, columns))
            {
                return false;
            }

            var mappingStorageEntityType = component as MappingStorageEntityType;
            if (mappingStorageEntityType != null)
            {
                _mappingStorageEntityType = mappingStorageEntityType;
            }

            return true;
        }
Пример #9
0
        // <summary>
        //     ITreeGridDesignerInitializeBranch
        // </summary>
        public override bool Initialize(object component, TreeGridDesignerColumnDescriptor[] columns)
        {
            if (!base.Initialize(component, columns))
            {
                return false;
            }

            _mappingFunctionTypeMapping = component as MappingFunctionEntityType;
            if (_mappingFunctionTypeMapping != null)
            {
                _columns = columns;
                PopulateHeaders(true);
                return true;
            }

            return false;
        }
Пример #10
0
        /// <summary>
        ///     Sets header info for this branch.
        /// </summary>
        internal void SetHeaderInfo(IList childBranchList, TreeGridDesignerColumnDescriptor[] columns)
        {
            if (childBranchList == null)
            {
                throw new ArgumentNullException("childBranchList");
            }

            _childBranchArray = new ChildBranchInfo[childBranchList.Count];
            childBranchList.CopyTo(_childBranchArray, 0);

            _columns = columns;

            _currentBranches = new List<ChildBranchInfo>(_childBranchArray.Length);
            for (var i = 0; i < _childBranchArray.Length; i++)
            {
                _currentBranches.Add(_childBranchArray[i]);
            }
        }
 internal ResultBindingBranch(MappingResultBindings mappingResultBindings, TreeGridDesignerColumnDescriptor[] columns)
     : base(mappingResultBindings, columns)
 {
     _mappingResultBindings = mappingResultBindings;
 }
Пример #12
0
        /// <summary>
        ///     Populates the tree via attributes specifed on th root object.  This object usually corresponds to
        ///     the selection made in a designer.
        /// </summary>
        /// <returns>True if the tree was populated.  False if the object passed in doesn't specify any branches.</returns>
        internal bool PopulateTree(object root)
        {
            object    attributeOwner;
            ArrayList rootBranches = null;

            var tree = Tree;

            if (tree != null &&
                root != null)
            {
                // determine which columns should be shown
                var attributes = FindAttributes(root, typeof(TreeGridDesignerColumnAttribute), out attributeOwner);
                TreeGridDesignerColumnDescriptor[] newColumns = null;

                if (attributes != null &&
                    attributes.Length > 0)
                {
                    var currentColumn = 0;

                    newColumns = new TreeGridDesignerColumnDescriptor[attributes.Length];
                    Array.Sort(attributes);
                    foreach (TreeGridDesignerColumnAttribute attribute in attributes)
                    {
                        // find the column descriptor in the cache or create it
                        newColumns[currentColumn++] = FindOrCreateColumn(attribute.ColumnType);
                    }
                }

                if (newColumns == null &&
                    _defaultColumns != null)
                {
                    newColumns = _defaultColumns;
                }

                if (newColumns != null)
                {
                    // determine which root nodes should be shown
                    attributes = FindAttributes(root, typeof(TreeGridDesignerRootBranchAttribute), out attributeOwner);
                    if (attributes.Length > 0)
                    {
                        Array.Sort(attributes);
                        rootBranches = new ArrayList(attributes.Length);
                        foreach (TreeGridDesignerRootBranchAttribute attribute in attributes)
                        {
                            var branchType = attribute.BranchType;

                            // support types that implement IBranch with a default constructor
                            var rootBranch = Activator.CreateInstance(branchType)
                                             as ITreeGridDesignerInitializeBranch;
                            if (rootBranch != null)
                            {
                                if (rootBranch.Initialize(attributeOwner, newColumns))
                                {
                                    // Only add in the branch if it can be successfully initialized. (Orphaned PELs can't)
                                    rootBranches.Add(rootBranch);
                                }
                            }
                        }

                        if (rootBranches.Count > 0)
                        {
                            // we have at least one root branch, now adjust columns accordingly
                            var refreshColumns = (_currentColumns == null) || (newColumns.Length != _currentColumns.Length);

                            if (!refreshColumns)
                            {
                                for (var i = 0; i < _currentColumns.Length && !refreshColumns; i++)
                                {
                                    refreshColumns = _currentColumns[i] != newColumns[i];
                                }
                            }

                            // refresh columns if necessary
                            if (refreshColumns)
                            {
                                _currentColumns = newColumns;

                                var variableColumnTree = tree as VariableColumnTree;

                                Debug.Assert(variableColumnTree != null, "unable to change column count.");
                                if (variableColumnTree != null)
                                {
                                    variableColumnTree.ChangeColumnCount(_currentColumns.Length);
                                    SetColumns(_currentColumns);
                                }
                            }

                            // root tree at branch
                            tree.Root = rootBranches.Count == 1 ? (IBranch)rootBranches[0] : new AggregateBranch(rootBranches, 0);
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
 internal AssociationSetEndBranch(MappingAssociationSet mappingAssociationSet, TreeGridDesignerColumnDescriptor[] columns)
     : base(mappingAssociationSet, columns)
 {
     _mappingAssociationSet = mappingAssociationSet;
 }
 internal FunctionImportScalarPropertyBranch(MappingFunctionImport mappingFunctionImport, TreeGridDesignerColumnDescriptor[] columns)
     : base(mappingFunctionImport, columns)
 {
     _mappingFunctionImport = mappingFunctionImport;
 }
Пример #15
0
 internal ParametersBranch(
     MappingModificationFunctionMapping mappingModificationFunctionMapping, TreeGridDesignerColumnDescriptor[] columns)
     : base(mappingModificationFunctionMapping, columns)
 {
     _mappingModificationFunctionMapping = mappingModificationFunctionMapping;
 }
 bool ITreeGridDesignerInitializeBranch.Initialize(object selection, TreeGridDesignerColumnDescriptor[] columns)
 {
     return Initialize(selection, columns);
 }
 internal ScalarPropertyBranch(MappingColumnMappings mappingColumnMappings, TreeGridDesignerColumnDescriptor[] columns)
     : base(mappingColumnMappings, columns)
 {
     _mappingColumnMappings = mappingColumnMappings;
 }
Пример #18
0
 internal ParameterBranch(
     MappingFunctionScalarProperties mappingFunctionScalarProperties, TreeGridDesignerColumnDescriptor[] columns)
     : base(mappingFunctionScalarProperties, columns)
 {
     _mappingFunctionScalarProperties = mappingFunctionScalarProperties;
 }
 internal ModificationFunctionBranch(
     MappingFunctionEntityType mappingFunctionTypeMapping, TreeGridDesignerColumnDescriptor[] columns)
     : base(mappingFunctionTypeMapping, columns)
 {
     _mappingFunctionTypeMapping = mappingFunctionTypeMapping;
 }
        /// <summary>
        ///     Populates the tree via attributes specifed on th root object.  This object usually corresponds to
        ///     the selection made in a designer.
        /// </summary>
        /// <returns>True if the tree was populated.  False if the object passed in doesn't specify any branches.</returns>
        internal bool PopulateTree(object root)
        {
            object attributeOwner;
            ArrayList rootBranches = null;

            var tree = Tree;
            if (tree != null
                && root != null)
            {
                // determine which columns should be shown
                var attributes = FindAttributes(root, typeof(TreeGridDesignerColumnAttribute), out attributeOwner);
                TreeGridDesignerColumnDescriptor[] newColumns = null;

                if (attributes != null
                    && attributes.Length > 0)
                {
                    var currentColumn = 0;

                    newColumns = new TreeGridDesignerColumnDescriptor[attributes.Length];
                    Array.Sort(attributes);
                    foreach (TreeGridDesignerColumnAttribute attribute in attributes)
                    {
                        // find the column descriptor in the cache or create it
                        newColumns[currentColumn++] = FindOrCreateColumn(attribute.ColumnType);
                    }
                }

                if (newColumns == null
                    && _defaultColumns != null)
                {
                    newColumns = _defaultColumns;
                }

                if (newColumns != null)
                {
                    // determine which root nodes should be shown
                    attributes = FindAttributes(root, typeof(TreeGridDesignerRootBranchAttribute), out attributeOwner);
                    if (attributes.Length > 0)
                    {
                        Array.Sort(attributes);
                        rootBranches = new ArrayList(attributes.Length);
                        foreach (TreeGridDesignerRootBranchAttribute attribute in attributes)
                        {
                            var branchType = attribute.BranchType;

                            // support types that implement IBranch with a default constructor
                            var rootBranch = Activator.CreateInstance(branchType) 
                                as ITreeGridDesignerInitializeBranch;
                            if (rootBranch != null)
                            {
                                if (rootBranch.Initialize(attributeOwner, newColumns))
                                {
                                    // Only add in the branch if it can be successfully initialized. (Orphaned PELs can't)
                                    rootBranches.Add(rootBranch);
                                }
                            }
                        }

                        if (rootBranches.Count > 0)
                        {
                            // we have at least one root branch, now adjust columns accordingly
                            var refreshColumns = (_currentColumns == null) || (newColumns.Length != _currentColumns.Length);

                            if (!refreshColumns)
                            {
                                for (var i = 0; i < _currentColumns.Length && !refreshColumns; i++)
                                {
                                    refreshColumns = _currentColumns[i] != newColumns[i];
                                }
                            }

                            // refresh columns if necessary
                            if (refreshColumns)
                            {
                                _currentColumns = newColumns;

                                var variableColumnTree = tree as VariableColumnTree;

                                Debug.Assert(variableColumnTree != null, "unable to change column count.");
                                if (variableColumnTree != null)
                                {
                                    variableColumnTree.ChangeColumnCount(_currentColumns.Length);
                                    SetColumns(_currentColumns);
                                }
                            }

                            // root tree at branch
                            tree.Root = rootBranches.Count == 1 ? (IBranch)rootBranches[0] : new AggregateBranch(rootBranches, 0);
                            return true;
                        }
                    }
                }
            }

            return false;
        }
 internal EndScalarPropertyBranch(MappingAssociationSetEnd mappingAssociationSetEnd, TreeGridDesignerColumnDescriptor[] columns)
     : base(mappingAssociationSetEnd, columns)
 {
     _mappingAssociationSetEnd = mappingAssociationSetEnd;
 }
Пример #22
0
        //private bool _registeredEventHandlers = false;

        internal ConditionBranch(MappingStorageEntityType mappingStorageEntityType, TreeGridDesignerColumnDescriptor[] columns)
            : base(mappingStorageEntityType, columns)
        {
            _mappingStorageEntityType = mappingStorageEntityType;
        }
Пример #23
0
        //private bool _registeredEventHandlers = false;

        internal TableBranch(MappingConceptualEntityType mappingConceptualTypeMapping, TreeGridDesignerColumnDescriptor[] columns)
            : base(mappingConceptualTypeMapping, columns)
        {
            _mappingConceptualTypeMapping = mappingConceptualTypeMapping;
        }
        /// <summary>
        ///     Set the columns to be displayed by the tree control
        /// </summary>
        /// <param name="columns"></param>
        internal void SetColumns(TreeGridDesignerColumnDescriptor[] columns)
        {
            if (columns == null)
            {
                throw new ArgumentNullException("columns");
            }

            // the current column may now be out of range.  
            // reset to 0 if that is the case
            if (CurrentColumn >= columns.Length)
            {
                CurrentColumn = 0;
            }

            _currentColumns = columns;

            // do initial percentage calculations.
            var percentages = new float[columns.Length];
            var calculatedPercentage = 1.0F;
            var calculatedColumns = columns.Length;
            for (var i = 0; i < columns.Length; i++)
            {
                var columnPercentage = columns[i].InitialPercentage;
                if (columnPercentage != TreeGridDesignerColumnDescriptor.CalculatePercentage)
                {
                    if (columnPercentage > calculatedPercentage)
                    {
                        percentages[i] = -1;
                        continue; // using the initial percentage specified by this column would cause all
                        // percentages to sum to more than 1, so we discard it.
                    }

                    calculatedPercentage -= columnPercentage;
                    calculatedColumns--;
                    percentages[i] = columnPercentage;
                }
                else
                {
                    percentages[i] = -1;
                }
            }

            // calculate percentage increment used for columns in which the percentage
            // is not specified explicitly
            var defaultPercentageIncr = calculatedColumns == 0 ? 0 : calculatedPercentage / calculatedColumns;

            // create headers
            var headers = new VirtualTreeColumnHeader[columns.Length];

            float percentage = 0;
            for (var i = 0; i < headers.Length - 1; ++i)
            {
                if (percentages[i] == -1)
                {
                    percentage += defaultPercentageIncr;
                }
                else
                {
                    percentage += percentages[i];
                }

                if (columns[i].ColumnIsCheckBox)
                {
                    headers[i] = new VirtualTreeColumnHeader(columns[i].Name, percentage, StateImageList.ImageSize.Width);
                }
                else
                {
                    headers[i] = new VirtualTreeColumnHeader(columns[i].Name, percentage);
                }
            }
            headers[headers.Length - 1] = new VirtualTreeColumnHeader(columns[headers.Length - 1].Name, 1f);

            SetColumnHeaders(headers, false);
        }
        //private bool _registeredEventHandlers = false;

        internal AssociationSetBranch(MappingAssociation mappingAssociation, TreeGridDesignerColumnDescriptor[] columns)
            : base(mappingAssociation, columns)
        {
            _mappingAssociation = mappingAssociation;
        }