コード例 #1
0
        public static Download ScheduleDownload(string name, string url, bool MCRequire)
        {
            Download dl = new Download();
            dl.Key = name;
            dl.Url = url;
            dl.MCRequire = MCRequire;

            ScheduleDownload(dl);

            return dl;
        }
コード例 #2
0
        public DownloadControl(Download d)
        {
            InitializeComponent();
            reference = d;
            label_name.Content = reference.Key;
            reference.ProgressUpdated += UpdateProgress;
            reference.Downloaded += (dl) =>
            {
                App.InvokeAction(delegate { this.Dispatcher.Invoke((Action)delegate { CloseBtn.IsEnabled = true; }); });
            };

            ContextMenu cm = new ContextMenu();
            MenuItem mi_link = new MenuItem();
            mi_link.Header = d.Url;
            cm.Items.Add(mi_link);
            MenuItem mi_cp = new MenuItem();
            mi_cp.Header = "Copy to clipboard";
            mi_cp.Click += delegate
            {
                Clipboard.SetText(d.Url);
            };
            cm.Items.Add(mi_cp);
            this.ContextMenu = cm;
        }
コード例 #3
0
        public void StoreAsset(Download d)
        {
            byte[] filedata = d.Data;
            using (MD5 hasher = MD5.Create())
            {
                byte[] downloadedHash = hasher.ComputeHash(filedata);
                StringBuilder sb = new StringBuilder();
                downloadedHash.ToList().ForEach(b => sb.Append(b.ToString("x2")));
                string hashString = sb.ToString();

                if (hashString == md5)
                {
                    Directory.CreateDirectory(new FileInfo(Path).DirectoryName); //MAKE SURE DIRECTORIES EXIST BEFORE WRITING!
                    if (!IsDirectory)
                    {
                        File.WriteAllBytes(Path, filedata);
                    }
                }
                else
                {
                    throw new Exception("MD5 hashes do not match for MinecraftAsset: " + Key + " stored md5: " + md5 + " downloaded md5: " + hashString);
                }
            }
        }
コード例 #4
0
 //public static List<Download> getAllDownloads()
 //{
 //    List<Download> dlp = new List<Download>();
 //    foreach (DownloadPackage dlp_ in downloads)
 //    {
 //        foreach (Download dl in dlp_.getDownloads())
 //        {
 //            dlp.Add(dl);
 //        }
 //    }
 //    return dlp;
 //}
 public static void ScheduleDownload(Download dl)
 {
     downloads.Add(dl);
     App.InvokeAction(delegate { DownloadControl dc = new DownloadControl(dl); App.mainWindow.listBox_downloadManager.Items.Add(dc); });
     Download();
 }
コード例 #5
0
ファイル: Library.cs プロジェクト: Northcode/MCM-reboot
 private void ApplyDlStuff(Download dl)
 {
     dl.ShouldContinue = true;
     dl.Downloaded += (d) => { Extract_(d.Data); dl.Continue(); };
 }
コード例 #6
0
        //public static List<Download> getAllDownloads()
        //{
        //    List<Download> dlp = new List<Download>();
        //    foreach (DownloadPackage dlp_ in downloads)
        //    {
        //        foreach (Download dl in dlp_.getDownloads())
        //        {
        //            dlp.Add(dl);
        //        }
        //    }
        //    return dlp;
        //}

        public static void ScheduleDownload(Download dl)
        {
            downloads.Add(dl);
            App.InvokeAction(delegate { DownloadControl dc = new DownloadControl(dl); App.mainWindow.listBox_downloadManager.Items.Add(dc); });
            Download();
        }
コード例 #7
0
ファイル: PluginManager.cs プロジェクト: Northcode/MCM-reboot
 static void dummyC(Download download)
 {
 }
コード例 #8
0
 private static void AssetDownloaded(Download dl)
 {
     MinecraftAsset asset = assets.Find(a => a.Url == dl.Url);
     asset.StoreAsset(dl);
 }
コード例 #9
0
 private void DownloadComplete(Download obj)
 {
     finishedFile(obj);
     ProgressUpdated((int)(((totalSize - (files.Count - 1)) / ((float)totalSize)) * 100));
 }