2015-07-25 15:10:59 -07:00
|
|
|
|
using System;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using xServer.Core.Helper;
|
|
|
|
|
using xServer.Core.Utilities;
|
2014-07-08 05:58:53 -07:00
|
|
|
|
|
2015-01-13 10:29:11 -08:00
|
|
|
|
namespace xServer.Controls
|
2014-07-08 05:58:53 -07:00
|
|
|
|
{
|
2015-07-25 15:10:59 -07:00
|
|
|
|
internal class AeroListView : ListView
|
2014-07-08 05:58:53 -07:00
|
|
|
|
{
|
2015-07-25 15:10:59 -07:00
|
|
|
|
private const uint WM_CHANGEUISTATE = 0x127;
|
|
|
|
|
|
|
|
|
|
private const int UIS_SET = 1;
|
|
|
|
|
private const int UISF_HIDEFOCUS = 0x1;
|
|
|
|
|
|
2015-09-03 12:44:57 -07:00
|
|
|
|
private ListViewColumnSorter LvwColumnSorter { get; set; }
|
|
|
|
|
|
2015-07-25 15:10:59 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Initializes a new instance of the <see cref="AeroListView"/> class.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public AeroListView()
|
|
|
|
|
: base()
|
2014-07-08 05:58:53 -07:00
|
|
|
|
{
|
2015-05-29 23:47:19 -07:00
|
|
|
|
SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);
|
2015-09-03 12:44:57 -07:00
|
|
|
|
this.LvwColumnSorter = new ListViewColumnSorter();
|
|
|
|
|
this.ListViewItemSorter = LvwColumnSorter;
|
2015-07-25 15:10:59 -07:00
|
|
|
|
this.View = View.Details;
|
|
|
|
|
this.FullRowSelect = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Raises the <see cref="E:HandleCreated" /> event.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
|
|
|
|
protected override void OnHandleCreated(EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnHandleCreated(e);
|
|
|
|
|
|
2015-07-27 04:20:39 -07:00
|
|
|
|
if (PlatformHelper.RunningOnMono) return;
|
|
|
|
|
|
|
|
|
|
if (PlatformHelper.VistaOrHigher)
|
2015-07-25 15:10:59 -07:00
|
|
|
|
{
|
2015-07-27 04:20:39 -07:00
|
|
|
|
// set window theme to explorer
|
2015-07-25 15:10:59 -07:00
|
|
|
|
NativeMethods.SetWindowTheme(this.Handle, "explorer", null);
|
2015-07-27 04:20:39 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (PlatformHelper.XpOrHigher)
|
|
|
|
|
{
|
|
|
|
|
// removes the ugly dotted line around focused item
|
|
|
|
|
NativeMethods.SendMessage(this.Handle, WM_CHANGEUISTATE,
|
|
|
|
|
NativeMethodsHelper.MakeLong(UIS_SET, UISF_HIDEFOCUS), 0);
|
2015-07-25 15:10:59 -07:00
|
|
|
|
}
|
2014-07-08 05:58:53 -07:00
|
|
|
|
}
|
2015-09-03 12:44:57 -07:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Raises the <see cref="E:ColumnClick" /> event.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="e">The <see cref="ColumnClickEventArgs"/> instance containing the event data.</param>
|
|
|
|
|
protected override void OnColumnClick(ColumnClickEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnColumnClick(e);
|
|
|
|
|
|
|
|
|
|
// Determine if clicked column is already the column that is being sorted.
|
|
|
|
|
if (e.Column == this.LvwColumnSorter.SortColumn)
|
|
|
|
|
{
|
|
|
|
|
// Reverse the current sort direction for this column.
|
|
|
|
|
this.LvwColumnSorter.Order = (this.LvwColumnSorter.Order == SortOrder.Ascending)
|
|
|
|
|
? SortOrder.Descending
|
|
|
|
|
: SortOrder.Ascending;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Set the column number that is to be sorted; default to ascending.
|
|
|
|
|
this.LvwColumnSorter.SortColumn = e.Column;
|
|
|
|
|
this.LvwColumnSorter.Order = SortOrder.Ascending;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Perform the sort with these new sort options.
|
|
|
|
|
this.Sort();
|
|
|
|
|
}
|
2014-07-08 05:58:53 -07:00
|
|
|
|
}
|
2015-04-21 11:27:52 -07:00
|
|
|
|
}
|