mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-26 22:01:45 +00:00
Image Selector Control: fixed a crash when clearing an image.
This commit is contained in:
parent
a94829b78e
commit
59f8bea419
3 changed files with 22 additions and 22 deletions
|
@ -1,33 +1,38 @@
|
|||
using System.Drawing;
|
||||
#region ================== Namespaces
|
||||
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Forms;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.Controls
|
||||
{
|
||||
public class ConfigurablePictureBox : PictureBox
|
||||
{
|
||||
#region ================== Variables
|
||||
|
||||
private InterpolationMode interpolationmode = InterpolationMode.NearestNeighbor;
|
||||
private SmoothingMode smoothingmode = SmoothingMode.Default;
|
||||
private CompositingQuality compositingquality = CompositingQuality.Default;
|
||||
private PixelOffsetMode pixeloffsetmode = PixelOffsetMode.None;
|
||||
private GraphicsUnit pageunit = GraphicsUnit.Pixel;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
||||
public InterpolationMode InterpolationMode { get { return interpolationmode; } set { interpolationmode = value; } }
|
||||
public SmoothingMode SmoothingMode { get { return smoothingmode; } set { smoothingmode = value; } }
|
||||
public CompositingQuality CompositingQuality { get { return compositingquality; } set { compositingquality = value; } }
|
||||
public PixelOffsetMode PixelOffsetMode { get { return pixeloffsetmode; } set { pixeloffsetmode = value; } }
|
||||
public GraphicsUnit PageUnit { get { return pageunit; } set { pageunit = value; } }
|
||||
|
||||
/*public ConfigurablePictureBox()
|
||||
{
|
||||
InterpolationMode = InterpolationMode.NearestNeighbor;
|
||||
SmoothingMode = SmoothingMode.Default;
|
||||
CompositingQuality = CompositingQuality.Default;
|
||||
PixelOffsetMode = PixelOffsetMode.None;
|
||||
PageUnit = GraphicsUnit.Pixel;
|
||||
}*/
|
||||
|
||||
protected override void OnPaint(PaintEventArgs pe)
|
||||
#endregion
|
||||
|
||||
#region ================== Events
|
||||
|
||||
protected override void OnPaint(PaintEventArgs pe)
|
||||
{
|
||||
pe.Graphics.InterpolationMode = InterpolationMode;
|
||||
pe.Graphics.SmoothingMode = SmoothingMode;
|
||||
|
@ -36,5 +41,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
pe.Graphics.PixelOffsetMode = PixelOffsetMode;
|
||||
base.OnPaint(pe);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
{
|
||||
if(disposing && (components != null))
|
||||
{
|
||||
if(bmp != null) bmp.Dispose();
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
|
|
|
@ -36,10 +36,9 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
|
||||
public event EventHandler OnValueChanged; //mxd
|
||||
|
||||
private Bitmap bmp;
|
||||
private MouseButtons button;
|
||||
private ImageData image; //mxd
|
||||
private string previousImageName; //mxd
|
||||
private string previousimagename; //mxd
|
||||
protected bool multipletextures; //mxd
|
||||
protected bool usepreviews = true; //mxd
|
||||
|
||||
|
@ -179,12 +178,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
private void ShowPreview(Image image)
|
||||
{
|
||||
// Dispose old image
|
||||
imagebox.BackgroundImage = null;
|
||||
if(bmp != null)
|
||||
{
|
||||
bmp.Dispose();
|
||||
bmp = null;
|
||||
}
|
||||
imagebox.Image = null;
|
||||
|
||||
if(image != null)
|
||||
{
|
||||
|
@ -194,9 +188,9 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
}
|
||||
|
||||
//mxd. Dispatch event
|
||||
if(OnValueChanged != null && previousImageName != name.Text)
|
||||
if(OnValueChanged != null && previousimagename != name.Text)
|
||||
{
|
||||
previousImageName = name.Text;
|
||||
previousimagename = name.Text;
|
||||
OnValueChanged(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue