Ejemplo n.º 1
0
        protected internal ICollectionView <GridViewRowInfo> LoadHierarchicalData(
            GridViewHierarchyRowInfo parent,
            ICollectionView <GridViewRowInfo> sourceView)
        {
            if (this.ViewTemplate.HierarchyDataProvider == null)
            {
                this.childRows = GridViewChildRowCollection.Empty;
                this.version   = this.ownerTemplate.DataView.Version;
                return((ICollectionView <GridViewRowInfo>)null);
            }
            IList <GridViewRowInfo> childRows = this.ViewTemplate.HierarchyDataProvider.GetChildRows((GridViewRowInfo)parent, this);

            for (int index = 0; index < childRows.Count; ++index)
            {
                childRows[index].ViewInfo = this;
                childRows[index].SetParent((GridViewRowInfo)parent);
            }
            if (sourceView == null || this.ViewTemplate.IsSelfReference)
            {
                Dictionary <string, bool> dictionary = new Dictionary <string, bool>();
                if (sourceView != null)
                {
                    for (int index = 0; index < sourceView.Groups.Count; ++index)
                    {
                        DataGroup group  = sourceView.Groups[index] as DataGroup;
                        string    header = group.Header;
                        if (string.IsNullOrEmpty(header))
                        {
                            header = index.ToString();
                        }
                        dictionary.Add(header, group.IsExpanded);
                    }
                }
                sourceView = (ICollectionView <GridViewRowInfo>) new SnapshotCollectionView <GridViewRowInfo>((IEnumerable <GridViewRowInfo>)childRows, this.ownerTemplate.DataView);
                if (this.ownerTemplate.GroupPredicate != null)
                {
                    ((SnapshotCollectionView <GridViewRowInfo>)sourceView).GroupPredicate = this.ownerTemplate.GroupPredicate;
                }
                for (int index = 0; index < sourceView.Groups.Count; ++index)
                {
                    DataGroup group  = sourceView.Groups[index] as DataGroup;
                    string    header = group.Header;
                    if (string.IsNullOrEmpty(header))
                    {
                        header = index.ToString();
                    }
                    if (dictionary.ContainsKey(header))
                    {
                        group.GroupRow.IsExpanded = dictionary[header];
                    }
                }
            }
            else
            {
                ((SnapshotCollectionView <GridViewRowInfo>)sourceView).Load((IEnumerable <GridViewRowInfo>)childRows);
            }
            return(sourceView);
        }
Ejemplo n.º 2
0
 public GridViewGroupRowInfo(GridViewInfo gridViewInfo, DataGroup dataGroup)
     : base(gridViewInfo)
 {
     this.topSummaryRowSource    = new List <GridViewSummaryRowInfo>();
     this.topSummaryRows         = new GridViewSummaryRowCollection((IList <GridViewSummaryRowInfo>) this.topSummaryRowSource);
     this.bottomSummaryRowSource = new List <GridViewSummaryRowInfo>();
     this.bottomSummaryRows      = new GridViewSummaryRowCollection((IList <GridViewSummaryRowInfo>) this.bottomSummaryRowSource);
     this.ownerGroup             = dataGroup;
     this.childRows = new GridViewChildRowCollection();
 }
 public GroupSummaryEvaluationEventArgs(
     object value,
     DataGroup group,
     string formatString,
     GridViewSummaryItem summaryItem,
     IHierarchicalRow parent,
     object context)
 {
     this.formatString = formatString;
     this.group        = group;
     this.value        = value;
     this.summaryItem  = summaryItem;
     this.parent       = parent;
     this.context      = context;
 }
Ejemplo n.º 4
0
        public Group <GridViewRowInfo> CreateGroup(
            object key,
            Group <GridViewRowInfo> parent,
            params object[] metaData)
        {
            DataGroup dataGroup = new DataGroup(key, parent, this.owner);
            GridViewCreateRowInfoEventArgs e = new GridViewCreateRowInfoEventArgs((GridViewRowInfo)dataGroup.GroupRow, this.owner.MasterViewInfo);

            this.owner.OnCreateRowInfo(e);
            GridViewGroupRowInfo rowInfo = e.RowInfo as GridViewGroupRowInfo;

            if (rowInfo != null && rowInfo != dataGroup.GroupRow)
            {
                rowInfo.ViewInfo   = this.owner.MasterViewInfo;
                dataGroup.GroupRow = rowInfo;
            }
            return((Group <GridViewRowInfo>)dataGroup);
        }
