public void StartDownload(GUIMod module) { if (module == null || !module.IsCKAN) { return; } Main.Instance.ShowWaitDialog(false); if (cacheWorker.IsBusy) { Task.Factory.StartNew(() => { // Just pass to the existing worker downloader.DownloadModules(new List <CkanModule> { module.ToCkanModule() }); module.UpdateIsCached(); }); } else { // Start up a new worker downloader = new NetAsyncModulesDownloader(Main.Instance.currentUser, Main.Instance.Manager.Cache); cacheWorker.RunWorkerAsync(module); } }
// cacheWorker.DoWork private void CacheMod(object sender, DoWorkEventArgs e) { Main.Instance.ResetProgress(); Main.Instance.ClearLog(); GUIMod gm = e.Argument as GUIMod; downloader.DownloadModules(new List <CkanModule> { gm.ToCkanModule() }); e.Result = e.Argument; }
private void _UpdateModContentsTree(bool force = false) { ContentsPreviewTree.BackColor = SystemColors.Window; ContentsPreviewTree.LineColor = SystemColors.WindowText; GUIMod guiMod = SelectedModule; if (!guiMod.IsCKAN) { return; } CkanModule module = guiMod.ToCkanModule(); if (Equals(module, currentModContentsModule) && !force) { return; } else { currentModContentsModule = module; } if (!guiMod.IsCached) { NotCachedLabel.Text = Properties.Resources.ModInfoNotCached; ContentsDownloadButton.Enabled = true; ContentsOpenButton.Enabled = false; ContentsPreviewTree.Enabled = false; } else { NotCachedLabel.Text = Properties.Resources.ModInfoCached; ContentsDownloadButton.Enabled = false; ContentsOpenButton.Enabled = true; ContentsPreviewTree.Enabled = true; } ContentsPreviewTree.Nodes.Clear(); ContentsPreviewTree.Nodes.Add(module.name); IEnumerable <string> contents = ModuleInstaller.GetInstance(manager.CurrentInstance, Main.Instance.Manager.Cache, Main.Instance.currentUser).GetModuleContentsList(module); if (contents == null) { return; } foreach (string item in contents) { ContentsPreviewTree.Nodes[0].Nodes.Add(item.Replace('/', Path.DirectorySeparatorChar)); } ContentsPreviewTree.Nodes[0].ExpandAll(); }
private void _UpdateModContentsTree(bool force = false) { GUIMod guiMod = SelectedModule; if (!guiMod.IsCKAN) { return; } CkanModule module = guiMod.ToCkanModule(); if (Equals(module, current_mod_contents_module) && !force) { return; } else { current_mod_contents_module = module; } if (!guiMod.IsCached) { NotCachedLabel.Text = Properties.Resources.MainModInfoNotCached; ContentsDownloadButton.Enabled = true; ContentsOpenButton.Enabled = false; ContentsPreviewTree.Enabled = false; } else { NotCachedLabel.Text = Properties.Resources.MainModInfoCached; ContentsDownloadButton.Enabled = false; ContentsOpenButton.Enabled = true; ContentsPreviewTree.Enabled = true; } ContentsPreviewTree.Nodes.Clear(); ContentsPreviewTree.Nodes.Add(module.name); IEnumerable <string> contents = ModuleInstaller.GetInstance(manager.CurrentInstance, Main.Instance.Manager.Cache, GUI.user).GetModuleContentsList(module); if (contents == null) { return; } foreach (string item in contents) { ContentsPreviewTree.Nodes[0].Nodes.Add(item); } ContentsPreviewTree.Nodes[0].ExpandAll(); }
private void _UpdateModContentsTree(bool force = false) { GUIMod guiMod = GetSelectedModule(); if (!guiMod.IsCKAN) { return; } CfanModule module = guiMod.ToCkanModule(); if (Equals(module, current_mod_contents_module) && !force) { return; } else { current_mod_contents_module = module; } if (!guiMod.IsCached) { NotCachedLabel.Text = "This mod is not in the cache, click 'Download' to preview contents"; ContentsDownloadButton.Enabled = true; ContentsPreviewTree.Enabled = false; } else { NotCachedLabel.Text = "Module is cached, preview available"; ContentsDownloadButton.Enabled = false; ContentsPreviewTree.Enabled = true; } ContentsPreviewTree.Nodes.Clear(); ContentsPreviewTree.Nodes.Add(module.title); IEnumerable <string> contents = ModuleInstaller.GetInstance(manager.CurrentInstance, GUI.user).GetModuleContentsList(module); if (contents == null) { return; } foreach (string item in contents) { ContentsPreviewTree.Nodes[0].Nodes.Add(item); } ContentsPreviewTree.Nodes[0].ExpandAll(); }
public void StartDownload(GUIMod module) { if (module == null || !module.IsCKAN) { return; } if (cacheWorker == null) { cacheWorker = new BackgroundWorker() { WorkerReportsProgress = true, WorkerSupportsCancellation = true, }; cacheWorker.DoWork += CacheMod; cacheWorker.RunWorkerCompleted += PostModCaching; } Main.Instance.ShowWaitDialog(false); if (cacheWorker.IsBusy) { Task.Factory.StartNew(() => { // Just pass to the existing worker downloader.DownloadModules(new List <CkanModule> { module.ToCkanModule() }); module.UpdateIsCached(); }); } else { // Start up a new worker downloader = new NetAsyncModulesDownloader(Main.Instance.currentUser, Main.Instance.Manager.Cache); cacheWorker.RunWorkerAsync(module); } }