-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
更新Wpf UI版本从3.05至4.0
- Loading branch information
Showing
5 changed files
with
119 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<UserControl x:Class="Desktop.NotifyIcon" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:tray="http://schemas.lepo.co/wpfui/2022/xaml/tray" | ||
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml" | ||
> | ||
<tray:NotifyIcon | ||
TooltipText="DDTV" | ||
Icon="pack://application:,,,/Assets/DDTV.ico" | ||
Visibility="Visible" | ||
LeftClick="NotifyIcon_Click"> | ||
|
||
<tray:NotifyIcon.Menu> | ||
<ContextMenu> | ||
<MenuItem Name="exitMenu" Header="退出"/> | ||
<MenuItem Name="forceShowMenu" Header="强制显示" /> | ||
</ContextMenu> | ||
</tray:NotifyIcon.Menu> | ||
</tray:NotifyIcon> | ||
</UserControl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
using Desktop.Views.Pages; | ||
using Core; | ||
using Core.LogModule; | ||
using Core.RuntimeObject; | ||
using Desktop.Models; | ||
using Desktop.Views.Pages; | ||
using Desktop.Views.Windows; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Data; | ||
using System.Windows.Documents; | ||
using System.Windows.Input; | ||
using System.Windows.Media; | ||
using System.Windows.Media.Imaging; | ||
using System.Windows.Shapes; | ||
using Wpf.Ui.Controls; | ||
|
||
namespace Desktop | ||
{ | ||
public partial class NotifyIcon | ||
{ | ||
public NotifyIcon() | ||
{ | ||
InitializeComponent(); | ||
initMenu(); | ||
} | ||
private void initMenu() | ||
{ | ||
exitMenu.Click += RightClickExit; | ||
forceShowMenu.Click += rightClickForceShow; | ||
|
||
} | ||
private void RightClickExit(object sender, RoutedEventArgs e) | ||
{ | ||
if (!MainWindow.IsProgrammaticClose) | ||
{ | ||
System.Windows.MessageBoxResult result = MessageBox.Show("确认要关闭DDTV吗?\r\n关闭后所有录制任务以及播放窗口均会结束。", "关闭确认", System.Windows.MessageBoxButton.YesNo, System.Windows.MessageBoxImage.Question); | ||
if (result == System.Windows.MessageBoxResult.Yes) | ||
{ | ||
DataPage.Timer_DataPage?.Dispose(); | ||
DataSource.LoginStatus.Timer_LoginStatus?.Dispose(); | ||
Environment.Exit(-114514); | ||
} | ||
} | ||
} | ||
|
||
private void rightClickForceShow(object sender, RoutedEventArgs e) | ||
{ | ||
MainWindow mainWindow = Application.Current.MainWindow as MainWindow; | ||
if (mainWindow != null) | ||
{ | ||
mainWindow.Show(); | ||
mainWindow.WindowState = WindowState.Normal; | ||
mainWindow.Left = (SystemParameters.PrimaryScreenWidth - mainWindow.ActualWidth) / 2; | ||
mainWindow.Top = (SystemParameters.PrimaryScreenHeight - mainWindow.ActualHeight) / 2; | ||
mainWindow.Activate(); | ||
} | ||
} | ||
private void NotifyIcon_Click(object? sender, EventArgs e) | ||
{ | ||
MainWindow mainWindow = Application.Current.MainWindow as MainWindow; | ||
mainWindow.Show(); | ||
mainWindow.WindowState = WindowState.Normal; | ||
} | ||
} | ||
|
||
} |