Exemplo n.º 1
0
 public TimeWatcher(DataManager newDataManager)
 {
     dataManager = newDataManager;
     timer = new Timer();
     timer.Tick += new EventHandler(timeCheck);
     timer.Interval = 60 * 1000;
     timer.Enabled = true;
 }
Exemplo n.º 2
0
 public SMSManager(DataManager newDataManager)
 {
     dataManager = newDataManager;
     smsFetcher = new SMSFetcher(this);
     smsFetcher.addSmsInterceptorForPhoneNumber("");
     smsParser = new SMSParser(this);
     smsList = new List<SMSMessageProcess>();
     unparsableSmsList = new List<SMSMessageProcess>();
     checkUnprocessedMessagesTimer = new Timer();
     checkUnprocessedMessagesTimer.Interval = 5000;
     checkUnprocessedMessagesTimer.Tick += new EventHandler(checkUnprocessedMessagesTimer_Tick);
     checkUnprocessedMessagesTimer.Enabled = true;
 }
Exemplo n.º 3
0
        public MainForm()
        {
            InitializeComponent();

            dataManager = new DataManager();

            importExportForm = new ImportExportForm(dataManager);
            teamsForm = new TeamsForm(dataManager);
            puzzlesForm = new PuzzlesForm(dataManager);
            eventsForm = new EventsForm(dataManager);
            actualStateForm = new ActualStateForm(dataManager);

            int loadResult = dataManager.loadData();
            switch (loadResult) {
                case -2:
                    MessageBox.Show("Error while loading last state!");
                    break;
            }
        }
Exemplo n.º 4
0
 private void refreshTeamViews(DataManager dataManager)
 {
     this.refreshPointsListView(dataManager);
     this.refreshTimesListView(dataManager);
     this.refreshHintsListView(dataManager);
     this.refreshTimeLabels(dataManager);
     this.refreshPointLabels(dataManager);
     this.refreshDescTextBox(dataManager);
 }
Exemplo n.º 5
0
 private void refreshPointLabels(DataManager dataManager)
 {
     string pointsLabelText = "-";
     string hintsLabelText = "-";
     string standingsLabelText = "-";
     if (this.selectedTeam != null)
     {
         pointsLabelText = String.Format("{0} b", this.dataManager.gameModel.getPointsForTeam(selectedTeam));
         hintsLabelText = String.Format("{0} / {1}", this.dataManager.gameModel.getHintsTakenForTeam(selectedTeam), this.dataManager.gameModel.gameRules.maxHintsPerTeam);
         standingsLabelText = String.Format("{0} / {1}", this.dataManager.gameModel.getStandingsTakenForTeam(selectedTeam), this.dataManager.gameModel.gameRules.maxStandingsPerTeam);
     }
     this.pointsLabel.Text = pointsLabelText;
     this.hintsLabel.Text = hintsLabelText;
     this.standingsLabel.Text = standingsLabelText;
 }
Exemplo n.º 6
0
        private void refreshTeamsCombobox(DataManager dataManager)
        {
            if (this.teamsComboBox.Items.Count == dataManager.gameModel.teams.Count)
                return;

            teamsComboBox.BeginUpdate();
            int newSelectedIndex = 0;
            HOHTeam previouslySelected = null;
            if (this.teamsComboBox.SelectedIndex >= 0 && this.teamsComboBox.SelectedIndex < this.teamsComboBoxBinding.Count)
                previouslySelected = this.teamsComboBoxBinding[this.teamsComboBox.SelectedIndex];
            this.teamsComboBox.Items.Clear();
            this.teamsComboBoxBinding.Clear();
            if (dataManager.gameModel.teams != null)
            {
                foreach (HOHTeam team in dataManager.gameModel.teams)
                {
                    this.teamsComboBox.Items.Add(team.name);
                    this.teamsComboBoxBinding.Add(team);
                    if (team == previouslySelected)
                        newSelectedIndex = this.teamsComboBox.Items.Count - 1;
                }
                if (this.teamsComboBox.Items.Count > newSelectedIndex)
                    this.teamsComboBox.SelectedIndex = newSelectedIndex;
            }
            teamsComboBox.EndUpdate();
        }
Exemplo n.º 7
0
 public ImportExportForm(DataManager newDataManager)
     : this()
 {
     dataManager = newDataManager;
 }
