コード例 #1
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();
            }
        }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: Jorch72/CS-Patchy
 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);
             }
         }
     }
 }
コード例 #3
0
ファイル: MainWindow.Rss.cs プロジェクト: salloo/Patchy
 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);
     }
 }
コード例 #4
0
        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();
                }
            }
        }
コード例 #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);
                }
            }
        }
コード例 #6
0
ファイル: MainWindow.xaml.cs プロジェクト: naiduv/Patchy
 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);
         }
     }
 }
コード例 #7
0
ファイル: MainWindow.Commands.cs プロジェクト: naiduv/Patchy
        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();
            }
        }
コード例 #8
0
ファイル: MainWindow.Logic.cs プロジェクト: halaszk/Patchy
        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 { }
                    }
                }));
        }
コード例 #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 { }
                }
            }));
        }
コード例 #10
0
ファイル: MainWindow.Commands.cs プロジェクト: salloo/Patchy
        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();
            }
        }