コード例 #1
0
        // TODO: Currently we are using the IGroup.Names as IComparables. Should we add IComparer?

        /// <summary>
        /// Compares two <see cref="IGroup"/>s based on their <see cref="IGroup.Name"/>s.
        /// </summary>
        /// <param name="results">The current aggregate results.</param>
        /// <param name="left">The first <see cref="IGroup"/> to compare.</param>
        /// <param name="right">The second <see cref="IGroup"/> to compare.</param>
        /// <param name="axis">Identifies if the groups are in <see cref="DataAxis.Rows"/> or <see cref="DataAxis.Columns"/>.</param>
        /// <returns>
        /// A signed integer that indicates the relative values of x and y, as shown in the following table.
        /// <para>Value Meaning Less than zero x is less than y.</para>
        /// <para>Zero x equals y.</para>
        /// <para>Greater than zero x is greater than y.</para>
        /// </returns>
        public override int CompareGroups(IAggregateResultProvider results, IGroup left, IGroup right, DataAxis axis)
        {
            if (left.Name == NullValue.Instance && right.Name == NullValue.Instance)
            {
                return(0);
            }
            else if (left.Name == NullValue.Instance)
            {
                return(1);
            }
            else if (right.Name == NullValue.Instance)
            {
                return(-1);
            }

            IComparable leftComparable = left.Name as IComparable;

            if (leftComparable != null)
            {
                return(leftComparable.CompareTo(right.Name));
            }

            IComparable rightComparable = right.Name as IComparable;

            if (rightComparable != null)
            {
                return(-rightComparable.CompareTo(left.Name));
            }

            return(0);
        }
コード例 #2
0
ファイル: TotalValue.cs プロジェクト: zyhong/UI-For-UWP
 internal TotalValue(IAggregateResultProvider results, Coordinate groups, int aggregate)
 {
     this.results        = results;
     this.aggregate      = aggregate;
     this.unasigendValue = true;
     this.Groups         = groups;
 }
コード例 #3
0
        public GroupComparerDecorator(GroupComparer groupComparer, SortOrder sortOrder, IAggregateResultProvider results, DataAxis axis)
        {
            this.groupComparer = groupComparer;
            this.results       = results;
            this.axis          = axis;

            this.sortOrderMultiplier = sortOrder == SortOrder.Descending ? -1 : 1;
        }
コード例 #4
0
        internal override bool Filter(IGroup group, IAggregateResultProvider results, DataAxis axis)
        {
            if (this.FilterImpl != null)
            {
                return(this.FilterImpl.PassesFilter(group));
            }

            return(true);
        }
コード例 #5
0
        /// <summary>
        /// Compares two <see cref="IGroup"/>s based on their grand totals.
        /// </summary>
        /// <param name="results">The current aggregate results.</param>
        /// <param name="left">The first <see cref="IGroup"/> to compare.</param>
        /// <param name="right">The second <see cref="IGroup"/> to compare.</param>
        /// <param name="axis">Identifies if the groups are in <see cref="DataAxis.Rows"/> or <see cref="DataAxis.Columns"/>.</param>
        /// <returns>
        /// A signed integer that indicates the relative values of x and y, as shown in the following table.
        /// <para>Value Meaning Less than zero x is less than y.</para>
        /// <para>Zero x equals y.</para>
        /// <para>Greater than zero x is greater than y.</para>
        /// </returns>
        public override int CompareGroups(IAggregateResultProvider results, IGroup left, IGroup right, DataAxis axis)
        {
            Coordinate grandTotalCoordinateX;
            Coordinate grandTotalCoordinateY;

            if (axis == DataAxis.Rows)
            {
                grandTotalCoordinateX = new Coordinate(left, results.Root.ColumnGroup);
                grandTotalCoordinateY = new Coordinate(right, results.Root.ColumnGroup);
            }
            else
            {
                grandTotalCoordinateX = new Coordinate(results.Root.RowGroup, left);
                grandTotalCoordinateY = new Coordinate(results.Root.RowGroup, right);
            }

            AggregateValue aggregateValueX = results.GetAggregateResult(this.AggregateIndex, grandTotalCoordinateX);
            AggregateValue aggregateValueY = results.GetAggregateResult(this.AggregateIndex, grandTotalCoordinateY);

            // TODO: Exception handling, Provide AggregateResults Comparer, Proper order on value-vs-null and null-vs-value cases
            if (aggregateValueX != null && aggregateValueY != null)
            {
                object valueX = aggregateValueX.GetValue();
                object valueY = aggregateValueY.GetValue();

                IComparable comparableX = valueX as IComparable;
                if (comparableX != null)
                {
                    return(comparableX.CompareTo(valueY));
                }

                IComparable comparableY = valueY as IComparable;
                if (comparableY != null)
                {
                    return(-comparableY.CompareTo(valueX));
                }
            }

            return(0);
        }
