forked from LiteCoder/DoubanFM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLyricsSettingWindow.xaml.cs
140 lines (120 loc) · 3.83 KB
/
LyricsSettingWindow.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/*
* Author : K.F.Storm
* Email : yk000123 at sina.com
* Website : http://www.kfstorm.com
* */
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
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;
namespace DoubanFM
{
/// <summary>
/// 歌词设置窗口
/// </summary>
public partial class LyricsSettingWindow : ChildWindowBase
{
public static readonly DependencyProperty LyricsSettingProperty = DependencyProperty.Register("LyricsSetting", typeof(LyricsSetting), typeof(LyricsSettingWindow));
public LyricsSetting LyricsSetting
{
get { return (LyricsSetting)GetValue(LyricsSettingProperty); }
set { SetValue(LyricsSettingProperty, value); }
}
public LyricsSettingWindow(LyricsSetting setting)
{
LyricsSetting = setting;
InitializeComponent();
this.Closed += delegate
{
if (CbShowLyricsBackground.IsChecked == true)
{
(Owner as DoubanFMWindow)._lyricsWindow.HideBoundary();
}
};
UpdateComboBoxOutputScreen();
}
private void CbShowLyrics_Checked(object sender, RoutedEventArgs e)
{
(Owner as DoubanFMWindow).ShowLyrics();
}
private void CbShowLyrics_Unchecked(object sender, RoutedEventArgs e)
{
(Owner as DoubanFMWindow).HideLyrics();
}
private void CbEnableDesktopLyrics_Checked(object sender, RoutedEventArgs e)
{
if ((FindResource("Player") as Core.Player).Settings.ShowLyrics)
(Owner as DoubanFMWindow).ShowDesktopLyrics();
}
private void CbEnableDesktopLyrics_Unchecked(object sender, RoutedEventArgs e)
{
(Owner as DoubanFMWindow).HideDesktopLyrics();
}
private void CbEnableEmbeddedLyrics_Checked(object sender, RoutedEventArgs e)
{
if ((FindResource("Player") as Core.Player).Settings.ShowLyrics)
(Owner as DoubanFMWindow).ShowEmbeddedLyrics();
}
private void CbEnableEmbeddedLyrics_Unchecked(object sender, RoutedEventArgs e)
{
(Owner as DoubanFMWindow).HideEmbeddedLyrics();
}
private void CbAutoForeground_Click(object sender, RoutedEventArgs e)
{
(Owner as DoubanFMWindow)._lyricsWindow.UpdateForegroundSetting();
}
private void CbShowLyricsBackground_Click(object sender, RoutedEventArgs e)
{
if (CbShowLyricsBackground.IsChecked == true)
{
(Owner as DoubanFMWindow)._lyricsWindow.ShowBoundary();
}
else
{
(Owner as DoubanFMWindow)._lyricsWindow.HideBoundary();
}
}
private void UpdateComboBoxOutputScreen()
{
pauseUpdateSizeAndLocation = true;
cbOutputScreen.Items.Clear();
var screens = Screen.AllScreens;
for (var i = 0; i < screens.Length; ++i)
{
cbOutputScreen.Items.Add(new ComboBoxItem() { Content = string.Format(DoubanFM.Resources.Resources.OutputScreenFormatString, i + 1), Tag = screens[i].DeviceName });
if (screens[i].DeviceName == LyricsSetting.DesktopLyricsScreen)
{
cbOutputScreen.SelectedIndex = i;
}
if (cbOutputScreen.SelectedItem == null && screens[i].Primary)
{
cbOutputScreen.SelectedIndex = i;
}
}
if (cbOutputScreen.SelectedItem != null)
{
LyricsSetting.DesktopLyricsScreen = (cbOutputScreen.SelectedItem as ComboBoxItem).Tag as string;
((DoubanFMWindow)Owner)._lyricsWindow.UpdateSizeAndLocation();
}
pauseUpdateSizeAndLocation = false;
}
private bool pauseUpdateSizeAndLocation = false;
private void cbOutputScreen_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (pauseUpdateSizeAndLocation) return;
if (e.AddedItems.Count <= 0) return;
var deviceName = ((ComboBoxItem)e.AddedItems[0]).Tag as string;
LyricsSetting.DesktopLyricsScreen = deviceName;
((DoubanFMWindow)Owner)._lyricsWindow.UpdateSizeAndLocation();
}
}
}