Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6605281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:15:55+00:00 2026-05-25T19:15:55+00:00

Can someone help me solve the question: How can I divide the figure into

  • 0

Can someone help me solve the question: How can I divide the figure into the fields, so depending on which area will be mouse click it will be carried out a specific event?

    private void LayoutRoot_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
    {
        //if (!isDragging)
        {
            //creating of my  user control element
            NodePicture node = new NodePicture();
            node.Width = 100;
            node.Height = 100;

            //use cursor position as the center of the figure
            Point point = e.GetPosition(this);
            node.SetValue(Canvas.TopProperty, point.Y - node.Height / 2);
            node.SetValue(Canvas.LeftProperty, point.X - node.Width / 2);
            node.MouseLeftButtonDown += controlReletionshipsLine;
            LayoutRoot.Children.Add(node);
        }
    }

    private void controlReletionshipsLine(object sender, MouseButtonEventArgs e)
    {
        //creating parant element of node
        ParentNode parentNode = new ParentNode();

        //creating connected element of the node
        ConnectedNode connectedNode = new ConnectedNode();

        //creating node element
        NodePicture node = (NodePicture)sender;

        //getting the relative position of the element
        Point point = e.GetPosition(this);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T19:15:55+00:00Added an answer on May 25, 2026 at 7:15 pm

    You can either divide the object mathematically, using the mouse position “relative to the object” to decide where you clicked, or you can overlay a number of polygons, each with the colour alpha-channel set to 1% (so they can be hit-tested, but are not visible).

    As you simply want to see which quarter of the circle you clicked in, call GetPosition on the LeftMouseButtonDown event args, passing the control itself as the parameter. This will give you back a Point object with the position relative to the top left corner of the control.

    Then it is just a matter of seeing which quarter it is in:

    private void ControlX_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
    {
        // Get the relative position of the element
        Point point = e.GetPosition(sender as UIElement);
    
        if (point.X > control.Width/2)
        {
            if (point.Y > control.Height/2)
            {
                // You are in the bottom right quarter
            }
            else
            {
                // You are in the top right quarter
            }
        }
        else
        {
            if (point.Y > control.Height/2)
            {
                // You are in the bottom left quarter
            }
            else
            {
                // You are in the top left quarter
            }
        }
    }
    

    In the sample code you sent me (in controlReletionshipsLine) you have:

    // getting the relative position of the element
    Point point = e.GetPosition(this);
    

    It should have been:

    // getting the relative position of the element
    Point point = e.GetPosition(sender as UIElement);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone help me figure out the following make file? BINS=file1 file2 file3 all:
Can someone help me please. I had replies to a similar question but am
Ok so perhaps someone can help me with a problem I'm trying to solve.
hope someone could help me to understand how to solve my question. I have
How can I solve this riddle programmatically? Could someone help me with some pseudo-code
thats my first question here and i hope someone can help me. I´m new
Can someone help me identify what the purpose of this unidentified syntax is. It
Can someone help explain the following: If I type: a=`ls -l` Then the output
Can someone help me with the getopt function? When I do the following in
Can someone help me with this: This is a program to find all the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.