Files
2024-11-06 23:23:16 -05:00

67 lines
2.6 KiB
C#

using Basketball_Scoreboard_System.classes;
using Basketball_Scoreboard_System.forms;
using System.Drawing.Text;
using System.Media;
namespace Basketball_Scoreboard_System
{
internal static class Program
{
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern bool SetProcessDPIAware();
public static AudienceWindow AudienceWindow = new();
public static ControlPanel ControlPanel = new();
public static Team HomeTeam = new(true, false, true);
public static Team AwayTeam = new(false, true, false);
public static Clock MainClock = new(Settings.Default.MainClockDefaultTime, false, true);
public static Clock ShotClock = new(Settings.Default.ShotClockDefaultTime, true, false);
public static readonly SoundPlayer BuzzerMainClock = new(Properties.Resources.BuzzerMainClock);
public static readonly SoundPlayer BuzzerShotClock = new(Properties.Resources.BuzzerShotClock);
public static int Period = 1;
[STAThread]
private static void Main()
{
SetProcessDPIAware();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
if (!IsFontInstalled("DSEG7 Classic") || !IsFontInstalled("DSEG14 Classic") || !IsFontInstalled("Fira Mono")) MessageBox.Show("Required fonts are not installed.\nThey can be found in:\n" + Path.Combine(Application.StartupPath, "fonts\\"), "Warning", MessageBoxButtons.OK);
ApplicationConfiguration.Initialize();
Application.Run(AudienceWindow);
}
public static bool IsFontInstalled(string FontName)
{
InstalledFontCollection AllFonts = new();
foreach (FontFamily Font in AllFonts.Families)
{
if (Font.Name == FontName) return true;
}
return false;
}
public static Font GetFontSize(Graphics Graphics, string Text, Size MaxStringSize, Font LabelFont)
{
float MinSize = 0.1f;
float MaxSize = MaxStringSize.Width;
float FontSize = LabelFont.Size;
while (MaxSize - MinSize > MinSize)
{
FontSize = (MaxSize + MinSize) / 2;
Font Font = new(LabelFont.Name, FontSize);
SizeF Size = Graphics.MeasureString(Text, Font);
if (Size.Width > MaxStringSize.Width) MaxSize = FontSize;
else MinSize = FontSize;
}
return new Font(LabelFont.Name, FontSize);
}
}
}