convert VB to C#
This commit is contained in:
26
Pilz.UI/Utilities/DrawingControl.cs
Normal file
26
Pilz.UI/Utilities/DrawingControl.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using global::System.Windows.Forms;
|
||||
|
||||
namespace Pilz.UI.Utils
|
||||
{
|
||||
public static class DrawingControl
|
||||
{
|
||||
private const int WM_SETREDRAW = 11;
|
||||
|
||||
public static void SuspendDrawing(this Control control)
|
||||
{
|
||||
User32Bridge.SendMessage(control.Handle, WM_SETREDRAW, false, 0);
|
||||
}
|
||||
|
||||
public static void ResumeDrawing(this Control control)
|
||||
{
|
||||
control.ResumeDrawing(true);
|
||||
}
|
||||
|
||||
public static void ResumeDrawing(this Control control, bool redraw)
|
||||
{
|
||||
User32Bridge.SendMessage(control.Handle, WM_SETREDRAW, true, 0);
|
||||
if (redraw)
|
||||
control.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
Imports System.Runtime.CompilerServices
|
||||
Imports System.Windows.Forms
|
||||
|
||||
Namespace Utils
|
||||
|
||||
Public Module DrawingControl
|
||||
|
||||
Private Const WM_SETREDRAW = 11
|
||||
|
||||
<Extension>
|
||||
Public Sub SuspendDrawing(control As Control)
|
||||
SendMessage(control.Handle, WM_SETREDRAW, False, 0)
|
||||
End Sub
|
||||
|
||||
<Extension>
|
||||
Public Sub ResumeDrawing(control As Control)
|
||||
ResumeDrawing(control, True)
|
||||
End Sub
|
||||
|
||||
<Extension>
|
||||
Public Sub ResumeDrawing(control As Control, redraw As Boolean)
|
||||
SendMessage(control.Handle, WM_SETREDRAW, True, 0)
|
||||
If redraw Then control.Refresh()
|
||||
End Sub
|
||||
|
||||
End Module
|
||||
|
||||
End Namespace
|
||||
11
Pilz.UI/Utilities/User32Bridge.cs
Normal file
11
Pilz.UI/Utilities/User32Bridge.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Pilz.UI
|
||||
{
|
||||
public static class User32Bridge
|
||||
{
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern int SendMessage(IntPtr hWnd, int Msg, bool wParam, int lParam);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
Public Module User32Bridge
|
||||
|
||||
Friend Declare Auto Function SendMessage Lib "user32.dll" (hWnd As IntPtr, Msg As Integer, wParam As Boolean, lParam As Integer) As Integer
|
||||
|
||||
End Module
|
||||
Reference in New Issue
Block a user