Пример #1
0
        /// <summary>
        /// Returns the download URL of the mod archive.
        /// Asks the User if necessary.
        /// </summary>
        /// <param name="forumURL">The KSP Forum thread URL of the mod.</param>
        /// <returns>The download URL of the mod archive.</returns>
        public static string GetDownloadURL(string forumURL)
        {
            string        downloadURL  = string.Empty;
            List <string> downloadURLs = GetDownloadURLs(forumURL);

            if (downloadURLs.Count != 1)
            {
                if (downloadURLs.Count > 1 || DialogResult.Yes ==
                    MessageBox.Show(string.Format("No download link to a zip, rar or 7zip found.{0}Do you want to select the download link manually?",
                                                  Environment.NewLine), "Error", MessageBoxButtons.YesNo))
                {
                    frmLinkSelection dlg = new frmLinkSelection {
                        URL = forumURL
                    };
                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        downloadURL = dlg.SelectedLink;
                    }
                }
            }
            else if (downloadURLs.Count == 1)
            {
                downloadURL = downloadURLs[0];
            }
            //else if (downloadURLs.Count > 1)
            //{
            //    frmSelectDownloadURL frm = new frmSelectDownloadURL { Links = downloadURLs };
            //    if (frm.ShowDialog() == DialogResult.OK)
            //        downloadURL = frm.SelectedLink;
            //}

            return(downloadURL);
        }
        /// <summary>
        /// Returns the download URL of the mod archive.
        /// Asks the User if necessary.
        /// </summary>
        /// <param name="forumURL">The KSP Forum thread URL of the mod.</param>
        /// <returns>The download URL of the mod archive.</returns>
        public static string GetDownloadURL(string forumURL)
        {
            string downloadURL = string.Empty;
            List<string> downloadURLs = GetDownloadURLs(forumURL); 
            if (downloadURLs.Count != 1)
            {
                if (downloadURLs.Count > 1 || DialogResult.Yes ==
                    MessageBox.Show(string.Format("No download link to a zip, rar or 7zip found.{0}Do you want to select the download link manually?",
                                    Environment.NewLine), "Error", MessageBoxButtons.YesNo))
                {
                    frmLinkSelection dlg = new frmLinkSelection { URL = forumURL };
                    if (dlg.ShowDialog() == DialogResult.OK)
                        downloadURL = dlg.SelectedLink;
                }
            }
            else if (downloadURLs.Count == 1)
            {
                downloadURL = downloadURLs[0];
            }
            //else if (downloadURLs.Count > 1)
            //{
            //    frmSelectDownloadURL frm = new frmSelectDownloadURL { Links = downloadURLs };
            //    if (frm.ShowDialog() == DialogResult.OK)
            //        downloadURL = frm.SelectedLink;
            //}

            return downloadURL;
        }