示例#1
0
        private void previewPanel_Paint(object sender, PaintEventArgs e)
        {
            HandleUpdate();
            ImageRef imageRef = null;

            Monitor.Enter(this);
            try
            {
                if (previewImage != null)
                {
                    imageRef = (ImageRef)previewImage.Duplicate("LegendOptionsPanel.previewPanel_Paint");
                }
            }
            finally
            {
                Monitor.Exit(this);
            }

            if (imageRef != null)
            {
                try
                {
                    GDIBigLockedImage image;
                    Monitor.Enter(image = imageRef.image);
                    try
                    {
                        Image image2 = imageRef.image.IPromiseIAmHoldingGDISLockSoPleaseGiveMeTheImage();
                        e.Graphics.DrawImage(image2,
                                             new Rectangle(new Point(0, 0), previewPanel.Size),
                                             new Rectangle(new Point(0, 0), previewPanel.Size),
                                             GraphicsUnit.Pixel);
                    }
                    finally
                    {
                        Monitor.Exit(image);
                    }
                }
                catch (Exception)
                {
                    D.Say(0, "Absorbing that disturbing bug wherein the mostRecentTile image is corrupt.");
                }

                imageRef.Dispose();
                return;
            }

            e.Graphics.DrawRectangle(new Pen(Color.Black),
                                     0,
                                     0,
                                     previewPanel.Size.Width - 1,
                                     previewPanel.Height - 1);
        }
示例#2
0
 private void UpdatePreviewImage(ImageRef imageRef)
 {
     Monitor.Enter(this);
     try
     {
         if (this.previewImage != null)
         {
             this.previewImage.Dispose();
             this.previewImage = null;
         }
         if (imageRef != null)
         {
             this.previewImage = (ImageRef)imageRef.Duplicate("LegendOptionsPanel.UpdatePreviewImage");
         }
     }
     finally
     {
         Monitor.Exit(this);
     }
     base.Invalidate();
 }