private void Window_Drop(object sender, DragEventArgs e) { var data = ((DataObject)e.Data); if (data.ContainsText()) { string text = (string)data.GetData(typeof(string)); if (!string.IsNullOrWhiteSpace(text)) { if (Utility.IsMagnetLink(text)) { state.AddTorrentByMagnet(text); } } } else { string toppest = (string)data.GetFileDropList()[0]; state.AddTorrentByPath(toppest); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { #if DEBUG LanguageEngine.SaveDummy(); #endif NotifyIcon.Icon = new System.Drawing.Icon("Assets/icon-16.ico"); this.Icon = new BitmapImage(new Uri("Assets/icon-allsizes.ico", UriKind.Relative)); this.Icon.Freeze(); var cts = new CancellationTokenSource(); state = new State { uiContext = uiContext, MainTaskCancellationTokenSource = cts }; Task.Run(() => Update(cts.Token), cts.Token); this.DataContext = new NiceDataContext <MainWindow>(this); this.mainlist.ItemsSource = this.state.Torrents; itemselector = ShowAll; graph = new GraphDrawer(graph_canvas); foreach (string str in App.to_add) { if (Utility.IsMagnetLink(str)) { state.AddTorrentByMagnet(str); } else { state.AddTorrentByPath(str); } } feeds_tree_item.ItemsSource = FeedsManager.EntriesList; if (!App.Settings.ImportedTorrents) { ImportTorrents(); } Utility.ReloadTheme(App.Settings.Theme); if (App.Settings.CheckForUpdates) { StartAutoUpdater(); } }
public void AddTorrentByPath(string path) { State.AddTorrentByPath(path); }