using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using System.ComponentModel; namespace Karna.Magnification { // Magnifier Window Styles internal enum MagnifierStyle : int { MS_SHOWMAGNIFIEDCURSOR = 0x0001, MS_CLIPAROUNDCURSOR = 0x0002, MS_INVERTCOLORS = 0x0004 } // Filter Modes internal enum FilterMode { MW_FILTERMODE_EXCLUDE = 0, MW_FILTERMODE_INCLUDE = 1 } [StructLayout(LayoutKind.Sequential)] internal struct Transformation { public float m00; public float m10; public float m20; public float m01; public float m11; public float m21; public float m02; public float m12; public float m22; public Transformation(float magnificationFactor) : this() { m00 = magnificationFactor; m11 = magnificationFactor; m22 = 1.0f; } } [StructLayout(LayoutKind.Sequential)] internal struct ColorEffect { public float transform00; public float transform10; public float transform20; public float transform30; public float transform40; public float transform01; public float transform02; public float transform03; public float transform04; public float transform11; public float transform12; public float transform13; public float transform14; public float transform21; public float transform22; public float transform23; public float transform24; public float transform31; public float transform32; public float transform33; public float transform34; public float transform41; public float transform42; public float transform43; public float transform44; } /// /// A Wrapper for a POINT struct /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "POINT"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")] [StructLayout(LayoutKind.Sequential)] internal struct POINT { /// /// The X coordinate of the point /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "X")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")] public int x; /// /// The Y coordinate of the point /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Y")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")] public int y; /// /// Initialize the point /// /// The x coordinate of the point. /// The y coordinate of the point. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "y"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "x")] public POINT(int x, int y) { this.x = x; this.y = y; } } /// /// A Wrapper for a RECT struct /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "RECT"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")] [StructLayout(LayoutKind.Sequential)] internal struct RECT { /// /// Position of left edge /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")] public int left; /// /// Position of top edge /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")] public int top; /// /// Position of right edge /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")] public int right; /// /// Position of bottom edge /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")] public int bottom; public RECT(int left, int top, int right, int bottom) { this.left = left; this.right = right; this.top = top; this.bottom = bottom; } public RECT(int width, int height) { this.left = 0; this.top = 0; this.right = width; this.bottom = height; } public override bool Equals(object obj) { RECT r = (RECT)obj; return (r.left == left && r.right == right && r.top == top && r.bottom == bottom); } public override int GetHashCode() { // Attempting a minor degree of "hash-ness" here return ((left ^ top) ^ right) ^ bottom; } public static bool operator ==(RECT a, RECT b) { return (a.left == b.left && a.right == b.right && a.top == b.top && a.bottom == b.bottom); } public static bool operator !=(RECT a, RECT b) { return !(a == b); } } /// /// Specifies the style of the window being created /// [FlagsAttribute] [Description("Specifies the style of the window being created")] internal enum WindowStyles : int { /// /// Creates an overlapped window. An overlapped window has a title bar and a border /// WS_OVERLAPPED = 0x00000000, /// /// Creates a pop-up window /// WS_POPUP = -2147483648, /// /// Creates a child window. A window with this style cannot have a menu bar. /// This style cannot be used with the WS_POPUP style. /// WS_CHILD = 0x40000000, /// /// Creates a window that is initially minimized. /// Same as the WS_ICONIC style. /// WS_MINIMIZE = 0x20000000, /// /// Creates a window that is initially visible. /// WS_VISIBLE = 0x10000000, /// /// Creates a window that is initially disabled. /// A disabled window cannot receive input from the user /// WS_DISABLED = 0x08000000, /// /// Clips child windows relative to each other; that is, when a particular child window /// receives a WM_PAINT message, the WS_CLIPSIBLINGS style clips all other overlapping /// child windows out of the region of the child window to be updated. /// If WS_CLIPSIBLINGS is not specified and child windows overlap, it is possible, /// when drawing within the client area of a child window, to draw within the client area /// of a neighboring child window. /// WS_CLIPSIBLINGS = 0x04000000, /// /// Excludes the area occupied by child windows when drawing occurs within the parent window. /// This style is used when creating the parent window. /// WS_CLIPCHILDREN = 0x02000000, /// /// Creates a window that is initially maximized. /// WS_MAXIMIZE = 0x01000000, /// /// Creates a window that has a title bar (includes the WS_BORDER style). /// WS_CAPTION = 0x00C00000, /// /// Creates a window that has a thin-line border. /// WS_BORDER = 0x00800000, /// /// Creates a window that has a border of a style typically used with dialog boxes. /// A window with this style cannot have a title bar. /// WS_DLGFRAME = 0x00400000, /// /// Creates a window that has a vertical scroll bar. /// WS_VSCROLL = 0x00200000, /// /// Creates a window that has a horizontal scroll bar. /// WS_HSCROLL = 0x00100000, /// /// Creates a window that has a window menu on its title bar. /// The WS_CAPTION style must also be specified. /// WS_SYSMENU = 0x00080000, /// /// Creates a window that has a sizing border. /// Same as the WS_SIZEBOX style. /// WS_THICKFRAME = 0x00040000, /// /// Specifies the first control of a group of controls. /// The group consists of this first control and all controls defined after it, /// up to the next control with the WS_GROUP style. The first control in each group /// usually has the WS_TABSTOP style so that the user can move from group to group. /// The user can subsequently change the keyboard focus from one control in the group /// to the next control in the group by using the direction keys. /// WS_GROUP = 0x00020000, /// /// Specifies a control that can receive the keyboard focus when the user presses the TAB key. /// Pressing the TAB key changes the keyboard focus to the next control with the /// WS_TABSTOP style. /// WS_TABSTOP = 0x00010000, /// /// Creates a window that has a minimize button. Cannot be combined with the WS_EX_CONTEXTHELP /// style. The WS_SYSMENU style must also be specified. /// WS_MINIMIZEBOX = 0x00020000, /// /// Creates a window that has a maximize button. Cannot be combined with the /// WS_EX_CONTEXTHELP style. The WS_SYSMENU style must also be specified. /// WS_MAXIMIZEBOX = 0x00010000 } /// ///Common window styles /// [Description("Common window styles")] internal enum CommonWindowStyles : int { /// ///Creates an overlapped window. An overlapped window has a title bar and a border. Same as the WS_OVERLAPPED style. /// WS_TILED = WindowStyles.WS_OVERLAPPED, /// ///Creates a window that is initially minimized. Same as the WS_MINIMIZE style. /// WS_ICONIC = WindowStyles.WS_MINIMIZE, /// ///Creates a window that has a sizing border. Same as the WS_THICKFRAME style. /// WS_SIZEBOX = WindowStyles.WS_THICKFRAME, /// /// Creates an overlapped window with the WS_OVERLAPPED, WS_CAPTION, WS_SYSMENU, WS_THICKFRAME, WS_MINIMIZEBOX, and WS_MAXIMIZEBOX styles. Same as the WS_TILEDWINDOW style. /// WS_OVERLAPPEDWINDOW = (WindowStyles.WS_OVERLAPPED | WindowStyles.WS_CAPTION | WindowStyles.WS_SYSMENU | WindowStyles.WS_THICKFRAME | WindowStyles.WS_MINIMIZEBOX | WindowStyles.WS_MAXIMIZEBOX), /// ///Creates an overlapped window with the WS_OVERLAPPED, WS_CAPTION, WS_SYSMENU, WS_THICKFRAME, WS_MINIMIZEBOX, and WS_MAXIMIZEBOX styles. Same as the WS_OVERLAPPEDWINDOW style. /// WS_TILEDWINDOW = WS_OVERLAPPEDWINDOW, /// ///Creates a pop-up window with WS_BORDER, WS_POPUP, and WS_SYSMENU styles. The WS_CAPTION and WS_POPUPWINDOW styles must be combined to make the window menu visible. /// WS_POPUPWINDOW = (WindowStyles.WS_POPUP | WindowStyles.WS_BORDER | WindowStyles.WS_SYSMENU), /// ///Same as the WS_CHILD style. /// WS_CHILDWINDOW = (WindowStyles.WS_CHILD) } [FlagsAttribute] internal enum SetWindowPosFlags : int { SWP_NOSIZE = 1, SWP_NOMOVE = 2, SWP_NOZORDER = 4, SWP_NOREDRAW = 8, SWP_NOACTIVATE = 0x10, SWP_FRAMECHANGED = 0x20, SWP_SHOWWINDOW = 0x40, SWP_HIDEWINDOW = 0x80, SWP_NOCOPYBITS = 0x100, SWP_NOOWNERZORDER = 0x200, SWP_NOSENDCHANGING = 0x400 } /// /// Specifies the extended style of the window /// [FlagsAttribute] [Description("Specifies the extended style of the window")] internal enum ExtendedWindowStyles : int { /// /// Creates a window that has a double border; the window can, optionally, /// be created with a title bar by specifying the WS_CAPTION style in the dwStyle parameter. /// WS_EX_DLGMODALFRAME = 0x00000001, /// /// Specifies that a child window created with this style does not send /// the WM_PARENTNOTIFY message to its parent window when it is created or destroyed. /// WS_EX_NOPARENTNOTIFY = 0x00000004, /// /// Specifies that a window created with this style should be placed above all nontopmost /// windows and stay above them even when the window is deactivated /// WS_EX_TOPMOST = 0x00000008, /// /// Windows that can accept dragged objects must be created with this style so that /// Windows can determine that the window will accept objects and can change the drag/drop /// cursor as the user drags an object over the window. /// WS_EX_ACCEPTFILES = 0x00000010, /// /// The WS_EX_TRANSPARENT style makes a window transparent; that is, the window can be seen through, /// and anything under the window is still visible. Transparent windows are not transparent /// to mouse or keyboard events. A transparent window receives paint messages when anything /// under it changes. Transparent windows are useful for drawing drag handles on top of other /// windows or for implementing "hot-spot" areas without having to hit test because the transparent /// window receives click messages. /// WS_EX_TRANSPARENT = 0x00000020, /// /// Creates an MDI child window. /// WS_EX_MDICHILD = 0x00000040, /// /// Creates a tool window, which is a window intended to be used as a floating toolbar. /// A tool window has a title bar that is shorter than a normal title bar, and the window title /// is drawn using a smaller font. A tool window does not appear in the task bar or in the window /// that appears when the user presses ALT+TAB. /// WS_EX_TOOLWINDOW = 0x00000080, /// /// Specifies that a window has a border with a raised edge. /// WS_EX_WINDOWEDGE = 0x00000100, /// /// Specifies that a window has a 3D look — that is, a border with a sunken edge. /// WS_EX_CLIENTEDGE = 0x00000200, /// /// Includes a question mark in the title bar of the window. /// When the user clicks the question mark, the cursor changes to a question mark with a pointer. /// If the user then clicks a child window, the child receives a WM_HELP message. /// WS_EX_CONTEXTHELP = 0x00000400, /// /// Gives a window generic right-aligned properties. This depends on the window class. /// WS_EX_RIGHT = 0x00001000, /// /// Gives window generic left-aligned properties. This is the default. /// WS_EX_LEFT = 0x00000000, /// /// Displays the window text using right-to-left reading order properties. /// WS_EX_RTLREADING = 0x00002000, /// /// Displays the window text using left-to-right reading order properties. This is the default. /// WS_EX_LTRREADING = 0x00000000, /// /// Places a vertical scroll bar to the left of the client area. /// WS_EX_LEFTSCROLLBAR = 0x00004000, /// /// Places a vertical scroll bar (if present) to the right of the client area. This is the default. /// WS_EX_RIGHTSCROLLBAR = 0x00000000, /// /// Allows the user to navigate among the child windows of the window by using the TAB key. /// WS_EX_CONTROLPARENT = 0x00010000, /// /// Creates a window with a three-dimensional border style intended to be used for items that /// do not accept user input. /// WS_EX_STATICEDGE = 0x00020000, /// /// Forces a top-level window onto the taskbar when the window is visible. /// WS_EX_APPWINDOW = 0x00040000, /// /// Creates a layered window. Note that this cannot be used for child windows /// WS_EX_LAYERED = 0x00080000, /// /// A window created with this style does not pass its window layout to its child windows. /// WS_EX_NOINHERITLAYOUT = 0x00100000, /// /// Creates a window whose horizontal origin is on the right edge. /// Increasing horizontal values advance to the left. /// WS_EX_LAYOUTRTL = 0x00400000, /// /// Paints all descendants of a window in bottom-to-top painting order using double-buffering. /// WS_EX_COMPOSITED = 0x02000000, /// /// A top-level window created with this style does not become the foreground window when the user /// clicks it. The system does not bring this window to the foreground when the user minimizes /// or closes the foreground window. /// WS_EX_NOACTIVATE = 0x08000000 } /// /// Common extended window styles /// [Description("Common extended window styles")] internal enum CommonExtendedWindowStyles : int { /// /// Combines the WS_EX_CLIENTEDGE and WS_EX_WINDOWEDGE styles. /// WS_EX_OVERLAPPEDWINDOW = (ExtendedWindowStyles.WS_EX_WINDOWEDGE | ExtendedWindowStyles.WS_EX_CLIENTEDGE), /// /// Combines the WS_EX_WINDOWEDGE, WS_EX_TOOLWINDOW, and WS_EX_TOPMOST styles. /// WS_EX_PALETTEWINDOW = (ExtendedWindowStyles.WS_EX_WINDOWEDGE | ExtendedWindowStyles.WS_EX_TOOLWINDOW | ExtendedWindowStyles.WS_EX_TOPMOST) } /// /// Layered window flags /// [FlagsAttribute] [Description("Layered window flags")] internal enum LayeredWindowAttributeFlags : int { /// /// Use key as a transparency color /// LWA_COLORKEY = 0x00000001, /// /// Use Alpha to determine the opacity of the layered window. /// LWA_ALPHA = 0x00000002 } [FlagsAttribute] internal enum LayeredWindowUpdateFlags : int { ULW_COLORKEY = 0x00000001, ULW_ALPHA = 0x00000002, ULW_OPAQUE = 0x00000004 } [FlagsAttribute] internal enum BlendOperations : byte { AC_SRC_OVER = 0x00, AC_SRC_ALPHA = 0x01 } internal enum ShowWindowStyles : short { SW_HIDE = 0, SW_SHOWNORMAL = 1, SW_NORMAL = 1, SW_SHOWMINIMIZED = 2, SW_SHOWMAXIMIZED = 3, SW_MAXIMIZE = 3, SW_SHOWNOACTIVATE = 4, SW_SHOW = 5, SW_MINIMIZE = 6, SW_SHOWMINNOACTIVE = 7, SW_SHOWNA = 8, SW_RESTORE = 9, SW_SHOWDEFAULT = 10, SW_FORCEMINIMIZE = 11, SW_MAX = 11 } internal enum WindowMessage : int { WM_CREATE = 0x0001, WM_DESTROY = 0x0002, WM_PAINT = 0x000F, WM_CLOSE = 0x0010, WM_QUERYENDSESSION = 0x0011, WM_QUIT = 0x0012, WM_ENDSESSION = 0x0016, WM_SETCURSOR = 0x0020, WM_MOVE = 0x0003, WM_SIZE = 0x0005, WM_MOUSEMOVE = 0x0200, WM_NCMOUSEMOVE = 0x00A0, WM_KEYDOWN = 0x0100, WM_SYSKEYDOWN = 0x0104, WM_KEYUP = 0x0101, WM_CHAR = 0x0102, WM_SYSCHAR = 0x0106, WM_LBUTTONDOWN = 0x0201, WM_LBUTTONUP = 0x0202, WM_LBUTTONDBLCLK = 0x0203, WM_RBUTTONDOWN = 0x0204, WM_RBUTTONUP = 0x0205, WM_RBUTTONDBLCLK = 0x0206, WM_MBUTTONDOWN = 0x0207, WM_MBUTTONUP = 0x0208, WM_MBUTTONDBLCLK = 0x0209, WM_MOUSEWHEEL = 0x020A, WM_MOUSEHOVER = 0x02A1, WM_MOUSELEAVE = 0x02A3, WM_NCLBUTTONDOWN = 0x00A1, WM_NCLBUTTONUP = 0x00A2, WM_NCLBUTTONDBLCLK = 0x00A3, WM_NCRBUTTONDOWN = 0x00A4, WM_NCRBUTTONUP = 0x00A5, WM_NCRBUTTONDBLCLK = 0x00A6, WM_NCMBUTTONDOWN = 0x00A7, WM_NCMBUTTONUP = 0x00A8, WM_NCMBUTTONDBLCLK = 0x00A9, WM_NCXBUTTONDOWN = 0x00AB, WM_NCXBUTTONUP = 0x00AC, WM_GETDLGCODE = 0x0087, WM_NCHITTEST = 0x0084, WM_WINDOWPOSCHANGING = 0x0046, WM_WINDOWPOSCHANGED = 0x0047, WM_KILLTIMER = 0x402, WM_TIMER = 0x113, WM_NCPAINT = 0x85, WM_ERASEBKGND = 20, WM_DROPFILES = 0x233, WM_MOUSEACTIVATE = 0x0021, WM_ACTIVATE = 0x0006, WM_ACTIVATEAPP = 0x001C, WM_KILLFOCUS = 8 } }