243 lines
7.7 KiB
C#
243 lines
7.7 KiB
C#
// Decompiled with JetBrains decompiler
|
|
// Type: RatonAccessTool.Controls.AeroListView
|
|
// Assembly: Raton, Version=0.4.0.0, Culture=neutral, PublicKeyToken=null
|
|
// MVID: 36C4E416-7F8D-4D23-930F-B5CCB0D810E7
|
|
// Assembly location: C:\Users\user\Desktop\v3.8.0 Deluxe Plugins (v4.0.0) cracked\Raton.exe
|
|
|
|
using System;
|
|
using System.Collections;
|
|
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.Runtime.InteropServices;
|
|
using System.Windows.Forms;
|
|
|
|
#nullable disable
|
|
namespace RatonAccessTool.Controls;
|
|
|
|
public class AeroListView : ListView
|
|
{
|
|
private const int WM_CHANGEUISTATE = 295;
|
|
private const short UIS_SET = 1;
|
|
private const short UISF_HIDEFOCUS = 1;
|
|
private readonly IntPtr _removeDots = new IntPtr(AeroListView.MakeWin32Long((short) 1, (short) 1));
|
|
private const int WM_VSCROLL = 277;
|
|
private const int SB_BOTTOM = 7;
|
|
private const int SB_TOP = 6;
|
|
private const int WS_VSCROLL = 2097152 /*0x200000*/;
|
|
private const int WS_HSCROLL = 1048576 /*0x100000*/;
|
|
private const int WM_PAINT = 15;
|
|
private const int LVM_GETHEADER = 4127;
|
|
private int _backgroundOpacity = (int) byte.MaxValue;
|
|
|
|
public Color VerticalLineColor { get; set; } = Color.FromArgb(80 /*0x50*/, 80 /*0x50*/, 80 /*0x50*/);
|
|
|
|
[Category("Appearance")]
|
|
[DefaultValue(255 /*0xFF*/)]
|
|
public int BackgroundOpacity
|
|
{
|
|
get => this._backgroundOpacity;
|
|
set
|
|
{
|
|
this._backgroundOpacity = Math.Max(0, Math.Min((int) byte.MaxValue, value));
|
|
this.Invalidate();
|
|
}
|
|
}
|
|
|
|
public AeroListView.ListViewColumnSorter LvwColumnSorter { get; set; }
|
|
|
|
public AeroListView()
|
|
{
|
|
this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer, true);
|
|
this.LvwColumnSorter = new AeroListView.ListViewColumnSorter();
|
|
this.ListViewItemSorter = (IComparer) this.LvwColumnSorter;
|
|
this.View = View.Details;
|
|
this.FullRowSelect = true;
|
|
this.GridLines = false;
|
|
this.Resize += new EventHandler(this.AeroListView_Resize);
|
|
}
|
|
|
|
protected override CreateParams CreateParams
|
|
{
|
|
get
|
|
{
|
|
CreateParams createParams = base.CreateParams;
|
|
createParams.Style |= 3145728 /*0x300000*/;
|
|
return createParams;
|
|
}
|
|
}
|
|
|
|
protected override void OnHandleCreated(EventArgs e)
|
|
{
|
|
base.OnHandleCreated(e);
|
|
if (AeroListView.PlatformHelper.RunningOnMono)
|
|
return;
|
|
if (AeroListView.PlatformHelper.VistaOrHigher)
|
|
AeroListView.NativeMethods.SetWindowTheme(this.Handle, "DarkMode_Explorer", (string) null);
|
|
if (AeroListView.PlatformHelper.XpOrHigher)
|
|
AeroListView.NativeMethods.SendMessage(this.Handle, 295, this._removeDots, IntPtr.Zero);
|
|
this.BeginInvoke((Delegate) (() => this.RefreshScrollBars()));
|
|
}
|
|
|
|
protected override void OnResize(EventArgs e)
|
|
{
|
|
base.OnResize(e);
|
|
this.RefreshScrollBars();
|
|
}
|
|
|
|
protected override void WndProc(ref Message m)
|
|
{
|
|
base.WndProc(ref m);
|
|
if (m.Msg != 15 || this.View != View.Details || this.Columns.Count <= 0)
|
|
return;
|
|
this.DrawVerticalLines();
|
|
}
|
|
|
|
private void DrawVerticalLines()
|
|
{
|
|
using (Graphics graphics = Graphics.FromHwnd(this.Handle))
|
|
{
|
|
using (Pen pen = new Pen(this.VerticalLineColor))
|
|
{
|
|
int headerHeight = this.GetHeaderHeight();
|
|
int height = this.ClientSize.Height;
|
|
int num = 0;
|
|
for (int index = 0; index < this.Columns.Count - 1; ++index)
|
|
{
|
|
num += this.Columns[index].Width;
|
|
graphics.DrawLine(pen, num - 1, headerHeight, num - 1, height);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private int GetHeaderHeight()
|
|
{
|
|
IntPtr hwnd = AeroListView.NativeMethods.SendMessage(this.Handle, 4127, IntPtr.Zero, IntPtr.Zero);
|
|
if (!(hwnd != IntPtr.Zero))
|
|
return 24;
|
|
AeroListView.RECT lpRect;
|
|
AeroListView.NativeMethods.GetWindowRect(hwnd, out lpRect);
|
|
return lpRect.Bottom - lpRect.Top;
|
|
}
|
|
|
|
private void AeroListView_Resize(object sender, EventArgs e)
|
|
{
|
|
if (this.Columns.Count == 0)
|
|
return;
|
|
int num1 = 0;
|
|
for (int index = 0; index < this.Columns.Count - 1; ++index)
|
|
num1 += this.Columns[index].Width;
|
|
int num2 = this.ClientSize.Width - num1;
|
|
if (num2 <= 0)
|
|
return;
|
|
this.Columns[this.Columns.Count - 1].Width = num2;
|
|
}
|
|
|
|
public void RefreshScrollBars()
|
|
{
|
|
if (!this.IsHandleCreated || AeroListView.PlatformHelper.RunningOnMono)
|
|
return;
|
|
AeroListView.NativeMethods.SendMessage(this.Handle, 277, (IntPtr) 7, IntPtr.Zero);
|
|
AeroListView.NativeMethods.SendMessage(this.Handle, 277, (IntPtr) 6, IntPtr.Zero);
|
|
this.BeginUpdate();
|
|
this.EndUpdate();
|
|
}
|
|
|
|
protected override void OnColumnClick(ColumnClickEventArgs e)
|
|
{
|
|
base.OnColumnClick(e);
|
|
if (e.Column == this.LvwColumnSorter.SortColumn)
|
|
{
|
|
this.LvwColumnSorter.Order = this.LvwColumnSorter.Order == SortOrder.Ascending ? SortOrder.Descending : SortOrder.Ascending;
|
|
}
|
|
else
|
|
{
|
|
this.LvwColumnSorter.SortColumn = e.Column;
|
|
this.LvwColumnSorter.Order = SortOrder.Ascending;
|
|
}
|
|
if (this.VirtualMode)
|
|
return;
|
|
this.Sort();
|
|
}
|
|
|
|
private static int MakeWin32Long(short lowPart, short highPart)
|
|
{
|
|
return (int) (ushort) lowPart | (int) highPart << 16 /*0x10*/;
|
|
}
|
|
|
|
protected override void OnPaintBackground(PaintEventArgs e)
|
|
{
|
|
if (this._backgroundOpacity < (int) byte.MaxValue || this.BackColor.A < byte.MaxValue)
|
|
{
|
|
using (SolidBrush solidBrush = new SolidBrush(Color.FromArgb(this._backgroundOpacity, this.BackColor)))
|
|
e.Graphics.FillRectangle((Brush) solidBrush, this.ClientRectangle);
|
|
}
|
|
else
|
|
base.OnPaintBackground(e);
|
|
}
|
|
|
|
private static class NativeMethods
|
|
{
|
|
[DllImport("user32.dll", CharSet = CharSet.Auto)]
|
|
public static extern IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
|
|
|
|
[DllImport("uxtheme.dll", CharSet = CharSet.Unicode)]
|
|
public static extern int SetWindowTheme(IntPtr hWnd, string pszSubAppName, string pszSubIdList);
|
|
|
|
[DllImport("user32.dll")]
|
|
public static extern bool GetWindowRect(IntPtr hwnd, out AeroListView.RECT lpRect);
|
|
}
|
|
|
|
private static class PlatformHelper
|
|
{
|
|
public static bool RunningOnMono => Type.GetType("Mono.Runtime") != (Type) null;
|
|
|
|
public static bool VistaOrHigher
|
|
{
|
|
get
|
|
{
|
|
return Environment.OSVersion.Platform == PlatformID.Win32NT && Environment.OSVersion.Version.Major >= 6;
|
|
}
|
|
}
|
|
|
|
public static bool XpOrHigher
|
|
{
|
|
get
|
|
{
|
|
return Environment.OSVersion.Platform == PlatformID.Win32NT && Environment.OSVersion.Version.Major >= 5;
|
|
}
|
|
}
|
|
}
|
|
|
|
private struct RECT
|
|
{
|
|
public int Left;
|
|
public int Top;
|
|
public int Right;
|
|
public int Bottom;
|
|
}
|
|
|
|
public class ListViewColumnSorter : IComparer
|
|
{
|
|
public int SortColumn { get; set; }
|
|
|
|
public SortOrder Order { get; set; }
|
|
|
|
public int Compare(object x, object y)
|
|
{
|
|
ListViewItem listViewItem1 = x as ListViewItem;
|
|
ListViewItem listViewItem2 = y as ListViewItem;
|
|
int? count1 = listViewItem1?.SubItems.Count;
|
|
int sortColumn1 = this.SortColumn;
|
|
string text1 = count1.GetValueOrDefault() > sortColumn1 & count1.HasValue ? listViewItem1.SubItems[this.SortColumn].Text : "";
|
|
int? count2 = listViewItem2?.SubItems.Count;
|
|
int sortColumn2 = this.SortColumn;
|
|
string text2 = count2.GetValueOrDefault() > sortColumn2 & count2.HasValue ? listViewItem2.SubItems[this.SortColumn].Text : "";
|
|
int num = string.Compare(text1, text2);
|
|
if (this.Order == SortOrder.Ascending)
|
|
return num;
|
|
return this.Order != SortOrder.Descending ? 0 : -num;
|
|
}
|
|
}
|
|
}
|