|
|
|
|
using KGIS.Plugin.LayerProperty.Model;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
|
|
|
|
|
namespace KGIS.Plugin.LayerProperty.Utils
|
|
|
|
|
{
|
|
|
|
|
public class Win32Util
|
|
|
|
|
{
|
|
|
|
|
public static short COLORONCOLOR = 3;
|
|
|
|
|
public static short HORZSIZE = 4;
|
|
|
|
|
public static short VERTSIZE = 6;
|
|
|
|
|
public static short HORZRES = 8;
|
|
|
|
|
public static short VERTRES = 10;
|
|
|
|
|
public static short ASPECTX = 40;
|
|
|
|
|
public static short ASPECTY = 42;
|
|
|
|
|
public static short LOGPIXELSX = 88;
|
|
|
|
|
public static short LOGPIXELSY = 90;
|
|
|
|
|
public static int InnerDC = 0;
|
|
|
|
|
private static int hdcSrc = 0;
|
|
|
|
|
private static int tempBitmap = 0;
|
|
|
|
|
public static void InitBitmap(int w, int h)
|
|
|
|
|
{
|
|
|
|
|
Win32Util.hdcSrc = User32.GetWindowDC(User32.GetDesktopWindow());
|
|
|
|
|
Win32Util.InnerDC = GDI32.CreateCompatibleDC(Win32Util.hdcSrc);
|
|
|
|
|
Win32Util.tempBitmap = GDI32.CreateCompatibleBitmap(Win32Util.hdcSrc, w, h);
|
|
|
|
|
GDI32.SelectObject(Win32Util.InnerDC, Win32Util.tempBitmap);
|
|
|
|
|
}
|
|
|
|
|
public static Bitmap GetBitmap(int w, int h)
|
|
|
|
|
{
|
|
|
|
|
return new Bitmap(Image.FromHbitmap(new IntPtr(Win32Util.tempBitmap)), w, h);
|
|
|
|
|
}
|
|
|
|
|
public static void ReleaseDC()
|
|
|
|
|
{
|
|
|
|
|
User32.ReleaseDC(User32.GetDesktopWindow(), Win32Util.hdcSrc);
|
|
|
|
|
GDI32.DeleteDC(Win32Util.InnerDC);
|
|
|
|
|
GDI32.DeleteObject(Win32Util.tempBitmap);
|
|
|
|
|
}
|
|
|
|
|
public static void ClearDC(int hDc, Color backgroundColor, int xmin, int ymin, int xmax, int ymax)
|
|
|
|
|
{
|
|
|
|
|
int num = 0;
|
|
|
|
|
RECT rECT;
|
|
|
|
|
rECT.Left_Renamed = xmin;
|
|
|
|
|
rECT.Top = ymin;
|
|
|
|
|
rECT.Right_Renamed = xmax;
|
|
|
|
|
rECT.Bottom = ymax;
|
|
|
|
|
int crColor = ColorTranslator.ToOle(backgroundColor);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
num = GDI32.CreateSolidBrush(crColor);
|
|
|
|
|
User32.FillRect(hDc, ref rECT, num);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception value)
|
|
|
|
|
{
|
|
|
|
|
Console.Write(value);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (num != 0)
|
|
|
|
|
{
|
|
|
|
|
GDI32.DeleteObject(num);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|