221 lines
6.6 KiB
C#
221 lines
6.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Diagnostics;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Klokkeprogram
|
|
{
|
|
public partial class controlPanel : Form
|
|
{
|
|
private displayWindow DWindow = new displayWindow();
|
|
public controlPanel()
|
|
{
|
|
InitializeComponent();
|
|
DWindow.Show();
|
|
tickTimer.Start();
|
|
}
|
|
|
|
private void Form1_Load(object sender, EventArgs e)
|
|
{}
|
|
|
|
private void teamOneLogoButton_Click(object sender, EventArgs e)
|
|
{
|
|
if (logoDialog.ShowDialog() == DialogResult.OK)
|
|
{
|
|
DWindow.teamOneLogo.Load(logoDialog.FileName);
|
|
}
|
|
}
|
|
|
|
private void teamTwoLogoButton_Click(object sender, EventArgs e)
|
|
{
|
|
if(logoDialog.ShowDialog() == DialogResult.OK)
|
|
{
|
|
DWindow.teamTwoLogo.Load(logoDialog.FileName);
|
|
}
|
|
}
|
|
private int teamOneGoal = 0;
|
|
private int teamTwoGoal = 0;
|
|
private void teamOneMinus_Click(object sender, EventArgs e)
|
|
{
|
|
if (teamOneGoal <= 0)
|
|
{
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
teamOneGoal = teamOneGoal - 1;
|
|
}
|
|
}
|
|
|
|
private void teamOnePlus_Click(object sender, EventArgs e)
|
|
{
|
|
teamOneGoal++;
|
|
}
|
|
|
|
private void teamTwoMinus_Click(object sender, EventArgs e)
|
|
{
|
|
if(teamTwoGoal <= 0)
|
|
{
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
teamTwoGoal--;
|
|
}
|
|
}
|
|
|
|
private void teamTwoPlus_Click(object sender, EventArgs e)
|
|
{
|
|
teamTwoGoal++;
|
|
}
|
|
private System.Diagnostics.Stopwatch Timer = new System.Diagnostics.Stopwatch();
|
|
private bool halfPassed = false; // Halftime
|
|
int maxMin = 90;
|
|
|
|
// Offset
|
|
private int offsetMin = 0;
|
|
private int offsetSec = 0;
|
|
|
|
private void tickTimer_Tick(object sender, EventArgs e)
|
|
{
|
|
TimeSpan TS = Timer.Elapsed;
|
|
int halfMin = maxMin / 2;
|
|
int hourMin = TS.Hours * 60;
|
|
int Minutes = TS.Minutes + hourMin + offsetMin;
|
|
int seconds = TS.Seconds + offsetSec;
|
|
|
|
if (seconds >= 60)
|
|
{
|
|
seconds = seconds - 60;
|
|
Minutes++;
|
|
}
|
|
|
|
string elapsedTime = String.Format("{0:00}:{1:00}", Minutes, seconds);
|
|
DWindow.clockLabel.Text = elapsedTime;
|
|
Debug.WriteLine("Elapsed time: " + elapsedTime);
|
|
|
|
if ( Minutes == halfMin && seconds == 0 && halfPassed == false )
|
|
{
|
|
Timer.Stop();
|
|
halfPassed = true;
|
|
}
|
|
else if ( Minutes == maxMin && seconds == 0 )
|
|
{
|
|
Timer.Stop();
|
|
}
|
|
|
|
if( Timer.IsRunning == true )
|
|
{
|
|
clockStatus.Text = "Pågår (" + elapsedTime + ")";
|
|
maxMinSelect.ReadOnly = true;
|
|
offsetSeconds.ReadOnly = true;
|
|
offsetMinutes.ReadOnly = true;
|
|
maxMinSelect.Minimum = maxMinSelect.Value;
|
|
maxMinSelect.Maximum = maxMinSelect.Value;
|
|
fontButton.Enabled = false;
|
|
}
|
|
else if( Timer.IsRunning == false && seconds == 0 && Minutes == 0 )
|
|
{
|
|
clockStatus.Text = "Stoppet (" + elapsedTime + ")";
|
|
}
|
|
else
|
|
{
|
|
clockStatus.Text = "Pauset (" + elapsedTime + ")";
|
|
maxMinSelect.ReadOnly = false;
|
|
offsetSeconds.ReadOnly = false;
|
|
offsetMinutes.ReadOnly = false;
|
|
maxMinSelect.Minimum = 2;
|
|
maxMinSelect.Maximum = 240;
|
|
fontButton.Enabled = true;
|
|
}
|
|
// Update goals
|
|
DWindow.teamOneScore.Text = teamOneGoal.ToString();
|
|
DWindow.teamTwoScore.Text = teamTwoGoal.ToString();
|
|
goalOne.Text = "Mål: " + teamOneGoal.ToString();
|
|
goalTwo.Text = "Mål: " + teamTwoGoal.ToString();
|
|
}
|
|
|
|
private void timerReset_Click(object sender, EventArgs e)
|
|
{
|
|
if(Timer.IsRunning == true)
|
|
{
|
|
Timer.Stop();
|
|
Timer.Reset();
|
|
}
|
|
else
|
|
{
|
|
Timer.Reset();
|
|
}
|
|
teamOneGoal = 0;
|
|
teamTwoGoal = 0;
|
|
fontButton.Enabled = true;
|
|
halfPassed = false;
|
|
}
|
|
|
|
private void timerToggle_Click(object sender, EventArgs e)
|
|
{
|
|
if (Timer.IsRunning == true)
|
|
{
|
|
Timer.Stop();
|
|
maxMinSelect.ReadOnly = false;
|
|
offsetSeconds.ReadOnly = false;
|
|
offsetMinutes.ReadOnly = false;
|
|
maxMinSelect.Minimum = 2;
|
|
maxMinSelect.Maximum = 240;
|
|
}
|
|
else
|
|
{
|
|
Timer.Start();
|
|
}
|
|
}
|
|
|
|
private void maxMinSelect_ValueChanged(object sender, EventArgs e)
|
|
{
|
|
int value = Convert.ToInt32(maxMinSelect.Value);
|
|
maxMin = value;
|
|
}
|
|
|
|
private void keyingButton_Click(object sender, EventArgs e)
|
|
{
|
|
if(colorDialog.ShowDialog() == DialogResult.OK)
|
|
{
|
|
DWindow.BackColor = colorDialog.Color;
|
|
}
|
|
}
|
|
|
|
private void fontButton_Click(object sender, EventArgs e)
|
|
{
|
|
fontDialog.ShowColor = true;
|
|
fontDialog.Font = DWindow.clockLabel.Font;
|
|
fontDialog.Color = DWindow.clockLabel.ForeColor;
|
|
|
|
if(fontDialog.ShowDialog() != DialogResult.Cancel)
|
|
{
|
|
DWindow.clockLabel.Font = fontDialog.Font;
|
|
DWindow.teamOneScore.Font = fontDialog.Font;
|
|
DWindow.teamTwoScore.Font = fontDialog.Font;
|
|
|
|
DWindow.clockLabel.ForeColor = fontDialog.Color;
|
|
DWindow.teamOneScore.ForeColor = fontDialog.Color;
|
|
DWindow.teamTwoScore.ForeColor = fontDialog.Color;
|
|
}
|
|
}
|
|
|
|
private void offsetMinutes_ValueChanged(object sender, EventArgs e)
|
|
{
|
|
offsetMin = Convert.ToInt32(offsetMinutes.Value);
|
|
}
|
|
|
|
private void offsetSeconds_ValueChanged(object sender, EventArgs e)
|
|
{
|
|
offsetSec = Convert.ToInt32(offsetSeconds.Value);
|
|
}
|
|
}
|
|
}
|