using Pulsar.Common.Helpers; using Pulsar.Server.Helper; using Pulsar.Server.Utilities; using System; using System.Windows.Forms; namespace Pulsar.Server.Extensions { public static class ListViewExtensions { private const uint SET_COLUMN_WIDTH = 4126; private static readonly IntPtr AUTOSIZE_USEHEADER = new IntPtr(-2); /// /// Automatically determines the correct column size on the the given listview. /// /// The listview whose columns are to be autosized. public static void AutosizeColumns(this ListView targetListView) { for (int lngColumn = 0; lngColumn <= (targetListView.Columns.Count - 1); lngColumn++) { NativeMethods.SendMessage(targetListView.Handle, SET_COLUMN_WIDTH, new IntPtr(lngColumn), AUTOSIZE_USEHEADER); } } /// /// Selects all items on the given listview. /// /// The listview whose items are to be selected. public static void SelectAllItems(this ListView targetListView) { NativeMethodsHelper.SetItemState(targetListView.Handle, -1, 2, 2); } } }