A FastObjectListView trades function for speed.

On my mid-range laptop, this view builds a list of 10,000 objects in 0.1 seconds, as opposed to a normal ObjectListView which takes 10-15 seconds. Lists of up to 50,000 items should be able to be handled with sub-second response times even on low end machines.

A FastObjectListView is implemented as a virtual list with many of the virtual modes limits (e.g. no sorting) fixed through coding. There are some functions that simply cannot be provided. Specifically, a FastObjectListView cannot: use Tile view show groups on XP

Наследование: VirtualObjectListView
Пример #1
0
        /// <summary>
        /// Apply thememanager theme to the treeview
        /// </summary>
        public static void StyleIt(FastObjectListView fastOlv, string emptyListString)
        {
            // Style the control
            fastOlv.OwnerDraw = true;
            fastOlv.Font = FontManager.GetFont(FontFunction.AutoCompletion);

            fastOlv.BackColor = ThemeManager.Current.MenuNormalBack;
            fastOlv.AlternateRowBackColor = ThemeManager.Current.MenuNormalAltBack;
            fastOlv.ForeColor = ThemeManager.Current.MenuNormalFore;

            fastOlv.HighlightBackgroundColor = ThemeManager.Current.MenuFocusedBack;
            fastOlv.HighlightForegroundColor = ThemeManager.Current.MenuFocusedFore;

            fastOlv.UnfocusedHighlightBackgroundColor = ThemeManager.Current.MenuFocusedBack;
            fastOlv.UnfocusedHighlightForegroundColor = ThemeManager.Current.MenuFocusedFore;

            // Decorate and configure hot item
            fastOlv.UseHotItem = true;
            fastOlv.HotItemStyle = new HotItemStyle {
                BackColor = ThemeManager.Current.MenuHoverBack,
                ForeColor = ThemeManager.Current.MenuHoverFore
            };

            // overlay of empty list :
            fastOlv.EmptyListMsg = emptyListString;
            TextOverlay textOverlay = fastOlv.EmptyListMsgOverlay as TextOverlay;
            if (textOverlay != null) {
                textOverlay.TextColor = ThemeManager.Current.ButtonNormalFore;
                textOverlay.BackColor = ThemeManager.Current.ButtonNormalBack;
                textOverlay.BorderColor = ThemeManager.Current.ButtonNormalBorder;
                textOverlay.BorderWidth = 4.0f;
                textOverlay.Font = FontManager.GetFont(FontStyle.Bold, 30f);
                textOverlay.Rotation = -5;
            }

            fastOlv.UseAlternatingBackColors = Config.Instance.GlobalUseAlternateBackColorOnGrid;
        }
 /// <summary>
 /// Create a FastObjectListDataSource
 /// </summary>
 /// <param name="listView"></param>
 public FastObjectListDataSource(FastObjectListView listView)
     : base(listView)
 {
 }
 public FastObjectListDataSource(FastObjectListView listView)
     : base(listView)
 {
 }
        public override IList <OLVGroup> GetGroups(GroupingParameters parms)
        {
            Converter <object, int> converter = null;
            FastObjectListView      folv      = (FastObjectListView)parms.ListView;
            int capacity = 0;
            NullableDictionary <object, List <object> > dictionary = new NullableDictionary <object, List <object> >();

            foreach (object obj2 in folv.Objects)
            {
                object groupKey = parms.GroupByColumn.GetGroupKey(obj2);
                if (!dictionary.ContainsKey(groupKey))
                {
                    dictionary[groupKey] = new List <object>();
                }
                dictionary[groupKey].Add(obj2);
                capacity++;
            }
            OLVColumn           col      = parms.SortItemsByPrimaryColumn ? parms.ListView.GetColumn(0) : parms.PrimarySort;
            ModelObjectComparer comparer = new ModelObjectComparer(col, parms.PrimarySortOrder, parms.SecondarySort, parms.SecondarySortOrder);

            foreach (object obj3 in dictionary.Keys)
            {
                dictionary[obj3].Sort(comparer);
            }
            List <OLVGroup> list = new List <OLVGroup>();

            foreach (object obj3 in dictionary.Keys)
            {
                string str = parms.GroupByColumn.ConvertGroupKeyToTitle(obj3);
                if (!string.IsNullOrEmpty(parms.TitleFormat))
                {
                    int count = dictionary[obj3].Count;
                    str = string.Format((count == 1) ? parms.TitleSingularFormat : parms.TitleFormat, str, count);
                }
                OLVGroup group = new OLVGroup(str)
                {
                    Key       = obj3,
                    SortValue = obj3 as IComparable
                };
                if (converter == null)
                {
                    converter = x => folv.IndexOf(x);
                }
                group.Contents         = dictionary[obj3].ConvertAll <int>(converter);
                group.VirtualItemCount = dictionary[obj3].Count;
                if (parms.GroupByColumn.GroupFormatter != null)
                {
                    parms.GroupByColumn.GroupFormatter(group, parms);
                }
                list.Add(group);
            }
            list.Sort(new OLVGroupComparer(parms.PrimarySortOrder));
            this.indexToGroupMap = new List <int>(capacity);
            this.indexToGroupMap.AddRange(new int[capacity]);
            for (int i = 0; i < list.Count; i++)
            {
                OLVGroup   group2   = list[i];
                List <int> contents = (List <int>)group2.Contents;
                foreach (int num4 in contents)
                {
                    this.indexToGroupMap[num4] = i;
                }
            }
            return(list);
        }
