public LyricsWindow(LyricsSetting lyricsSetting = null) { this.InitializeComponent(); // 在此点之下插入创建对象所需的代码。 _wrongFontGeometry = (Geometry)FindResource("WrongFontGeometry"); LyricsSetting = lyricsSetting; ChangeLyricsStoryboard = (Storyboard)FindResource("ChangeLyricsStoryboard"); HideLyricsStoryboard = (Storyboard)FindResource("HideLyricsStoryboard"); this.SourceInitialized += new EventHandler((o, e) => { var hwnd = new WindowInteropHelper(this).Handle; int extendedStyle = NativeMethods.GetWindowLong(hwnd, GWL.EXSTYLE); NativeMethods.SetWindowLong(hwnd, GWL.EXSTYLE, extendedStyle //鼠标穿透 | WS.EX.TRANSPARENT //在按下Alt+Tab时不显示 | WS.EX.TOOLWINDOW); }); //更新歌词前景色 UpdateForegroundSetting(); //更新窗口大小和位置 UpdateSizeAndLocation(); //监听Windows的显示设置,当分辨率改变或任务栏位置和大小改变时,能够调整歌词位置 Screen.DisplayChanged += (sender, e) => UpdateSizeAndLocation(); //将歌词窗口的属性与设置绑定 Binding binding = new Binding(); binding.Source = LyricsSetting; binding.Path = new PropertyPath(DoubanFM.LyricsSetting.FontFamilyProperty); this.SetBinding(LyricsFontFamilyProperty, binding); Binding binding2 = new Binding(); binding2.Source = LyricsSetting; binding2.Path = new PropertyPath(DoubanFM.LyricsSetting.FontSizeProperty); this.SetBinding(LyricsFontSizeProperty, binding2); Binding binding3 = new Binding(); binding3.Source = LyricsSetting; binding3.Path = new PropertyPath(DoubanFM.LyricsSetting.FontWeightProperty); binding3.Converter = new OpenTypeWeightToFontWeightConverter(); this.SetBinding(LyricsFontWeightProperty, binding3); Binding binding4 = new Binding(); binding4.Source = LyricsSetting; binding4.Path = new PropertyPath(DoubanFM.LyricsSetting.StrokeWeightProperty); this.SetBinding(LyricsStrokeWeightProperty, binding4); }
public LyricsSettingWindow(LyricsSetting setting) { LyricsSetting = setting; InitializeComponent(); this.Closed += delegate { if (CbShowLyricsBackground.IsChecked == true) { (Owner as DoubanFMWindow)._lyricsWindow.HideBoundary(); } }; UpdateComboBoxOutputScreen(); }
protected LyricsSetting(SerializationInfo info, StreamingContext context) { LyricsSetting def = new LyricsSetting(); try { FontFamily = new FontFamily(info.GetString("FontFamily")); } catch { } try { FontSize = info.GetDouble("FontSize"); } catch { } try { FontWeight = info.GetInt32("FontWeight"); } catch { } try { StrokeWeight = info.GetDouble("StrokeWeight"); } catch { } try { TopMargin = info.GetDouble("TopMargin"); } catch { } try { BottomMargin = info.GetDouble("BottomMargin"); } catch { } try { LeftMargin = info.GetDouble("LeftMargin"); } catch { } try { RightMargin = info.GetDouble("RightMargin"); } catch { } try { EnableDesktopLyrics = info.GetBoolean("EnableDesktopLyrics"); } catch { } try { EnableEmbeddedLyrics = info.GetBoolean("EnableEmbeddedLyrics"); } catch { } try { Opacity = info.GetDouble("Opacity"); } catch { } try { Foreground = (Color)ColorConverter.ConvertFromString(info.GetString("Foreground")); } catch { } try { StrokeColor = (Color)ColorConverter.ConvertFromString(info.GetString("StrokeColor")); } catch { } try { ShadowColor = (Color)ColorConverter.ConvertFromString(info.GetString("ShadowColor")); } catch { } try { AutoForeground = info.GetBoolean("AutoForeground"); } catch { } try { SingleLineLyrics = info.GetBoolean("SingleLineLyrics"); } catch { } try { HorizontalAlignment = (HorizontalAlignment)info.GetValue("HorizontalAlignment", typeof(HorizontalAlignment)); } catch { } try { VerticalAlignment = (VerticalAlignment)info.GetValue("VerticalAlignment", typeof(VerticalAlignment)); } catch { } try { ForceTopMost = info.GetBoolean("ForceTopMost"); } catch { } try { HideWhenPause = info.GetBoolean("HideWhenPause"); } catch { } try { DesktopLyricsScreen = info.GetString("DesktopLyricsScreen"); } catch { } }
/// <summary> /// 加载设置 /// </summary> internal static LyricsSetting Load() { LyricsSetting setting = null; try { using (FileStream stream = File.OpenRead(Path.Combine(_dataFolder, "LyricsSetting.dat"))) { BinaryFormatter formatter = new BinaryFormatter(); setting = (LyricsSetting)formatter.Deserialize(stream); } } catch { setting = new LyricsSetting(); } return(setting); }
/// <summary> /// 加载设置 /// </summary> internal static LyricsSetting Load() { LyricsSetting setting = null; try { using (FileStream stream = File.OpenRead(Path.Combine(_dataFolder, "LyricsSetting.dat"))) { BinaryFormatter formatter = new BinaryFormatter(); setting = (LyricsSetting)formatter.Deserialize(stream); } } catch { setting = new LyricsSetting(); } return setting; }