Hi, there.
I want to change the value of textBoxW or change the value of textBoxH in the TextChanged event to change the width or height of the overlayNode, but when this code is executed, an error will be reported:
I want to change the value of textBoxW or change the value of textBoxH in the TextChanged event to change the width or height of the overlayNode, but when this code is executed, an error will be reported:
var newBounds = new System.Windows.Rect(imageNode.Bounds.Right-overlayNodeWidth , imageNode.Bounds.Bottom-overlayNodeHeight, overlayNodeWidth, overlayNodeHeight);
The error content is: System.NullReferenceException: "The object reference was not set to the instance of the object."
Message=The object reference is not set to the instance of the object.
[Call stack has been truncated]
But this code appears in the textBoxW_PreviewMouseMove event, there is no problem. May I ask why this happens?
The error content is: System.NullReferenceException: "The object reference was not set to the instance of the object."
Message=The object reference is not set to the instance of the object.
[Call stack has been truncated]
But this code appears in the textBoxW_PreviewMouseMove event, there is no problem. May I ask why this happens?
private void textBoxW_PreviewMouseMove(object sender, MouseEventArgs e)
{
if (isDragging)
{
//double newValue;
System.Windows.Point p = e.GetPosition(this);
if (p.X > clickPoint.X)
{
if (double.TryParse(textBoxW.Text, out newValueW))
newValueW += 0.1;
if (double.TryParse(textBoxH.Text, out newValueH))
{
var newBounds = new System.Windows.Rect(imageNode.Bounds.Right - newValueW, imageNode.Bounds.Bottom - newValueH,
newValueW, newValueH);
// Change the node's position / dimensions
overlayNode.SetBounds(newBounds, true, true);
textBoxW.Text = newValueW.ToString();
}
}
else if (p.X < clickPoint.X)
{
if (double.TryParse(textBoxW.Text, out newValueW))
newValueW -= 0.1;
if (double.TryParse(textBoxH.Text, out newValueH))
{
var newBounds = new System.Windows.Rect(imageNode.Bounds.Right - newValueW, imageNode.Bounds.Bottom - newValueH,
newValueW, newValueH);
// Change the node's position / dimensions
overlayNode.SetBounds(newBounds, true, true);
textBoxW.Text = newValueW.ToString();
}
}
else
base.OnPreviewMouseMove(e);
}
diagram.InvalidateForeground();
}
Any assistance would be appreciated.
Cheers,
Jack