/// <summary> /// Set font of homework text. /// </summary> /// <param name="target">The target of this change. <see cref="FontTarget"/>.</param> /// <param name="font">The new font. <see cref="FontGroup"/>.</param> /// <param name="save">If true, this change will be saved.</param> public static void SetFont(FontTarget target, FontGroup font, bool save = true) { if (font == null) { return; } switch (target) { case FontTarget.NormalHomeworks: Global.userData.settings.fonts.NormalHomeworksFont = font; break; case FontTarget.Tests: Global.userData.settings.fonts.TestsFont = font; break; case FontTarget.subjects: Global.userData.settings.fonts.SubjectsFont = font; break; default: throw new Exception("FontTarget value \"" + target + "\" isn't known (SettingsManager.SetFont)"); } HomeworkManager.RefontViewers(); EventsManager.Call_FontChanged(target, font); if (save) { Save.SaveData(); } }
private static FontSize GetFontSize(FontTarget target) { switch (Settings.Current.FontSize) { case FontSizeMultiplier.X1: switch (target) { case FontTarget.Game: return(FontSize.X050); case FontTarget.Interface: return(FontSize.X075); default: throw new ApplicationException($"Unrecognized font size: {target}"); } case FontSizeMultiplier.X2: switch (target) { case FontTarget.Game: return(FontSize.X075); case FontTarget.Interface: return(FontSize.X1); default: throw new ApplicationException($"Unrecognized font size: {target}"); } default: throw new ApplicationException($"Unrecognized font size multiplier: {Settings.Current.FontSize}"); } }
protected GameViewBase(ILog log, FontTarget font = FontTarget.Interface) : base( log, FontProvider.GetScreenWidth(font), FontProvider.GetScreenHeight(font), FontProvider.GetFont(font)) { }
public static Font GetFont(FontTarget target) { var fontSize = GetFontSize(target); return(GetFontForSize(fontSize)); }
private static int GetFontSizePixels(FontTarget target) { var fontSize = GetFontSize(target); return(GetFontPixels(fontSize)); }
public static int GetScreenHeight(FontTarget fontTarget) { var heightInPx = BaseScreenHeight * GetFontSizePixels(FontTarget.Game); return((int)Math.Floor(heightInPx / (double)GetFontSizePixels(fontTarget))); }
public static int GetScreenWidth(FontTarget fontTarget) { var widthInPx = BaseScreenWidth * GetFontSizePixels(FontTarget.Game); return((int)Math.Floor(widthInPx / (double)GetFontSizePixels(fontTarget))); }
/// <summary> /// Invoke FontChanged event /// </summary> /// <param name="target">Type of element of this font (homework, test, subject)</param> /// <param name="font">New font</param> internal static void Call_FontChanged(FontTarget target, FontGroup font) { FontChanged?.Invoke(target, font); }
protected GameViewBase(FontTarget font = FontTarget.Interface) : this( (ILog)LogManager.GetLog <GameViewBase>(), font) { }