コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: ijat/byteflood
        private string GetDirectoryKeyRelativePath(Aga.Controls.Tree.TreeNode item_node)
        {
            List <string> dirs = new List <string>();

            _recursive_resolve(item_node, dirs);
            dirs.Reverse();
            string res = System.IO.Path.Combine(dirs.ToArray());

            return(res);
        }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: ijat/byteflood
        private void _recursive_resolve(Aga.Controls.Tree.TreeNode node, List <string> dirs)
        {
            DirectoryKey dk = node.Tag as DirectoryKey;

            if (dk != null)
            {
                dirs.Add(dk.Name);
                _recursive_resolve(node.Parent, dirs);
            }
        }
コード例 #3
0
ファイル: MainWindow.xaml.cs プロジェクト: ijat/byteflood
        public void TorrentCommands_OpenFile(object sender, ExecutedRoutedEventArgs e)
        {
            Aga.Controls.Tree.TreeNode item = files_tree.SelectedItem as Aga.Controls.Tree.TreeNode;

            if (item != null)
            {
                FileInfo fi = item.Tag as FileInfo;
                if (fi != null)
                {
                    System.IO.FileInfo fifo = new System.IO.FileInfo(fi.FullPath);

                    if (fifo.Exists)
                    {
                        string[] dangerous_file_types = { ".exe", ".scr", ".pif", ".js", ".com", ".bat", ".cmd", ".vbs", ".hta" };

                        if (dangerous_file_types.Contains(fifo.Extension.ToLower()))
                        {
                            if (MessageBox.Show(string.Format(@"Opening files downloaded from the Internet may result in harm to your computer or your data."
                                                              + " Are you sure that you want to open {0}?", fifo.Name),
                                                "Warning", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
                            {
                                Process.Start(fifo.FullName);
                            }
                        }
                        else
                        {
                            Process.Start(fifo.FullName);
                        }
                    }
                    else
                    {
                        MessageBox.Show("File doesn't exist", "Error");
                    }
                }
                else
                {
                    DirectoryKey dk = item.Tag as DirectoryKey;
                    if (dk != null)
                    {
                        string partial_path = this.GetDirectoryKeyRelativePath(item);
                        string full_path    = System.IO.Path.Combine(dk.OwnerTorrent.SavePath, partial_path);
                        System.IO.Directory.CreateDirectory(full_path);
                        Process.Start("explorer.exe", string.Format("\"{0}\"", full_path));
                    }
                }
            }
        }
コード例 #4
0
ファイル: MainWindow.xaml.cs プロジェクト: ijat/byteflood
        public void TorrentCommands_OpenFileLocation(object sender, RoutedEventArgs e)
        {
            Aga.Controls.Tree.TreeNode item = files_tree.SelectedItem as Aga.Controls.Tree.TreeNode;

            if (item != null)
            {
                FileInfo fi = item.Tag as FileInfo;
                if (fi != null)
                {
                    if (System.IO.File.Exists(fi.FullPath))
                    {
                        Process.Start("explorer.exe", string.Format("/select, \"{0}\"", fi.FullPath));
                    }
                    else
                    {
                        string directory = System.IO.Path.GetDirectoryName(fi.FullPath);
                        System.IO.Directory.CreateDirectory(directory);
                        Process.Start("explorer.exe", string.Format("\"{0}\"", directory));
                    }
                    return;
                }

                //we must have hit a directory then
                //if it's a directory residing inside the torrent folder (root folder), we simply
                //open the torrent save dir
                DirectoryKey dk = item.Tag as DirectoryKey;
                if (dk != null)
                {
                    if (item.Parent != null && item.Parent.Tag != null)
                    {
                        //it's a subdirectory
                        string partial_path = GetDirectoryKeyRelativePath(item.Parent);
                        string full_path    = System.IO.Path.Combine(dk.OwnerTorrent.SavePath, partial_path);
                        System.IO.Directory.CreateDirectory(full_path);
                        Process.Start("explorer.exe", string.Format("/select, \"{0}\"", full_path));
                    }
                    else
                    {
                        //it's a root dir
                        System.IO.Directory.CreateDirectory(dk.OwnerTorrent.SavePath);
                        Process.Start("explorer.exe", string.Format("/select, \"{0}\"", dk.OwnerTorrent.SavePath));
                    }
                }
            }
        }