Exemplo n.º 8
0
        private void refreshPointsListView(DataManager dataManager)
        {
            if (selectedPuzzle == null)
                return;

            this.pointsListView.BeginUpdate();
            List<HOHTeam> alreadyCounted = new List<HOHTeam>();

            pointsListView.Items.Clear();
            int i = 0;
            foreach (HOHEvent oneEvent in selectedPuzzle.events)
            {
                if (oneEvent.eventType == HOHEvent.HOHEventType.SolutionEventType && !alreadyCounted.Contains(oneEvent.team))
                {
                    alreadyCounted.Add(oneEvent.team);
                    ListViewItem newLine = new ListViewItem();
                    if (oneEvent.hasCorrectSolution())
                    {
                        i++;
                        newLine.Text = i.ToString();
                    }
                    else {
                        newLine.Text = "x";
                    }
                    newLine.SubItems.Add(oneEvent.team.name);
                    newLine.SubItems.Add(oneEvent.solutionText);
                    newLine.SubItems.Add(this.dataManager.gameModel.getPointsForTeamAtPuzzle(oneEvent.team, selectedPuzzle).ToString());
                    pointsListView.Items.Add(newLine);
                }
            }
            this.pointsListView.EndUpdate();
        }
Exemplo n.º 9
0
 public TeamsForm(DataManager newDataManager)
     : this()
 {
     dataManager = newDataManager;
     this.refreshAllViews(dataManager);
 }
Exemplo n.º 10
0
 private void refreshDescTextBox(DataManager dataManager)
 {
     string descTextBoxText = "";
     if (this.selectedTeam != null)
         descTextBoxText = this.selectedTeam.description;
     this.descTextBox.Text = descTextBoxText;
 }
Exemplo n.º 11
0
 private void refreshAllViews(DataManager dataManager)
 {
     refreshEventsView(dataManager);
     refreshProblemsView(dataManager);
     refreshGameRulesTextBox(dataManager);
 }
Exemplo n.º 12
0
 private void refreshEventsView(DataManager dataManager)
 {
     eventsListView.BeginUpdate();
     eventsListView.Items.Clear();
     foreach (HOHEvent oneEvent in this.dataManager.gameModel.events) {
         ListViewItem eventListViewItem = new ListViewItem();
         switch (oneEvent.eventType)
         {
             case HOHEvent.HOHEventType.SolutionEventType:
                 eventListViewItem.Text = oneEvent.dateTime.ToString();
                 if (oneEvent.solutionText.CompareTo(oneEvent.puzzle.solution) == 0)
                 {
                     eventListViewItem.SubItems.Add(String.Format("Spravna odpoved na sifru {0} ({1}) od tymu {2}.", oneEvent.puzzle.name, oneEvent.solutionText, oneEvent.team.name));
                 }
                 else
                 {
                     eventListViewItem.SubItems.Add(String.Format("Spatna odpoved na sifru {0} ({1}, ma byt {2}) od tymu {3}.", oneEvent.puzzle.name, oneEvent.solutionText, oneEvent.puzzle.solution, oneEvent.team.name));
                 }
                 eventListViewItem.SubItems.Add(oneEvent.SMSText);
                 break;
             case HOHEvent.HOHEventType.HintRequestEventType:
                 eventListViewItem.Text = oneEvent.dateTime.ToString();
                 eventListViewItem.SubItems.Add(String.Format("Zadost o napovedu na sifru {0} od tymu {1}.", oneEvent.puzzle.name, oneEvent.team.name));
                 eventListViewItem.SubItems.Add(oneEvent.SMSText);
                 break;
             case HOHEvent.HOHEventType.HintReplyEventType:
                 eventListViewItem.Text = oneEvent.dateTime.ToString();
                 eventListViewItem.SubItems.Add(String.Format("Odeslana napoveda k sifre {0} tymu {1} na cislo {2}.", oneEvent.puzzle.name, oneEvent.team.name, oneEvent.phoneNumber));
                 eventListViewItem.SubItems.Add(oneEvent.SMSText);
                 break;
             case HOHEvent.HOHEventType.StandigsRequestType:
                 eventListViewItem.Text = oneEvent.dateTime.ToString();
                 eventListViewItem.SubItems.Add(String.Format("Zadost o poradi od tymu {0}.", oneEvent.team.name));
                 eventListViewItem.SubItems.Add(oneEvent.SMSText);
                 break;
             case HOHEvent.HOHEventType.StandingsReplyEventType:
                 eventListViewItem.Text = oneEvent.dateTime.ToString();
                 eventListViewItem.SubItems.Add(String.Format("Odeslano info o poradi tymu {0} na cislo {1}.", oneEvent.team.name, oneEvent.phoneNumber));
                 eventListViewItem.SubItems.Add(oneEvent.SMSText);
                 break;
             case HOHEvent.HOHEventType.GivingUpEventType:
                 eventListViewItem.Text = oneEvent.dateTime.ToString();
                 eventListViewItem.SubItems.Add(String.Format("Tym {0} vzdal hru.", oneEvent.team.name));
                 eventListViewItem.SubItems.Add(oneEvent.SMSText);
                 break;
             case HOHEvent.HOHEventType.SendFailedEventType:
                 eventListViewItem.Text = oneEvent.dateTime.ToString();
                 eventListViewItem.SubItems.Add(String.Format("Nepodarilo se odeslat SMS tymu {0} na cislo {1}.", oneEvent.team.name, oneEvent.phoneNumber));
                 eventListViewItem.SubItems.Add(oneEvent.SMSText);
                 break;
         }
         eventsListView.Items.Add(eventListViewItem);
     }
     eventsListView.EndUpdate();
 }
