public ControlWindow() { InitializeComponent(); _scoreboardData = ScoreboardContainer.Container.GetInstance <IScoreboardData>(); _scoreboardData.ScoreboardBoxFont.FontSize = 150; for (int i = 100; i >= 0; i--) { ScoreboardBoxOpacity.Items.Add(String.Format("{0}%", i)); ScoreboardBoxBorderOpacity.Items.Add(String.Format("{0}%", i)); } ScoreboardBoxOpacity.SelectedIndex = 0; ScoreboardBoxBorderOpacity.SelectedIndex = 0; ScoreFont.SetFontSizes(20, 300); ScoreFont.FontSize = 150; ClockFont.SetFontSizes(20, 300); ClockFont.FontSize = 80; Title.SetFontSizes(20, 300); Title.FontSize = 100; Title.OnSetButtonClicked += Title_OnSetButtonClicked; ScoreFont.OnSetButtonClicked += ScoreFont_OnSetButtonClicked; ClockFont.OnSetButtonClicked += ClockFont_OnSetButtonClicked; TeamOneName.OnSetButtonClicked += TeamOneName_OnSetButtonClicked; TeamTwoName.OnSetButtonClicked += TeamTwoName_OnSetButtonClicked; }
/// <summary>Render the clock (for the first time)</summary> public void Render() { Init(); SetColor(); ClearClock(); ClockFont.DrawText(RenderedTime, LeftPos, TopPos); RenderDate(); ResetColor(); }
/// <summary>Re-render the clock </summary> public void Rerender() { //First lets verify if the new DisplayTime is equal to the already rendered time string DisplayTime = PrepareRenderedTime(); string DisplayDate = PrepareRenderedDate(); if (RenderedTime.Length != DisplayTime.Length || RenderedDate.Length != DisplayDate.Length) { SetColor(); ClearClock(); ResetColor(); Render(); return; } //If they're different length, a setting has changed. Redraw the whole thing. if (RenderedTime == DisplayTime && RenderedDate == DisplayDate) { return; } //no changes need to be made SetColor(); if (RenderedTime != DisplayTime) { //Time to hunt for the differences for (int i = RenderedTime.Length - 1; i > -1; i--) { if (RenderedTime[i] != ' ' && DisplayTime[i] == ' ') { Draw.Box(Console.BackgroundColor, ClockFont.Width, ClockFont.Height, LeftPos + CalculateLeftposAdjustment(i), TopPos); } //If what is rendered isn't a space, but what is to be rendered *is* a space, draw a box. if (RenderedTime[i] != DisplayTime[i]) { ClockFont.DrawText("" + DisplayTime[i], LeftPos + CalculateLeftposAdjustment(i), TopPos); } //render only the changed text } RenderedTime = DisplayTime; //Save the new rendered time. } if (RenderedDate != DisplayDate) { ClearDate(); RenderedDate = DisplayTime; RenderDate(); } ResetColor(); }