public void Initialize(PackageClass package, bool isInstalled) { this.Package = package; this.isInstalled = isInstalled; this.meetsAllDependencies = !package.CheckDependency(true); if (isInstalled) { UpdatePackage = MpeCore.MpeInstaller.KnownExtensions.GetUpdate(package); } extensionControlCollapsed.Initialize( package.GeneralInfo.Name, package.GeneralInfo.Author, package.GeneralInfo.Version.ToString(), meetsAllDependencies, UpdatePackage != null ? UpdatePackage.GeneralInfo.Version.ToString() : null, CollapsedItemClicked); Height = extensionControlCollapsed.PreferredSize.Height + Margin.Top + Margin.Bottom; if (ApplicationSettings.Instance.ExpandTile) { Expand(); } }
public void InstallFile(string file, bool silent, bool gui) { if (!File.Exists(file)) { if (!silent) { MessageBox.Show("File not found !"); } return; } if (IsOldFormat(file)) { if (!silent) { MessageBox.Show("This is an old format file (mpi). The extension will NOT be installed. "); } return; } MpeCore.MpeInstaller.Init(); PackageClass pak = new PackageClass(); pak = pak.ZipProvider.Load(file); if (pak == null) { if (!silent) { MessageBox.Show("Wrong file format !"); } return; } if (pak.CheckDependency(false)) { PackageClass installedPak = MpeCore.MpeInstaller.InstalledExtensions.Get(pak.GeneralInfo.Id); if (installedPak != null) { if (pak.GeneralInfo.Params[ParamNamesConst.FORCE_TO_UNINSTALL_ON_UPDATE].GetValueAsBool()) { if (!silent) { if ( MessageBox.Show( "Another version of this extension is installed\nand needs to be uninstalled first.\nDo you want to continue?\n" + "Old extension version: " + installedPak.GeneralInfo.Version + "\n" + "New extension version: " + pak.GeneralInfo.Version, "Install extension", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) != DialogResult.Yes) { return; } } UnInstall dlg = new UnInstall(); dlg.Execute(installedPak, true); pak.CopyGroupCheck(installedPak); } else { MpeCore.MpeInstaller.InstalledExtensions.Remove(installedPak); } } if (gui) { this.Hide(); } pak.Silent = silent; pak.StartInstallWizard(); if (gui) { SetFilterForKnownExtensionsList(); RefreshListControls(); this.Show(); } } else { if (!silent) { if (MessageBox.Show("Dependency check error! Install aborted!\nWould you like to view more details?", pak.GeneralInfo.Name, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { DependencyForm frm = new DependencyForm(pak); frm.ShowDialog(); } } } }
private bool DoUpdate(PackageClass packageClass, PackageClass newpackageClass, bool silent) { string newPackageLoacation = ExtensionUpdateDownloader.GetPackageLocation(newpackageClass, Client_DownloadProgressChanged, Client_DownloadFileCompleted); if (!File.Exists(newPackageLoacation)) { if (!silent) { MessageBox.Show("Can't locate the installer package. Update aborted"); } return(false); } PackageClass pak = new PackageClass(); pak = pak.ZipProvider.Load(newPackageLoacation); if (pak == null) { if (!silent) { MessageBox.Show("Invalid package format ! Update aborted !"); } return(false); } if (pak.GeneralInfo.Id != newpackageClass.GeneralInfo.Id || pak.GeneralInfo.Version.CompareTo(newpackageClass.GeneralInfo.Version) < 0) { if (!silent) { MessageBox.Show("Invalid update information ! Update aborted!"); } return(false); } if (!pak.CheckDependency(false)) { if (!silent) { if (MessageBox.Show("Dependency check error! Update aborted!\nWould you like to view more details?", pak.GeneralInfo.Name, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { DependencyForm frm = new DependencyForm(pak); frm.ShowDialog(); } } return(false); } if (!silent) { if ( MessageBox.Show( "This operation will update the extension " + packageClass.GeneralInfo.Name + " to the version " + pak.GeneralInfo.Version + " \n Do you want to continue ? ", "Install extension", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) != DialogResult.Yes) { return(false); } } // only uninstall previous version, if the new package has the setting to force uninstall of previous version on update if (pak.GeneralInfo.Params[ParamNamesConst.FORCE_TO_UNINSTALL_ON_UPDATE].GetValueAsBool()) { UnInstall dlg = new UnInstall(); dlg.Execute(packageClass, true); } else { MpeCore.MpeInstaller.InstalledExtensions.Remove(packageClass); } pak.CopyGroupCheck(packageClass); pak.Silent = true; pak.StartInstallWizard(); return(true); }
private void extensionListControl_InstallExtension(object sender, PackageClass packageClass) { string newPackageLoacation = ExtensionUpdateDownloader.GetPackageLocation(packageClass, Client_DownloadProgressChanged, Client_DownloadFileCompleted); if (!File.Exists(newPackageLoacation)) { MessageBox.Show("Can't locate the installer package. Install aborted"); return; } PackageClass pak = new PackageClass(); pak = pak.ZipProvider.Load(newPackageLoacation); if (pak == null) { MessageBox.Show("Package loading error ! Install aborted!"); try { if (newPackageLoacation != packageClass.GeneralInfo.Location) { File.Delete(newPackageLoacation); } } catch { } return; } if (!pak.CheckDependency(false)) { if (MessageBox.Show("Dependency check error! Install aborted!\nWould you like to view more details?", pak.GeneralInfo.Name, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { DependencyForm frm = new DependencyForm(pak); frm.ShowDialog(); } pak.ZipProvider.Dispose(); try { if (newPackageLoacation != packageClass.GeneralInfo.Location) { File.Delete(newPackageLoacation); } } catch { } return; } if (packageClass.GeneralInfo.Version.CompareTo(pak.GeneralInfo.Version) != 0) { if (MessageBox.Show( string.Format(@"Downloaded version of {0} is {1} and differs from your selected version: {2}! Do you want to continue ?", packageClass.GeneralInfo.Name, pak.GeneralInfo.Version, packageClass.GeneralInfo.Version), "Install extension", MessageBoxButtons.YesNo, MessageBoxIcon.Error) != DialogResult.Yes) { return; } } if ( MessageBox.Show( "This operation will install " + packageClass.GeneralInfo.Name + " version " + pak.GeneralInfo.Version + "\n Do you want to continue ?", "Install extension", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) != DialogResult.Yes) { return; } this.Hide(); packageClass = MpeCore.MpeInstaller.InstalledExtensions.Get(packageClass.GeneralInfo.Id); if (packageClass != null) { if (pak.GeneralInfo.Params[ParamNamesConst.FORCE_TO_UNINSTALL_ON_UPDATE].GetValueAsBool()) { if ( MessageBox.Show( "Another version of this extension is installed\nand needs to be uninstalled first.\nDo you want to continue?\n" + "Old extension version: " + packageClass.GeneralInfo.Version + "\n" + "New extension version: " + pak.GeneralInfo.Version, "Install extension", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) != DialogResult.Yes) { this.Show(); return; } UnInstall dlg = new UnInstall(); dlg.Execute(packageClass, false); } else { MpeCore.MpeInstaller.InstalledExtensions.Remove(packageClass); } pak.CopyGroupCheck(packageClass); } pak.StartInstallWizard(); RefreshListControls(); pak.ZipProvider.Dispose(); try { if (newPackageLoacation != packageClass.GeneralInfo.Location) { File.Delete(newPackageLoacation); } } catch { } this.Show(); }
private bool DoUpdate(PackageClass packageClass, PackageClass newpackageClass, bool silent) { string newPackageLoacation = GetPackageLocation(newpackageClass); if (!File.Exists(newPackageLoacation)) { if (!silent) { MessageBox.Show("Can't locate the installer package. Update aborted"); } return(false); } PackageClass pak = new PackageClass(); pak = pak.ZipProvider.Load(newPackageLoacation); if (pak == null) { if (!silent) { MessageBox.Show("Invalid package format ! Update aborted !"); } return(false); } if (pak.GeneralInfo.Id != newpackageClass.GeneralInfo.Id || pak.GeneralInfo.Version.CompareTo(newpackageClass.GeneralInfo.Version) < 0) { if (!silent) { MessageBox.Show("Invalid update information ! Update aborted!"); } return(false); } if (!pak.CheckDependency(false)) { if (!silent) { if (MessageBox.Show("Dependency check error! Update aborted!\nWould you like to view more details?", string.Empty, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { DependencyForm frm = new DependencyForm(pak); frm.ShowDialog(); } } return(false); } if (!silent) { if ( MessageBox.Show( "This operation will update the extension " + packageClass.GeneralInfo.Name + " to the version " + pak.GeneralInfo.Version + " \n Do you want to continue ? ", "Install extension", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) != DialogResult.Yes) { return(false); } } UnInstall dlg = new UnInstall(); dlg.Execute(packageClass, true); pak.CopyGroupCheck(packageClass); pak.Silent = true; pak.StartInstallWizard(); return(true); }
private void extensionListControl_InstallExtension(object sender, PackageClass packageClass) { string newPackageLoacation = GetPackageLocation(packageClass); if (!File.Exists(newPackageLoacation)) { MessageBox.Show("Can't locate the installer package. Install aborted"); return; } PackageClass pak = new PackageClass(); pak = pak.ZipProvider.Load(newPackageLoacation); if (pak == null) { MessageBox.Show("Package loading error ! Install aborted!"); try { if (newPackageLoacation != packageClass.GeneralInfo.Location) { File.Delete(newPackageLoacation); } } catch { } return; } if (!pak.CheckDependency(false)) { if (MessageBox.Show("Dependency check error! Install aborted!\nWould you like to view more details?", string.Empty, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { DependencyForm frm = new DependencyForm(pak); frm.ShowDialog(); } pak.ZipProvider.Dispose(); try { if (newPackageLoacation != packageClass.GeneralInfo.Location) { File.Delete(newPackageLoacation); } } catch { } return; } if ( MessageBox.Show( "This operation will install extension " + packageClass.GeneralInfo.Name + " version " + pak.GeneralInfo.Version + " \n Do you want to continue ? ", "Install extension", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) != DialogResult.Yes) { return; } this.Hide(); packageClass = MpeCore.MpeInstaller.InstalledExtensions.Get(packageClass.GeneralInfo.Id); if (packageClass != null) { UnInstall dlg = new UnInstall(); dlg.Execute(packageClass, true); pak.CopyGroupCheck(packageClass); } pak.StartInstallWizard(); RefreshLists(); pak.ZipProvider.Dispose(); try { if (newPackageLoacation != packageClass.GeneralInfo.Location) { File.Delete(newPackageLoacation); } } catch { } this.Show(); }
public ExtensionControl(PackageClass packageClass) { _client.DownloadFileCompleted += _client_DownloadFileCompleted; InitializeComponent(); lbl_name.Text = packageClass.GeneralInfo.Name + " - " + packageClass.GeneralInfo.Author; lbl_version.Text = packageClass.GeneralInfo.Version.ToString(); lbl_description.Text = packageClass.GeneralInfo.ExtensionDescription; bool haveimage = false; if (Directory.Exists(packageClass.LocationFolder)) { DirectoryInfo di = new DirectoryInfo(packageClass.LocationFolder); FileInfo[] fileInfos = di.GetFiles("icon.*"); if (fileInfos.Length > 0) { img_logo.LoadAsync(fileInfos[0].FullName); haveimage = true; } } if (!haveimage && !string.IsNullOrEmpty(packageClass.GeneralInfo.Params[ParamNamesConst.ONLINE_ICON].Value)) { try { _downloadItem.SourceUrl = packageClass.GeneralInfo.Params[ParamNamesConst.ONLINE_ICON].Value; _downloadItem.TempDestination = Path.GetTempFileName(); _downloadItem.Destination = packageClass.LocationFolder + "icon" + Path.GetExtension(_downloadItem.SourceUrl); if (!Directory.Exists(Path.GetDirectoryName(_downloadItem.Destination))) { Directory.CreateDirectory(Path.GetDirectoryName(_downloadItem.Destination)); } _client.DownloadFileAsync(new Uri(_downloadItem.SourceUrl), _downloadItem.TempDestination); } catch (Exception) {} } btn_screenshot.Enabled = !string.IsNullOrEmpty(packageClass.GeneralInfo.Params[ParamNamesConst.ONLINE_SCREENSHOT].Value); Package = MpeCore.MpeInstaller.InstalledExtensions.Get(packageClass); if (Package == null) { Package = packageClass; btn_conf.Visible = false; btn_update.Visible = false; btn_uninstall.Visible = false; } btn_home.Visible = !string.IsNullOrEmpty(Package.GeneralInfo.HomePage); btn_forum.Visible = !string.IsNullOrEmpty(Package.GeneralInfo.ForumPage); PopulateInstallBtn(); btn_conf.Enabled = !string.IsNullOrEmpty(Package.GeneralInfo.Params[ParamNamesConst.CONFIG].GetValueAsPath()); if (!Package.CheckDependency(true)) { img_dep.Visible = true; img_dep1.Visible = true; } else { img_dep.Visible = false; img_dep1.Visible = false; } Selected = false; SelectControl(); SetButtonState(); }