// top left, autosized
 public void TextAutosize(Point topleft, Size max, string text, Font dp, Color c, Color backcolour, float backscale = 1.0F, Object t = null, string tt = null)
 {
     img     = BitMapHelpers.DrawTextIntoAutoSizedBitmap(text, max, dp, c, backcolour, backscale);
     pos     = new Rectangle(topleft.X, topleft.Y, img.Width, img.Height);
     tag     = t;
     tooltip = tt;
 }
 // top left, sized
 public void TextFixedSizeC(Point topleft, Size size, string text, Font dp, Color c, Color backcolour,
                            float backscale = 1.0F, bool centertext = false,
                            Object t        = null, string tt = null)
 {
     img     = BitMapHelpers.DrawTextIntoFixedSizeBitmapC(text, size, dp, c, backcolour, backscale, centertext);
     pos     = new Rectangle(topleft.X, topleft.Y, img.Width, img.Height);
     tag     = t;
     tooltip = tt;
 }
        // taking image elements, draw to main bitmap. set if resize control, and if we have a min size of bitmap, or a margin
        public void Render(bool resizecontrol = true, Size?minsize = null, Size?margin = null)
        {
            Size max = DisplaySize();

            Image?.Dispose();
            Image = null;
            if (max.Width > 0 && max.Height > 0)  // will be zero if no elements
            {
                elementin = null;

                if (minsize.HasValue)           // minimum map size
                {
                    max.Width  = Math.Min(max.Width, minsize.Value.Width);
                    max.Height = Math.Min(max.Height, minsize.Value.Height);
                }

                if (margin.HasValue)            // and any margin to allow for control growth
                {
                    max.Width  += margin.Value.Width;
                    max.Height += margin.Value.Height;
                }

                Bitmap newrender = new Bitmap(max.Width, max.Height);   // size bitmap to contents

                if (!FillColor.IsFullyTransparent())
                {
                    BitMapHelpers.FillBitmap(newrender, FillColor);
                }

                using (Graphics gr = Graphics.FromImage(newrender))
                {
                    foreach (ImageElement i in elements)
                    {
                        gr.DrawImage(i.img, i.pos);
                    }
                }

                Image = newrender;      // and replace the image

                if (resizecontrol)
                {
                    this.Size = new Size(max.Width, max.Height);
                }
            }
            else
            {
                Image = null;       // nothing, null image
            }
        }