/// <summary> /// Sets the Scroll Down indicator Texture /// </summary> /// <param name="Path">Path to load the Texture from</param> /// <returns>True if succeeded</returns> public bool SetScrollDown(string Path) { // dispose old background DisposeScrollDown(); try { // use custom loader to load ScrollDown = OrbitTextureLoader.Load(display, Path); // only loaded if not null if (ScrollDown != null) { // get description and set path properly Global.Configuration.Images.ScrollDownImagePath = Path; return(true); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message + "\n" + ex.StackTrace); } // code will only reach this if failed loading Global.Configuration.Images.ScrollDownImagePath = ""; return(false); }
/// <summary> /// Sets the background image (the actual preview image) /// </summary> /// <param name="NewImage">Image to set that to</param> protected void SetBackground(Image NewImage) { // checking if i have the needed info if (NewImage == null || this.ScreenshotTexture != null /* || this.ScreenshotImage!=null*/) { return; } /*if(!Orbit.Core.FeatureSets.UseHQPreviews) * { * ScreenshotImage=ImageHelper.GetAspectThumbnail((Bitmap)NewImage, new Size(Global.Configuration.Appearance.IconMagnifiedSize, Global.Configuration.Appearance.IconMagnifiedSize)); * return; * }*/ try { //using(Bitmap IconThumb=(Bitmap)ImageHelper.GetAspectThumbnail((Bitmap)NewImage, new Size(Global.Configuration.Appearance.IconMagnifiedSize, Global.Configuration.Appearance.IconMagnifiedSize))) using (Bitmap IconThumb = (Bitmap)ImageHelper.GetBestSizeFor((Bitmap)NewImage, new Size(Global.Configuration.Appearance.IconMagnifiedSize, Global.Configuration.Appearance.IconMagnifiedSize))) { // load OrbitTexture oldTexture = this.ScreenshotTexture; this.ScreenshotTexture = OrbitTextureLoader.Load(display, IconThumb); UnloadTexture(ref oldTexture); } } catch (Exception) { try { UnloadTexture(ref ScreenshotTexture); } catch (Exception) {} } }
/// <summary> /// Loads the embedded texture loading error texture. /// </summary> protected void CannotLoadHoverIcon() { try { // load this._HoverIcon = OrbitTextureLoader.Load(display, System.Reflection.Assembly.LoadFile(System.Windows.Forms.Application.ExecutablePath).GetManifestResourceStream("Orbit.Images.ImageErrorIcon.png")); } catch (Exception) { UnloadTexture(ref _HoverIcon); } }
/// <summary> /// Loads the embedded texture loading error texture. /// </summary> protected void CannotLoadIcon() { // TODO: See how we can best join this and the CannotLoadHoverIcon() methods to avoid repeating code try { // load this._Icon = OrbitTextureLoader.Load(display, System.Reflection.Assembly.LoadFile(System.Windows.Forms.Application.ExecutablePath).GetManifestResourceStream("Orbit.Images.ImageErrorIcon.png")); } catch (Exception) { UnloadTexture(ref _Icon); } }
/// <summary> /// Loads the icon for the item from a bitmap /// </summary> /// <param name="NewImage">Bitmap to load the icon from</param> /// <returns>True if succeeded</returns> public bool SetIcon(Image NewImage) { // any result of this function implies that the item no longer has an image path this._ImagePath = null; // checking if i have the needed info if (NewImage == null) { CannotLoadIcon(); return(false); } try { //using(Bitmap IconThumb=(Bitmap)ImageHelper.GetAspectThumbnail((Bitmap)NewImage, new Size(Global.Configuration.Appearance.IconMagnifiedSize, Global.Configuration.Appearance.IconMagnifiedSize))) using (Bitmap IconThumb = (Bitmap)ImageHelper.GetBestSizeFor((Bitmap)NewImage, new Size(Global.Configuration.Appearance.IconMagnifiedSize, Global.Configuration.Appearance.IconMagnifiedSize))) { // load //OrbitTexture newIcon=Texture.FromBitmap(display, IconThumb, Usage.Dynamic, Pool.Default); OrbitTexture newIcon = OrbitTextureLoader.Load(display, IconThumb); if (this._Icon != null) { OrbitTexture oldIcon = this._Icon; this._Icon = newIcon; UnloadTexture(ref oldIcon); } else { //this.UnloadTexture(); this._Icon = newIcon; } } return(true); } catch (Exception) { try { UnloadTexture(ref this._Icon); } catch (Exception) {} CannotLoadIcon(); return(false); } }