Added extra null checks

This commit is contained in:
Jaex 2017-10-25 01:47:40 +03:00
parent cadd9c7fca
commit 4ea6ce887b

View file

@ -281,8 +281,16 @@ private void OnMoved()
private void Pan(int deltaX, int deltaY, bool updateCenterPoint = false)
{
ImageRectangle = ImageRectangle.LocationOffset(deltaX, deltaY);
backgroundBrush.TranslateTransform(deltaX, deltaY);
ShapeManager.MoveAll(deltaX, deltaY);
if (backgroundBrush != null)
{
backgroundBrush.TranslateTransform(deltaX, deltaY);
}
if (ShapeManager != null)
{
ShapeManager.MoveAll(deltaX, deltaY);
}
if (updateCenterPoint)
{
@ -295,7 +303,7 @@ private void Pan(Point delta, bool updateCenterPoint = false)
Pan(delta.X, delta.Y, updateCenterPoint);
}
private void UpdatePan(Vector2 center)
private void AutomaticPan(Vector2 center)
{
int x = (int)Math.Round(ScreenRectangle0Based.Width * center.X);
int y = (int)Math.Round(ScreenRectangle0Based.Height * center.Y);
@ -306,9 +314,9 @@ private void UpdatePan(Vector2 center)
Pan(deltaX, deltaY);
}
private void UpdatePan()
private void AutomaticPan()
{
UpdatePan(CanvasCenterPoint);
AutomaticPan(CanvasCenterPoint);
}
private void UpdateCenterPoint()
@ -320,7 +328,7 @@ private void UpdateCenterPoint()
private void CenterCanvas()
{
CanvasCenterPoint = new Vector2(0.5f, 0.5f);
UpdatePan();
AutomaticPan();
}
public void SetDefaultCursor()
@ -341,7 +349,7 @@ private void RegionCaptureForm_Shown(object sender, EventArgs e)
private void RegionCaptureForm_Resize(object sender, EventArgs e)
{
OnMoved();
UpdatePan();
AutomaticPan();
}
private void RegionCaptureForm_LocationChanged(object sender, EventArgs e)