Пример #1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            MatchEvent matchNew = new MatchEvent(
                txtTeam1.Text,
                txtTeam2.Text,
                mergeDate(dtpDateBegin.Value, dtpTimeBegin.Value),
                (int)nudDuration.Value);

            if (matchNew.DateBegin < DateTime.Now)
            {
                MessageBox.Show("You can not to add match which starts in the past", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            string matchIntersects = getIntersectsMatches(matchNew);
            if (matchIntersects == string.Empty ||
                MessageBox.Show("Are you really want to add match which intersects with existing match?" + matchIntersects, Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                matches.Add(matchNew);

                saveData();
                lstMatches.Items.Clear();
                loadData();
                lstMatches.SetSelected(matches.Count - 1, true);
            }
        }
Пример #2
0
        private void loadData()
        {
            matches = new ArrayList();

            XmlDocument xmlDoc = new XmlDocument();

            try
            {
                xmlDoc.Load(dataURL);

                foreach (XmlNode node in xmlDoc.DocumentElement.ChildNodes)
                {
                    MatchEvent match = new MatchEvent(node);

                    if (match.DateBegin >= DateTime.Today)
                    {
                        matches.Add(match);
                        lstMatches.Items.Add(match.Team1 + " - " + match.Team2);
                    }
                }

                updateTrayIcon();
            }
            catch
            {
            }
        }
Пример #3
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            int selected = lstMatches.SelectedIndex;

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

                if (matchUpdate.DateBegin < DateTime.Now)
                {
                    MessageBox.Show("You can not to update match which starts in the past", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                string matchIntersects = getIntersectsMatches(matchUpdate);
                if (matchIntersects == string.Empty ||
                    MessageBox.Show("Are you really want to update match which intersects with existing match?" + matchIntersects, Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    saveData();
                    lstMatches.Items.Clear();
                    loadData();
                    lstMatches.SetSelected(selected, true);
                }
            }
        }
Пример #4
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            MatchEvent matchNew = new MatchEvent(
                txtTeam1.Text,
                txtTeam2.Text,
                mergeDate(dtpDateBegin.Value, dtpTimeBegin.Value),
                (int)nudDuration.Value);

            if (matchNew.DateBegin < DateTime.Now)
            {
                MessageBox.Show("You can not to add match which starts in the past", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            string matchIntersects = getIntersectsMatches(matchNew);

            if (matchIntersects == string.Empty ||
                MessageBox.Show("Are you really want to add match which intersects with existing match?" + matchIntersects, Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                matches.Add(matchNew);

                saveData();
                lstMatches.Items.Clear();
                loadData();
                lstMatches.SetSelected(matches.Count - 1, true);
            }
        }
Пример #5
0
        private void MainForm_Resize(object sender, EventArgs e)
        {
            if (WindowState == FormWindowState.Minimized)
            {
                Hide();

                MatchEvent matchNext = getNextMatch();
                string     tipText   = matchNext != null?matchNext.getDescription() : "No matches in calendar";

                niTray.ShowBalloonTip(500, Application.ProductName, tipText, ToolTipIcon.Info);
            }
        }
Пример #6
0
        private void updateTrayIcon()
        {
            MatchEvent next = getNextMatch();

            if (next != null && (next.DateBegin - DateTime.Now).Days < 14)
            {
                niTray.Icon = MatchCalendar.Properties.Resources.football2;
            }
            else
            {
                niTray.Icon = MatchCalendar.Properties.Resources.football1;
            }
        }
Пример #7
0
        private string getIntersectsMatches(MatchEvent match)
        {
            string intersects = string.Empty;

            foreach (MatchEvent m in matches)
            {
                if (match.isIntersectWith(m))
                {
                    intersects += ("\n" + m.getDescription());
                }
            }

            return(intersects);
        }
Пример #8
0
        private MatchEvent getNextMatch()
        {
            MatchEvent next = null;

            if (matches.Count > 0)
            {
                next = (MatchEvent)matches[0];
                foreach (MatchEvent m in matches)
                {
                    if (next.DateBegin > m.DateBegin)
                    {
                        next = m;
                    }
                }
            }

            return(next);
        }
Пример #9
0
        private void niTray_MouseMove(object sender, MouseEventArgs e)
        {
            MatchEvent matchNext = getNextMatch();

            if (matchNext != null)
            {
                TimeSpan delay       = matchNext.DateBegin - DateTime.Now;
                string   description = matchNext.getDescription();
                string   through     = "Match through " + delay.Days.ToString("00") + ":" + delay.Hours.ToString("00") + ":" + delay.Minutes.ToString("00");
                string   tipText     = (description + "\n" + through);

                niTray.Text = tipText.Length < 64 ? tipText : description;
            }
            else
            {
                niTray.Text = "No matches in calendar";
            }
        }
Пример #10
0
        private void lstMatches_SelectedIndexChanged(object sender, EventArgs e)
        {
            int selected = lstMatches.SelectedIndex;

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

                btnUpdate.Enabled = true;
                btnDelete.Enabled = true;
            }
            else
            {
                btnUpdate.Enabled = false;
                btnDelete.Enabled = false;
            }

            checkAllowAdd();
        }
Пример #11
0
        private void loadData()
        {
            matches = new ArrayList();

            XmlDocument xmlDoc = new XmlDocument();
            try
            {
                xmlDoc.Load(dataURL);

                foreach (XmlNode node in xmlDoc.DocumentElement.ChildNodes)
                {
                    MatchEvent match = new MatchEvent(node);

                    if (match.DateBegin >= DateTime.Today)
                    {
                        matches.Add(match);
                        lstMatches.Items.Add(match.Team1 + " - " + match.Team2);
                    }
                }

                updateTrayIcon();
            }
            catch
            {

            }
        }
Пример #12
0
        private string getIntersectsMatches(MatchEvent match)
        {
            string intersects = string.Empty;
            foreach (MatchEvent m in matches)
            {
                if (match.isIntersectWith(m))
                {
                    intersects += ("\n" + m.getDescription());
                }
            }

            return intersects;
        }
Пример #13
0
 public bool isIntersectWith(MatchEvent match)
 {
     return (match != this && (DateBegin < match.DateEnd && DateEnd > match.DateBegin));
 }
Пример #14
0
 public bool isIntersectWith(MatchEvent match)
 {
     return(match != this && (DateBegin < match.DateEnd && DateEnd > match.DateBegin));
 }