コード例 #6
0
 /// <summary>
 /// Formats the value located at the <paramref name="groups"/> <see cref="Coordinate"/>. The current value could be retrieved from the <paramref name="results"/>.
 /// </summary>
 /// <param name="groups">The <see cref="Coordinate"/> for the formatted value.</param>
 /// <param name="results">The current results in the data grouping.</param>
 /// <param name="aggregateIndex">The index of the aggregate description we are formatting value for.</param>
 /// <returns>The formatted value.</returns>
 protected internal abstract AggregateValue FormatValue(Coordinate groups, IAggregateResultProvider results, int aggregateIndex);
コード例 #7
0
        // TODO: Consider wrapping the IGroups in small objects that has settable 'IsFiltered' property similar to the TotalValue that has settable 'FormattedValue'.
        // TODO: Or the other way around - make them both return an ISet/IDictionary implementations that contain the filtered groups / values for groups.

        /// <summary>
        /// Filters the groups within a parent group. Can filter based on count, average values or sorted values.
        /// </summary>
        /// <param name="groups">A read only list of all siblings.</param>
        /// <param name="results">The current aggregate results.</param>
        /// <param name="axis">Identifies if the groups are in <see cref="DataAxis.Rows"/> or <see cref="DataAxis.Columns"/>.</param>
        /// <param name="level">The level of the groups.</param>
        /// <returns>A <see cref="ICollection{IGroup}"/> implementation that is used to filter the groups.</returns>
        protected internal abstract ICollection <IGroup> Filter(IReadOnlyList <object> groups, IAggregateResultProvider results, DataAxis axis, int level);
コード例 #8
0
 public override int CompareGroups(IAggregateResultProvider results, IGroup x, IGroup y, DataAxis axis)
 {
     throw new NotImplementedException();
 }
コード例 #9
0
 /// <summary>
 /// Gets a read only collection of the <see cref="TotalValue"/>s for all siblings at the <see cref="Level"/> and <see cref="Axis"/>. Based on the <see cref="TotalValue.Value"/>s the <see cref="TotalValue.FormattedValue"/> should be set.
 /// </summary>
 /// <param name="valueFormatters">A read only list of the <see cref="TotalValue"/>s for all siblings at the <see cref="Level"/> and <see cref="Axis"/>.</param>
 /// <param name="results">The <see cref="IAggregateResultProvider"/> with the current data grouping results.</param>
 protected internal abstract void FormatTotals(IReadOnlyList <TotalValue> valueFormatters, IAggregateResultProvider results);
コード例 #10
0
ファイル: RunningTotalsIn.cs プロジェクト: zyhong/UI-For-UWP
        /// <inheritdoc />
        protected internal override void FormatTotals(IReadOnlyList <TotalValue> valueFormatters, IAggregateResultProvider results)
        {
            double accumulation = 0;

            foreach (var valueFormatter in valueFormatters)
            {
                AggregateValue value = valueFormatter.Value;
                if (value != null)
                {
                    accumulation += Convert.ToDouble(value.GetValue(), CultureInfo.InvariantCulture);
                }

                valueFormatter.FormattedValue = new ConstantValueAggregate(accumulation);
            }
        }
コード例 #11
0
ファイル: GroupComparer.cs プロジェクト: zyhong/UI-For-UWP
 /// <summary>
 /// Compares two <see cref="IGroup"/>s based on the current aggregate results.
 /// </summary>
 /// <param name="results">The current aggregate results.</param>
 /// <param name="left">The first <see cref="IGroup"/> to compare.</param>
 /// <param name="right">The second <see cref="IGroup"/> to compare.</param>
 /// <param name="axis">Identifies if the groups are in <see cref="DataAxis.Rows"/> or <see cref="DataAxis.Columns"/>.</param>
 /// <returns>
 /// A signed integer that indicates the relative values of x and y, as shown in the following table.
 /// <para>Value Meaning Less than zero x is less than y.</para>
 /// <para>Zero x equals y.</para>
 /// <para>Greater than zero x is greater than y.</para>
 /// </returns>
 public abstract int CompareGroups(IAggregateResultProvider results, IGroup left, IGroup right, DataAxis axis);
コード例 #12
0
 /// <summary>
 /// Identifies if a group should be filtered or not.
 /// </summary>
 /// <param name="group">The group.</param>
 /// <param name="results">Results for the current grouping. Could be used for totals lookup.</param>
 /// <param name="axis">Identifies if the <paramref name="group"/> is positioned in the <see cref="DataAxis.Rows"/> or <see cref="DataAxis.Columns"/>.</param>
 /// <returns>True if the group should be preserved, False if the group should be removed.</returns>
 internal abstract bool Filter(IGroup group, IAggregateResultProvider results, DataAxis axis);