CarotDav_decompile/CarotDAV/WallMarkListView.cs

203 lines
6.7 KiB
C#
Raw Normal View History

// Decompiled with JetBrains decompiler
// Type: CarotDAV.WallMarkListView
// Assembly: CarotDAV, Version=1.13.2.18337, Culture=neutral, PublicKeyToken=null
// MVID: C31F2651-A4A8-4D09-916A-8C6106F5E7C8
// Assembly location: F:\Eigene Dateien\Dropbox\portable Collection\Progs\CarotDAV\CarotDAV.exe
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace CarotDAV
{
public class WallMarkListView : ListView
{
private const int LVM_FIRST = 4096;
private const int LVM_SETBKIMAGE = 4234;
private const int LVM_GETBKCOLOR = 4096;
private const int LVM_SETTILEINFO = 4260;
private const int LVIS_CUT = 4;
private const int LVIS_DROPHILITED = 8;
private const int LVIS_GLOW = 16;
private const int LVIS_ACTIVATING = 32;
private const int LVIS_OVERLAYMASK = 3840;
private const int LVM_SETIMAGELIST = 4099;
private const int LVM_SETITEMSTATE = 4139;
public WallMarkListView()
{
int num = (int) Application.OleRequired();
this.DoubleBuffered = true;
}
protected override void CreateHandle()
{
base.CreateHandle();
if (this.BackgroundImage == null)
return;
this.SetBackgroundImage();
}
protected override void OnBackgroundImageChanged(EventArgs e)
{
this.SetBackgroundImage();
}
protected override void OnEnabledChanged(EventArgs e)
{
base.OnEnabledChanged(e);
this.SetBackgroundImage();
}
public void SetBackgroundImage()
{
int num = (int) Application.OleRequired();
WallMarkListView.LVBKIMAGE lParam = new WallMarkListView.LVBKIMAGE();
lParam.ulFlags = WallMarkListView.LVBKIF.LVBKIF_SOURCE_NONE;
WallMarkListView.SendMessage(this.Handle, 4234, IntPtr.Zero, lParam);
if (this.BackgroundImage == null)
{
lParam.ulFlags = WallMarkListView.LVBKIF.LVBKIF_SOURCE_NONE;
lParam.hBmp = IntPtr.Zero;
WallMarkListView.SendMessage(this.Handle, 4234, IntPtr.Zero, lParam);
}
else
{
lParam.ulFlags = WallMarkListView.LVBKIF.LVBKIF_TYPE_WATERMARK;
using (Bitmap bitmap = new Bitmap(this.BackgroundImage.Width, this.BackgroundImage.Height, PixelFormat.Format32bppArgb))
{
Color color = !this.Enabled ? SystemColors.Control : this.BackColor;
using (Graphics graphics = Graphics.FromImage((Image) bitmap))
{
graphics.Clear(color);
graphics.DrawImage(this.BackgroundImage, 0, 0);
}
lParam.hBmp = bitmap.GetHbitmap();
}
WallMarkListView.SendMessage(this.Handle, 4234, IntPtr.Zero, lParam);
}
this.Invalidate();
}
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, WallMarkListView.LVBKIMAGE lParam);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, WallMarkListView.LVTILEINFO lParam);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, WallMarkListView.LVITEM lParam);
[DllImport("comctl32.dll")]
private static extern int ImageList_SetOverlayImage(IntPtr himl, int iImage, int iOverlay);
public void SetTileVisibleColumn(int itemindex, int[] columns)
{
if (columns == null)
columns = new int[0];
WallMarkListView.LVTILEINFO lParam = new WallMarkListView.LVTILEINFO();
lParam.cbSize = checked ((uint) Marshal.SizeOf((object) lParam));
lParam.iItem = itemindex;
lParam.cColumns = checked ((uint) columns.Length);
lParam.puColumns = Marshal.AllocHGlobal(checked (columns.Length * 4));
int num1 = 0;
int num2 = checked (columns.Length - 1);
int index = num1;
while (index <= num2)
{
Marshal.WriteInt32(lParam.puColumns, checked (index * 4), columns[index]);
checked { ++index; }
}
WallMarkListView.SendMessage(this.Handle, 4260, IntPtr.Zero, lParam);
Marshal.FreeHGlobal(lParam.puColumns);
}
public static void SetOverlayIcon(ImageList imagelist, int index, int overlayindex)
{
WallMarkListView.ImageList_SetOverlayImage(imagelist.Handle, index, overlayindex);
}
public static void ListViewOverlay(ListViewItem listitem, uint overlayIndex)
{
if ((long) overlayIndex > 15L)
throw new ArgumentOutOfRangeException(nameof (overlayIndex));
WallMarkListView.SendMessage(listitem.ListView.Handle, 4139, new IntPtr(listitem.Index), new WallMarkListView.LVITEM()
{
stateMask = 3840,
state = checked ((int) (((long) overlayIndex & 15L) << 8))
});
}
public static void ListViewItemSetStateCut(ListViewItem listitem, bool value)
{
WallMarkListView.SendMessage(listitem.ListView.Handle, 4139, new IntPtr(listitem.Index), new WallMarkListView.LVITEM()
{
stateMask = 4,
state = !value ? 0 : 4
});
}
public static void ListViewItemSetStateDropHilited(ListViewItem listitem, bool value)
{
WallMarkListView.SendMessage(listitem.ListView.Handle, 4139, new IntPtr(listitem.Index), new WallMarkListView.LVITEM()
{
stateMask = 8,
state = !value ? 0 : 8
});
}
[Flags]
private enum LVBKIF
{
LVBKIF_SOURCE_NONE = 0,
LVBKIF_SOURCE_HBITMAP = 1,
LVBKIF_SOURCE_URL = 2,
LVBKIF_SOURCE_MASK = LVBKIF_SOURCE_URL | LVBKIF_SOURCE_HBITMAP,
LVBKIF_STYLE_NORMAL = 0,
LVBKIF_STYLE_TIKE = 16,
LVBKIF_STYLE_MASK = LVBKIF_STYLE_TIKE,
LVBKIF_TYPE_WATERMARK = 268435456,
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
private class LVBKIMAGE
{
public WallMarkListView.LVBKIF ulFlags;
public IntPtr hBmp;
public string pszImage;
public uint cchImageMax;
public int xOffset;
public int yOffset;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
private class LVTILEINFO
{
public uint cbSize;
public int iItem;
public uint cColumns;
public IntPtr puColumns;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public class LVITEM
{
public int mask;
public int iItem;
public int iSubItem;
public int state;
public int stateMask;
public string pszText;
public int cchTextMax;
public int iImage;
public IntPtr lParam;
public int iIndent;
public int iGroupId;
public int cColumns;
public IntPtr puColumns;
}
}
}