private void ExecuteOpen(object sender, ExecutedRoutedEventArgs e)
        {
            var window = new AddTorrentWindow(SettingsManager);

            if (window.ShowDialog().Value)
            {
                PeriodicTorrent torrent;
                if (window.IsMagnet)
                {
                    torrent = AddTorrent(window.MagnetLink, window.DestinationPath);
                }
                else
                {
                    torrent = AddTorrent(window.Torrent, window.DestinationPath);
                }
                torrentGrid.SelectedItem = torrent;
                if (window.EditAdditionalSettings)
                {
                    detailTabs.SelectedItem = torrentOptionsTab;
                }

                if (Visibility == Visibility.Hidden)
                {
                    Visibility = Visibility.Visible;
                    Activate();
                }
                SaveSettings();
            }
        }
Exemple #2
0
 private void Window_Drop(object sender, DragEventArgs e)
 {
     if (e.Data.GetDataPresent(DataFormats.FileDrop))
     {
         var files = (string[])e.Data.GetData(DataFormats.FileDrop);
         if (files.Any(f => !f.EndsWith(".torrent")))
         {
             return;
         }
         if (files.Length == 1)
         {
             var dialog = new AddTorrentWindow(SettingsManager, files[0]);
             if (dialog.ShowDialog().Value)
             {
                 AddTorrent(dialog.Torrent, dialog.DestinationPath);
             }
         }
         else
         {
             foreach (var file in files)
             {
                 AddTorrent(Torrent.Load(file), SettingsManager.DefaultDownloadLocation);
             }
         }
     }
 }
Exemple #3
0
 private void rssEntryAddClicked(object sender, RoutedEventArgs e)
 {
     var button = (sender as Button);
     var entry = (RssFeedEntry)button.Tag;
     var magnetLink = new MagnetLink(entry.Link);
     if (!SettingsManager.PromptForSaveOnShellLinks)
         AddTorrent(magnetLink, SettingsManager.DefaultDownloadLocation);
     else
     {
         var window = new AddTorrentWindow(SettingsManager);
         window.MagnetLink = magnetLink;
         if (window.ShowDialog().Value)
             AddTorrent(window.MagnetLink, window.DestinationPath);
     }
 }
        private void ExecuteNew(object sender, ExecutedRoutedEventArgs e)
        {
            var window = new AddTorrentWindow(SettingsManager.DefaultDownloadLocation);
            if (window.ShowDialog().GetValueOrDefault(false))
            {
                if (window.IsMagnet)
                    AddTorrent(window.MagnetLink, window.DestinationPath);
                else
                    AddTorrent(window.Torrent, window.DestinationPath);

                if (Visibility == Visibility.Hidden)
                {
                    Visibility = Visibility.Visible;
                    Focus();
                }
            }
        }
Exemple #5
0
        private void rssEntryAddClicked(object sender, RoutedEventArgs e)
        {
            var button     = (sender as Button);
            var entry      = (RssFeedEntry)button.Tag;
            var magnetLink = new MagnetLink(entry.Link);

            if (!SettingsManager.PromptForSaveOnShellLinks)
            {
                AddTorrent(magnetLink, SettingsManager.DefaultDownloadLocation);
            }
            else
            {
                var window = new AddTorrentWindow(SettingsManager);
                window.MagnetLink = magnetLink;
                if (window.ShowDialog().Value)
                {
                    AddTorrent(window.MagnetLink, window.DestinationPath);
                }
            }
        }
Exemple #6
0
 private void Window_Drop(object sender, DragEventArgs e)
 {
     if (e.Data.GetDataPresent(DataFormats.FileDrop))
     {
         var files = (string[])e.Data.GetData(DataFormats.FileDrop);
         if (files.Any(f => !f.EndsWith(".torrent")))
             return;
         if (files.Length == 1)
         {
             var dialog = new AddTorrentWindow(SettingsManager, files[0]);
             if (dialog.ShowDialog().Value)
                 AddTorrent(dialog.Torrent, dialog.DestinationPath);
         }
         else
         {
             foreach (var file in files)
                 AddTorrent(Torrent.Load(file), SettingsManager.DefaultDownloadLocation);
         }
     }
 }
Exemple #7
0
        private void ExecuteOpen(object sender, ExecutedRoutedEventArgs e)
        {
            var window = new AddTorrentWindow(SettingsManager);
            if (window.ShowDialog().Value)
            {
                PeriodicTorrent torrent;
                if (window.IsMagnet)
                    torrent = AddTorrent(window.MagnetLink, window.DestinationPath);
                else
                    torrent = AddTorrent(window.Torrent, window.DestinationPath);
                torrentGrid.SelectedItem = torrent;
                if (window.EditAdditionalSettings)
                    detailTabs.SelectedItem = torrentOptionsTab;

                if (Visibility == Visibility.Hidden)
                {
                    Visibility = Visibility.Visible;
                    Activate();
                }
                SaveSettings();
            }
        }
