Beispiel #1
0
		/// <summary>
		/// Return the index at which the given item is shown in the given group
		/// </summary>
		/// <param name="group"></param>
		/// <param name="itemIndex"></param>
		/// <returns></returns>
		public virtual int GetIndexWithinGroup(OLVGroup group, int itemIndex) {
			return -1;
		}
Beispiel #2
0
		/// <summary>
		/// Create a GroupTaskClickedEventArgs
		/// </summary>
		/// <param name="group"></param>
		public GroupTaskClickedEventArgs(OLVGroup group) {
			this.group = group;
		}
Beispiel #3
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="group"></param>
		/// <param name="itemIndex"></param>
		/// <returns></returns>
		public override int GetIndexWithinGroup(OLVGroup group, int itemIndex) {
			return group.Contents.IndexOf(itemIndex);
		}
Beispiel #4
0
		/// <summary>
		/// Return the index of the item that appears at the given position within the given group.
		/// </summary>
		/// <param name="group"></param>
		/// <param name="indexWithinGroup"></param>
		/// <returns></returns>
		public virtual int GetGroupMember(OLVGroup group, int indexWithinGroup) {
			return -1;
		}
Beispiel #5
0
		/// <summary>
		/// Create groups for FastListView
		/// </summary>
		/// <param name="parmameters"></param>
		/// <returns></returns>
		public override IList<OLVGroup> GetGroups(GroupingParameters parmameters) {
			// This strategy can only be used on FastObjectListViews
			FastObjectListView folv = (FastObjectListView)parmameters.ListView;

			// Separate the list view items into groups, using the group key as the descrimanent
			int objectCount = 0;
			NullableDictionary<object, List<object>> map = new NullableDictionary<object, List<object>>();
			foreach (object model in folv.FilteredObjects) {
				object key = parmameters.GroupByColumn.GetGroupKey(model);
				if (!map.ContainsKey(key))
					map[key] = new List<object>();
				map[key].Add(model);
				objectCount++;
			}

			// Sort the items within each group
			OLVColumn primarySortColumn = parmameters.SortItemsByPrimaryColumn ? parmameters.ListView.GetColumn(0) : parmameters.PrimarySort;
			ModelObjectComparer sorter = new ModelObjectComparer(primarySortColumn, parmameters.PrimarySortOrder,
				parmameters.SecondarySort, parmameters.SecondarySortOrder);
			foreach (object key in map.Keys) {
				map[key].Sort(sorter);
			}

			// Make a list of the required groups
			List<OLVGroup> groups = new List<OLVGroup>();
			foreach (object key in map.Keys) {
				string title = parmameters.GroupByColumn.ConvertGroupKeyToTitle(key);
				if (!String.IsNullOrEmpty(parmameters.TitleFormat)) {
					int count = map[key].Count;
					title = String.Format((count == 1 ? parmameters.TitleSingularFormat : parmameters.TitleFormat), title, count);
				}
				OLVGroup lvg = new OLVGroup(title);
				lvg.Key = key;
				lvg.SortValue = key as IComparable;
				lvg.Contents = map[key].ConvertAll<int>(delegate(object x) { return folv.IndexOf(x); });
				lvg.VirtualItemCount = map[key].Count;
				if (parmameters.GroupByColumn.GroupFormatter != null)
					parmameters.GroupByColumn.GroupFormatter(lvg, parmameters);
				groups.Add(lvg);
			}

			// Sort the groups
			groups.Sort(new OLVGroupComparer(parmameters.PrimarySortOrder));

			// Build an array that remembers which group each item belongs to.
			this.indexToGroupMap = new List<int>(objectCount);
			this.indexToGroupMap.AddRange(new int[objectCount]);

			for (int i = 0; i < groups.Count; i++) {
				OLVGroup group = groups[i];
				List<int> members = (List<int>)group.Contents;
				foreach (int j in members)
					this.indexToGroupMap[j] = i;
			}

			return groups;
		}
Beispiel #6
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="group"></param>
		/// <param name="indexWithinGroup"></param>
		/// <returns></returns>
		public override int GetGroupMember(OLVGroup group, int indexWithinGroup) {
			return (int)group.Contents[indexWithinGroup];
		}