Exemplo n.º 13
0
 private int nextProblemIndex(DataManager dataManager, int newSelectedProblemIndex)
 {
     newSelectedProblemIndex++;
     if (newSelectedProblemIndex > dataManager.smsManager.unparsableSmsList.Count - 1)
         newSelectedProblemIndex = dataManager.smsManager.unparsableSmsList.Count - 1;
     return newSelectedProblemIndex;
 }
Exemplo n.º 14
0
 private int previousProblemIndex(DataManager dataManager, int newSelectedProblemIndex)
 {
     if (newSelectedProblemIndex > 0) newSelectedProblemIndex--;
     if (newSelectedProblemIndex > dataManager.smsManager.unparsableSmsList.Count)
         newSelectedProblemIndex = dataManager.smsManager.unparsableSmsList.Count - 1;
     return newSelectedProblemIndex;
 }
Exemplo n.º 15
0
        private void refreshTimesListView(DataManager dataManager)
        {
            if (selectedPuzzle == null)
                return;

            this.timesListView.BeginUpdate();

            List<HOHTeam> alreadyCounted = new List<HOHTeam>();

            timesListView.Items.Clear();
            int i = 0;
            foreach (HOHEvent oneEvent in selectedPuzzle.events)
            {
                if (oneEvent.eventType == HOHEvent.HOHEventType.SolutionEventType && !alreadyCounted.Contains(oneEvent.team))
                {
                    alreadyCounted.Add(oneEvent.team);
                    i++;
                    ListViewItem newLine = new ListViewItem();
                    newLine.Text = i.ToString();
                    newLine.SubItems.Add(oneEvent.team.name);
                    newLine.SubItems.Add("-");
                    newLine.SubItems.Add(oneEvent.dateTime.ToString());
                    newLine.SubItems.Add("-");
                    timesListView.Items.Add(newLine);
                }
            }
            this.timesListView.EndUpdate();
        }
Exemplo n.º 16
0
 private void refreshPuzzlesViews(DataManager dataManager)
 {
     this.refreshPointsListView(dataManager);
     this.refreshTimesListView(dataManager);
     this.refreshHintsListView(dataManager);
     this.refreshDescTextBox(dataManager);
 }
