예제 #1
0
            /// <summary>
            /// Partition a static IBranch instance
            /// </summary>
            /// <param name="innerBranch">The branch to partition</param>
            /// <param name="indexer">An array of indices to reorder the items in the branch (optional)</param>
            /// <param name="sections">One or more PartitionSection structures indicating how the branch should be split up. If indexer is specified, then the Start and Count properties of the partition should be relative to the indexer, not the starting branch.</param>
            public BranchPartition(IBranch innerBranch, int[] indexer, params BranchPartitionSection[] sections)
            {
                myInnerBranch = innerBranch;
                myIndexer     = indexer;
                mySections    = sections;
                int sectionCount = sections.Length;
                int totalCount   = 0;

                myInnerMultiColumnBranch = innerBranch as IMultiColumnBranch;
                BranchFeatures requiredFeatures = 0;

                for (int i = 0; i < sectionCount; ++i)
                {
                    BranchPartitionSection currentSection = sections[i];
                    int visibleCount = sections[i].VisibleItemCount;
                    if (visibleCount != 0)
                    {
                        if (currentSection.Header != null && requiredFeatures == 0)
                        {
                            requiredFeatures = BranchFeatures.Expansions | ((myInnerMultiColumnBranch != null) ? BranchFeatures.JaggedColumns : 0);
                        }
                        totalCount += visibleCount;
                    }
                }
                myItemCount = totalCount;
                myFeatures  = requiredFeatures;
            }
예제 #2
0
            /// <summary>
            /// Translate an incoming row to a row on the inner branch
            /// </summary>
            /// <param name="row">The incoming row for this branch</param>
            /// <param name="section">The corresponding partion section</param>
            /// <returns>A translated row, or -1 for a section header.</returns>
            private int TranslateRow(int row, out BranchPartitionSection section)
            {
                BranchPartitionSection[] sections = mySections;
                int sectionCount = sections.Length;

                for (int i = 0; i < sectionCount; ++i)
                {
                    BranchPartitionSection currentSection = sections[i];
                    int visibleOnThisSection = currentSection.VisibleItemCount;
                    if (row < visibleOnThisSection)
                    {
                        section = currentSection;
                        if (currentSection.Header != null)
                        {
                            return(-1);
                        }
                        row = currentSection.Start + row;
                        int[] indexer = myIndexer;
                        if (indexer != null)
                        {
                            row = indexer[row];
                        }
                        return(row);
                    }
                    row -= visibleOnThisSection;
                }
                throw new ArgumentOutOfRangeException();
            }
예제 #3
0
			/// <summary>
			/// Translate an incoming row to a row on the inner branch
			/// </summary>
			/// <param name="row">The incoming row for this branch</param>
			/// <param name="section">The corresponding partion section</param>
			/// <returns>A translated row, or -1 for a section header.</returns>
			private int TranslateRow(int row, out BranchPartitionSection section)
			{
				BranchPartitionSection[] sections = mySections;
				int sectionCount = sections.Length;
				for (int i = 0; i < sectionCount; ++i)
				{
					BranchPartitionSection currentSection = sections[i];
					int visibleOnThisSection = currentSection.VisibleItemCount;
					if (row < visibleOnThisSection)
					{
						section = currentSection;
						if (currentSection.Header != null)
						{
							return -1;
						}
						row = currentSection.Start + row;
						int[] indexer = myIndexer;
						if (indexer != null)
						{
							row = indexer[row];
						}
						return row;
					}
					row -= visibleOnThisSection;
				}
				throw new ArgumentOutOfRangeException();
			}