/// <summary> /// Gets the unique list of extensions with highest version /// </summary> /// <param name="exlude">Exlude these extensions</param> /// <returns></returns> public ExtensionCollection GetUniqueList(ExtensionCollection exlude) { HashSet<string> exludedIds = new HashSet<string>(); if (exlude != null) exlude.Items.ForEach(p => exludedIds.Add(p.GeneralInfo.Id)); Dictionary<string, PackageClass> ids = new Dictionary<string, PackageClass>(); foreach (PackageClass item in Items) { if (item.IsHiden || exludedIds.Contains(item.GeneralInfo.Id)) continue; PackageClass currentVersion = null; if (!ids.TryGetValue(item.GeneralInfo.Id, out currentVersion)) { ids.Add(item.GeneralInfo.Id, item); } else { // overwrite if has a higher version if (item.GeneralInfo.Version.CompareTo(currentVersion.GeneralInfo.Version) > 0) { ids[item.GeneralInfo.Id] = item; } } } var collection = new ExtensionCollection(); foreach (var package in ids.Values) collection.Add(package); return collection; }
public void Add(ExtensionCollection collection) { foreach (PackageClass item in collection.Items) { Add(item); } }
/// <summary> /// Gets the unique list of extensions with hightess version /// </summary> /// <returns></returns> public ExtensionCollection GetUniqueList() { List<string> ids = new List<string>(); foreach (PackageClass item in Items) { if (item.IsHiden) continue; if (!ids.Contains(item.GeneralInfo.Id)) ids.Add(item.GeneralInfo.Id); } var collection = new ExtensionCollection(); foreach (string id in ids) { collection.Add(Get(id)); } return collection; }
/// <summary> /// Gets a list of extensions with same ids /// </summary> /// <param name="id">The id.</param> /// <returns></returns> public ExtensionCollection GetList(string id) { ExtensionCollection resp = new ExtensionCollection(); foreach (PackageClass item in Items) { if (item.IsHiden) { continue; } if (item.GeneralInfo.Id == id) { resp.Add(item); } } resp.Items.Sort(PackageClass.Compare); return(resp); }
/// <summary> /// Gets the unique list of extensions with highest version /// </summary> /// <param name="exlude">Exlude these extensions</param> /// <returns></returns> public ExtensionCollection GetUniqueList(ExtensionCollection exlude) { HashSet <string> exludedIds = new HashSet <string>(); if (exlude != null) { exlude.Items.ForEach(p => exludedIds.Add(p.GeneralInfo.Id)); } Dictionary <string, PackageClass> ids = new Dictionary <string, PackageClass>(); foreach (PackageClass item in Items) { if (item.IsHiden || exludedIds.Contains(item.GeneralInfo.Id)) { continue; } PackageClass currentVersion = null; if (!ids.TryGetValue(item.GeneralInfo.Id, out currentVersion)) { ids.Add(item.GeneralInfo.Id, item); } else { // overwrite if has a higher version if (item.GeneralInfo.Version.CompareTo(currentVersion.GeneralInfo.Version) > 0) { ids[item.GeneralInfo.Id] = item; } } } var collection = new ExtensionCollection(); foreach (var package in ids.Values) { collection.Add(package); } return(collection); }
/// <summary> /// Gets the unique list of extensions with hightess version /// </summary> /// <returns></returns> public ExtensionCollection GetUniqueList() { List <string> ids = new List <string>(); foreach (PackageClass item in Items) { if (item.IsHiden) { continue; } if (!ids.Contains(item.GeneralInfo.Id)) { ids.Add(item.GeneralInfo.Id); } } var collection = new ExtensionCollection(); foreach (string id in ids) { collection.Add(Get(id)); } return(collection); }
/// <summary> /// Loads the specified file name. /// if some error ocure, empty list will be returned /// </summary> /// <param name="fileName">Name of the file.</param> /// <returns></returns> public static ExtensionCollection Load(string fileName) { if (String.IsNullOrEmpty(fileName)) { return(new ExtensionCollection()); } if (!File.Exists(fileName)) { return(new ExtensionCollection()); } FileStream fs = null; try { XmlSerializer serializer = new XmlSerializer(typeof(ExtensionCollection)); fs = new FileStream(fileName, FileMode.Open); ExtensionCollection extensionCollection = (ExtensionCollection)serializer.Deserialize(fs); fs.Close(); extensionCollection.Items.Sort(PackageClass.Compare); foreach (PackageClass item in extensionCollection.Items) { item.Parent = extensionCollection; } return(extensionCollection); } catch { if (fs != null) { fs.Dispose(); } return(new ExtensionCollection()); } }
public void Set(ExtensionCollection collection, bool isListOfInstalledExtensions) { var oldCursor = ParentForm.Cursor; try { ParentForm.Cursor = Cursors.WaitCursor; flowLayoutPanel1.SuspendLayout(); collection.Sort(false); comboBox1.Items.Clear(); comboBox1.Items.Add("All"); TagList.Clear(); toolTip1.RemoveAll(); // removes all created user-objects for the tooltip - reuse this tooltip instance, otherwise memory leak! foreach (Control c in flowLayoutPanel1.Controls) c.Dispose(); flowLayoutPanel1.Controls.Clear(); foreach (PackageClass item in collection.Items) { var extHostCtrl = new ExtensionControlHost(); flowLayoutPanel1.Controls.Add(extHostCtrl); extHostCtrl.Initialize(item, isListOfInstalledExtensions); AddTags(item.GeneralInfo.TagList); } comboBox1.Text = "All"; textBox1.Text = string.Empty; foreach (KeyValuePair<string, int> tagList in TagList) { if (tagList.Value > 1) comboBox1.Items.Add(tagList.Key); } flowLayoutPanel1.ResumeLayout(); flowLayoutPanel1_SizeChanged(this, EventArgs.Empty); } finally { ParentForm.Cursor = oldCursor; } }
/// <summary> /// Gets a list of extensions with same ids /// </summary> /// <param name="id">The id.</param> /// <returns></returns> public ExtensionCollection GetList(string id) { ExtensionCollection resp = new ExtensionCollection(); foreach (PackageClass item in Items) { if (item.IsHiden) continue; if (item.GeneralInfo.Id == id) { resp.Add(item); } } resp.Items.Sort(PackageClass.Compare); return resp; }
private void CleanCache_Click(object sender, EventArgs e) { if (MessageBox.Show("Do you want to clear all unused data?\nYou need to redownload update info.", "Cleanup", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { ExtensionCollection collection = new ExtensionCollection(); foreach (PackageClass item in MpeCore.MpeInstaller.KnownExtensions.Items) { if (MpeCore.MpeInstaller.InstalledExtensions.Get(item) == null) { collection.Items.Add(item); } } foreach (PackageClass packageClass in collection.Items) { try { if (Directory.Exists(packageClass.LocationFolder)) Directory.Delete(packageClass.LocationFolder, true); string baseExtensionPath = Path.GetDirectoryName(packageClass.LocationFolder.Trim('\\')); if (Directory.Exists(baseExtensionPath) && Directory.GetFileSystemEntries(baseExtensionPath).Length == 0) { Directory.Delete(baseExtensionPath); } MpeCore.MpeInstaller.KnownExtensions.Remove(packageClass); } catch (Exception ex) { MessageBox.Show("Error : " + ex.Message); } } ApplicationSettings.Instance.LastUpdate = DateTime.MinValue; MpeCore.MpeInstaller.Save(); SetFilterForKnownExtensionsList(); RefreshListControls(); } }
public static void Init() { InstallerTypeProviders = new Dictionary<string, IInstallerTypeProvider>(); PathProviders = new Dictionary<string, IPathProvider>(); SectionPanels = new SectionProviderHelper(); ActionProviders = new Dictionary<string, IActionType>(); VersionProviders = new Dictionary<string, IVersionProvider>(); ZipProvider = new ZipProviderClass(); AddInstallType(new CopyFile()); AddInstallType(new CopyFont()); AddInstallType(new GenericSkinFile()); PathProviders.Add("MediaPortalPaths", new MediaPortalPaths()); PathProviders.Add("TvServerPaths", new TvServerPaths()); PathProviders.Add("WindowsPaths", new WindowsPaths()); AddSection(new Welcome()); AddSection(new LicenseAgreement()); AddSection(new ReadmeInformation()); AddSection(new ImageRadioSelector()); AddSection(new TreeViewSelector()); AddSection(new InstallSection()); AddSection(new Finish()); AddSection(new GroupCheck()); AddSection(new GroupCheckScript()); AddActionProvider(new InstallFiles()); AddActionProvider(new ShowMessageBox()); AddActionProvider(new ClearSkinCache()); AddActionProvider(new RunApplication()); AddActionProvider(new KillTask()); AddActionProvider(new CreateShortCut()); AddActionProvider(new CreateFolder()); AddActionProvider(new ExtensionInstaller()); AddActionProvider(new ConfigurePlugin()); AddActionProvider(new Script()); AddVersion(new MediaPortalVersion()); AddVersion(new SkinVersion()); AddVersion(new TvServerVersion()); AddVersion(new ExtensionVersion()); AddVersion(new InstallerVersion()); InstalledExtensions = ExtensionCollection.Load(string.Format("{0}\\InstalledExtensions.xml", BaseFolder)); KnownExtensions = ExtensionCollection.Load(string.Format("{0}\\KnownExtensions.xml", BaseFolder)); }
private void add_list_Click(object sender, EventArgs e) { string xmlFile = txt_list1.Text; ExtensionCollection list = new ExtensionCollection(); ExtensionCollection list2 = new ExtensionCollection(); if (File.Exists(xmlFile)) list = ExtensionCollection.Load(xmlFile); if (File.Exists(txt_list2.Text)) list2 = ExtensionCollection.Load(txt_list2.Text); list.Add(list2); list.Save(xmlFile); }
private void btn_clean_Click(object sender, EventArgs e) { if (MessageBox.Show("Do you want to clear all unused data ?\nYou need to redownload update info .", "Cleanup", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { ExtensionCollection collection = new ExtensionCollection(); foreach (PackageClass item in MpeCore.MpeInstaller.KnownExtensions.Items) { if (MpeCore.MpeInstaller.InstalledExtensions.Get(item) == null) { collection.Items.Add(item); } } foreach (PackageClass packageClass in collection.Items) { try { if (Directory.Exists(packageClass.LocationFolder)) Directory.Delete(packageClass.LocationFolder, true); MpeCore.MpeInstaller.KnownExtensions.Remove(packageClass); } catch (Exception ex) { MessageBox.Show("Error : " + ex.Message); } } MpeCore.MpeInstaller.Save(); FilterList(); RefreshLists(); } }