我正在製作一個簡單的圖像調試器展示臺。代碼如下。我不確定是否需要手動處理Image實例?因爲我正在製作一個窗體窗口和其中包含我的動態圖像的圖片框裏面..我需要添加一些特殊的代碼時,窗體終止,處置這個?我是否需要處理這個Image實例?
這裏的代碼..
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
using Microsoft.VisualStudio.DebuggerVisualizers;
using DebuggerVisualizers;
[assembly: DebuggerVisualizer(
typeof (ImageDebuggerVisualizer),
typeof (VisualizerObjectSource),
Target = typeof (Image),
Description = "Image Visualizer")]
namespace DebuggerVisualizers
{
public class ImageDebuggerVisualizer : DialogDebuggerVisualizer
{
protected override void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider)
{
Image image = (Image) objectProvider.GetObject();
Form form = new Form
{
Text = ("Image Visualizer - " + image.HorizontalResolution + " " + image.VerticalResolution),
Width = image.Width,
Height = image.Height
};
PictureBox pictureBox = new PictureBox {Image = image, SizeMode = PictureBoxSizeMode.AutoSize};
form.Controls.Add(pictureBox);
form.ShowDialog();
}
}
}
感謝您的幫助:)
System.Drawing.Image實現IDisposable,所以你應該調用它的處置。 – 2008-11-25 14:15:03
好的..那麼當表單被銷燬時,我需要的覆蓋是什麼? – 2008-11-25 14:20:34