Ejemplo n.º 5
0
        protected override Group <GridViewRowInfo> GetGroup(
            GroupCollection <GridViewRowInfo> cache,
            Group <GridViewRowInfo> newGroup,
            Group <GridViewRowInfo> parent,
            object key,
            int level)
        {
            GroupDescriptor groupDescriptor = this.CollectionView.GroupDescriptors[level];
            DataGroup       group           = (DataGroup)base.GetGroup(cache, newGroup, parent, key, level);

            if (group.GroupDescriptor != null && group.GroupDescriptor != groupDescriptor)
            {
                group.GroupDescriptor = (GroupDescriptor)null;
                group = (DataGroup)this.CollectionView.GroupFactory.CreateGroup(key, parent);
                group.GroupBuilder = (GroupBuilder <GridViewRowInfo>) this;
            }
            group.GroupDescriptor = groupDescriptor;
            return((Group <GridViewRowInfo>)group);
        }
Ejemplo n.º 6
0
        internal DataGroup FindGroup(DataGroup dataGroup)
        {
            if (this.data.Groups.Count == 0)
            {
                return((DataGroup)null);
            }
            Stack <GroupCollection <GridViewRowInfo> > groupCollectionStack = new Stack <GroupCollection <GridViewRowInfo> >();

            groupCollectionStack.Push(this.data.Groups);
            while (groupCollectionStack.Count > 0)
            {
                GroupCollection <GridViewRowInfo> groupCollection = groupCollectionStack.Pop();
                int index = groupCollection.IndexOf((Group <GridViewRowInfo>)dataGroup);
                if (index >= 0)
                {
                    return(this.data.Groups[index] as DataGroup);
                }
                foreach (Group <GridViewRowInfo> group in (ReadOnlyCollection <Group <GridViewRowInfo> >)groupCollection)
                {
                    groupCollectionStack.Push(group.Groups);
                }
            }
            return((DataGroup)null);
        }
Ejemplo n.º 7
0
 public GroupExpandedEventArgs(DataGroup dataGroup, bool isExpanded)
 {
     this.dataGroup  = dataGroup;
     this.isExpanded = isExpanded;
 }
Ejemplo n.º 8
0
        public virtual string GetSummary(GridViewDataColumn column)
        {
            if (column.Index < 0)
            {
                return(string.Empty);
            }
            if (this.summaryValueVersion != this.ViewInfo.summaryValueVersion)
            {
                this.ClearCache();
                this.summaryValueVersion = this.ViewInfo.summaryValueVersion;
            }
            object obj1 = this.Cache[(GridViewColumn)column];

            if (obj1 != null)
            {
                return(obj1.ToString());
            }
            if (this.summaryRowItem == null)
            {
                return(string.Empty);
            }
            StringBuilder stringBuilder = new StringBuilder(16);

            foreach (GridViewSummaryItem summaryItem in (Collection <GridViewSummaryItem>) this.summaryRowItem)
            {
                if (summaryItem.Name == column.Name)
                {
                    DataGroup        group = (DataGroup)null;
                    object           obj2  = (object)null;
                    IHierarchicalRow parent;
                    if (this.groupRow != null)
                    {
                        obj2   = summaryItem.Evaluate((IHierarchicalRow)this.groupRow);
                        parent = (IHierarchicalRow)this.groupRow;
                        group  = this.groupRow.Group;
                    }
                    else if (this.hierarchyRow != null)
                    {
                        if (this.hierarchyRow.ActiveView.ChildRows.Count > 0)
                        {
                            obj2 = summaryItem.Evaluate((IHierarchicalRow)this.hierarchyRow);
                        }
                        parent = (IHierarchicalRow)this.hierarchyRow;
                    }
                    else
                    {
                        if (this.ViewTemplate.DataView.Count > 0)
                        {
                            obj2 = summaryItem.Evaluate((IHierarchicalRow)this.ViewTemplate);
                        }
                        parent = (IHierarchicalRow)this.ViewTemplate;
                    }
                    string formatString = summaryItem.FormatString;
                    object obj3         = obj2;
                    if (!this.suspendGroupSummaryEvaluateEvent)
                    {
                        this.suspendGroupSummaryEvaluateEvent = true;
                        GroupSummaryEvaluationEventArgs args = new GroupSummaryEvaluationEventArgs(obj2, group, summaryItem.FormatString, summaryItem, parent, (object)this);
                        this.ViewTemplate.EventDispatcher.RaiseEvent <GroupSummaryEvaluationEventArgs>(EventDispatcher.GroupSummaryEvaluate, (object)this.ViewTemplate, args);
                        formatString = args.FormatString;
                        obj3         = args.Value;
                        this.suspendGroupSummaryEvaluateEvent = false;
                    }
                    if (obj2 != null)
                    {
                        stringBuilder.Append(string.Format(formatString, obj3));
                    }
                }
            }
            string str = stringBuilder.ToString();

            this.Cache[(GridViewColumn)column] = (object)str;
            return(str);
        }
