Ejemplo n.º 1
0
        /// <summary>
        /// Create a OlvListViewHitTestInfo
        /// </summary>
        public OlvListViewHitTestInfo(OLVListItem olvListItem, OLVListSubItem subItem, int flags, OLVGroup group)
        {
            this.item              = olvListItem;
            this.subItem           = subItem;
            this.location          = ConvertNativeFlagsToDotNetLocation(olvListItem, flags);
            this.HitTestLocationEx = (HitTestLocationEx)flags;
            this.Group             = group;

            switch (location)
            {
            case ListViewHitTestLocations.StateImage:
                this.HitTestLocation = HitTestLocation.CheckBox;
                break;

            case ListViewHitTestLocations.Image:
                this.HitTestLocation = HitTestLocation.Image;
                break;

            case ListViewHitTestLocations.Label:
                this.HitTestLocation = HitTestLocation.Text;
                break;

            default:
                if ((this.HitTestLocationEx & HitTestLocationEx.LVHT_EX_GROUP_COLLAPSE) == HitTestLocationEx.LVHT_EX_GROUP_COLLAPSE)
                {
                    this.HitTestLocation = HitTestLocation.GroupExpander;
                }
                else if ((this.HitTestLocationEx & HitTestLocationEx.LVHT_EX_GROUP_MINUS_FOOTER_AND_BKGRD) != 0)
                {
                    this.HitTestLocation = HitTestLocation.Group;
                }
                else
                {
                    this.HitTestLocation = HitTestLocation.Nothing;
                }
                break;
            }
        }
Ejemplo n.º 2
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));
 }
Ejemplo n.º 3
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]);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Create groups for FastListView
        /// </summary>
        /// <param name="parmameters"></param>
        /// <returns></returns>
        public override IList <OLVGroup> GetGroups(GroupingParameters parmameters)
        {
            // There is a lot of overlap between this method and ObjectListView.MakeGroups()
            // Any changes made here may need to be reflected there

            // 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
            // TODO: Give parameters a ModelComparer property
            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;
                    string format = (count == 1 ? parmameters.TitleSingularFormat : parmameters.TitleFormat);
                    try {
                        title = String.Format(format, title, count);
                    } catch (FormatException) {
                        title = "Invalid group format: " + format;
                    }
                }
                OLVGroup lvg = new OLVGroup(title);
                lvg.Collapsible      = folv.HasCollapsibleGroups;
                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
            if (parmameters.GroupByOrder != SortOrder.None)
            {
                groups.Sort(parmameters.GroupComparer ?? new OLVGroupComparer(parmameters.GroupByOrder));
            }

            // 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);
        }
Ejemplo n.º 5
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);
 }
Ejemplo n.º 6
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);
 }