/// <summary> /// Update a single plugin /// </summary> /// <param name="upd">Update information for plugin</param> /// <param name="sPluginFolder">Target folder for plugin file</param> /// <param name="sTranslationFolder">Target folder for plugin translations</param> /// <param name="bTranslationsOnly">Only download newest translations</param> /// <returns></returns> internal bool UpdatePlugin(PluginUpdate upd, string sPluginFolder, bool bTranslationsOnly) { bool bOK = true; if (m_slUpdatePlugins != null) { m_slUpdatePlugins.SetText(string.Format(PluginTranslate.PluginUpdating, upd.Title), LogStatusType.Info); } if (!bTranslationsOnly) { bOK = upd.Download(sPluginFolder); } if (upd is OwnPluginUpdate) { bool bTranslationsOK = (upd as OwnPluginUpdate).DownloadTranslations(sPluginFolder, PluginConfig.DownloadActiveLanguage, bTranslationsOnly); if (bTranslationsOnly) { bOK = bTranslationsOK; } } if (bOK) { bOK = upd.ProcessDownload(sPluginFolder); } upd.Cleanup(); return(bOK); }
internal static void LoadPlugins(bool bReload) { lock (Plugins) //Might be called in multiple threads, ensure a plugin is listed only once { if (!bReload && Plugins.Count > 0) { return; } Plugins.Clear(); if (m_Plugins.Count == 0) { m_Plugins = Tools.GetLoadedPluginsName(); } if (Plugins.Count > 0) { return; //Might have been filled from different thread meanwhile } List <string> lPluginnames = new List <string>(); foreach (string sPlugin in m_Plugins.Keys) { try { string s = sPlugin.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries)[0]; Plugin p = (Plugin)Tools.GetPluginInstance(s); if (p == null) { continue; } AssemblyCompanyAttribute[] comp = (AssemblyCompanyAttribute[])p.GetType().Assembly.GetCustomAttributes(typeof(AssemblyCompanyAttribute), false); bool bOwnPlugin = string.Compare("rookiestyle", comp[0].Company, StringComparison.InvariantCultureIgnoreCase) == 0; PluginUpdate pu = null; if (bOwnPlugin) { pu = new OwnPluginUpdate(p.GetType().Namespace); } else { try { pu = new OtherPluginUpdate(p.GetType().Namespace); } catch { } } if (pu != null && Plugins.Find(x => x.Name == pu.Name) == null) { Plugins.Add(pu); if (pu.UpdatePossible) { lPluginnames.Add(pu.Name); } } } catch (Exception ex) { PluginDebug.AddError(ex.Message, 0); } } PluginDebug.AddInfo("Installed updatable plugins", 0, lPluginnames.ToArray()); } }
private void ContextMenuStrip_Opening(object sender, System.ComponentModel.CancelEventArgs e) { e.Cancel = true; try { var lv = (sender as ContextMenuStrip).SourceControl as ListView; var lvi = lv.SelectedItems[0]; PluginUpdate upd = PluginUpdateHandler.Plugins.Find(x => x.Title == lvi.SubItems[0].Text); e.Cancel = upd == null; } catch { } }
private void OnReleasePageClick(object sender, EventArgs e) { try { var lv = ((sender as ToolStripItem).Owner as ContextMenuStrip).SourceControl as CustomListViewEx; var lvi = lv.SelectedItems[0]; PluginUpdate upd = PluginUpdateHandler.Plugins.Find(x => x.Title == lvi.SubItems[0].Text); if (upd == null) { return; } string url = upd.URL; Tools.OpenUrl(url); } catch { } }
private void OnUpdateCheckFormPluginMouseClick(object sender, MouseEventArgs e) { ListViewHitTestInfo info = (sender as ListView).HitTest(e.X, e.Y); PluginUpdate upd = info.Item.SubItems[info.Item.SubItems.Count - 1].Tag as PluginUpdate; if (upd == null) { return; } upd.Selected = !upd.Selected; if (!ShowUpdateButton((sender as Control).Parent as Form, PluginUpdateHandler.Plugins.Find(x => x.Selected == true) != null)) { upd.Selected = !upd.Selected; bUpdatePlugins_Click(sender, e); } else { (sender as ListView).Parent.Refresh(); } }
private void LvPlugins_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) { ListView lvPlugins = sender as ListView; e.DrawDefault = true; if (e.ColumnIndex != lvPlugins.Items[0].SubItems.Count) { return; } PluginUpdate upd = PluginUpdateHandler.Plugins.Find(x => x.Title == e.Item.SubItems[0].Text); if (upd == null) { return; } e.DrawDefault = false; var imageRect = new RectangleF(e.Bounds.X, e.Bounds.Y, e.Bounds.Height, e.Bounds.Height); e.Graphics.DrawImage(upd.Selected ? m_ImgApply : m_ImgUnselected, e.Bounds.X, e.Bounds.Y); }
private void LvPlugins_ItemActivate(object sender, EventArgs e) { try { var lv = sender as CustomListViewEx; var lvi = lv.SelectedItems[0]; PluginUpdate upd = PluginUpdateHandler.Plugins.Find(x => x.Title == lvi.SubItems[0].Text); if (upd == null) { foreach (Delegate d in m_lEventHandlerItemActivate) { d.DynamicInvoke(new object[] { sender, e }); } } else { string url = upd.URL; try { Tools.OpenUrl(url); } catch (Exception exUrl) { Tools.ShowError(url + "\n\n" + exUrl.Message); } } } catch { } }