Example #1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            MatchItem matchNew = new MatchItem(
                txtTeam1.Text,
                txtTeam2.Text,
                MatchHelper.MergeDate(dtpDateBegin.Value, dtpTimeBegin.Value),
                (int)nudDuration.Value);

            if (matchNew.DateBegin < DateTime.Now)
            {
                MessageBox.Show(Strings.NotAdd, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            string matchIntersects = MatchHelper.ToIntersectsString(matchProvider, matchNew);
            if (matchIntersects == string.Empty ||
                MessageBox.Show(Strings.IntersectAdd + matchIntersects, Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                matchProvider.Add(matchNew);

                matchProvider.Save();
                lstMatches.Items.Clear();
                matchProvider.Load();
                lstMatches.SetSelected(matchProvider.Count - 1, true);
            }
        }
Example #2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            MatchItem matchNew = new MatchItem(
                txtTeam1.Text,
                txtTeam2.Text,
                MatchHelper.MergeDate(dtpDateBegin.Value, dtpTimeBegin.Value),
                (int)nudDuration.Value);

            if (matchNew.DateBegin < DateTime.Now)
            {
                MessageBox.Show(Strings.NotAdd, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            string matchIntersects = MatchHelper.ToIntersectsString(matchProvider, matchNew);

            if (matchIntersects == string.Empty ||
                MessageBox.Show(Strings.IntersectAdd + matchIntersects, Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                matchProvider.Add(matchNew);

                matchProvider.Save();
                lstMatches.Items.Clear();
                matchProvider.Load();
                lstMatches.SetSelected(matchProvider.Count - 1, true);
            }
        }
Example #3
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            int selected = lstMatches.SelectedIndex;

            if (selected > -1 && selected < matchProvider.Count)
            {
                MatchItem matchUpdate = matchProvider[selected];
                matchUpdate.Team1     = txtTeam1.Text;
                matchUpdate.Team2     = txtTeam2.Text;
                matchUpdate.DateBegin = MatchHelper.MergeDate(dtpDateBegin.Value, dtpTimeBegin.Value);
                matchUpdate.Duration  = (int)nudDuration.Value;

                if (matchUpdate.DateBegin < DateTime.Now)
                {
                    MessageBox.Show(Strings.NotUpdate, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                string matchIntersects = MatchHelper.ToIntersectsString(matchProvider, matchUpdate);
                if (matchIntersects == string.Empty ||
                    MessageBox.Show(Strings.IntersectUpdate + matchIntersects, Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    matchProvider.Save();
                    lstMatches.Items.Clear();
                    matchProvider.Load();
                    lstMatches.SetSelected(selected, true);
                }
            }
        }
Example #4
0
        private void updateTrayIcon()
        {
            MatchItem next = matchProvider.GetNextMatch();

            if (next != null && (next.DateBegin - DateTime.Now).Days < Config.DaysThrough)
            {
                niTray.Icon = MatchCalendar.Properties.Resources.football2;
            }
            else
            {
                niTray.Icon = MatchCalendar.Properties.Resources.football1;
            }
        }
Example #5
0
        public static string ToIntersectsString(MatchProvider provider, MatchItem match)
        {
            string intersects = string.Empty;
            foreach (MatchItem m in provider)
            {
                if (match.isIntersectWith(m))
                {
                    intersects += ("\n" + m.getDescription());
                }
            }

            return intersects;
        }
Example #6
0
        private void MainForm_Resize(object sender, EventArgs e)
        {
            if (WindowState == FormWindowState.Minimized)
            {
                Hide();

                MatchItem matchNext = matchProvider.GetNextMatch();

                string tipText = Strings.NoMatches;
                if (matchNext != null)
                {
                    tipText = matchNext.getDescription();
                }

                niTray.ShowBalloonTip(500, Application.ProductName, tipText, ToolTipIcon.Info);
            }
        }
Example #7
0
        private void lstMatches_SelectedIndexChanged(object sender, EventArgs e)
        {
            int selected = lstMatches.SelectedIndex;

            if (selected > -1 && selected < matchProvider.Count)
            {
                MatchItem match = matchProvider[selected];
                txtTeam1.Text      = match.Team1;
                txtTeam2.Text      = match.Team2;
                dtpDateBegin.Value = match.DateBegin;
                dtpTimeBegin.Value = match.DateBegin;
                nudDuration.Value  = match.Duration;
            }

            checkAllowUpdate();
            checkAllowDelete();
            checkAllowAdd();
        }
Example #8
0
        private void niTray_MouseMove(object sender, MouseEventArgs e)
        {
            MatchItem matchNext = matchProvider.GetNextMatch();

            if (matchNext != null)
            {
                TimeSpan delay       = matchNext.DateBegin - DateTime.Now;
                string   description = matchNext.getDescription();
                int      minutes     = delay.Minutes + (delay.Seconds > 30 ? 1 : 0);
                string   through     = Strings.Through + delay.Days.ToString("00") + ":" + delay.Hours.ToString("00") + ":" + minutes.ToString("00");
                string   tipText     = (description + "\n" + through);

                niTray.Text = tipText.Length < 64 ? tipText : description;
            }
            else
            {
                niTray.Text = Strings.NoMatches;
            }
        }
Example #9
0
 public bool isIntersectWith(MatchItem match)
 {
     return (match != this && (DateBegin < match.DateEnd && DateEnd > match.DateBegin));
 }
Example #10
0
 public bool isIntersectWith(MatchItem match)
 {
     return(match != this && (DateBegin < match.DateEnd && DateEnd > match.DateBegin));
 }