本文主要是介绍做一个桌面悬浮翻页时钟,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
毛玻璃效果翻页桌面悬浮时钟,TopMost(Topmost=“True”),不在任务栏显示(ShowInTaskbar=“False”),在托盘区显示图标,双击托盘区图标实现最小化和还原,右键托盘图标可选“最小化”和“退出”
1.安装HandyControl
2.前端代码
<Windowx:Class="IClock.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:hc="https://handyorg.github.io/handycontrol"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"Title="IClock"Width="300"Height="80"AllowsTransparency="True"Background="Transparent"Icon="/clock.png"ShowInTaskbar="False"Topmost="True"WindowStyle="None"mc:Ignorable="d"><Window.Resources><ContextMenux:Key="ContextMenu"Width="160"><MenuItemClick="Min"Header="最小化" /><MenuItemClick="Exit"Header="退出软件" /></ContextMenu></Window.Resources><Grid><hc:NotifyIconContextMenu="{StaticResource ContextMenu}"Icon="/clock.png"MouseDoubleClick="NotifyIcon_MouseDoubleClick"Text="IClock"Visibility="Visible" /><Border CornerRadius="10"Background="White"Opacity="0.4" /><StackPanelHorizontalAlignment="Center"VerticalAlignment="Center"><Viewbox><hc:FlipClockMargin="10"MouseLeftButtonDown="FlipClock_MouseLeftButtonDown" /></Viewbox></StackPanel></Grid>
</Window>
3.后端代码
public partial class MainWindow : Window{public MainWindow(){InitializeComponent();}private void Exit(object sender, RoutedEventArgs e){Close();}private void Min(object sender, RoutedEventArgs e){WindowState = WindowState.Minimized;}private void NotifyIcon_MouseDoubleClick(object sender, RoutedEventArgs e){WindowState = WindowState == WindowState.Minimized ? WindowState.Normal : WindowState.Minimized;}private void FlipClock_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e){this.DragMove();}}
4.源代码
【免费】wpf桌面悬浮时钟源代码资源-CSDN文库
这篇关于做一个桌面悬浮翻页时钟的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!