Пример #5
0
 protected CList(FastObjectListView listView, Type type)
 {
     ListView = listView;
     PropInfo = type.GetProperties();
     Scripts = new List<DatabaseClass>();
 }
Пример #6
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);
        }
Пример #7
0
        /// <summary>
        /// Resizes the event list's columns
        /// </summary>
        public static void ResizeEventListColumns(FastObjectListView list, bool hasSignatureColumn)
        {
            if (list.Items.Count == 0)
            {
                list.BeginUpdate();
                foreach (ColumnHeader column in list.Columns)
                {
                    column.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize);
                }
                list.EndUpdate();
            }
            else
            {
                list.BeginUpdate();
                list.Columns[(int)Global.FieldsEvent.SrcIp].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
                list.Columns[(int)Global.FieldsEvent.SrcPort].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
                list.Columns[(int)Global.FieldsEvent.DstIp].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
                list.Columns[(int)Global.FieldsEvent.DstPort].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
                list.Columns[(int)Global.FieldsEvent.Host].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
                list.Columns[(int)Global.FieldsEvent.Protocol].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
                list.Columns[(int)Global.FieldsEvent.Timestamp].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
                list.Columns[(int)Global.FieldsEvent.Classification].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
                list.Columns[(int)Global.FieldsEvent.Initials].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);

                if (hasSignatureColumn == true)
                {
                    list.Columns[(int)Global.FieldsEvent.Payload].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
                }

                list.EndUpdate();
            }
        }
Пример #8
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="field"></param>
        public static string CopyDataToClipboard(UserControl uc, FastObjectListView list, Global.FieldsEventCopy field)
        {
            if (list.SelectedObjects.Count != 1)
            {
                return string.Empty;
            }

            Event temp = (Event)list.SelectedObjects[0];
            if (temp == null)
            {
                UserInterface.DisplayErrorMessageBox(uc, "Unable to locate event");
                return string.Empty;
            }

            string value = string.Empty;
            switch (field)
            {
                case Global.FieldsEventCopy.SrcIp:
                    value = temp.IpSrcTxt.ToString();
                    break;
                case Global.FieldsEventCopy.SrcPort:
                    value = temp.SrcPort.ToString();
                    break;
                case Global.FieldsEventCopy.DstIp:
                    value = temp.IpDstTxt.ToString();
                    break;
                case Global.FieldsEventCopy.DstPort:
                    value = temp.DstPort.ToString();
                    break;
                case Global.FieldsEventCopy.HttpHost:
                    value = temp.HttpHost.ToString();
                    break;
                case Global.FieldsEventCopy.PayloadAscii:
                    value = temp.PayloadAscii.ToString();
                    break;
                case Global.FieldsEventCopy.Sid:
                    value = temp.SigSid.ToString();
                    break;
                case Global.FieldsEventCopy.SigName:
                    value = temp.SigName.ToString();
                    break;
                case Global.FieldsEventCopy.Cid:
                    value = temp.Cid.ToString();
                    break;
                case Global.FieldsEventCopy.Timestamp:
                    value = temp.Timestamp.ToString();
                    break;
            }

            Clipboard.SetText(value);

            if (field != Global.FieldsEventCopy.PayloadAscii)
            {
                //UpdateStatusBar("\"" + value + "\" copied to the clipboard");
            }
            else
            {
                //UpdateStatusBar("Payload (ASCII) copied to the clipboard");
            }

            return string.Empty;
        }
Пример #9
0
 public SmartScriptList(FastObjectListView listView)
     : base(listView, typeof(SmartScript))
 {
     _oListView = listView;
     _oListView.FormatRow += oListView_FormatRow;
 }
 public FastObjectListDataSource(FastObjectListView listView) : base(listView)
 {
     this.objectList        = new ArrayList();
     this.objectsToIndexMap = new Dictionary <object, int>();
 }
Пример #11
0
        public override IList <OLVGroup> GetGroups(GroupingParameters parms)
        {
            // This strategy can only be used on FastObjectListViews
            FastObjectListView folv = (FastObjectListView)parms.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.Objects)
            {
                object key = parms.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 = parms.SortItemsByPrimaryColumn ? parms.ListView.GetColumn(0) : parms.PrimarySort;
            ModelObjectComparer sorter            = new ModelObjectComparer(primarySortColumn, parms.PrimarySortOrder,
                                                                            parms.SecondarySort, parms.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 = parms.GroupByColumn.ConvertGroupKeyToTitle(key);
                if (!String.IsNullOrEmpty(parms.TitleFormat))
                {
                    int count = map[key].Count;
                    title = String.Format((count == 1 ? parms.TitleSingularFormat : parms.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 (parms.GroupByColumn.GroupFormatter != null)
                {
                    parms.GroupByColumn.GroupFormatter(lvg, parms);
                }
                groups.Add(lvg);
            }

            // Sort the groups
            groups.Sort(new OLVGroupComparer(parms.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);
        }