/// <summary>
        /// Create a OlvListViewHitTestInfo
        /// </summary>
        public OlvListViewHitTestInfo(OLVListItem olvListItem, OLVListSubItem subItem, int flags, OLVGroup group, int iColumn)
        {
            item              = olvListItem;
            this.subItem      = subItem;
            location          = ConvertNativeFlagsToDotNetLocation(olvListItem, flags);
            HitTestLocationEx = (HitTestLocationEx)flags;
            Group             = group;
            ColumnIndex       = iColumn;
            ListView          = olvListItem == null ? null : (AdvancedListView)olvListItem.ListView;

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

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

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

            default:
                if ((HitTestLocationEx & HitTestLocationEx.LVHT_EX_GROUP_COLLAPSE) == HitTestLocationEx.LVHT_EX_GROUP_COLLAPSE)
                {
                    HitTestLocation = HitTestLocation.GroupExpander;
                }
                else if ((HitTestLocationEx & HitTestLocationEx.LVHT_EX_GROUP_MINUS_FOOTER_AND_BKGRD) != 0)
                {
                    HitTestLocation = HitTestLocation.Group;
                }
                else
                {
                    HitTestLocation = HitTestLocation.Nothing;
                }

                break;
            }
        }
示例#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));
 }
示例#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]);
 }
示例#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 FluentListView.MakeGroups()
            // Any changes made here may need to be reflected there

            // This strategy can only be used on FastFluentListViews
            FastListView folv = (FastListView)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);
        }
示例#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);
 }
示例#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);
 }