Exemple #1
0
 /// <summary>
 /// Method called to invoke before change on the list.
 /// </summary>
 /// <param name="args">RejectableEventArgsC object with generic type T.</param>
 protected virtual void DoBeforeChange(CustomEventArgs <T> args)
 {
     if (null != BeforeChange)
     {
         BeforeChange.Invoke(this, args);
     }
 }
Exemple #2
0
        private void Watcher_Changed(object sender, FileSystemEventArgs e)
        {
            lock (ThreadLock)
            {
                Timer.Restart();

                if (!Waiting)
                {
                    Waiting = true;
                    BeforeChange?.Invoke(this, e);
                    Task.Run(() => {
                        while (true)
                        {
                            lock (ThreadLock)
                            {
                                Waiting = true;
                                if (Timer.ElapsedMilliseconds >= Threshold)
                                {
                                    break;
                                }
                            }

                            Thread.Sleep(1);
                        }

                        Waiting = false;
                        AfterChange?.Invoke(this, e);
                    });
                }
            }
        }
Exemple #3
0
        private void listTracks_DragDrop(object sender, DragEventArgs e)
        {
            // Get drop index
            var point = listTracks.PointToClient(new Point(e.X, e.Y));
            var index = listTracks.InsertionMark.NearestIndex(point);

            // Get the list of items to drop
            var items = e.Data.GetData(typeof(ListViewItem[])) as ListViewItem[];

            // decide on move order
            items = (index > items[0].Index) ? items : items.Reverse().ToArray();

            // Fire before change notification
            BeforeChange?.Invoke(this, null);

            foreach (var item in items)
            {
                // Remove from list
                listTracks.Items.Remove(item);
                m_Tracks.Remove(item.Tag as TrackInfo);

                // Insert in new position
                listTracks.Items.Insert(index, item);
                m_Tracks.Insert(index, item.Tag as TrackInfo);
            }

            // Fire tracks change notification
            TracksChanged?.Invoke(this, null);
        }
Exemple #4
0
        private void listTracks_KeyDown(object sender, KeyEventArgs e)
        {
            // Was delete key pressed?
            if (e.KeyCode == Keys.Delete)
            {
                // Is there anything selected?
                if (listTracks.SelectedItems.Count > 0)
                {
                    // Compose message
                    var msgText = "Delete ";
                    msgText += (listTracks.SelectedItems.Count == 1) ? ((TrackInfo)listTracks.SelectedItems[0].Tag).Name : listTracks.SelectedItems.Count + " Tracks";
                    msgText += "?";

                    // Ask user
                    if (MessageBox.Show(this, msgText, @"Confirm Delete", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
                    {
                        // Fire before change notification
                        BeforeChange?.Invoke(this, null);

                        // Remove items
                        var itemsToRemove = listTracks.SelectedItems.Cast <ListViewItem>().ToList();
                        foreach (var item in itemsToRemove)
                        {
                            listTracks.Items.Remove(item);
                            m_Tracks.Remove(item.Tag as TrackInfo);
                        }

                        // Fire tracks change notification
                        TracksRemoved?.Invoke(this, null);
                    }
                }
                e.Handled = true;
            }
        }
Exemple #5
0
        protected override void RemoveItem(int index)
        {
            T deletedItem = this.Items[index];

            BeforeChange?.Invoke(deletedItem);
            base.RemoveItem(index);
        }
Exemple #6
0
        private void listTracks_AfterLabelEdit(object sender, LabelEditEventArgs e)
        {
            // Check if label has text
            if (!string.IsNullOrWhiteSpace(e.Label))
            {
                // Fire before change notification
                BeforeChange?.Invoke(this, null);

                // Assign edited value back to track
                ((TrackInfo)listTracks.Items[e.Item].Tag).Name = e.Label;

                // Fire tracks change notification
                TracksChanged?.Invoke(this, null);
            }
        }
Exemple #7
0
 private void OnBeforeChangeEvent(RejectableArgs <T> rejectableEventArgs) => BeforeChange?.Invoke(this, rejectableEventArgs);
 protected virtual void OnBeforeChange(RejectableEventArgs_Subclass <T> args)
 {
     BeforeChange?.Invoke(this, args);
 }