Exemplo n.º 1
0
 /// <summary>
 /// Updates the windows form that contains the image of the current content.
 /// </summary>
 /// <param name="cascade">If true, it will call UpdateDisplay on NextDisplay as well</param>
 /// <returns></returns>
 public bool UpdateDisplay(bool cascade)
 {
     if (content != null)
     {
         if (pictureBox != null)
         {
             // Preview, or mini-Live display
             pictureBox.Image = ShowBeam.DrawProportionalBitmap(pictureBox.Size, GetBitmap(this.Size)).Bitmap;
         }
         else if (imagepanel != null)
         {
             imagepanel.ImagePack = ShowBeam.DrawProportionalBitmap(imagepanel.Size, GetBitmap(this.Size));
         }
         else if (showBeam != null && showBeam.TopLevelControl.Visible)
         {
             // Live display
             showBeam.GDIDraw(this.GetBitmap(Size));
         }
     }
     if (cascade && NextDisplay != null)
     {
         return(NextDisplay.UpdateDisplay(cascade));
     }
     return(true);
 }
Exemplo n.º 2
0
        public Bitmap GetBitmap(int Width, int Height)
        {
            if (this.RenderedFramesContains(this.VisibleHashCode()))
            {
                Console.WriteLine("ImageContent pre-render cache hit.");
                return(this.RenderedFramesGet(this.VisibleHashCode()) as Bitmap);
            }

            Bitmap   bmp      = new Bitmap(Width, Height);
            Graphics graphics = Graphics.FromImage(bmp);

            #region Render background image
            // Draw background image
            if (this.HideBG == false)
            {
                string fullPath = DreamTools.GetFullPathOrNull(DreamTools.GetDirectory(DirType.DataRoot), this.BGImagePath);
                if (DreamTools.FileExists(fullPath))
                {
                    if (this.bgImage == null)
                    {
                        try {
                            this.bgImage = Image.FromFile(fullPath);
                        } catch { }
                    }
                }

                if (this.bgImage != null)
                {
                    if (this._proportional)
                    {
                        graphics.DrawImage(ShowBeam.DrawProportionalBitmap(new System.Drawing.Size(Width, Height), this.bgImage).Bitmap, 0, 0, Width, Height);
                    }
                    else
                    {
                        graphics.DrawImage(this.bgImage, 0, 0, Width, Height);
                    }
                }
            }
            else
            {
                // Draw blank rectangle if no image is defined
                graphics.FillRectangle(new SolidBrush(Color.Black), new Rectangle(0, 0, Width, Height));
            }
            #endregion

            graphics.Dispose();
            this.RenderedFramesSet(this.VisibleHashCode(), bmp);

            return(bmp);
        }