-
Notifications
You must be signed in to change notification settings - Fork 1
/
MiniModePage.xaml.cs
executable file
·125 lines (110 loc) · 5.01 KB
/
MiniModePage.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
125
using SMPlayer.Controls;
using SMPlayer.Models;
using System;
using Windows.Foundation;
using Windows.UI.ViewManagement;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
// https://go.microsoft.com/fwlink/?LinkId=234238 上介绍了“空白页”项模板
namespace SMPlayer
{
/// <summary>
/// 可用于自身或导航至 Frame 内部的空白页。
/// </summary>
public sealed partial class MiniModePage : Page, IMainPageContainer
{
public static Size PageSize { get => new Size(300, 300); }
public static bool IsMiniMode
{
get => ApplicationView.GetForCurrentView().ViewMode != ApplicationViewMode.Default;
}
//public static Size PageSize { get => new Size(300, Settings.settings.MiniModeWithDropdown ? 900 : 300); }
public static ViewModePreferences ViewModePreferences
{
get
{
var pref = ViewModePreferences.CreateDefault(ApplicationViewMode.CompactOverlay);
pref.CustomSize = PageSize;
return pref;
}
}
public MiniModePage()
{
this.InitializeComponent();
var coreTitleBar = Windows.ApplicationModel.Core.CoreApplication.GetCurrentView().TitleBar;
// Register a handler for when the size of the overlaid caption control changes.
// For example, when the app moves to a screen with a different DPI.
coreTitleBar.LayoutMetricsChanged += (sender, args) => UpdateTitleBarLayout(sender);
// Register a handler for when the title bar visibility changes.
// For example, when the title bar is invoked in full screen mode.
coreTitleBar.IsVisibleChanged += (sender, args) => AppTitleBar.Visibility = sender.IsVisible ? Visibility.Visible : Visibility.Collapsed;
}
private void Page_Loaded(object sender, RoutedEventArgs e)
{
TitleBarHelper.SetDarkTitleBar();
Window.Current.SetTitleBar(AppTitleBar);
UpdateTitleBarLayout(Windows.ApplicationModel.Core.CoreApplication.GetCurrentView().TitleBar);
//DropdownButton.Content = Settings.settings.MiniModeWithDropdown ? "\uE70E" : "\uE70D";
}
private void UpdateTitleBarLayout(Windows.ApplicationModel.Core.CoreApplicationViewTitleBar coreTitleBar)
{
// Update title bar control size as needed to account for system size changes.
AppTitleBar.Height = coreTitleBar.Height;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
SpinArrowAnimation.Begin();
Settings.settings.MiniModeWithDropdown = !Settings.settings.MiniModeWithDropdown;
var size = PageSize;
ApplicationView.GetForCurrentView().SetPreferredMinSize(size);
ApplicationView.GetForCurrentView().TryResizeView(size);
}
public static async void EnterMiniMode()
{
if (!ApplicationView.GetForCurrentView().IsViewModeSupported(ApplicationViewMode.CompactOverlay))
{
Helper.ShowNotification("MiniModeFailed");
return;
}
(Window.Current.Content as Frame).Navigate(typeof(MiniModePage));
ApplicationView.GetForCurrentView().SetPreferredMinSize(PageSize);
await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.CompactOverlay, ViewModePreferences);
}
public static async void ExitMiniMode()
{
(Window.Current.Content as Frame).GoBack();
ApplicationView.GetForCurrentView().SetPreferredMinSize(new Size());
await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.Default);
}
void IMainPageContainer.ShowNotification(string message, int duration)
{
}
void IMainPageContainer.ShowButtonedNotification(string message, string button, Action<InAppNotificationWithButton> action, int duration)
{
}
void IMainPageContainer.ShowButtonedNotification(string message, string button1, Action<InAppNotificationWithButton> action1, string button2, Action<InAppNotificationWithButton> action2, int duration)
{
}
void IMainPageContainer.ShowMultiSelectCommandBar(MultiSelectCommandBarOption option)
{
}
void IMainPageContainer.CancelMultiSelectCommandBar()
{
}
void IMainPageContainer.SetMultiSelectListener(IMultiSelectListener listener)
{
}
MediaElement IMainPageContainer.GetMediaElement()
{
return mediaElement;
}
MultiSelectCommandBar IMainPageContainer.GetMultiSelectCommandBar()
{
return null;
}
MediaControl IMainPageContainer.GetMediaControl()
{
return MiniMediaControl;
}
}
}