mirror of
https://gitee.com/handyorg/HandyControl.git
synced 2024-11-30 02:48:03 +08:00
init pr add-notifyicon
This commit is contained in:
parent
422b10d1f8
commit
cbb0bd0fc1
31
HandyControl/Controls/Other/NotifyIcon.cs
Normal file
31
HandyControl/Controls/Other/NotifyIcon.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Media;
|
||||
using HandyControl.Tools;
|
||||
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
public class NotifyIcon : FrameworkElement
|
||||
{
|
||||
private Popup _trayPopup;
|
||||
|
||||
private readonly object _syncObj = new object();
|
||||
|
||||
public static readonly DependencyProperty IconProperty = DependencyProperty.Register(
|
||||
"Icon", typeof(ImageSource), typeof(NotifyIcon), new PropertyMetadata(default(ImageSource)));
|
||||
|
||||
public ImageSource Icon
|
||||
{
|
||||
get => (ImageSource) GetValue(IconProperty);
|
||||
set => SetValue(IconProperty, value);
|
||||
}
|
||||
|
||||
private void UpdateIcon(bool showIconInTray)
|
||||
{
|
||||
lock (_syncObj)
|
||||
{
|
||||
if (DesignerHelper.IsInDesignMode) return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -112,6 +112,7 @@
|
||||
<Compile Include="Controls\Cover\CoverView\CoverView.cs" />
|
||||
<Compile Include="Controls\Other\ChatBubble.cs" />
|
||||
<Compile Include="Controls\Other\GotoTop.cs" />
|
||||
<Compile Include="Controls\Other\NotifyIcon.cs" />
|
||||
<Compile Include="Controls\Transfer\Transfer.cs" />
|
||||
<Compile Include="Controls\Transfer\TransferGroup.cs" />
|
||||
<Compile Include="Controls\Transfer\TransferItem.cs" />
|
||||
|
@ -10,13 +10,40 @@ using System.Threading;
|
||||
|
||||
namespace HandyControl.Tools
|
||||
{
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
internal class ExternDllHelper
|
||||
{
|
||||
private const string Gdi32 = "gdi32.dll";
|
||||
|
||||
private const string User32 = "user32.dll";
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
private const string Shell32 = "shell32.dll";
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
|
||||
public class NOTIFYICONDATA
|
||||
{
|
||||
public int cbSize = Marshal.SizeOf(typeof(NOTIFYICONDATA));
|
||||
public IntPtr hWnd;
|
||||
public int uID;
|
||||
public int uFlags;
|
||||
public int uCallbackMessage;
|
||||
public IntPtr hIcon;
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
|
||||
public string szTip;
|
||||
public int dwState = 0;
|
||||
public int dwStateMask = 0;
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
|
||||
public string szInfo;
|
||||
public int uTimeoutOrVersion;
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)]
|
||||
public string szInfoTitle;
|
||||
public int dwInfoFlags;
|
||||
}
|
||||
|
||||
[DllImport(Shell32, CharSet = CharSet.Auto)]
|
||||
[ResourceExposure(ResourceScope.None)]
|
||||
public static extern int Shell_NotifyIcon(int message, NOTIFYICONDATA pnid);
|
||||
|
||||
public const int E_FAIL = unchecked((int) 0x80004005);
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
|
@ -84,6 +84,8 @@
|
||||
|
||||
public static readonly string GotoTopDemoCtl = nameof(GotoTopDemoCtl);
|
||||
|
||||
public static readonly string NotifyIconDemoCtl = nameof(NotifyIconDemoCtl);
|
||||
|
||||
public static readonly string ButtonDemoCtl = nameof(ButtonDemoCtl);
|
||||
|
||||
public static readonly string ToggleButtonDemoCtl = nameof(ToggleButtonDemoCtl);
|
||||
|
@ -44,7 +44,8 @@ var controlList = new List<string>
|
||||
"ProgressButtonDemoCtl",
|
||||
"TransferDemoCtl",
|
||||
"ChatBubbleDemoCtl",
|
||||
"GotoTopDemoCtl"
|
||||
"GotoTopDemoCtl",
|
||||
"NotifyIconDemoCtl"
|
||||
};
|
||||
var styleList = new List<string>
|
||||
{
|
||||
|
@ -178,6 +178,9 @@
|
||||
<Compile Include="UserControl\Controls\GotoTopDemoCtl.xaml.cs">
|
||||
<DependentUpon>GotoTopDemoCtl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="UserControl\Controls\NotifyIconDemoCtl.xaml.cs">
|
||||
<DependentUpon>NotifyIconDemoCtl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="UserControl\Controls\OutlineTextDemoCtl.xaml.cs">
|
||||
<DependentUpon>OutlineTextDemoCtl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@ -495,6 +498,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="UserControl\Controls\NotifyIconDemoCtl.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="UserControl\Controls\OutlineTextDemoCtl.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
@ -753,6 +760,7 @@
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<LastGenOutput>MessageToken.cs</LastGenOutput>
|
||||
</Content>
|
||||
<Resource Include="Resources\Img\LeftMainContent\NotificationHub_16x.png" />
|
||||
<Resource Include="Resources\Img\LeftMainContent\GoToTop_16x.png" />
|
||||
<Resource Include="Resources\Img\LeftMainContent\Label_16x.png" />
|
||||
<Resource Include="Resources\Img\Chat\chat_back1.jpg" />
|
||||
|
11
HandyControlDemo/Properties/Langs/Lang.Designer.cs
generated
11
HandyControlDemo/Properties/Langs/Lang.Designer.cs
generated
@ -47,7 +47,7 @@ namespace HandyControlDemo.Properties.Langs {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写当前线程的 CurrentUICulture 属性
|
||||
/// 使用此强类型资源类,为所有资源查找
|
||||
/// 重写当前线程的 CurrentUICulture 属性。
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
@ -645,6 +645,15 @@ namespace HandyControlDemo.Properties.Langs {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 托盘图标 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string NotifyIcon {
|
||||
get {
|
||||
return ResourceManager.GetString("NotifyIcon", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 数值选择控件 的本地化字符串。
|
||||
/// </summary>
|
||||
|
@ -501,4 +501,7 @@
|
||||
<data name="GotoTop" xml:space="preserve">
|
||||
<value>GotoTop</value>
|
||||
</data>
|
||||
<data name="NotifyIcon" xml:space="preserve">
|
||||
<value>NotifyIcon</value>
|
||||
</data>
|
||||
</root>
|
@ -501,4 +501,7 @@
|
||||
<data name="GotoTop" xml:space="preserve">
|
||||
<value>回到顶部</value>
|
||||
</data>
|
||||
<data name="NotifyIcon" xml:space="preserve">
|
||||
<value>托盘图标</value>
|
||||
</data>
|
||||
</root>
|
Binary file not shown.
After Width: | Height: | Size: 335 B |
@ -2,8 +2,9 @@
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:userControl="clr-namespace:HandyControlDemo.UserControl"
|
||||
xmlns:controls="clr-namespace:HandyControl.Controls;assembly=HandyControl"
|
||||
Background="{DynamicResource RegionBrush}">
|
||||
<ContentControl>
|
||||
<controls:TransitioningContentControl>
|
||||
<StackPanel Orientation="Horizontal" Margin="32">
|
||||
<userControl:ChatBox>
|
||||
<userControl:ChatBox.Background>
|
||||
@ -16,5 +17,5 @@
|
||||
</userControl:ChatBox.Background>
|
||||
</userControl:ChatBox>
|
||||
</StackPanel>
|
||||
</ContentControl>
|
||||
</controls:TransitioningContentControl>
|
||||
</UserControl>
|
||||
|
@ -0,0 +1,8 @@
|
||||
<UserControl x:Class="HandyControlDemo.UserControl.NotifyIconDemoCtl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Background="{DynamicResource RegionBrush}">
|
||||
<Grid>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
@ -0,0 +1,10 @@
|
||||
namespace HandyControlDemo.UserControl
|
||||
{
|
||||
public partial class NotifyIconDemoCtl
|
||||
{
|
||||
public NotifyIconDemoCtl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
@ -203,6 +203,11 @@
|
||||
<Image Source="../../Resources/Img/LeftMainContent/Bubble_16xLG.png"/>
|
||||
</controls:EdgeElement.LeftContent>
|
||||
</ListBoxItem>
|
||||
<ListBoxItem Style="{StaticResource ListBoxItemNew}" Tag="{x:Static data:MessageToken.NotifyIconDemoCtl}" Content="{x:Static langs:Lang.NotifyIcon}">
|
||||
<controls:EdgeElement.LeftContent>
|
||||
<Image Source="../../Resources/Img/LeftMainContent/NotificationHub_16x.png"/>
|
||||
</controls:EdgeElement.LeftContent>
|
||||
</ListBoxItem>
|
||||
<ListBoxItem Tag="{x:Static data:MessageToken.NumericUpDownDemoCtl}" Content="{x:Static langs:Lang.NumericUpDown}">
|
||||
<controls:EdgeElement.LeftContent>
|
||||
<Image Source="../../Resources/Img/LeftMainContent/NumericListBox_16x.png"/>
|
||||
@ -303,7 +308,7 @@
|
||||
<Image Source="../../Resources/Img/LeftMainContent/DetailDataView_16x.png"/>
|
||||
</controls:EdgeElement.LeftContent>
|
||||
</ListBoxItem>
|
||||
<ListBoxItem Style="{StaticResource ListBoxItemNew}" Tag="{x:Static data:MessageToken.CoverFlowDemoCtl}" Content="{x:Static langs:Lang.CoverFlow}">
|
||||
<ListBoxItem Tag="{x:Static data:MessageToken.CoverFlowDemoCtl}" Content="{x:Static langs:Lang.CoverFlow}">
|
||||
<controls:EdgeElement.LeftContent>
|
||||
<Image Source="../../Resources/Img/LeftMainContent/LinearCarousel_16x.png"/>
|
||||
</controls:EdgeElement.LeftContent>
|
||||
@ -378,7 +383,7 @@
|
||||
<Image Source="../../Resources/Img/LeftMainContent/ScrollBox_16x.png"/>
|
||||
</controls:EdgeElement.LeftContent>
|
||||
</ListBoxItem>
|
||||
<ListBoxItem Style="{StaticResource ListBoxItemNew}" Tag="{x:Static data:MessageToken.WindowDemoCtl}" Content="{x:Static langs:Lang.Window}">
|
||||
<ListBoxItem Tag="{x:Static data:MessageToken.WindowDemoCtl}" Content="{x:Static langs:Lang.Window}">
|
||||
<controls:EdgeElement.LeftContent>
|
||||
<Image Source="../../Resources/Img/LeftMainContent/WindowsForm_16x.png"/>
|
||||
</controls:EdgeElement.LeftContent>
|
||||
|
Loading…
Reference in New Issue
Block a user