Ejemplo n.º 9
0
 public bool MoveNext()
 {
     if (this.groups == null || this.groups.Count == 0)
     {
         return(false);
     }
     if (this.currentTraverser == null)
     {
         this.currentTraverser = new Stack <GroupRowTraverser>();
         this.currentTraverser.Push(new GroupRowTraverser(((DataGroup)this.groups[0]).GroupRow));
         this.parentGroup = new Stack <DataGroup>();
         this.parentGroup.Push((DataGroup)null);
         this.currentGroupIndex = new Stack <int>();
         this.currentGroupIndex.Push(0);
         this.isOnGroupRow = true;
         return(true);
     }
     if (this.parentGroup.Peek() == null && this.groups[this.currentGroupIndex.Peek()].Groups.Count > 0)
     {
         DataGroup group = (DataGroup)this.groups[this.currentGroupIndex.Peek()];
         this.parentGroup.Push(group);
         this.currentGroupIndex.Push(0);
         this.currentTraverser.Push(new GroupRowTraverser(group.GroupRow));
         this.isOnGroupRow = true;
         return(true);
     }
     if (this.parentGroup.Peek() != null && this.parentGroup.Peek().Groups.Count > 0)
     {
         DataGroup group = this.parentGroup.Peek().Groups[this.currentGroupIndex.Peek()];
         this.parentGroup.Push(group);
         this.currentGroupIndex.Push(0);
         this.currentTraverser.Push(new GroupRowTraverser(group.GroupRow));
         this.isOnGroupRow = true;
         return(true);
     }
     if (this.parentGroup.Peek() == null && this.currentGroupIndex.Peek() < this.groups.Count && this.currentGroupIndex.Peek() > 0)
     {
         DataGroup group = (DataGroup)this.groups[this.currentGroupIndex.Peek()];
         this.parentGroup.Push(group);
         this.currentGroupIndex.Push(0);
         this.currentTraverser.Push(new GroupRowTraverser(group.GroupRow));
         this.isOnGroupRow = true;
         return(true);
     }
     if (this.currentTraverser.Peek().MoveNext())
     {
         this.isOnGroupRow = false;
         return(true);
     }
     if (this.parentGroup.Peek() != null)
     {
         this.parentGroup.Pop();
         this.currentTraverser.Pop();
         this.currentGroupIndex.Pop();
     }
     this.currentGroupIndex.Push(this.currentGroupIndex.Pop() + 1);
     for (int index = this.parentGroup.Peek() == null ? this.groups.Count : this.parentGroup.Peek().Groups.Count; this.currentGroupIndex.Count > 0 && this.currentGroupIndex.Peek() >= index; index = this.parentGroup.Peek() == null ? this.groups.Count : this.parentGroup.Peek().Groups.Count)
     {
         this.parentGroup.Pop();
         this.currentTraverser.Pop();
         this.currentGroupIndex.Pop();
         if (this.currentGroupIndex.Count != 0)
         {
             this.currentGroupIndex.Push(this.currentGroupIndex.Pop() + 1);
         }
         else
         {
             break;
         }
     }
     if (this.parentGroup.Count > 0)
     {
         if (this.parentGroup.Peek() == null && (this.groups[this.currentGroupIndex.Peek()].Groups.Count > 0 || this.currentGroupIndex.Peek() < this.groups.Count))
         {
             DataGroup group = (DataGroup)this.groups[this.currentGroupIndex.Peek()];
             this.parentGroup.Push(group);
             this.currentGroupIndex.Push(0);
             this.currentTraverser.Push(new GroupRowTraverser(group.GroupRow));
             this.isOnGroupRow = true;
             return(true);
         }
         if (this.parentGroup.Peek() != null && this.parentGroup.Peek().Groups.Count > 0)
         {
             DataGroup group = this.parentGroup.Peek().Groups[this.currentGroupIndex.Peek()];
             this.parentGroup.Push(group);
             this.currentGroupIndex.Push(0);
             this.currentTraverser.Push(new GroupRowTraverser(group.GroupRow));
             this.isOnGroupRow = true;
             return(true);
         }
     }
     return(false);
 }