示例#1
0
        private async void DeleteTorrent_Click(object sender, RoutedEventArgs e)
        {
            TorrentStatusViewModel res = (TorrentStatusViewModel)this.FindResource("TorrentStatusViewModel");

            System.Windows.Controls.Button os = (System.Windows.Controls.Button)e.OriginalSource;
            TorrentItem ti             = (TorrentItem)os.DataContext;
            var         dialogSettings = new MetroDialogSettings
            {
                SuppressDefaultResources = true,
                AffirmativeButtonText    = (string)FindResource("DelAffermativeButton"),
                NegativeButtonText       = (string)FindResource("No"),
                FirstAuxiliaryButtonText = (string)FindResource("DelFirstAuxiliary"),
            };

            switch (await this.ShowMessageAsync("", (string)FindResource("DelTorrentMessage") + " " + ti.Name + " " + "?", MessageDialogStyle.AffirmativeAndNegativeAndSingleAuxiliary, dialogSettings))
            {
            case MessageDialogResult.Affirmative:
                SessionManager.Instance.deleteTorrent(ti.Hash, true);
                res.TorrentList.Remove(ti);
                torrentList.Items.Refresh();
                break;

            case MessageDialogResult.Negative:
                break;

            case MessageDialogResult.FirstAuxiliary:
                SessionManager.Instance.deleteTorrent(ti.Hash, false);
                res.TorrentList.Remove(ti);
                torrentList.Items.Refresh();
                break;

            default:
                break;
            }
        }
示例#2
0
        private void ComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            Preferences res = (Preferences)this.FindResource("Preferences");
            ColorItem   ci  = (ColorItem)cmbColor.SelectedItem;

            //res.ThemeColor = cmbColor.SelectedItem.ToString();
            res.ThemeColor = ci.Name;

            // devo fare refresh per tutti i grafici presenti in tutti i TorrentItem in download
            // altrimenti non cambiano colore
            TorrentStatusViewModel tsvm = (TorrentStatusViewModel)FindResource("TorrentStatusViewModel");

            foreach (TorrentItem ti in tsvm.TorrentList)
            {
                ti.CallPropertyChanged("ColorFrom");
                ti.CallPropertyChanged("ColorTo");
            }
        }