private void FetchImage() { bool sizeIsSet = Size != null && Size.Height > 0 && Size.Width > 0; localPath = localImage.GetLocalImagePath(); if (sizeIsSet) { localPath = localImage.GetLocalImagePath(Size.Width, Size.Height); } if (localImage.Corrupt) { Logger.ReportWarning("Image " + localPath + " is Corrupt."); doneProcessing = true; IsLoaded = true; Microsoft.MediaCenter.UI.Application.DeferredInvoke(_ => { if (afterLoad != null) { afterLoad(); } }); return; } Image newImage = null; Microsoft.MediaCenter.UI.Application.DeferredInvoke(_ => { if (newImage == null) { //Logger.ReportVerbose("Loading image : " + localPath); string imageRef = "file://" + localPath; newImage = new Image(imageRef); } lock (this) { image = newImage; if (!sizeIsSet) { size = new Size(localImage.Width, localImage.Height); } doneProcessing = true; } IsLoaded = true; if (afterLoad != null) { afterLoad(); } }); }
// Initilize method to initialize the members public void Initialize() { // Requestr the overlaySurface to allocate a region. Microsoft.MediaCenter.UI.Size size = new Microsoft.MediaCenter.UI.Size(1200, 800); _overlaySurface.Allocate(size, true, true); // the user cannot override the zoom or rendering will be off _videoSurface.SetUserZoomModeOverride(false); // Initialize the audio stream. _audioStreamSwitcher.Initialize(); // Add delegate to handle events. _eventHandler.Initialize(); // Reset the selection to 0,0 _selectionX = 0; _selectionY = 0; }
private void LoadImageImpl() { byte[] bytes; bool sizeIsSet = Size != null && Size.Height > 0 && Size.Width > 0; var localImage = source(); // if the image is invalid it may be null. if (localImage != null) { string localPath = localImage.GetLocalImagePath(); if (sizeIsSet) { localPath = localImage.GetLocalImagePath(Size.Width, Size.Height); } bytes = File.ReadAllBytes(localPath); MemoryStream imageStream = new MemoryStream(bytes); imageStream.Position = 0; Image newImage = (Image)ImageFromStream.Invoke(null, new object[] { null, imageStream }); lock (this) { image = newImage; if (!sizeIsSet) { size = new Size(localImage.Width, localImage.Height); } } if (afterLoad != null) { // this makes it a bit more convenient Microsoft.MediaCenter.UI.Application.DeferredInvoke(_ => afterLoad()); } } }
public void SetPrimarySmallToTiny() { var windowSize = GetWindowSize(new Size(1280, 720)); this.preferredImageSmallSize = new Size(-1, windowSize.Height / 8); }
private void FetchImage() { bool sizeIsSet = Size != null && Size.Height > 0 && Size.Width > 0; localPath = localImage.GetLocalImagePath(); if (sizeIsSet) { localPath = localImage.GetLocalImagePath(Size.Width, Size.Height); } if (localImage.Corrupt) { Logger.ReportWarning("Image " + localPath + " is Corrupt."); doneProcessing = true; IsLoaded = true; Microsoft.MediaCenter.UI.Application.DeferredInvoke(_ => { if (afterLoad != null) { afterLoad(); } }); return; } Image newImage = null; if (Kernel.Instance.ConfigData.CacheAllImagesInMemory) { //defunct code.. //if (Kernel.Instance.ConfigData.UseSQLImageCache) //{ // Logger.ReportVerbose("Loading image (from sql): " + localPath); // var imageStream = ImageCache.Instance.GetImageStream(localImage.Id, localImage.Width); // //System.Drawing.Image test = System.Drawing.Image.FromStream(imageStream); // //test.Save("c:\\users\\eric\\my documents\\imagetest\\" + localImage.Id + localImage.Width + ".png"); // //test.Dispose(); // newImage = (Image)ImageFromStream.Invoke(null, new object[] { null, imageStream }); //} //else { Logger.ReportVerbose("Loading image (cacheall true) : " + localPath); byte[] bytes; lock (ProtectedFileStream.GetLock(localPath)) { bytes = File.ReadAllBytes(localPath); } MemoryStream imageStream = new MemoryStream(bytes); imageStream.Position = 0; newImage = (Image)ImageFromStream.Invoke(null, new object[] { null, imageStream }); } } Microsoft.MediaCenter.UI.Application.DeferredInvoke(_ => { if (newImage == null) { //Logger.ReportVerbose("Loading image : " + localPath); string imageRef = "file://" + localPath; newImage = new Image(imageRef); } lock (this) { image = newImage; if (!sizeIsSet) { size = new Size(localImage.Width, localImage.Height); } doneProcessing = true; } IsLoaded = true; if (afterLoad != null) { afterLoad(); } }); }
private void LoadImageImpl() { byte[] bytes; bool sizeIsSet = Size != null && Size.Height > 0 && Size.Width > 0; var localImage = source(); // if the image is invalid it may be null. if (localImage != null) { string localPath = localImage.GetLocalImagePath(); if (sizeIsSet) { localPath = localImage.GetLocalImagePath(Size.Width, Size.Height); } bytes = File.ReadAllBytes(localPath); MemoryStream imageStream = new MemoryStream(bytes); imageStream.Position = 0; Image newImage = (Image)ImageFromStream.Invoke(null, new object[] { null, imageStream }); lock (this) { image = newImage; if (!sizeIsSet) { size = new Size(localImage.Width, localImage.Height); } } if (afterLoad != null) { // this makes it a bit more convenient Microsoft.MediaCenter.UI.Application.DeferredInvoke( _ => afterLoad()); } } }
private void FetchImage() { bool sizeIsSet = Size != null && Size.Height > 0 && Size.Width > 0; if (sizeIsSet) localPath = localImage.GetLocalImagePath(Size.Width, Size.Height); else localPath = localImage.GetLocalImagePath(); if (localImage.Corrupt) { Logger.ReportWarning("Image " + localPath + " is Corrupt."); doneProcessing = true; IsLoaded = true; if (afterLoad != null) { afterLoad(); } return; } Image newImage = null; if (newImage == null) { //Logger.ReportVerbose("Loading image : " + localPath); string imageRef = "file://" + localPath; newImage = new Image(imageRef); } lock (this) { image = newImage; if (!sizeIsSet) { size = new Size(localImage.Width, localImage.Height); } doneProcessing = true; } IsLoaded = true; if (afterLoad != null) { afterLoad(); } }