Example #1
0
 private void deleteSingleToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (singlesListView.SelectedItems.Count == 1)
     {
         MusicSingle single = (MusicSingle)singlesListView.SelectedItems[0].Tag;
         removeSingleInModel(single);
         OnActivated(EventArgs.Empty);
     }
 }
Example #2
0
        public void removeSingle(MusicSingle single)
        {
            int idx = singlesList.FindIndex(s => s.Title == single.Title &&
                                            s.Author == single.Author && s.TrackDate == single.TrackDate);

            if (idx != -1)
            {
                singlesList.RemoveAt(idx);
            }
            onDeleted(new MyEventArgs(single, isNewer(single), false));
        }
Example #3
0
 private ListViewItem getItem(MusicSingle single)
 {
     foreach (ListViewItem item in singlesListView.Items)
     {
         if (ReferenceEquals(single, item.Tag))
         {
             return(item);
         }
     }
     return(null);
 }
Example #4
0
        public void editSingle(MusicSingle single, String title, String author, DateTime trackDate, MusicStyle style)
        {
            single.Title  = title;
            single.Author = author;
            DateTime oldDate = single.TrackDate;

            single.TrackDate = trackDate;
            single.Style     = style;
            bool changedGeneration = isChangedGeneration(oldDate, trackDate);

            onEdited(new MyEventArgs(single, isNewer(single), changedGeneration));
        }
Example #5
0
        // Methods for updating appropriate form

        private void addedSingle(object sender, MyEventArgs e)
        {
            MusicSingle lastSingle = model.getLastSingle();

            if (allCheckBox.Checked || (newerCheckBox.Checked && lastSingle.TrackDate.Year >= 2000) ||
                (olderCheckBox.Checked && lastSingle.TrackDate.Year < 2000))
            {
                ListViewItem item = new ListViewItem();
                item.Tag = model.getLastSingle();
                updateItem(item);
                singlesListView.Items.Add(item);
            }
        }
Example #6
0
        //To update item in ListView

        private void updateItem(ListViewItem item)
        {
            MusicSingle single = (MusicSingle)item.Tag;

            // 5 due to zeroColumn
            while (item.SubItems.Count < 5)
            {
                item.SubItems.Add(new ListViewItem.ListViewSubItem());
            }
            item.SubItems[1].Text = single.Title;
            item.SubItems[2].Text = single.Author;
            item.SubItems[3].Text = single.TrackDate.ToShortDateString();
            item.SubItems[4].Text = single.Style.ToString();
        }
Example #7
0
 private void editSingleToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (singlesListView.SelectedItems.Count == 1)
     {
         MusicSingle single     = (MusicSingle)singlesListView.SelectedItems[0].Tag;
         AddEditForm dialogForm = new AddEditForm(single);
         if (dialogForm.ShowDialog() == DialogResult.OK)
         {
             editSingleInModel(single, dialogForm.SingleTitle, dialogForm.SingleAuthor,
                               dialogForm.SingleTrackDate, dialogForm.SingleStyle);
             OnActivated(EventArgs.Empty);
         }
     }
 }
Example #8
0
        private void deletedSingle(object sender, MyEventArgs e)
        {
            MusicSingle single  = e.getSingle();
            bool        isNewer = e.getNewer();

            if (allCheckBox.Checked || (newerCheckBox.Checked && isNewer) ||
                (olderCheckBox.Checked && !isNewer))
            {
                if (single != null)
                {
                    ListViewItem item = getItem(single);
                    getItem(single).Remove();
                }
            }
        }
Example #9
0
        private void editedSingle(object sender, MyEventArgs e)
        {
            MusicSingle single              = e.getSingle();
            bool        isNewerSingle       = e.getNewer();
            bool        isChangedGeneration = e.getChangedGeneration();

            if (allCheckBox.Checked)
            {
                updateItem(getItem(single));
            }
            else
            {
                if ((newerCheckBox.Checked && isNewerSingle) ||
                    (olderCheckBox.Checked && !isNewerSingle))
                {
                    if (isChangedGeneration)
                    {
                        ListViewItem item = new ListViewItem();
                        item.Tag = single;
                        updateItem(item);
                        singlesListView.Items.Add(item);
                    }
                    else
                    {
                        updateItem(getItem(single));
                    }
                }
                else
                {
                    if (isChangedGeneration)
                    {
                        if ((newerCheckBox.Checked && !isNewerSingle) ||
                            (olderCheckBox.Checked && isNewerSingle))
                        {
                            ListViewItem item = getItem(single);
                            item.Remove();
                        }
                    }
                }
            }
        }
Example #10
0
 public AddEditForm(MusicSingle single)
 {
     this.single = single;
     this.Load  += new System.EventHandler(addEditForm_Load);
     InitializeComponent();
 }
Example #11
0
 protected void editSingleInModel(MusicSingle single, String singleTitle, String singleAuthor, DateTime singleTrackDate, MusicStyle singleStyle)
 {
     model.editSingle(single, singleTitle, singleAuthor, singleTrackDate, singleStyle);
 }
Example #12
0
 public MyEventArgs(MusicSingle single)
 {
     this.single = single;
 }
Example #13
0
 private static bool isNewer(MusicSingle single)
 {
     return(single.TrackDate.Year >= 2000);
 }
Example #14
0
 public void addSingle(MusicSingle single)
 {
     singlesList.Add(single);
     onAdded(new MyEventArgs());
 }
Example #15
0
 protected void removeSingleInModel(MusicSingle single)
 {
     model.removeSingle(single);
 }
Example #16
0
 public MyEventArgs(MusicSingle single, bool newer, bool changedGeneration)
 {
     this.single            = single;
     this.newer             = newer;
     this.changedGeneration = changedGeneration;
 }
Example #17
0
        protected void addSingleToModel(String singleTitle, String singleAuthor, DateTime singleTrackDate, MusicStyle singleStyle)
        {
            MusicSingle newSingle = new MusicSingle(singleTitle, singleAuthor, singleTrackDate, singleStyle);

            model.addSingle(newSingle);
        }