Ejemplo n.º 1
0
 //-------------------------------------------------------------------------------------
 static void parent_SizeChanged(object sender, EventArgs e)
 {
  Control parent = (Control)sender;
  SimProgress box = new SimProgress();
  foreach(Control c in parent.Controls)
   if(c is SimProgress)
   {
    box = (SimProgress)c;
    break;
   }
  if(box == null)
   return;
  Rectangle r = new Rectangle(Point.Empty, parent.Size);
  if(box.BackgroundImage == null)
   box.Bounds = r;
  else
  {
   box.Hide();
   r.X = -1*(parent.Width - parent.ClientSize.Width)/2;
   r.Y = -1*(parent.Height - parent.ClientSize.Height)/2;
   Bitmap bmp = new Bitmap(r.Width, r.Height);
   parent.DrawToBitmap(bmp, new Rectangle(Point.Empty, parent.Size)); //parent.Location 
   BitmapEffects.GaussianBlur(bmp, 4);
   BitmapEffects.Ligth(bmp, 50);
   if(box.BackgroundImageLayout != ImageLayout.Center)
    box.BackgroundImageLayout = ImageLayout.Center;
   box.BackgroundImage = bmp;
   box.Location = new Point((parent.Width - box.Width)/2, (parent.Height - box.Height)/2);
   box.Bounds = r;
   box.Show();
   box.BringToFront();
  }
 }
Ejemplo n.º 2
0
 //-------------------------------------------------------------------------------------
 /// <summary>
 /// Отображает контрол в указанном родителе.
 /// </summary>
 /// <param name="parent">Родительский контрол.</param>
 /// <param name="useBack">Определяет, будет ли использоваться эмуляция прозрачности фона.</param>
 public static void Show(Control parent, bool useBack = true)
 {
  SimProgress box = new SimProgress();
  foreach(Control c in parent.Controls)
   if(c is SimProgress)
   {
    ((SimProgress)c).Start();
    return;
   }
  Rectangle r = new Rectangle(Point.Empty, parent.Size);
  try
  {
   if(useBack)
   {
    r.X = -1*(parent.Width - parent.ClientSize.Width)/2;
    r.Y = -1*(parent.Height - parent.ClientSize.Height)/2;
    Bitmap bmp = new Bitmap(r.Width, r.Height);
    parent.DrawToBitmap(bmp, new Rectangle(Point.Empty, parent.Size)); //parent.Location 
    BitmapEffects.GaussianBlur(bmp, 4);
    BitmapEffects.Ligth(bmp, 50);
    if(box.BackgroundImageLayout != ImageLayout.Center)
     box.BackgroundImageLayout = ImageLayout.Center;
    box.BackgroundImage = bmp;  
   }
   else
    box.BackColor = Color.Transparent;
  }
  catch
  {
  }
  box.Bounds = r;
  parent.Controls.Add(box);
  box.BringToFront();
  box.timer.Start();
  parent.SizeChanged += new EventHandler(parent_SizeChanged);
 }