Exemplo n.º 17
0
        private void refreshPuzzlesCombobox(DataManager dataManager)
        {
            if (this.puzzlesComboBox.Items.Count == dataManager.gameModel.puzzles.Count)
                return;

            this.puzzlesComboBox.BeginUpdate();
            int newSelectedIndex = 0;
            HOHPuzzle previouslySelected = null;
            if (this.puzzlesComboBox.SelectedIndex >= 0 && this.puzzlesComboBox.SelectedIndex < this.puzzlesComboBoxBinding.Count)
                previouslySelected = this.puzzlesComboBoxBinding[this.puzzlesComboBox.SelectedIndex];
            this.puzzlesComboBox.Items.Clear();
            this.puzzlesComboBoxBinding.Clear();
            if (dataManager.gameModel.puzzles != null)
            {
                foreach (HOHPuzzle puzzle in dataManager.gameModel.puzzles)
                {
                    this.puzzlesComboBox.Items.Add(puzzle.name);
                    this.puzzlesComboBoxBinding.Add(puzzle);
                    if (puzzle == previouslySelected)
                        newSelectedIndex = this.puzzlesComboBox.Items.Count - 1;
                }
                if (this.puzzlesComboBox.Items.Count > newSelectedIndex)
                    this.puzzlesComboBox.SelectedIndex = newSelectedIndex;
            }
            this.puzzlesComboBox.EndUpdate();
        }
Exemplo n.º 18
0
        private void refreshTimeLabels(DataManager dataManager)
        {
            string startTimeLabelText = "-";
            string timeToFinishLabelText = "-";
            string finishedTimeLabelText = "-";
            string giveUpTimeLabelText = "-";

            if (this.selectedTeam != null)
            {
                if (this.selectedTeam.hasStarted)
                {
                    startTimeLabelText = String.Format("{0}", this.selectedTeam.startTime);
                    timeToFinishLabelText = String.Format("{0}", this.dataManager.gameModel.getTimeToFinishForTeam(selectedTeam));
                }
                if (this.selectedTeam.hasFinished)
                    finishedTimeLabelText = String.Format("{0}", this.selectedTeam.finishTime);
                if (this.selectedTeam.hasGivenUp)
                    giveUpTimeLabelText = String.Format("{0}", this.selectedTeam.giveUpTime);

                this.finishedTimeLabel.Visible = this.selectedTeam.hasFinished;
                this.giveUpTimeLabel.Visible = this.selectedTeam.hasGivenUp;
                this.label3.Visible = this.selectedTeam.hasFinished;
                this.label4.Visible = this.selectedTeam.hasGivenUp;
            }

            this.startTimeLabel.Text = startTimeLabelText;
            this.timeToFinishLabel.Text = timeToFinishLabelText;
            this.finishedTimeLabel.Text = finishedTimeLabelText;
            this.giveUpTimeLabel.Text = giveUpTimeLabelText;
        }
Exemplo n.º 19
0
 private void refreshGameRulesTextBox(DataManager dataManager)
 {
     string gameRulesTextBoxText = "";
     gameRulesTextBoxText = dataManager.gameModel.gameRules.description;
     this.gameRulesTextBox.Text = gameRulesTextBoxText;
 }
Exemplo n.º 20
0
        private void refreshTimesListView(DataManager dataManager)
        {
            if (selectedTeam == null)
                return;

            List<HOHPuzzle> alreadyCounted = new List<HOHPuzzle>();

            timesListView.BeginUpdate();
            timesListView.Items.Clear();
            int i = 0;
            foreach (HOHEvent oneEvent in selectedTeam.events)
            {
                if ((oneEvent.eventType == HOHEvent.HOHEventType.SolutionEventType) && !alreadyCounted.Contains(oneEvent.puzzle))
                {
                    alreadyCounted.Add(oneEvent.puzzle);

                    if (oneEvent.hasCorrectSolution())
                        i++;
                    ListViewItem newLine = new ListViewItem();
                    newLine.Text = i.ToString();
                    newLine.SubItems.Add(oneEvent.puzzle.name);
                    newLine.SubItems.Add(dataManager.gameModel.getPlaceForTeamAtPuzzle(selectedTeam, oneEvent.puzzle).ToString());
                    newLine.SubItems.Add("-");
                    newLine.SubItems.Add(oneEvent.dateTime.ToString());
                    newLine.SubItems.Add("-");
                    timesListView.Items.Add(newLine);
                }
            }
            timesListView.EndUpdate();
        }
Exemplo n.º 21
0
 public ActualStateForm(DataManager newDataManager)
     : this()
 {
     dataManager = newDataManager;
 }
Exemplo n.º 22
0
 private void refreshAllViews(DataManager dataManager)
 {
     this.refreshTeamsCombobox(dataManager);
     this.refreshTeamViews(dataManager);
 }
