Skip to content

Commit 15ef991

Browse files
committed
rename class
1 parent b095c72 commit 15ef991

File tree

5 files changed

+29
-29
lines changed

5 files changed

+29
-29
lines changed

src/DreamScene2/MainForm.cs

+17-17
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ void OpenVideo(string path)
106106
videoWindow.SetPosition(_screen.Bounds);
107107
videoWindow.Show();
108108

109-
PInvoke.SetParent(videoWindow.GetHandle(), _desktopWindowHandle);
109+
NativeMethods.SetParent(videoWindow.GetHandle(), _desktopWindowHandle);
110110
}
111111

112112
((IPlayerControl)_player).Source = new Uri(path, UriKind.Absolute);
@@ -137,7 +137,7 @@ void OpenWeb(string url)
137137
webWindow.SetPosition(_screen.Bounds);
138138
webWindow.Show();
139139

140-
PInvoke.SetParent(webWindow.GetHandle(), _desktopWindowHandle);
140+
NativeMethods.SetParent(webWindow.GetHandle(), _desktopWindowHandle);
141141
}
142142

143143
((IPlayerControl)_player).Source = new Uri(url);
@@ -165,7 +165,7 @@ void SetWindow(IntPtr hWnd)
165165
WindowPlayer windowPlayer = new WindowPlayer(hWnd);
166166
_player = windowPlayer;
167167
windowPlayer.SetPosition(_screen.Bounds);
168-
PInvoke.SetParent(windowPlayer.GetHandle(), _desktopWindowHandle);
168+
NativeMethods.SetParent(windowPlayer.GetHandle(), _desktopWindowHandle);
169169

170170
EnableControl();
171171
}
@@ -190,7 +190,7 @@ void CloseWindow(WindowType wt)
190190
toolStripMenuItem27.Enabled = true;
191191

192192
if (_player is IPlayerInteractive && _settings.UseDesktopInteraction)
193-
PInvoke.DS2_EndForwardMouseKeyboardMessage();
193+
NativeMethods.DS2_EndForwardMouseKeyboardMessage();
194194

195195
if (_lwt == WindowType.Web && !((IPlayerControl)_player).IsPlaying)
196196
Play_();
@@ -204,14 +204,14 @@ void CloseWindow(WindowType wt)
204204
_lwt = wt;
205205

206206
GC.Collect();
207-
PInvoke.DS2_RefreshDesktop();
207+
NativeMethods.DS2_RefreshDesktop();
208208
}
209209

210210
void ForwardMessage()
211211
{
212212
IntPtr hWnd = ((IPlayerInteractive)_player).GetMessageHandle();
213213
if (hWnd != IntPtr.Zero)
214-
PInvoke.DS2_StartForwardMouseKeyboardMessage(hWnd);
214+
NativeMethods.DS2_StartForwardMouseKeyboardMessage(hWnd);
215215
}
216216

217217
#endregion
@@ -222,7 +222,7 @@ void ForwardMessage()
222222

