Exemplo n.º 1
0
        public void Handle_AddExistingLabel(object sender, RoutedEventArgs e)
        {
            if (mainlist.SelectedItems.Count > 0)
            {
                TorrentInfo[] arr = new TorrentInfo[mainlist.SelectedItems.Count];
                mainlist.SelectedItems.CopyTo(arr, 0);
                Action <TorrentInfo> f = new Action <TorrentInfo>(t => { });

                MenuItem source = e.OriginalSource as MenuItem;

                if (source.Header is TorrentLabel)
                {
                    TorrentLabel l = (TorrentLabel)source.Header;
                    if (l.Name == null)
                    {
                        //clear the labels
                        f = new Action <TorrentInfo>(t => state.LabelManager.ClearLabels(t));
                    }
                    else
                    {
                        f = new Action <TorrentInfo>(t => state.LabelManager.AddLabelForTorrent(t, l));
                    }
                }

                foreach (var t in arr)
                {
                    f(t);
                }
            }
        }
Exemplo n.º 2
0
        private void Handle_Label_ContextMenu(object sender, RoutedEventArgs e)
        {
            MenuItem     send = sender as MenuItem;
            TorrentLabel l    = send.CommandParameter as TorrentLabel;

            state.LabelManager.RemoveLabel(l);
            return;
        }
Exemplo n.º 3
0
        public void RemoveLabel(TorrentLabel label)
        {
            if (label.Name != null)
            {
                label.RefreshCount();
                if (label.Count != 0)
                {
                    label.UnregisterAll();
                }
                this.Labels.Remove(label);

                Labels[0].RefreshCount();
            }
        }
Exemplo n.º 4
0
        private TorrentLabel check_label(string label)
        {
            var results = Labels.Where(t => t.Name == label);

            if (results.Count() == 1)
            {
                return(results.First());
            }
            else
            {
                TorrentLabel t = new TorrentLabel(label, new ObservableCollection <TorrentInfo>(), this);
                Labels.Add(t);
                return(t);
            }
        }
Exemplo n.º 5
0
        public string[] GetLabelsForTorrent(TorrentInfo ti)
        {
            List <string> a = new List <string>();

            for (int i = 1 /*skip the null label*/; i < Labels.Count; i++)
            {
                TorrentLabel label = Labels[i];
                if (label.HasTorrent(ti))
                {
                    a.Add(label.Name);
                }
            }

            return(a.ToArray());
        }
Exemplo n.º 6
0
        private void Handle_Label_Selection(object sender, RoutedEventArgs e)
        {
            TreeViewItem source = e.OriginalSource as TreeViewItem;

            if (source.Header.GetType() == typeof(TorrentLabel))
            {
                TorrentLabel l = (TorrentLabel)source.Header;
                state.LabelManager.EnableFilter  = true;
                state.LabelManager.SelectedLabel = l.Name;
            }
            else if (source.Header.GetType() == typeof(StackPanel))
            {
                state.LabelManager.EnableFilter  = false;
                state.LabelManager.SelectedLabel = null;
            }

            foreach (TorrentInfo ti in state.Torrents)
            {
                ti.UpdateList("ShowOnList");
            }
        }
Exemplo n.º 7
0
 public void AddLabelForTorrent(TorrentInfo ti, TorrentLabel label)
 {
     label.RegisterTorrent(ti);
     Labels[0].RefreshCount();
 }
Exemplo n.º 8
0
        private TorrentLabel check_label(string label)
        {
            var results = Labels.Where(t => t.Name == label);

            if (results.Count() == 1)
            {
                return results.First();
            }
            else
            {
                TorrentLabel t = new TorrentLabel(label, new ObservableCollection<TorrentInfo>(), this);
                Labels.Add(t);
                return t;
            }
        }
Exemplo n.º 9
0
        public void RemoveLabel(TorrentLabel label)
        {
            if (label.Name != null)
            {
                label.RefreshCount();
                if (label.Count != 0)
                    label.UnregisterAll();
                this.Labels.Remove(label);

                Labels[0].RefreshCount();
            }
        }
Exemplo n.º 10
0
 public void AddLabelForTorrent(TorrentInfo ti, TorrentLabel label)
 {
     label.RegisterTorrent(ti);
     Labels[0].RefreshCount();
 }