Exemplo n.º 23
0
 private void refreshProblemsView(DataManager dataManager)
 {
     if (selectedProblemIndex < 0 && dataManager.smsManager.unparsableSmsList.Count > 0)
         selectedProblemIndex = dataManager.smsManager.unparsableSmsList.Count - 1;
     if (selectedProblemIndex > dataManager.smsManager.unparsableSmsList.Count -1 )
         selectedProblemIndex = dataManager.smsManager.unparsableSmsList.Count - 1;
     if (selectedProblemIndex >= 0)
     {
         SMSMessageProcess problemSMS = dataManager.smsManager.unparsableSmsList[selectedProblemIndex];
         //if (problemSMS.correctedBody.CompareTo("") != 0)
         //    smsTextTextBox.Text = problemSMS.correctedBody;
         //else
         //    smsTextTextBox.Text = problemSMS.smsMessage.Body;
         smsTextTextBox.Text = problemSMS.getMessageBody();
         smsTextTextBox.ReadOnly = false;
         if (problemSMS.getRecipientPhoneNumber().CompareTo("<>") == 0)
             errorDescriptionLabel.Text = String.Format(errorDescriptionFormat, "<testovací>", problemSMS.getReceivedDate());
         else
             errorDescriptionLabel.Text = String.Format(errorDescriptionFormat, problemSMS.getRecipientPhoneNumber(), problemSMS.getReceivedDate());
         titleLabel.Text = String.Format(titleLabelTextFormat, (selectedProblemIndex + 1).ToString(), dataManager.smsManager.unparsableSmsList.Count);
     }
     else {
         smsTextTextBox.Text = "";
         smsTextTextBox.ReadOnly = true;
         errorDescriptionLabel.Text = "";
         titleLabel.Text = titleLabelTextNoProblems;
     }
     refreshProblemsButtonsState(dataManager);
 }
Exemplo n.º 24
0
        private void refreshHintsListView(DataManager dataManager)
        {
            if (selectedTeam == null)
                return;

            hintsListView.BeginUpdate();
            hintsListView.Items.Clear();
            int i = 0;
            foreach (HOHEvent oneEvent in selectedTeam.events){
                if (oneEvent.eventType == HOHEvent.HOHEventType.HintReplyEventType) {
                    i++;
                    ListViewItem newLine = new ListViewItem();
                    newLine.Text = i.ToString();
                    newLine.SubItems.Add(oneEvent.puzzle.name);
                    newLine.SubItems.Add(oneEvent.dateTime.ToString());
                    hintsListView.Items.Add(newLine);
                }
            }
            hintsListView.EndUpdate();
        }
Exemplo n.º 25
0
 private void refreshActualStateList(DataManager dataManager)
 {
     this.actualStateList.BeginUpdate();
     actualStateList.Items.Clear();
     int i = 0;
     foreach (HOHTeam team in dataManager.gameModel.getTeamPlacesList())
     {
         i++;
         ListViewItem actualListViewItem = new ListViewItem();
         decimal points = dataManager.gameModel.getPointsForTeam(team);
         string pointsString = points.ToString();
         if (points < -(dataManager.gameModel.gameRules.pointPenaltyForTimeout / 2)) {
             pointsString = "DNF";
         }
         actualListViewItem.Text = i.ToString();
         actualListViewItem.SubItems.Add(team.name);
         actualListViewItem.SubItems.Add(dataManager.gameModel.getPuzzlesTakenForTeam(team).ToString());
         actualListViewItem.SubItems.Add(dataManager.gameModel.getHintsTakenForTeam(team).ToString());
         actualListViewItem.SubItems.Add(pointsString);
         actualStateList.Items.Add(actualListViewItem);
     }
     this.actualStateList.EndUpdate();
 }
Exemplo n.º 26
0
 private void refreshProblemsButtonsState(DataManager dataManager)
 {
     previousProblembutton.Enabled = (!(selectedProblemIndex == previousProblemIndex(dataManager, selectedProblemIndex)));
     nextProblemButton.Enabled = (!(selectedProblemIndex == nextProblemIndex(dataManager, selectedProblemIndex)));
     problemCorrectedButton.Enabled = (selectedProblemIndex != -1);
 }
Exemplo n.º 27
0
 private void refreshAllViews(DataManager dataManager)
 {
     this.refreshPuzzlesCombobox(dataManager);
     this.refreshPuzzlesViews(dataManager);
 }