223223
private void MainForm_Load(object sender, EventArgs e)
224224
{
225-
_desktopWindowHandle = PInvoke.DS2_GetDesktopWindowHandle();
225+
_desktopWindowHandle = NativeMethods.DS2_GetDesktopWindowHandle();
226226
if (_desktopWindowHandle == IntPtr.Zero)
227227
{
228228
btnOpenFile.Enabled = false;
@@ -271,7 +271,7 @@ private void MainForm_Load(object sender, EventArgs e)
271271
const int MOD_NOREPEAT = 0x4000;
272272
const int MOD_CONTROL = 0x0002;
273273
const int MOD_ALT = 0x0001;
274-
PInvoke.RegisterHotKey(this.Handle, PLAY_HOTKEY_ID, MOD_NOREPEAT | MOD_CONTROL | MOD_ALT, (int)'P');
274+
NativeMethods.RegisterHotKey(this.Handle, PLAY_HOTKEY_ID, MOD_NOREPEAT | MOD_CONTROL | MOD_ALT, (int)'P');
275275
}
276276

277277
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
@@ -293,7 +293,7 @@ private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
293293
else
294294
{
295295
notifyIcon1.Visible = false;
296-
PInvoke.UnregisterHotKey(this.Handle, PLAY_HOTKEY_ID);
296+
NativeMethods.UnregisterHotKey(this.Handle, PLAY_HOTKEY_ID);
297297
CloseWindow(WindowType.None);
298298
}
299299

@@ -401,7 +401,7 @@ private void timer1_Tick(object sender, EventArgs e)
401401
bool fullScreen;
402402
if (_settings.AutoPause3)
403403
{
404-
fullScreen = PInvoke.DS2_TestScreen(_screen.WorkingArea.ToRECT()) == 0;
404+
fullScreen = NativeMethods.DS2_TestScreen(_screen.WorkingArea.ToRECT()) == 0;
405405
if (fullScreen)
406406
{
407407
if (((IPlayerControl)_player).IsPlaying)
@@ -433,7 +433,7 @@ private void timer1_Tick(object sender, EventArgs e)
433433

434434
if (_settings.AutoPause1)
435435
{
436-
bool val = PInvoke.DS2_GetLastInputTickCount() < 500;
436+
bool val = NativeMethods.DS2_GetLastInputTickCount() < 500;
437437
array_push(_parr, val ? 1 : 0);
438438

439439
if (array_is_max(_parr))
@@ -464,7 +464,7 @@ private void timer1_Tick(object sender, EventArgs e)
464464
private void contextMenuStrip1_Opening(object sender, System.ComponentModel.CancelEventArgs e)
465465
{
466466
toolStripMenuItem12.Checked = Helper.CheckStartOnBoot();
467-
int val = PInvoke.DS2_IsVisibleDesktopIcons();
467+
int val = NativeMethods.DS2_IsVisibleDesktopIcons();
468468
toolStripMenuItem13.Text = val != 0 ? "隐藏桌面图标" : "显示桌面图标";
469469
}
470470

@@ -577,7 +577,7 @@ private void toolStripMenuItem10_DropDownOpening(object sender, EventArgs e)
577577
_screen = Screen.AllScreens[_screenIndex];
578578
System.Drawing.Rectangle bounds = _screen.Bounds;
579579

580-
PInvoke.DS2_RefreshDesktop();
580+
NativeMethods.DS2_RefreshDesktop();
581581

582582
if (_player != null)
583583
_player.SetPosition(bounds);
@@ -599,10 +599,10 @@ private void toolStripMenuItem16_DropDownOpening(object sender, EventArgs e)
599599
foreach (var val in _hWndSet)
600600
{
601601
IntPtr ptr = val;
602-
bool b = PInvoke.IsWindowVisible(ptr);
602+
bool b = NativeMethods.IsWindowVisible(ptr);
603603

604604
StringBuilder sb = new StringBuilder(128);
605-
PInvoke.GetWindowText(ptr, sb, sb.Capacity);
605+
NativeMethods.GetWindowText(ptr, sb, sb.Capacity);
606606
string title = sb.ToString();
607607

608608
ToolStripMenuItem toolStripMenuItem = new ToolStripMenuItem(title + (b ? "" : " (Invalidate)"));
@@ -677,7 +677,7 @@ private void toolStripMenuItem26_Click(object sender, EventArgs e)
677677

678678
private void toolStripMenuItem13_Click(object sender, EventArgs e)
679679
{
680-
PInvoke.DS2_ToggleShowDesktopIcons();
680+
NativeMethods.DS2_ToggleShowDesktopIcons();
681681
}
682682

683683
private void toolStripMenuItem27_Click(object sender, EventArgs e)
@@ -688,7 +688,7 @@ private void toolStripMenuItem27_Click(object sender, EventArgs e)
688688
if (_settings.UseDesktopInteraction)
689689
ForwardMessage();
690690
else
691-
PInvoke.DS2_EndForwardMouseKeyboardMessage();
691+
NativeMethods.DS2_EndForwardMouseKeyboardMessage();
692692
}
693693
}
694694

src/DreamScene2/PInvoke.cs src/DreamScene2/NativeMethods.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace DreamScene2
66
{
7-
public static class PInvoke
7+
public static class NativeMethods
88
{
99
[DllImport("User32.dll")]
1010
public static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);

src/DreamScene2/Program.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ internal static class Program
1515
[STAThread]
1616
static void Main(string[] args)
1717
{
18-
IntPtr hwnd = PInvoke.FindWindow(null, Constant.MainWindowTitle);
18+
IntPtr hwnd = NativeMethods.FindWindow(null, Constant.MainWindowTitle);
1919
if (hwnd != IntPtr.Zero)
2020
{
2121
const int SW_RESTORE = 9;
22-
PInvoke.ShowWindow(hwnd, SW_RESTORE);
23-
PInvoke.SetForegroundWindow(hwnd);
22+
NativeMethods.ShowWindow(hwnd, SW_RESTORE);
23+
NativeMethods.SetForegroundWindow(hwnd);
2424
return;
2525
}
2626

src/DreamScene2/WebWindow.xaml.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -73,32 +73,32 @@ public bool IsMuted
7373

7474
public void Play()
7575
{
76-
PInvoke.DS2_ToggleProcess(_d3dRenderingSubProcessPid, 1);
76+
NativeMethods.DS2_ToggleProcess(_d3dRenderingSubProcessPid, 1);
7777
IsPlaying = true;
7878
}
7979

8080
public void Pause()
8181
{
8282
_d3dRenderingSubProcessPid = GetD3DRenderingSubProcessPid();
83-
PInvoke.DS2_ToggleProcess(_d3dRenderingSubProcessPid, 0);
83+
NativeMethods.DS2_ToggleProcess(_d3dRenderingSubProcessPid, 0);
8484
IsPlaying = false;
8585
}
8686

8787
public IntPtr GetMessageHandle()
8888
{
89-
IntPtr chrome_WidgetWin_0 = PInvoke.FindWindowEx(webView2.Handle, IntPtr.Zero, "Chrome_WidgetWin_0", null);
89+
IntPtr chrome_WidgetWin_0 = NativeMethods.FindWindowEx(webView2.Handle, IntPtr.Zero, "Chrome_WidgetWin_0", null);
9090
if (chrome_WidgetWin_0 == IntPtr.Zero)
9191
return IntPtr.Zero;
92-
return PInvoke.FindWindowEx(chrome_WidgetWin_0, IntPtr.Zero, "Chrome_WidgetWin_1", null);
92+
return NativeMethods.FindWindowEx(chrome_WidgetWin_0, IntPtr.Zero, "Chrome_WidgetWin_1", null);
9393
}
9494

9595
public uint GetD3DRenderingSubProcessPid()
9696
{
9797
IntPtr chrome_WidgetWin_1 = GetMessageHandle();
9898
if (chrome_WidgetWin_1 != IntPtr.Zero)
9999
{
100-
IntPtr d3dWindowHandle = PInvoke.FindWindowEx(chrome_WidgetWin_1, IntPtr.Zero, "Intermediate D3D Window", null);
101-
PInvoke.GetWindowThreadProcessId(d3dWindowHandle, out uint pid);
100+
IntPtr d3dWindowHandle = NativeMethods.FindWindowEx(chrome_WidgetWin_1, IntPtr.Zero, "Intermediate D3D Window", null);
101+
NativeMethods.GetWindowThreadProcessId(d3dWindowHandle, out uint pid);
102102
return pid;
103103
}
104104
return 0;

src/DreamScene2/WindowPlayer.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ public IntPtr GetHandle()
1919

2020
public void SetPosition(Rectangle rect)
2121
{
22-
PInvoke.DS2_SetWindowPosition(_windowHandle, rect.ToRECT());
22+
NativeMethods.DS2_SetWindowPosition(_windowHandle, rect.ToRECT());
2323
}
2424

2525
public void Shutdown()
2626
{
2727
_windowHandle = IntPtr.Zero;
28-
PInvoke.DS2_RestoreLastWindowPosition();
28+
NativeMethods.DS2_RestoreLastWindowPosition();
2929
}
3030
}
3131
}

0 commit comments

Comments
 (0)