378 references to NativeMethods
aspire-tray (378)
FolderApplication.cs (2)
122
Marshal.ThrowExceptionForHR(
NativeMethods
.ParseDisplayName(path, 0, out var item, 0, out _));
125
Marshal.ThrowExceptionForHR(
NativeMethods
.OpenFolderAndSelectItems(item, 0, 0, 0));
NativeMethods.Automation.cs (4)
148
NativeMethods
.ProviderOptions get_ProviderOptions();
168
IRawElementProviderFragment? Navigate(
NativeMethods
.NavigateDirection direction);
173
NativeMethods
.UiaRect get_BoundingRectangle();
204
NativeMethods
.ToggleState get_ToggleState();
Program.cs (2)
156
NativeMethods
.OutputDebugString($"Tray diagnostic write failed ({ex.GetType().Name}).{Environment.NewLine}");
158
NativeMethods
.OutputDebugString(message + Environment.NewLine);
TrayApplication.Actions.cs (3)
101
ShowMessage("Aspire", ex.Message,
NativeMethods
.MbIconError);
158
NativeCallException.Require(
NativeMethods
.MessageBox(_modalOwner, detail, title, flags) != 0, "MessageBoxW");
177
var result =
NativeMethods
.ShellExecute(_window, "open", uri.AbsoluteUri, null, null, 1);
TrayApplication.Clipboard.cs (8)
20
var memory =
NativeMethods
.GlobalAlloc(0x2, checked((nuint)(path.Length + 1) * sizeof(char)));
24
var buffer =
NativeMethods
.GlobalLock(memory);
30
var unlocked =
NativeMethods
.GlobalUnlock(memory);
32
NativeCallException.Require(
NativeMethods
.OpenClipboard(_window) != 0, "OpenClipboard");
35
NativeCallException.Require(
NativeMethods
.EmptyClipboard() != 0, "EmptyClipboard");
36
NativeCallException.Require(
NativeMethods
.SetClipboardData(13, memory) != 0, "SetClipboardData");
41
NativeCallException.Require(
NativeMethods
.CloseClipboard() != 0, "CloseClipboard");
48
Cleanup(
NativeMethods
.GlobalFree(memory) == 0, "GlobalFree(clipboard)");
TrayApplication.cs (72)
36
private
NativeMethods
.NotifyIconData _iconData;
62
if (_window != 0 &&
NativeMethods
.PostMessage(_window,
NativeMethods
.RestoreMessage, 0, 0) == 0)
76
if (_window != 0 && !_loopEnded &&
NativeMethods
.PostMessage(_window,
NativeMethods
.QuitMessage, 0, 0) == 0)
89
|| sizeof(
NativeMethods
.WindowClass) != 72 || sizeof(
NativeMethods
.Message) != 48
90
|| sizeof(
NativeMethods
.NotifyIconData) != 976
91
|| sizeof(
NativeMethods
.IconInfo) != 32 || sizeof(
NativeMethods
.BitmapInfo) != 44
92
|| sizeof(
NativeMethods
.ToolInfo) != 72)
107
var result =
NativeMethods
.GetMessage(out var message, 0, 0, 0);
113
NativeMethods
.TranslateMessage(in message);
114
NativeMethods
.DispatchMessage(in message);
134
_previousDpiContext =
NativeMethods
.SetThreadDpiAwarenessContext(-4);
136
_module =
NativeMethods
.GetModuleHandle(null);
138
_taskbarCreated =
NativeMethods
.RegisterWindowMessage("TaskbarCreated");
142
var windowClass = new
NativeMethods
.WindowClass
146
NativeCallException.Require(
NativeMethods
.RegisterClass(ref windowClass) != 0, "RegisterClassW");
150
var window =
NativeMethods
.CreateWindowEx(0, ClassName, "Aspire Tray", 0, 0, 0, 0, 0, 0, 0, _module, 0);
156
_iconData = new
NativeMethods
.NotifyIconData
158
Size = (uint)sizeof(
NativeMethods
.NotifyIconData), Window = window, Id = 1,
159
Flags =
NativeMethods
.NifMessage |
NativeMethods
.NifIcon |
NativeMethods
.NifTip |
NativeMethods
.NifShowTip,
160
CallbackMessage =
NativeMethods
.TrayCallback
178
_timerAdded =
NativeMethods
.SetTimer(window, TimerId, 200, 0) != 0;
183
NativeCallException.Require(
NativeMethods
.PostMessage(window,
NativeMethods
.ReadyMessage, 0, 0) != 0, "PostMessageW(ready)");
194
if (
NativeMethods
.PostMessage(_window,
NativeMethods
.RefreshMessage, 0, 0) == 0)
210
var replacement = new Artwork(this,
NativeMethods
.GetDpiForWindow(_window));
230
if (
NativeMethods
.ShellNotifyIcon(
NativeMethods
.NimAdd, ref _iconData) == 0)
239
_iconData.Version =
NativeMethods
.NotifyIconVersion4;
240
if (
NativeMethods
.ShellNotifyIcon(
NativeMethods
.NimSetVersion, ref _iconData) == 0)
263
if (
NativeMethods
.ShellNotifyIcon(
NativeMethods
.NimModify, ref _iconData) == 0)
307
NativeMethods
.PostQuitMessage(1);
311
return
NativeMethods
.DefWindowProc(window, message, wParam, lParam);
325
case
NativeMethods
.ReadyMessage:
336
case
NativeMethods
.RefreshMessage:
343
case
NativeMethods
.RestoreMessage:
346
case
NativeMethods
.QuitMessage:
349
case
NativeMethods
.WmTimer when wParam == TimerId:
352
case
NativeMethods
.WmDpiChanged:
353
case
NativeMethods
.WmSettingChange:
354
case
NativeMethods
.WmSysColorChange:
355
case
NativeMethods
.WmThemeChanged:
360
case
NativeMethods
.TrayCallback when !_quitRequested && _modalDepth == 0:
368
if (notification is
NativeMethods
.NinSelect or
NativeMethods
.WmContextMenu or
NativeMethods
.NinKeySelect)
370
TogglePanel(keyboard: notification ==
NativeMethods
.NinKeySelect
371
|| (notification ==
NativeMethods
.WmContextMenu && IsKeyboardContextMenu()));
374
case
NativeMethods
.WmClose:
375
case
NativeMethods
.WmDestroy:
376
case
NativeMethods
.WmEndSession when wParam != 0:
380
return
NativeMethods
.DefWindowProc(window, message, wParam, lParam);
442
Cleanup(
NativeMethods
.PostMessage(popup,
NativeMethods
.WmClose, 0, 0) != 0, "PostMessageW(close dialog)");
445
NativeMethods
.PostQuitMessage(ExitCode);
453
return
NativeMethods
.GetWindow(owner,
NativeMethods
.GwEnabledPopup);
489
Cleanup(
NativeMethods
.KillTimer(_window, TimerId) != 0, "KillTimer");
493
Cleanup(
NativeMethods
.ShellNotifyIcon(
NativeMethods
.NimDelete, ref _iconData) != 0, "Shell_NotifyIconW(NIM_DELETE)");
500
if (
NativeMethods
.DestroyWindow(_window) == 0)
507
if (_classRegistered &&
NativeMethods
.UnregisterClass(ClassName, _module) == 0)
515
Cleanup(
NativeMethods
.SetThreadDpiAwarenessContext(_previousDpiContext) != 0, "SetThreadDpiAwarenessContext(restore)");
TrayApplication.Icons.cs (21)
23
if (_iconAdded &&
NativeMethods
.ShellNotifyIcon(
NativeMethods
.NimModify, ref _iconData) == 0)
43
Size =
NativeMethods
.GetSystemMetricsForDpi(
NativeMethods
.SmCxSmallIcon, dpi);
47
var original =
NativeMethods
.LoadImage(0, Path.Combine(AppContext.BaseDirectory, "Aspire.ico"),
48
NativeMethods
.ImageIcon, Size, Size,
NativeMethods
.LrLoadFromFile);
119
var mask =
NativeMethods
.CreateBitmap(Size, Size, 1, 1, (nint)maskBits);
123
var info = new
NativeMethods
.IconInfo { IsIcon = 1, Color = canvas.Handle, Mask = mask };
124
var icon =
NativeMethods
.CreateIconIndirect(ref info);
131
_owner.Cleanup(
NativeMethods
.DeleteObject(mask) != 0, "DeleteObject(icon mask)");
145
_owner.Cleanup(
NativeMethods
.DestroyIcon(icon) != 0, "DestroyIcon");
161
var info = new
NativeMethods
.BitmapInfo
165
Handle =
NativeMethods
.CreateDIBSection(0, ref info, 0, out var bits, 0, 0);
232
var dc =
NativeMethods
.CreateCompatibleDC(0);
237
previous =
NativeMethods
.SelectObject(dc, Handle);
239
NativeCallException.Require(
NativeMethods
.DrawIconEx(dc, 0, 0, icon, _size, _size, 0, 0, 3) != 0, "DrawIconEx");
241
NativeCallException.Require(
NativeMethods
.GdiFlush() != 0, "GdiFlush");
247
_owner.Cleanup(
NativeMethods
.SelectObject(dc, previous) != 0, "SelectObject(restore)");
249
_owner.Cleanup(
NativeMethods
.DeleteDC(dc) != 0, "DeleteDC");
257
_owner.Cleanup(
NativeMethods
.DeleteObject(Handle) != 0, "DeleteObject(canvas)");
TrayApplication.NativeSmoke.cs (54)
20
var data = new
NativeMethods
.NotifyIconData
22
Size = (uint)sizeof(
NativeMethods
.NotifyIconData),
28
Icon =
NativeMethods
.LoadIcon(0, 32512)
31
Program.Log($"C# NOTIFYICONDATAW architecture={RuntimeInformation.ProcessArchitecture} size={sizeof(
NativeMethods
.NotifyIconData)} "
36
var added =
NativeMethods
.ShellNotifyIcon(
NativeMethods
.NimAdd, ref data);
40
NativeCallException.Require(
NativeMethods
.ShellNotifyIcon(
NativeMethods
.NimDelete, ref data) != 0, "Shell_NotifyIconW(smoke control delete)");
43
static nint Offset(string field) => Marshal.OffsetOf<
NativeMethods
.NotifyIconData>(field);
124
NativeCallException.Require(
NativeMethods
.GetWindowRect(_panelWindow, out var rect) != 0, "GetWindowRect(capture)");
129
var screen =
NativeMethods
.GetDC(0);
131
var memory =
NativeMethods
.CreateCompatibleDC(screen);
132
var bitmap =
NativeMethods
.CreateCompatibleBitmap(screen, width, height);
135
var previous =
NativeMethods
.SelectObject(memory, bitmap);
137
NativeCallException.Require(
NativeMethods
.BitBlt(memory, 0, 0, width, height, screen, rect.Left, rect.Top, 0x00CC0020 | 0x40000000) != 0,
139
NativeMethods
.SelectObject(memory, previous);
140
RequireGdiplus(
NativeMethods
.GdipCreateBitmapFromHBITMAP(bitmap, 0, out var image), "GdipCreateBitmapFromHBITMAP");
143
RequireGdiplus(
NativeMethods
.GdipSaveImageToFile(image, path, in s_pngEncoder, 0), "GdipSaveImageToFile");
147
NativeMethods
.GdipDisposeImage(image);
153
Cleanup(
NativeMethods
.DeleteObject(bitmap) != 0, "DeleteObject(capture)");
154
Cleanup(
NativeMethods
.DeleteDC(memory) != 0, "DeleteDC(capture)");
155
NativeMethods
.ReleaseDC(0, screen);
179
var defaultId = (nuint)
NativeMethods
.SendMessage(dialog, 0x400, 0, 0);
182
var button =
NativeMethods
.GetDlgItem(dialog, pending.Response);
186
NativeCallException.Require(
NativeMethods
.PostMessage(dialog,
NativeMethods
.WmCommand, (nuint)pending.Response, button) != 0, "PostMessageW(smoke dialog response)");
234
NativeMethods
.SendMessage(_panelWindow,
NativeMethods
.WmMouseMove, 0, point);
235
NativeMethods
.SendMessage(_panelWindow,
NativeMethods
.WmLeftButtonDown, 1, point);
236
NativeMethods
.SendMessage(_panelWindow,
NativeMethods
.WmLeftButtonUp, 0, point);
247
NativeMethods
.SendMessage(_panelWindow,
NativeMethods
.WmKeyDown, (nuint)virtualKey, 0);
285
NativeMethods
.UpdateWindow(_panelWindow);
322
(
NativeMethods
.NinSelect, false), (
NativeMethods
.WmContextMenu, null), (
NativeMethods
.NinKeySelect, true)
328
NativeMethods
.SendMessage(_window,
NativeMethods
.TrayCallback, 0, (nint)notification);
332
NativeMethods
.SendMessage(_window,
NativeMethods
.TrayCallback, 0, (nint)notification);
335
NativeMethods
.SendMessage(_window,
NativeMethods
.TrayCallback, 0, (nint)notification);
347
NativeCallException.Require(
NativeMethods
.GetKeyboardState(state) != 0, "GetKeyboardState(smoke)");
350
NativeCallException.Require(
NativeMethods
.SetKeyboardState(state) != 0, "SetKeyboardState(smoke)");
358
NativeMethods
.SetKeyboardState(state);
407
NativeCallException.Require(
NativeMethods
.ShellNotifyIcon(
NativeMethods
.NimDelete, ref _iconData) != 0, "Shell_NotifyIconW(smoke delete)");
409
NativeMethods
.SendMessage(_window, _taskbarCreated, 0, 0);
417
NativeMethods
.SendMessage(_window,
NativeMethods
.WmDpiChanged, 0, 0);
445
NativeSmokeHarness.Require(_iconData.CallbackMessage ==
NativeMethods
.TrayCallback, "The icon must report activations to the panel.");
450
&&
NativeMethods
.SendMessage(_panelTooltip, 0x040D, 0, 0) == _panelTooltips.Count, // TTM_GETTOOLCOUNT
TrayApplication.Panel.cs (149)
38
private List<(
NativeMethods
.Rect Bounds, string Text)> _panelTooltips = [];
85
if (
NativeMethods
.SetForegroundWindow(_panelWindow) == 0)
91
NativeMethods
.SetFocus(_panelWindow);
102
if (
NativeMethods
.GetKeyState(0x5D) < 0 ||
NativeMethods
.GetKeyState(0x79) < 0) // VK_APPS, VK_F10
106
var identifier = new
NativeMethods
.NotifyIconIdentifier
108
Size = (uint)sizeof(
NativeMethods
.NotifyIconIdentifier), Window = _window, Id = 1
110
return
NativeMethods
.ShellNotifyIconGetRect(in identifier, out var icon) >= 0
111
&&
NativeMethods
.GetCursorPos(out var point) != 0
123
NativeMethods
.ShowWindow(_panelWindow, 0); // SW_HIDE
132
var input = new
NativeMethods
.GdiplusStartupInput { GdiplusVersion = 1 };
133
if (
NativeMethods
.GdiplusStartup(out _gdiplusToken, in input, 0) != 0)
139
var windowClass = new
NativeMethods
.WindowClass
141
Style =
NativeMethods
.CsDropShadow,
144
Cursor =
NativeMethods
.LoadCursor(0, 32512), // IDC_ARROW
147
NativeCallException.Require(
NativeMethods
.RegisterClass(ref windowClass) != 0, "RegisterClassW(flyout)");
153
_panelWindow =
NativeMethods
.CreateWindowEx(
NativeMethods
.WsExToolWindow |
NativeMethods
.WsExTopmost, PanelClassName, "Aspire",
154
NativeMethods
.WsPopup, 0, 0, 1, 1, _window, 0, _module, 0);
160
_panelUsesDwmCorners =
NativeMethods
.DwmSetWindowAttribute(_panelWindow, 33, &preference, sizeof(int)) >= 0;
166
var center = new
NativeMethods
.Point { X = (anchor.Left + anchor.Right) / 2, Y = (anchor.Top + anchor.Bottom) / 2 };
167
var monitor =
NativeMethods
.MonitorFromPoint(center, 2); // MONITOR_DEFAULTTONEAREST
168
var info = new
NativeMethods
.MonitorInfo { Size = (uint)sizeof(
NativeMethods
.MonitorInfo) };
169
NativeCallException.Require(
NativeMethods
.GetMonitorInfo(monitor, ref info) != 0, "GetMonitorInfoW(flyout)");
170
if (
NativeMethods
.GetDpiForMonitor(monitor, 0, out var dpi, out _) < 0 || dpi == 0)
172
dpi =
NativeMethods
.GetDpiForWindow(_window);
213
NativeCallException.Require(
NativeMethods
.SetWindowPos(_panelWindow, -1, x, y, width, height, show ? 0x40u : 0x10u) != 0,
218
var region =
NativeMethods
.CreateRoundRectRgn(0, 0, width + 1, height + 1, diameter, diameter);
220
if (region != 0 &&
NativeMethods
.SetWindowRgn(_panelWindow, region, 1) == 0)
222
Cleanup(
NativeMethods
.DeleteObject(region) != 0, "DeleteObject(region)");
225
NativeMethods
.InvalidateRect(_panelWindow, 0, 0);
240
var controls = new
NativeMethods
.CommonControls
242
Size = (uint)sizeof(
NativeMethods
.CommonControls), Classes =
NativeMethods
.IccBarClasses
244
NativeCallException.Require(
NativeMethods
.InitCommonControlsEx(in controls) != 0, "InitCommonControlsEx");
246
_panelTooltip =
NativeMethods
.CreateWindowEx(
NativeMethods
.WsExTopmost, "tooltips_class32", "",
247
NativeMethods
.WsPopup |
NativeMethods
.TtsAlwaysTip |
NativeMethods
.TtsNoPrefix, 0, 0, 0, 0, _panelWindow, 0, _module, 0);
258
var tool = new
NativeMethods
.ToolInfo { Size = (uint)sizeof(
NativeMethods
.ToolInfo), Window = _panelWindow, Id = (nuint)i };
259
NativeMethods
.SendMessage(_panelTooltip,
NativeMethods
.TtmDelTool, 0, (nint)(&tool));
267
var tool = new
NativeMethods
.ToolInfo
269
Size = (uint)sizeof(
NativeMethods
.ToolInfo),
270
Flags =
NativeMethods
.TtfSubclass,
276
NativeCallException.Require(
NativeMethods
.SendMessage(_panelTooltip,
NativeMethods
.TtmAddTool, 0, (nint)(&tool)) != 0,
282
private
NativeMethods
.Rect GetNotifyIconRect()
284
var identifier = new
NativeMethods
.NotifyIconIdentifier
286
Size = (uint)sizeof(
NativeMethods
.NotifyIconIdentifier), Window = _window, Id = 1
288
if (
NativeMethods
.ShellNotifyIconGetRect(in identifier, out var rect) >= 0)
293
NativeCallException.Require(
NativeMethods
.GetCursorPos(out var point) != 0, "GetCursorPos(flyout)");
314
NativeMethods
.GetWindowRect(_panelWindow, out var rect);
321
NativeMethods
.InvalidateRect(_panelWindow, 0, 0);
396
var contrast = new
NativeMethods
.HighContrast { Size = (uint)sizeof(
NativeMethods
.HighContrast) };
397
if (
NativeMethods
.GetHighContrast(0x42, contrast.Size, ref contrast, 0) != 0 && (contrast.Flags & 1) != 0)
406
var value =
NativeMethods
.GetSysColor(index);
429
var dc =
NativeMethods
.BeginPaint(_panelWindow, out var paint);
436
NativeMethods
.GetClientRect(_panelWindow, out var client);
440
var memory =
NativeMethods
.CreateCompatibleDC(dc);
442
var bitmap =
NativeMethods
.CreateCompatibleBitmap(dc, width, height);
446
var previous =
NativeMethods
.SelectObject(memory, bitmap);
448
NativeCallException.Require(
NativeMethods
.BitBlt(dc, 0, 0, width, height, memory, 0, 0, 0x00CC0020) != 0, "BitBlt(flyout)"); // SRCCOPY
449
NativeMethods
.SelectObject(memory, previous);
455
Cleanup(
NativeMethods
.DeleteObject(bitmap) != 0, "DeleteObject(flyout bitmap)");
457
Cleanup(
NativeMethods
.DeleteDC(memory) != 0, "DeleteDC(flyout)");
462
NativeMethods
.EndPaint(_panelWindow, in paint);
471
RequireGdiplus(
NativeMethods
.GdipCreateFromHDC(dc, out var graphics), "GdipCreateFromHDC");
476
RequireGdiplus(
NativeMethods
.GdipSetSmoothingMode(graphics, 4), "GdipSetSmoothingMode");
477
RequireGdiplus(
NativeMethods
.GdipSetPixelOffsetMode(graphics, 4), "GdipSetPixelOffsetMode");
478
RequireGdiplus(
NativeMethods
.GdipScaleWorldTransform(graphics, scale, scale, 0), "GdipScaleWorldTransform");
504
NativeMethods
.DrawIconEx(gdi, rect.Left, rect.Top, icon, rect.Right - rect.Left, rect.Bottom - rect.Top, 0, 0, 3) != 0,
523
RequireGdiplus(
NativeMethods
.GdipSaveGraphics(graphics, out var state), "GdipSaveGraphics");
525
RequireGdiplus(
NativeMethods
.GdipSetClipRect(graphics, (float)clip.Bounds.X, (float)clip.Bounds.Y,
530
RequireGdiplus(
NativeMethods
.GdipRestoreGraphics(graphics, clips.Pop().State), "GdipRestoreGraphics");
537
NativeMethods
.GdipDeleteGraphics(graphics);
546
RequireGdiplus(
NativeMethods
.GdipGetDC(graphics, out var dc), "GdipGetDC");
547
var saved =
NativeMethods
.SaveDC(dc);
553
NativeMethods
.IntersectClipRect(dc, clip.Left, clip.Top, clip.Right, clip.Bottom);
559
NativeMethods
.RestoreDC(dc, saved);
560
NativeMethods
.GdipReleaseDC(graphics, dc);
569
RequireGdiplus(
NativeMethods
.GdipCreateSolidFill(ToArgb(color), out var brush), "GdipCreateSolidFill");
572
RequireGdiplus(
NativeMethods
.GdipFillPath(graphics, brush, path), "GdipFillPath");
576
NativeMethods
.GdipDeleteBrush(brush);
581
NativeMethods
.GdipDeletePath(path);
591
RequireGdiplus(
NativeMethods
.GdipCreatePen1(ToArgb(color), (float)width, 0, out var pen), "GdipCreatePen1");
594
RequireGdiplus(
NativeMethods
.GdipSetPenLineCap197819(pen, 2, 2, 2), "GdipSetPenLineCap");
595
RequireGdiplus(
NativeMethods
.GdipSetPenLineJoin(pen, 2), "GdipSetPenLineJoin");
596
RequireGdiplus(
NativeMethods
.GdipDrawPath(graphics, pen, path), "GdipDrawPath");
600
NativeMethods
.GdipDeletePen(pen);
605
NativeMethods
.GdipDeletePath(path);
617
var points = new List<
NativeMethods
.PointF>();
646
fixed (
NativeMethods
.PointF* pointData = pointArray)
650
RequireGdiplus(
NativeMethods
.GdipCreatePath2(pointData, typeData, pointArray.Length, 0, out var path), "GdipCreatePath2");
658
var previous =
NativeMethods
.SelectObject(dc, font);
661
NativeMethods
.SetBkMode(dc, 1); // TRANSPARENT
664
NativeMethods
.SetTextColor(dc, (uint)(color.R | (color.G << 8) | (color.B << 16)));
685
NativeCallException.Require(
NativeMethods
.GetTextMetrics(dc, out var metrics) != 0, "GetTextMetricsW(flyout)");
692
NativeMethods
.DrawText(dc, value, value.Length, ref rect, format);
696
NativeMethods
.SelectObject(dc, previous);
741
var rect = new
NativeMethods
.Rect();
743
NativeMethods
.DrawText(dc, value, value.Length, ref rect, 0x400 | 0x20 | 0x800);
755
Cleanup(
NativeMethods
.DestroyIcon(_panelLogo) != 0, "DestroyIcon(flyout logo)");
757
_panelLogo =
NativeMethods
.LoadImage(0, Path.Combine(AppContext.BaseDirectory, "Aspire.ico"),
758
NativeMethods
.ImageIcon, size, size,
NativeMethods
.LrLoadFromFile);
762
NativeCallException.Require(
NativeMethods
.DrawIconEx(dc, rect.Left, rect.Top, _panelLogo, size, size, 0, 0, 3) != 0,
776
if (executable is null ||
NativeMethods
.SHDefExtractIcon(executable, 0, 0, out icon, null, (uint)size) != 0)
795
font =
NativeMethods
.CreateFont(height, 0, 0, 0, weight, 0, 0, 0, 1, 0, 0, 5, 0, _panelFontFace);
800
Cleanup(
NativeMethods
.DeleteObject(font) != 0, "DeleteObject(flyout font)");
809
var previous =
NativeMethods
.SelectObject(dc, font);
813
var length =
NativeMethods
.GetTextFace(dc, 64, buffer);
818
NativeMethods
.SelectObject(dc, previous);
823
private
NativeMethods
.Rect ToDevice(PanelRect rect)
849
return
NativeMethods
.DefWindowProc(window, message, wParam, lParam);
856
case
NativeMethods
.WmPaint:
859
case
NativeMethods
.WmEraseBackground:
861
case
NativeMethods
.WmMouseMove:
865
var track = new
NativeMethods
.TrackMouseEventData
867
Size = (uint)sizeof(
NativeMethods
.TrackMouseEventData), Flags = 2, Window = window
869
_panelTrackingMouse =
NativeMethods
.TrackMouseEvent(ref track) != 0;
873
case
NativeMethods
.WmMouseLeave:
877
case
NativeMethods
.WmLeftButtonDown:
878
NativeMethods
.SetCapture(window);
881
case
NativeMethods
.WmLeftButtonUp:
882
NativeMethods
.ReleaseCapture();
885
case
NativeMethods
.WmMouseWheel:
890
case
NativeMethods
.WmKeyDown when wParam == 0xBC &&
NativeMethods
.GetKeyState(0x11) < 0:
897
case
NativeMethods
.WmKeyDown:
902
0x09 =>
NativeMethods
.GetKeyState(0x10) < 0 ? PanelKey.ShiftTab : PanelKey.Tab,
916
case
NativeMethods
.WmActivate when (wParam & 0xFFFF) == 0 && _previewExport is null:
921
case
NativeMethods
.WmDpiChanged when _panelVisible:
924
case
NativeMethods
.WmGetObject when unchecked((int)lParam) ==
NativeMethods
.UiaRootObjectId:
930
return
NativeMethods
.DefWindowProc(window, message, wParam, lParam);
937
Cleanup(
NativeMethods
.DestroyWindow(_panelTooltip) != 0, "DestroyWindow(flyout tooltip)");
944
Cleanup(
NativeMethods
.DestroyWindow(_panelWindow) != 0, "DestroyWindow(flyout)");
949
Cleanup(
NativeMethods
.UnregisterClass(PanelClassName, _module) != 0, "UnregisterClassW(flyout)");
954
Cleanup(
NativeMethods
.DeleteObject(font) != 0, "DeleteObject(flyout font)");
959
Cleanup(
NativeMethods
.DestroyIcon(_panelLogo) != 0, "DestroyIcon(flyout logo)");
964
Cleanup(
NativeMethods
.DestroyIcon(icon) != 0, "DestroyIcon(application icon)");
969
NativeMethods
.GdiplusShutdown(_gdiplusToken);
997
return
NativeMethods
.DefWindowProc(window, message, wParam, lParam);
TrayApplication.PanelAutomation.cs (63)
40
return
NativeMethods
.UiaReturnRawElementProvider(window, wParam, lParam, provider);
66
var listening =
NativeMethods
.UiaClientsAreListening();
97
WithSimpleProvider(node,
NativeMethods
.UiaDisconnectProvider);
113
RaisePropertyChanged(node,
NativeMethods
.UiaToggleToggleStatePropertyId,
118
RaisePropertyChanged(node,
NativeMethods
.UiaNamePropertyId, ComVariant.Create(previous.Name), ComVariant.Create(element.Name));
129
var result =
NativeMethods
.UiaRaiseStructureChangedEvent(root,
NativeMethods
.StructureChangeType.ChildrenInvalidated, rootId, 2);
145
WithSimpleProvider(focused, provider =>
NativeMethods
.UiaRaiseAutomationEvent(provider,
NativeMethods
.UiaAutomationFocusChangedEventId));
153
WithSimpleProvider(node, provider =>
NativeMethods
.UiaRaiseAutomationPropertyChangedEvent(provider, property,
154
NativeMethods
.NativeVariant.From(oldValue),
NativeMethods
.NativeVariant.From(newValue)));
173
NativeMethods
.GetWindowRect(_panelWindow, out var window);
187
private
NativeMethods
.UiaRect ToScreenRect(PanelRect bounds)
189
NativeMethods
.GetWindowRect(_panelWindow, out var window);
216
NativeMethods
.UiaReturnRawElementProvider(_panelWindow, 0, 0, 0);
220
WithSimpleProvider(node,
NativeMethods
.UiaDisconnectProvider);
222
WithSimpleProvider(_automationRoot,
NativeMethods
.UiaDisconnectProvider);
230
private static
NativeMethods
.ToggleState ToToggleState(bool? value) => value == true ?
NativeMethods
.ToggleState.On :
NativeMethods
.ToggleState.Off;
271
public
NativeMethods
.ProviderOptions get_ProviderOptions() =>
NativeMethods
.ProviderOptions.ServerSideProvider;
279
NativeMethods
.UiaControlTypePropertyId => Variant(
NativeMethods
.UiaPaneControlTypeId),
280
NativeMethods
.UiaNamePropertyId => Variant("Aspire"),
281
NativeMethods
.UiaFrameworkIdPropertyId => Variant("Aspire"),
289
Marshal.ThrowExceptionForHR(
NativeMethods
.UiaHostProviderFromHwnd(owner._panelWindow, out var host));
293
public IRawElementProviderFragment? Navigate(
NativeMethods
.NavigateDirection direction) => direction switch
295
NativeMethods
.NavigateDirection.FirstChild => owner._automationOrder.FirstOrDefault(),
296
NativeMethods
.NavigateDirection.LastChild => owner._automationOrder.LastOrDefault(),
302
public
NativeMethods
.UiaRect get_BoundingRectangle() => default;
330
public
NativeMethods
.ProviderOptions get_ProviderOptions() =>
NativeMethods
.ProviderOptions.ServerSideProvider;
338
(
NativeMethods
.UiaInvokePatternId, PanelAccessibleRole.Button) => (nint)ComInterfaceMarshaller<IInvokeProvider>.ConvertToUnmanaged(this),
339
(
NativeMethods
.UiaTogglePatternId, PanelAccessibleRole.Switch) => (nint)ComInterfaceMarshaller<IToggleProvider>.ConvertToUnmanaged(this),
349
return
NativeMethods
.UiaElementNotAvailable;
354
NativeMethods
.UiaControlTypePropertyId => Variant(element.Role switch
356
PanelAccessibleRole.Switch =>
NativeMethods
.UiaCheckBoxControlTypeId,
357
PanelAccessibleRole.Text =>
NativeMethods
.UiaTextControlTypeId,
358
_ =>
NativeMethods
.UiaButtonControlTypeId
360
NativeMethods
.UiaNamePropertyId => Variant(element.Name),
361
NativeMethods
.UiaAutomationIdPropertyId => Variant(element.Target?.Kind.ToString() ?? element.Key.Label),
362
NativeMethods
.UiaHelpTextPropertyId => Variant(element.Description),
363
NativeMethods
.UiaIsEnabledPropertyId => Variant(element.Enabled),
364
NativeMethods
.UiaIsKeyboardFocusablePropertyId => Variant(element.Target is { Enabled: true }),
365
NativeMethods
.UiaHasKeyboardFocusPropertyId => Variant(IsFocused),
366
NativeMethods
.UiaIsOffscreenPropertyId => Variant(element.IsOffscreen),
367
NativeMethods
.UiaFrameworkIdPropertyId => Variant("Aspire"),
375
public IRawElementProviderFragment? Navigate(
NativeMethods
.NavigateDirection direction)
382
NativeMethods
.NavigateDirection.Parent => owner._automationRoot,
383
NativeMethods
.NavigateDirection.NextSibling when index >= 0 && index + 1 < siblings.Count => siblings[index + 1],
384
NativeMethods
.NavigateDirection.PreviousSibling when index > 0 => siblings[index - 1],
393
var array =
NativeMethods
.SafeArrayCreateVector(3, 0, 2); // VT_I4
398
Marshal.ThrowExceptionForHR(
NativeMethods
.SafeArrayAccessData(array, out var data));
399
((int*)data)[0] =
NativeMethods
.UiaAppendRuntimeId;
401
Marshal.ThrowExceptionForHR(
NativeMethods
.SafeArrayUnaccessData(array));
405
public
NativeMethods
.UiaRect get_BoundingRectangle()
433
if (
NativeMethods
.PostMessage(owner._panelWindow, WmPanelAutomationInvoke, (nuint)id, 0) == 0)
446
public
NativeMethods
.ToggleState get_ToggleState()
456
Marshal.ThrowExceptionForHR(
NativeMethods
.UiaElementNotAvailable);
466
Marshal.ThrowExceptionForHR(
NativeMethods
.UiaElementNotAvailable);
470
Marshal.ThrowExceptionForHR(
NativeMethods
.UiaElementNotEnabled);