** Proyek ini merupakan kelanjutan dari proyek dasar yang tidak aktif ke platform lain (WinUI/Uno.Skia.Wpf/Console) - https://github.com/hardcodet/wpf-notifyicon **
Ini adalah implementasi dari NotifyIcon (alias ikon baki sistem atau ikon bilah tugas) untuk platform .Net 6 WPF/WinUI/Uno.Skia.WPF/Console. Itu tidak hanya mengandalkan komponen Windows Forms NotifyIcon, namun merupakan kontrol independen murni yang memanfaatkan beberapa fitur kerangka WPF/WinUI untuk menampilkan tooltips yang kaya, popup, menu konteks, dan pesan balon. Itu dapat digunakan langsung dalam kode atau disematkan dalam file XAML apa pun.
Install-Package H.NotifyIcon.Wpf
Install-Package H.NotifyIcon.WinUI
Install-Package H.NotifyIcon.Uno
Install-Package H.NotifyIcon.Uno.WinUI
# If you need other platforms, you can use this Core library -
# it allows you to make NotifyIcon even in a console application.
Install-Package H.NotifyIcon
< Window
xmlns : tb = " clr-namespace:H.NotifyIcon;assembly=H.NotifyIcon.Wpf " // WPF
xmlns : tb = " using:H.NotifyIcon " // WinUI
>
< tb : TaskbarIcon
ToolTipText = " ToolTip "
IconSource = " /Images/TrayIcons/Logo.ico "
ContextMenu = " {StaticResource TrayMenu} "
MenuActivation = " LeftOrRightClick "
TrayPopup = " {StaticResource TrayStatusPopup} "
PopupActivation = " DoubleClick "
TrayToolTip = " {StaticResource TrayToolTip} "
/>
</ Window >
Windows 11 memperkenalkan konsep baru yang disebut Mode Efisiensi.
Karena, pada dasarnya, perpustakaan ini ditujukan agar aplikasi ada di latar belakang dengan kemampuan berinteraksi melalui TrayIcon, perpustakaan mengimplementasikan API untuk mode ini:
EfficiencyModeUtilities . SetEfficiencyMode ( bool value )
WindowExtensions . Hide ( this Window window , enableEfficiencyMode : true ) // default value
WindowExtensions . Show ( this Window window , disableEfficiencyMode : true ) // default value
TaskbarIcon . ForceCreate ( bool enablesEfficiencyMode = true ) // default value
Contoh 1:
< tb : TaskbarIcon >
< tb : TaskbarIcon .IconSource>
< tb : GeneratedIconSource
Text = " "
Foreground = " Red "
/>
</ tb : TaskbarIcon .IconSource>
</ tb : TaskbarIcon >
Contoh 2:
< tb : TaskbarIcon
IconSource = " /Icons/Error.ico "
>
< tb : TaskbarIcon .IconSource>
< tb : GeneratedIconSource
Text = " 5 "
Foreground = " Black "
FontSize = " 36 "
FontWeight = " Bold "
/>
</ tb : TaskbarIcon .IconSource>
</ tb : TaskbarIcon >
Contoh 3:
< tb : TaskbarIcon >
< tb : TaskbarIcon .IconSource>
< tb : GeneratedIconSource
Text = " "
Foreground = " Red "
FontFamily = " Segoe UI Emoji "
Background = " AliceBlue "
FontWeight = " Bold "
FontSize = " 38 "
/>
</ tb : TaskbarIcon .IconSource>
</ tb : TaskbarIcon >
Contoh 4:
< tb : TaskbarIcon >
< tb : TaskbarIcon .IconSource>
< tb : GeneratedIconSource
Text = " "
BorderThickness = " 5 "
FontSize = " 46 "
>
< tb : GeneratedIconSource .Foreground>
< LinearGradientBrush StartPoint = " 0,0 " EndPoint = " 128,128 " >
< GradientStop Color = " White " />
< GradientStop Color = " Red " />
</ LinearGradientBrush >
</ tb : GeneratedIconSource .Foreground>
< tb : GeneratedIconSource .BorderBrush>
< LinearGradientBrush StartPoint = " 0,0 " EndPoint = " 128,128 " >
< GradientStop Color = " White " />
< GradientStop Color = " Red " />
</ LinearGradientBrush >
</ tb : GeneratedIconSource .BorderBrush>
</ tb : GeneratedIconSource >
</ tb : TaskbarIcon .IconSource>
</ tb : TaskbarIcon >
Disarankan untuk menyematkan ikon desainer agar mudah dilihat. Untuk melakukan ini, buka Pengaturan Taskbar -> Ikon baki sistem lainnya dan aktifkan ikon ini:
Saat ini, ada tiga mode yang diterapkan, masing-masing dengan kelebihan dan kekurangannya masing-masing.
Ketersediaan berbagai pilihan(tergantung pada versi WindowsAppSDK
yang Anda gunakan):
Pilihan | Aplikasi Terpaket | Aplikasi Tanpa Paket |
---|---|---|
Transparansi | dari 1.1.0-pratinjau | dari 1.1.0-pratinjau |
Tanpa batas | dari 1.1.0-pratinjau | |
Animasi | , tetapi dengan batas | dari 1.1.0-pratinjau |
Submenu |
Tempat prioritas untuk bug: https://github.com/HavenDV/H.NotifyIcon/issues Tempat prioritas untuk ide dan pertanyaan umum: https://github.com/HavenDV/H.NotifyIcon/discussions Saya juga punya Discord saluran dukungan:
https://discord.gg/g8u2t9dKgE