Beispiel #7
0
 /// <summary>
 /// Return the index at which the given item is shown in the given group
 /// </summary>
 /// <param name="group"></param>
 /// <param name="itemIndex"></param>
 /// <returns></returns>
 public virtual int GetIndexWithinGroup(OLVGroup group, int itemIndex)
 {
     return(-1);
 }
Beispiel #8
0
 /// <summary>
 /// Return the index of the item that appears at the given position within the given group.
 /// </summary>
 /// <param name="group"></param>
 /// <param name="indexWithinGroup"></param>
 /// <returns></returns>
 public virtual int GetGroupMember(OLVGroup group, int indexWithinGroup)
 {
     return(-1);
 }
Beispiel #9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="group"></param>
 /// <param name="itemIndex"></param>
 /// <returns></returns>
 public override int GetIndexWithinGroup(OLVGroup group, int itemIndex)
 {
     return(group.Contents.IndexOf(itemIndex));
 }
Beispiel #10
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="group"></param>
 /// <param name="indexWithinGroup"></param>
 /// <returns></returns>
 public override int GetGroupMember(OLVGroup group, int indexWithinGroup)
 {
     return((int)group.Contents[indexWithinGroup]);
 }
Beispiel #11
0
        /// <summary>
        /// Create groups for FastListView
        /// </summary>
        /// <param name="parmameters"></param>
        /// <returns></returns>
        public override IList <OLVGroup> GetGroups(GroupingParameters parmameters)
        {
            // This strategy can only be used on FastObjectListViews
            FastObjectListView folv = (FastObjectListView)parmameters.ListView;

            // Separate the list view items into groups, using the group key as the descrimanent
            int objectCount = 0;
            NullableDictionary <object, List <object> > map = new NullableDictionary <object, List <object> >();

            foreach (object model in folv.FilteredObjects)
            {
                object key = parmameters.GroupByColumn.GetGroupKey(model);
                if (!map.ContainsKey(key))
                {
                    map[key] = new List <object>();
                }
                map[key].Add(model);
                objectCount++;
            }

            // Sort the items within each group
            OLVColumn           primarySortColumn = parmameters.SortItemsByPrimaryColumn ? parmameters.ListView.GetColumn(0) : parmameters.PrimarySort;
            ModelObjectComparer sorter            = new ModelObjectComparer(primarySortColumn, parmameters.PrimarySortOrder,
                                                                            parmameters.SecondarySort, parmameters.SecondarySortOrder);

            foreach (object key in map.Keys)
            {
                map[key].Sort(sorter);
            }

            // Make a list of the required groups
            List <OLVGroup> groups = new List <OLVGroup>();

            foreach (object key in map.Keys)
            {
                string title = parmameters.GroupByColumn.ConvertGroupKeyToTitle(key);
                if (!String.IsNullOrEmpty(parmameters.TitleFormat))
                {
                    int count = map[key].Count;
                    title = String.Format((count == 1 ? parmameters.TitleSingularFormat : parmameters.TitleFormat), title, count);
                }
                OLVGroup lvg = new OLVGroup(title);
                lvg.Key              = key;
                lvg.SortValue        = key as IComparable;
                lvg.Contents         = map[key].ConvertAll <int>(delegate(object x) { return(folv.IndexOf(x)); });
                lvg.VirtualItemCount = map[key].Count;
                if (parmameters.GroupByColumn.GroupFormatter != null)
                {
                    parmameters.GroupByColumn.GroupFormatter(lvg, parmameters);
                }
                groups.Add(lvg);
            }

            // Sort the groups
            groups.Sort(new OLVGroupComparer(parmameters.PrimarySortOrder));

            // Build an array that remembers which group each item belongs to.
            this.indexToGroupMap = new List <int>(objectCount);
            this.indexToGroupMap.AddRange(new int[objectCount]);

            for (int i = 0; i < groups.Count; i++)
            {
                OLVGroup   group   = groups[i];
                List <int> members = (List <int>)group.Contents;
                foreach (int j in members)
                {
                    this.indexToGroupMap[j] = i;
                }
            }

            return(groups);
        }