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 { } }
/// <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); }