예제 #1
0
 public NewNonSportEntryForm(NonSportEntry entry) : this()
 {
     txtName.Text  = entry.Note;
     dtpFrom.Value = entry.Date.Value;
     dtpTo.Value   = entry.GetEndDate;
     comColorNames.SelectedIndex = comColorNames.Items.IndexOf(entry.DrawColor.Value.Name);
 }
예제 #2
0
        private void ButOkClick(object sender, EventArgs e)
        {
            if (txtName.Text == "")
            {
                MessageBox.Show("Please enter a name", "No name entered", MessageBoxButtons.OK,
                                MessageBoxIcon.Exclamation);
                return;
            }
            Entry = new NonSportEntry(dtpFrom.Value.Date, dtpTo.Value.Date, txtName.Text, labColor.BackColor);

            Close();
        }
예제 #3
0
        private void ShowNewEntryDialog(NonSportEntry entry = null)
        {
            var form = entry == null ? new NewNonSportEntryForm() : new NewNonSportEntryForm(entry);

            form.FormClosing += (ss, ee) =>
            {
                if (form.Entry == null)
                {
                    return;
                }
                AddEntry(form.Entry);
                Model.Instance.AddEntry(form.Entry);
            };
            form.Show();
        }
예제 #4
0
        private void AddEntry(NonSportEntry entry)
        {
            if (entry.DrawColor == null || entry.Date == null)
            {
                throw new Exception();
            }

            var index = 0;

            for (var i = 0; i < lisEntries.Items.Count; i++)
            {
                if (DateTime.Parse(lisEntries.Items[i].SubItems[2].Text) > entry.Date.Value)
                {
                    index = i;
                    break;
                }
            }

            lisEntries.Items.Insert(index, new ListViewItem(new[] { entry.Note ?? "ERROR: NOTE NOT SET", entry.DrawColor.Value.Name, entry.Date.Value.ToShortDateString(), entry.GetEndDate.ToShortDateString() })
            {
                BackColor = entry.DrawColor.Value
            });
        }