Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Draws another texture using this element's vertex buffer
        /// </summary>
        /// <param name="overrideTexture">Texture to be drawn on this item's vertex buffer</param>
        public void Draw(OrbitTexture overrideTexture)
        {
            // TODO: add position OFFSET support to this call
            DrawTextureOnBuffer(this.SpriteVertexBuffer, overrideTexture.Texture, this.Rectangle, Color.White);

            /*return;
             * try
             * {
             *      display.SamplerState[0].MagFilter = TextureFilter.Linear;
             *      display.SamplerState[0].MinFilter = TextureFilter.Linear;
             *      display.SamplerState[0].MipFilter = TextureFilter.Linear;
             *      display.SamplerState[0].MipMapLevelOfDetailBias = -1f;
             *
             *      display.SetTexture(0, overrideTexture);
             *
             *      //display.VertexFormat = CustomVertex.TransformedColoredTextured.Format;
             *      display.VertexFormat = CustomVertex.PositionColoredTextured.Format;
             *
             *      Matrix Scaling=Matrix.Scaling(this.Rectangle.Width+1, this.Rectangle.Height+1, 1f);
             *      Matrix Translation=Matrix.Translation(this.Rectangle.X+this.Rectangle.Width/2, this.Rectangle.Y+this.Rectangle.Height/2, 0f);
             *      display.Transform.World=Scaling * Translation;
             *
             *      display.SetStreamSource(0, this.SpriteVertexBuffer, 0);
             *      display.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
             * }
             * catch(Exception){}*/
        }
Ejemplo n.º 3
0
        /// <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) {}
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Unloads the specified texture from memory
 /// </summary>
 /// <param name="texture">texture to unload</param>
 protected void UnloadTexture(ref OrbitTexture texture)
 {
     if (texture != null)
     {
         texture.FreeReference();
         texture = null;
     }
 }
Ejemplo n.º 5
0
 private void DisposeScrollDown()
 {
     // scroll down
     if (this.ScrollDown != null)
     {
         this.ScrollDown.FreeReference();
         this.ScrollDown = null;
     }
 }
Ejemplo n.º 6
0
 private void DisposeScrollUp()
 {
     // scroll up
     if (this.ScrollUp != null)
     {
         this.ScrollUp.FreeReference();
         this.ScrollUp = null;
     }
 }
Ejemplo n.º 7
0
 private void DisposeIconSelected()
 {
     // Icon selected indicator
     if (this.IconSelected != null)
     {
         this.IconSelected.FreeReference();
         this.IconSelected = null;
     }
 }
Ejemplo n.º 8
0
 private void DisposeIconBg()
 {
     // icon background
     if (this.IconBg != null)
     {
         this.IconBg.FreeReference();
         this.IconBg = null;
     }
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Loads the icon for the item from a path
        /// </summary>
        /// <param name="texture">Texture to set</param>
        /// <returns>True if succeeded</returns>
        public bool SetIcon(OrbitTexture texture)
        {
            OrbitTexture oldIcon = this._Icon;

            this._Icon = texture;
            UnloadTexture(ref oldIcon);
            this._ImagePath = this._Icon.Path;

            return(true);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Loads the icon for the item from a path
        /// </summary>
        /// <param name="Path">Path to load the icon from</param>
        /// <returns>True if succeeded</returns>
        public bool SetIcon(string Path)
        {
            // TODO: possibly join this path validation thing and the SetToggledIcon one
            // checking if i have the needed info
            if ((Global.Configuration.Locations.ImagesPath == "" || Global.Configuration.Locations.ImagesPath == null || Path == null) && !System.IO.File.Exists(Path))
            {
                CannotLoadIcon();
                this._ImagePath = null;
                return(false);
            }

            // checking for relative path
            string PathToLoad;

            if (Path.IndexOf(":\\") > 0)
            {
                PathToLoad = Path;
            }
            else
            {
                PathToLoad = System.IO.Path.Combine(Global.Configuration.Locations.ImagesPath, Path);
            }

            // bail out if this doesn't exist
            if (!System.IO.File.Exists(PathToLoad))
            {
                System.Diagnostics.Debug.WriteLine("Cannot load texture: " + PathToLoad);
                CannotLoadIcon();
                this._ImagePath = null;
                return(false);
            }

            // dispose an old one
            //this.UnloadTexture();

            // and load new
            // Use Loader to load texture
            OrbitTexture oldIcon = this._Icon;

            this._Icon = Orbit.Utilities.OrbitTextureLoader.Load(display, PathToLoad);
            this.UnloadTexture(ref oldIcon);

            // generate the sprite information
            if (this._Icon != null)
            {
                this._ImagePath = PathToLoad;
            }
            else
            {
                CannotLoadIcon();
                this._ImagePath = null;
            }
            return(true);
        }
Ejemplo n.º 11
0
 /// <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);
     }
 }
Ejemplo n.º 12
0
 private void DisposeComposite()
 {
     // the composition screen
     if (this.CompositeScreen != null)
     {
         this.CompositeScreen.FreeReference();
         this.CompositeScreen = null;
     }
     if (this.composite != null)
     {
         this.composite.Dispose();
     }
 }
Ejemplo n.º 13
0
 /// <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);
     }
 }
Ejemplo n.º 14
0
        /// <summary>
        /// Loads the hover icon for the item
        /// </summary>
        /// <param name="Path">Path to load the icon from</param>
        /// <returns>True if succeeded</returns>
        public bool SetHoverIcon(string Path)
        {
            // checking if i have the needed info
            if (Global.Configuration.Locations.ImagesPath == "" || Global.Configuration.Locations.ImagesPath == null || Path == null)
            {
                CannotLoadHoverIcon();
                return(false);
            }
            // checking for relative path
            string PathToLoad;

            if (Path.IndexOf(":\\") > 0)
            {
                PathToLoad = Path;
            }
            else
            {
                PathToLoad = System.IO.Path.Combine(Global.Configuration.Locations.ImagesPath, Path);
            }

            // bail out if this doesn't exist
            if (!System.IO.File.Exists(PathToLoad))
            {
                System.Diagnostics.Debug.WriteLine("Cannot load texture: " + PathToLoad + ". Path not found.");
                CannotLoadHoverIcon();
                return(false);
            }

            // dispose an old one
            //this.UnloadHoverTexture();

            // or else load
            //this._HoverTexture=Orbit.Utilities.OrbitTextureLoader.Load(display, PathToLoad);
            OrbitTexture oldIcon = this._HoverIcon;

            this._HoverIcon = Orbit.Utilities.OrbitTextureLoader.Load(display, PathToLoad);
            this.UnloadTexture(ref oldIcon);

            // generate the sprite information
            if (this._HoverIcon == null)
            {
                CannotLoadHoverIcon();
            }
            return(true);
        }
Ejemplo n.º 15
0
        /// <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);
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Initializes the Composite buffer
        /// </summary>
        public void InitCompositeTexture()
        {
            DisposeComposite();

            try
            {
                Texture compositeScreen = new Texture(display, 512, Convert.ToInt32((Global.Configuration.Fonts.DescriptionSize + Global.Configuration.Fonts.LabelSize + 5) * 3f / 2f), 1, Usage.RenderTarget, Format.A8R8G8B8, Pool.Default);
                this.CompositeScreen = new OrbitTexture(compositeScreen);
                this.CompositeScreen.GetReference();
                composite = CompositeScreen.Texture.GetSurfaceLevel(0);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message + "\n" + ex.StackTrace);
                try
                {
                    CompositeScreen.FreeReference();
                    CompositeScreen = null;
                }
                catch (Exception) {}
            }
        }