AddRectangle Exception
-
Hi i seem to be getting an argumentException on the indicated line for no reason that i can see. There is a perameter not valid message however it is, as i create the rectangle and add it straight away.
// Add two rectangles to graphics path Rectangle rectangle = new Rectangle(5, 5, 10, 10); // Create two rectangles representing the node and expand box Rectangle textBacking = new Rectangle(m\_expandBox.Width + (m\_gap \* 2), m\_gap - (int)(m\_gap \* 0.5), Size.Width - m\_gap, Size.Height - m\_gap);
-----> m_gpExpandBox.AddRectangle(rectangle);
m_gpTextBacking.AddRectangle(textBacking);Does anyone know why this is happening. I cannot see any information on the net that would reveal the cause of the problem. Thanx George
-
Hi i seem to be getting an argumentException on the indicated line for no reason that i can see. There is a perameter not valid message however it is, as i create the rectangle and add it straight away.
// Add two rectangles to graphics path Rectangle rectangle = new Rectangle(5, 5, 10, 10); // Create two rectangles representing the node and expand box Rectangle textBacking = new Rectangle(m\_expandBox.Width + (m\_gap \* 2), m\_gap - (int)(m\_gap \* 0.5), Size.Width - m\_gap, Size.Height - m\_gap);
-----> m_gpExpandBox.AddRectangle(rectangle);
m_gpTextBacking.AddRectangle(textBacking);Does anyone know why this is happening. I cannot see any information on the net that would reveal the cause of the problem. Thanx George
We would probably need to know more about whatever m_gpExpandBox is, and what it's AddRectangle method is declared as.
If Barbie is so popular, why do you have to buy her friends? Eagles may soar, but weasels don't get sucked into jet engines. If at first you don't succeed, destroy all evidence that you tried.
-
We would probably need to know more about whatever m_gpExpandBox is, and what it's AddRectangle method is declared as.
If Barbie is so popular, why do you have to buy her friends? Eagles may soar, but weasels don't get sucked into jet engines. If at first you don't succeed, destroy all evidence that you tried.
Yep thats kwl: GraphicsPath.AddRectangle(); (standard method .net) Takes a rectangle as perameter and adds it to graphics path
private GraphicsPath m_gpExpandBox; // Represents the box for the expand and contract
public Node(string name) { // Set the name of this node m\_name = name; // Create objects m\_childNodes = new List<Node>();
-----> m_gpExpandBox = new GraphicsPath();
m_gpTextBacking = new GraphicsPath();
m_fontLocation = new Point(0, 0);// Set size and location of the node m\_size = new Size(60, 20); m\_location = new Point(0, 0); }
There is too much code to include every reference to m_gpExpandBox. It is a graphics path i add to in order to draw an expansion box on a node of a tree view control. Do you think this could be a cause of the problem even though it complains of an invalid perameter. Thanx George
-
Yep thats kwl: GraphicsPath.AddRectangle(); (standard method .net) Takes a rectangle as perameter and adds it to graphics path
private GraphicsPath m_gpExpandBox; // Represents the box for the expand and contract
public Node(string name) { // Set the name of this node m\_name = name; // Create objects m\_childNodes = new List<Node>();
-----> m_gpExpandBox = new GraphicsPath();
m_gpTextBacking = new GraphicsPath();
m_fontLocation = new Point(0, 0);// Set size and location of the node m\_size = new Size(60, 20); m\_location = new Point(0, 0); }
There is too much code to include every reference to m_gpExpandBox. It is a graphics path i add to in order to draw an expansion box on a node of a tree view control. Do you think this could be a cause of the problem even though it complains of an invalid perameter. Thanx George
My bad - I missed the hungarian notation and GraphicsPath reference.
gwithey wrote:
Do you think this could be a cause of the problem even though it complains of an invalid perameter.
Don't know - have you stuck a breakpoint on and looked at the actual values of the rectangle?
If Barbie is so popular, why do you have to buy her friends? Eagles may soar, but weasels don't get sucked into jet engines. If at first you don't succeed, destroy all evidence that you tried.
-
My bad - I missed the hungarian notation and GraphicsPath reference.
gwithey wrote:
Do you think this could be a cause of the problem even though it complains of an invalid perameter.
Don't know - have you stuck a breakpoint on and looked at the actual values of the rectangle?
If Barbie is so popular, why do you have to buy her friends? Eagles may soar, but weasels don't get sucked into jet engines. If at first you don't succeed, destroy all evidence that you tried.
-
My bad - I missed the hungarian notation and GraphicsPath reference.
gwithey wrote:
Do you think this could be a cause of the problem even though it complains of an invalid perameter.
Don't know - have you stuck a breakpoint on and looked at the actual values of the rectangle?
If Barbie is so popular, why do you have to buy her friends? Eagles may soar, but weasels don't get sucked into jet engines. If at first you don't succeed, destroy all evidence that you tried.
public int Draw(Graphics g)
{
DrawNode();// Create font for text Font nodeFont = new Font(FontFamily.GenericSansSerif, 10f, FontStyle.Regular); // Fill node if selected if (m\_selected) { g.FillPath(Brushes.Red, m\_gpTextBacking); g.DrawString(m\_name, nodeFont, Brushes.White, m\_fontLocation); } else { g.DrawString(m\_name, nodeFont, Brushes.Black, m\_fontLocation); } // Draw node backing if hover is true if (m\_hover) { g.DrawPath(Pens.Black, m\_gpTextBacking); } // Draw expand box g.FillPath(Brushes.Gray, m\_gpExpandBox); g.DrawPath(Pens.Black, m\_gpExpandBox); // Dispose of graphics paths
------> //m_gpExpandBox.Dispose();
------> //m_gpTextBacking.Dispose();Thank you for the help found the soulution. It now works when comment out the indicated lines