Exemple #1
0
            /// <summary>
            /// Adds new torrent based on openFileDialog choice of user
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void ToolStripButtonAdd_Click(object sender, EventArgs e)
            {
                if (openFileDialogFile.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                Torrent t = Torrent.CreateFromPath(openFileDialogFile.FileName);

                AddRow(t);
                manager.Add(t);
            }
Exemple #2
0
            /// <summary>
            /// Constructs manager from XmlElement
            /// </summary>
            /// <param name="xmlElement"></param>
            /// <returns></returns>
            public static TorrentManager FromXml(XmlElement xmlElement)
            {
                TorrentManager torrentManager = new TorrentManager();

                foreach (XmlElement e in xmlElement["torrents"])
                {
                    Torrent t = Torrent.CreateFromXml(e);
                    torrentManager.Add(t); //later automatic start
                }

                torrentManager.ForceIp = bool.Parse(xmlElement["forceip"].InnerText);
                ConnectInfo loadedConnectInfo = ConnectInfo.ParseXml(xmlElement[ConnectInfo.XmlName]);

                if (torrentManager.ForceIp)
                {
                    torrentManager.MyConnectInfo = loadedConnectInfo;
                }
                else
                {
                    torrentManager.MyConnectInfo = new ConnectInfo(GetLocalIpAddress(), loadedConnectInfo.Port);
                }

                return(torrentManager);
            }