Exemple #8
0
        public void HandleArguments(string[] args)
        {
            if (args.Length == 0)
            {
                Dispatcher.BeginInvoke(new Action(() =>
                    {
                        Visibility = Visibility.Visible;
                        Activate();
                    }));
                return;
            }
            if (args[0] == "--minimized")
            {
                Visibility = Visibility.Hidden;
                ShowInTaskbar = false;
                ShowActivated = false;
                WindowStyle = WindowStyle.None;
                Width = Height = 0;
                return;
            }
            Dispatcher.BeginInvoke(new Action(() =>
                {
                    try
                    {
                        var magnetLink = new MagnetLink(args[0]);
                        if (SettingsManager.PromptForSaveOnShellLinks)
                        {
                            var window = new AddTorrentWindow(SettingsManager);
                            window.MagnetLink = magnetLink;
                            if (window.ShowDialog().Value)
                            {
                                if (window.IsMagnet)
                                    AddTorrent(window.MagnetLink, window.DestinationPath);
                                else
                                    AddTorrent(window.Torrent, window.DestinationPath);

                                SaveSettings();

                                Visibility = Visibility.Visible;
                                Activate();
                                FlashWindow(new WindowInteropHelper(this).Handle, true);
                            }
                        }
                        else
                        {
                            var path = Path.Combine(SettingsManager.DefaultDownloadLocation, ClientManager.CleanFileName(magnetLink.Name));
                            if (!Directory.Exists(path))
                                Directory.CreateDirectory(path);
                            AddTorrent(magnetLink, path, true);
                        }
                    }
                    catch
                    {
                        try
                        {
                            var torrent = Torrent.Load(args[0]);
                            if (SettingsManager.PromptForSaveOnShellLinks)
                            {
                                var window = new AddTorrentWindow(SettingsManager, args[0]);
                                if (window.ShowDialog().Value)
                                {
                                    if (window.IsMagnet)
                                        AddTorrent(window.MagnetLink, window.DestinationPath);
                                    else
                                        AddTorrent(window.Torrent, window.DestinationPath);

                                    SaveSettings();

                                    Visibility = Visibility.Visible;
                                    Activate();
                                    FlashWindow(new WindowInteropHelper(this).Handle, true);
                                }
                            }
                            else
                            {
                                var path = Path.Combine(SettingsManager.DefaultDownloadLocation, ClientManager.CleanFileName(torrent.Name));
                                if (!Directory.Exists(path))
                                    Directory.CreateDirectory(path);
                                AddTorrent(torrent, path, true);

                                Visibility = Visibility.Visible;
                                Activate();
                                FlashWindow(new WindowInteropHelper(this).Handle, true);
                            }
                        }
                        catch { }
                    }
                }));
        }
Exemple #9
0
        public void HandleArguments(string[] args)
        {
            if (args.Length == 0)
            {
                Dispatcher.BeginInvoke(new Action(() =>
                {
                    Visibility = Visibility.Visible;
                    Activate();
                }));
                return;
            }
            if (args[0] == "--minimized")
            {
                Visibility    = Visibility.Hidden;
                ShowInTaskbar = false;
                ShowActivated = false;
                WindowStyle   = WindowStyle.None;
                Width         = Height = 0;
                return;
            }
            Dispatcher.BeginInvoke(new Action(() =>
            {
                try
                {
                    var magnetLink = new MagnetLink(args[0]);
                    if (SettingsManager.PromptForSaveOnShellLinks)
                    {
                        var window        = new AddTorrentWindow(SettingsManager);
                        window.MagnetLink = magnetLink;
                        if (window.ShowDialog().Value)
                        {
                            if (window.IsMagnet)
                            {
                                AddTorrent(window.MagnetLink, window.DestinationPath);
                            }
                            else
                            {
                                AddTorrent(window.Torrent, window.DestinationPath);
                            }

                            SaveSettings();

                            Visibility = Visibility.Visible;
                            Activate();
                            FlashWindow(new WindowInteropHelper(this).Handle, true);
                        }
                    }
                    else
                    {
                        var path = Path.Combine(SettingsManager.DefaultDownloadLocation, ClientManager.CleanFileName(magnetLink.Name));
                        if (!Directory.Exists(path))
                        {
                            Directory.CreateDirectory(path);
                        }
                        AddTorrent(magnetLink, path, true);
                    }
                }
                catch
                {
                    try
                    {
                        var torrent = Torrent.Load(args[0]);
                        if (SettingsManager.PromptForSaveOnShellLinks)
                        {
                            var window = new AddTorrentWindow(SettingsManager, args[0]);
                            if (window.ShowDialog().Value)
                            {
                                if (window.IsMagnet)
                                {
                                    AddTorrent(window.MagnetLink, window.DestinationPath);
                                }
                                else
                                {
                                    AddTorrent(window.Torrent, window.DestinationPath);
                                }

                                SaveSettings();

                                Visibility = Visibility.Visible;
                                Activate();
                                FlashWindow(new WindowInteropHelper(this).Handle, true);
                            }
                        }
                        else
                        {
                            var path = Path.Combine(SettingsManager.DefaultDownloadLocation, ClientManager.CleanFileName(torrent.Name));
                            if (!Directory.Exists(path))
                            {
                                Directory.CreateDirectory(path);
                            }
                            AddTorrent(torrent, path, true);

                            Visibility = Visibility.Visible;
                            Activate();
                            FlashWindow(new WindowInteropHelper(this).Handle, true);
                        }
                    }
                    catch { }
                }
            }));
        }
Exemple #10
0
        private void ExecuteOpen(object sender, ExecutedRoutedEventArgs e)
        {
            var window = new AddTorrentWindow(SettingsManager);
            if (window.ShowDialog().Value)
            {
                if (window.IsMagnet)
                    AddTorrent(window.MagnetLink, window.DestinationPath);
                else
                    AddTorrent(window.Torrent, window.DestinationPath);

                if (Visibility == Visibility.Hidden)
                {
                    Visibility = Visibility.Visible;
                    Activate();
                }
                SaveSettings();
            }
        }