public bool CheckForUpdate(out Version installedVersion, out Version newVersion) { // Find the vsix on the vs gallery // IMPORTANT: The .AsEnumerble() call is REQUIRED. Don't remove it or the update service won't work. GalleryEntry nugetVsix = _extensionRepository.CreateQuery <GalleryEntry>(includeTypeInQuery: false, includeSkuInQuery: true) .Where(e => e.VsixID == NuGetVSIXId) .AsEnumerable() .FirstOrDefault(); // Get the current NuGet VSIX version IInstalledExtension installedNuGet = _extensionManager.GetInstalledExtension(NuGetVSIXId); installedVersion = installedNuGet.Header.Version; // If we're running an older version then update if (nugetVsix != null && nugetVsix.NonNullVsixVersion > installedVersion) { newVersion = nugetVsix.NonNullVsixVersion; return(true); } else { newVersion = installedVersion; return(false); } }
public async Task <IActionResult> Edit(int id, [Bind("GalleryEntryID,Title,Description,Instructions")] GalleryEntry galleryEntry) { if (id != galleryEntry.GalleryEntryID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(galleryEntry); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GalleryEntryExists(galleryEntry.GalleryEntryID)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(View(galleryEntry)); }
// Start is called before the first frame update void Start() { flashCanvas.SetActive(true); string sceneName = SceneLoaderScript.getLastSceneName(); sceneName = sceneName != null ? sceneName : ""; LevelDatabase.LevelData level = LevelDatabase.GetLevelData(sceneName); string levelName = level != null ? level.name : "Unknown level"; string levelImage = level != null ? level.polaroidPath : ""; DateTime time = DateTime.UtcNow.Date; dateField.text = time.ToShortDateString(); SetLevelDuration(); levelNameField.text = levelName; selfie.GeneratePose(); tagsField.text = GetRandomTagsText(); backgroundImage.sprite = Resources.Load <Sprite>(levelImage); if (level != null) { string levelNameForPath = levelName.Replace(' ', '_'); screenShot.TakeScreenShot(levelNameForPath, path => { GalleryEntry entry = new GalleryEntry(levelName, path); GalleryManager.Instance.SaveEntry(entry); }); } }
public void SaveEntry(GalleryEntry entry) { var entries = LoadEntries(); entries.RemoveAll(item => item.name == entry.name); entries.Add(entry); OverrideEntriesOnDisk(entries); }
/// <summary> /// Compute the number of likes a particular gallery entry has /// </summary> /// <param name="galleryEntry">The primary key of the gallery entry</param> /// <returns>The number of likes on the gallery entry</returns> public async Task <int> ComputeNLikes(GalleryEntry galleryEntry) { List <GalleryEntry_ApplicationUser> likes = await _sparkClipsContext.GalleryEntry_ApplicationUser .Include(ge_au => ge_au.GalleryEntry) .Include(ge_au => ge_au.ApplicationUser) .Where(ge_au => ge_au.GalleryEntry == galleryEntry) .ToListAsync(); return(likes.Count()); }
// GET: /Gallery/Detail/1 public async Task <IActionResult> Detail(int ID) { GalleryEntry galleryEntry = await _galleryRepository.GetGalleryEntryByID(ID); if (galleryEntry == null) { return(NotFound()); } return(View(galleryEntry)); }
/// <summary> /// Return a specific GalleryEntry /// </summary> /// <param name="galleryEntryID">The primary key of the gallery entry you want</param> /// <returns> /// GalleryEntry or null if a GalleryEntry with that pk doesn't exit /// </returns> public async Task <GalleryEntry> GetGalleryEntryByID(int galleryEntryID) { GalleryEntry galleryEntry = await _sparkClipsContext.GalleryEntries .Include(ge => ge.Images) .ThenInclude(image => image.Image) .Include(ge => ge.Tags) .ThenInclude(tag => tag.Tag) .SingleOrDefaultAsync(g => g.GalleryEntryID == galleryEntryID); return(galleryEntry); }
public async Task <IActionResult> Create([Bind("GalleryEntryID,Title,Description,Instructions")] GalleryEntry galleryEntry) { if (ModelState.IsValid) { _context.Add(galleryEntry); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(galleryEntry)); }
/// <summary> /// Compute the thumbnail url for a particular gallery entry /// </summary> /// <param name="galleryEntry">The gallery entry whose thumbnail you want to compute /// Note: The collection navigation property "Images" needs to be set on this GalleryEntry instance /// </param> /// <returns>A string which is the thumbnail as a URL</returns> public string ComputeThumbnail(GalleryEntry galleryEntry) { if (galleryEntry.Images.Count() == 0) { // if this gallery entry has no images defined, return a random stock photo return("/images/no-image.png"); // return "https://unsplash.it/g/200/300/?random"; } else { // get first related entry in the associative many2many table GalleryEntry_Image firstImage = galleryEntry.Images.First(); return(firstImage.Image.Url); } }
private void SetPolaroid(GalleryEntry entry, GameObject page, int index) { var go = page.transform.GetChild(index); var image = go.GetComponent <Image>(); var sprite = CreateSprite(entry.path); image.sprite = sprite; image.color = new Color(1, 1, 1, 1); Button button = go.gameObject.AddComponent(typeof(Button)) as Button; button.onClick.AddListener(() => { showDetailCanvas(sprite); }); }
public static bool CheckForUpdate(IInstalledExtension extension, out IInstallableExtension update) { var _repository = serviceProvider.Get <IVsExtensionRepository>(); // Find the vsix on the vs gallery // IMPORTANT: The .AsEnumerble() call is REQUIRED. Don't remove it or the update service won't work. GalleryEntry entry = _repository.CreateQuery <GalleryEntry>(false, true) .Where(e => e.VsixID == extension.Header.Identifier) .AsEnumerable() .FirstOrDefault(); // If we're running an older version then update if (entry != null && entry.NonNullVsixVersion > extension.Header.Version) { update = _repository.Download(entry); return(UpdateCanInstalledToCurrentProduct(update)); } return(CheckForUpdateWithReflection(extension, out update) && UpdateCanInstalledToCurrentProduct(update)); }
private async System.Threading.Tasks.Task ExtMgrInstallExtensionAsync() { GalleryEntry entry = null; try { // Waits for MEF to initialize before the extension manager is ready to use var scComponentModel = VSPackageInstaller.VSPackage.GetGlobalService(typeof(SComponentModel)); IVsExtensionRepository repository = VSPackageInstaller.VSPackage.GetGlobalService(typeof(SVsExtensionRepository)) as IVsExtensionRepository; IVsExtensionManager manager = VSPackageInstaller.VSPackage.GetGlobalService(typeof(SVsExtensionManager)) as IVsExtensionManager; Logger.Log($"{Environment.NewLine}{this.Extension.Title}"); Logger.Log(" " + "Verifying ", false); entry = repository.GetVSGalleryExtensions <GalleryEntry>(new System.Collections.Generic.List <string> { this.Extension.VsixId.ToString() }, 1033, false)?.FirstOrDefault(); if (entry != null) { // ensure that we update the URL if it is empty if (entry.DownloadUrl == null) { entry.DownloadUrl = this.Extension.Installer; throw new Exception("This is not a VsiX"); } Logger.Log("Marketplace OK"); // Marketplace ok Logger.Log(" " + "Downloading"); IInstallableExtension installable = repository.Download(entry); if (installable == null) { throw new Exception("This is not a VsiX"); } Logger.Log("Downloading OK"); // Download ok Logger.Log(" " + "Installing"); manager.Install(installable, false); Logger.Log("Installation queued OK"); // Install ok Logger.Log("This extension package will now be automatically installed when you exist all instances of Visual Studio"); } else { Logger.Log("Marketplace failed"); // Markedplace failed // This is not a VsiX throw new Exception("This is not a VsiX"); Logger.Log("Done"); } } catch (Exception ex) { Logger.Log("Extension Manager installtion failed exception: " + ex); Logger.Log("Trying manual downloand and install"); await this.ManualInstallExtensionAsync(); } finally { await System.Threading.Tasks.Task.Yield(); } }