i'm trying to share the variable: target
This section of code:
Is in the ImageProcessing class and this;
is in the CoordinateList inner-class. I could never get classes to share a variable..It’s as if I need a global variable but C# of course doesn’t use them plus it would be considered bad OOP.
This section of code:
Code:
//draw rectangles for the edges filter
if( coordinateList.CalculateEdges().Length > 0 )
{
using( Graphics graphics = Graphics.FromImage( newImage ) )
{
graphics.DrawRectangles(
new Pen( Color.Blue, 1 ),
coordinateList.CalculateEdges());
//code i added to display 'target'
graphics.DrawRectangle(
new Pen(Color.Red, 2), target);
}
}
Is in the ImageProcessing class and this;
Code:
if (coordinateList.Count != 0)
{
int x1 = 0;
foreach (PointOfInterest p in coordinateList)
{
x1 += p.XCoordinate;
}
double aX = x1 / coordinateList.Count;
int y1 = 0;
foreach (PointOfInterest p in coordinateList)
{
y1 += p.YCoordinate;
}
double aY = y1 / coordinateList.Count;
int x = (int)Math.Round(aX, 0);
int y = (int)Math.Round(aY, 0);
PointOfInterest target = new PointOfInterest(x, y);
coordinateList.Add(target);
}
Comment