Click here to Skip to main content
15,895,256 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My program takes a set of input nodes with coordinates and links hard-coded, then when the user left clicks a node(ellipse) the program should take that mouse input and run through the algo, changing the clicked node's color to identify the startnode. my code makes sense, zero errors.

The only way I can get the initial graph of nodes and links to show is if I call the function to draw them inside the

public Window()
{
   InitializeComponent();
}


region. It also doesn't seem to be calling the function to detect the node click:

C#
public void Window1_MouseClick(object sender, MouseButtonEventArgs e)
{

if (e.ClickCount == 2 && e.Source is Ellipse)
            {
                findNode = e.GetPosition(TestSpace);
                textBlock2.Text = "test complete";
                if (e.ChangedButton == MouseButton.Left)
                {
                    DoFindShortestPathTree((int)findNode.X, (int)findNode.Y);
                }
                else if (e.ChangedButton == MouseButton.Right)
                {
                    textBlock2.Text = "test complete";
                    DoFindShortestPath((int)findNode.X, (int)findNode.Y);
                }
            }
        }
}


This block is located just outside of the Window() region, inside the Window1 partial class.
Posted

1 solution

You need to handle the click event for the "node" (the visual representation of it on the screen).

This means you need to add the handler when you create the node.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900