-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWPopupPlayer.xaml.cs
124 lines (107 loc) · 3.19 KB
/
WPopupPlayer.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
using CustomToolbox.Common.Extensions;
using CustomToolbox.Common.Sets;
using MouseEventArgs = System.Windows.Forms.MouseEventArgs;
using Serilog.Events;
using System.ComponentModel;
using System.Windows;
using System.Windows.Forms.Integration;
namespace CustomToolbox;
/// <summary>
/// WPopupPlayer.xaml 的互動邏輯
/// </summary>
public partial class WPopupPlayer : Window
{
/// <summary>
/// WMain
/// </summary>
private readonly WMain _WMain;
/// <summary>
/// WFHContainer
/// </summary>
private readonly WindowsFormsHost _WFHContainer;
/// <summary>
/// PlayerHost
/// </summary>
private readonly Panel _PlayerHost;
/// <summary>
/// TTTips
/// </summary>
private readonly ToolTip _TTTips;
public WPopupPlayer(WMain window)
{
InitializeComponent();
_WMain = window;
_WFHContainer = _WMain.WFHContainer;
_PlayerHost = _WMain.PlayerHost;
_TTTips = _WMain.TTTips;
KeyDown += _WMain.WMain_KeyDown;
}
private void WPopupPlayer_Loaded(object sender, RoutedEventArgs e)
{
try
{
Dispatcher.BeginInvoke(new Action(() =>
{
Title = _WMain.Title;
Icon = _WMain.Icon;
WFHContainer.Child = _PlayerHost;
_WFHContainer.Child = null;
Panel PPlaceholder = new()
{
BackColor = Color.Gray,
Dock = DockStyle.Fill
};
_TTTips.SetToolTip(PPlaceholder, MsgSet.MsgDoubleClickToTogglePopupWindow);
PPlaceholder.MouseDoubleClick += PPlaceholder_MouseDoubleClick;
_WFHContainer.Child = PPlaceholder;
}));
}
catch (Exception ex)
{
_WMain?.WriteLog(
message: MsgSet.GetFmtStr(
MsgSet.MsgErrorOccured,
ex.GetExceptionMessage()),
logEventLevel: LogEventLevel.Error);
}
}
private void WPopupPlayer_Closing(object sender, CancelEventArgs e)
{
try
{
Dispatcher.BeginInvoke(new Action(() =>
{
KeyDown -= _WMain.WMain_KeyDown;
_WFHContainer.Child = null;
_WFHContainer.Child = WFHContainer.Child;
WFHContainer.Child = null;
}));
}
catch (Exception ex)
{
_WMain?.WriteLog(
message: MsgSet.GetFmtStr(
MsgSet.MsgErrorOccured,
ex.GetExceptionMessage()),
logEventLevel: LogEventLevel.Error);
}
}
private void PPlaceholder_MouseDoubleClick(object? sender, MouseEventArgs e)
{
try
{
Dispatcher.BeginInvoke(new Action(() =>
{
_WMain.PlayerHost_MouseDoubleClick(sender, e);
}));
}
catch (Exception ex)
{
_WMain?.WriteLog(
message: MsgSet.GetFmtStr(
MsgSet.MsgErrorOccured,
ex.GetExceptionMessage()),
logEventLevel: LogEventLevel.Error);
}
}
}