Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Selecting objects on a WPF canvas?
Message
De
24/02/2009 14:33:33
 
 
À
24/02/2009 14:22:12
Information générale
Forum:
ASP.NET
Catégorie:
Windows Presentation Foundation (WPF)
Divers
Thread ID:
01383557
Message ID:
01383882
Vues:
35
>>>Well, I've learned more!!! I think I've done it...
>>>
>>>First, I've moved the move event handling to the Canvas instead of each Ellipse. That's good and bad, from an OOP standpoint. At least when the mouse event handling is a responsibility of the HolePattern to set it on up each Hole (the ellipse that is the visual of the Hole), it is abstracted away so that any consumer of my HolePattern will get this functioanality automactically. However, by moving it to the main UI code, I now am dealing with my canvas mouse event at a higher level. But that's not all bad either. We could discuss this part for days.
>>>
>>>The point is, I have designed a way to create a "margin of error" when picking something on a canvas with a mouse, and then reading the Hole that the selected Ellipse belongs to, and then I can read the HolePattern that the Hole belongs to, and my entire UI (ListView, textboxes, gridview fo coordinates) are ALL updated by the existing XAML binding, and the Canvas is updated with one call to an existing method to regenerate the canvas.
>>>
>>>To be honest, I can't believe I've figured all this out (with your help and others too, of course). It is such a cool feeling to have the vision of this this and see it come to be.
>>
>>I wouldn't have been worried about the 50 events thing, since they would have been encapsulated in the hole code. It would probably be less events than a form with 25 textboxes on it. (You may not be handling the events on a textbox, but someone has to, so they still exist.) An event is just a memory pointer, so it's not a lot of memory that is being used.
>>
>>However, your method of doing it from the canvas is another totally valid way of doing it. Glad to see you got it working.
>>
>>Your holes seem large enough that click area should not have been a problem. Not sure what was up with that. Was it just for when the holes got real small, or were you getting click through on the transparency?
>
>Did you see my suggestion of using a Fill on the ellipse?

Ah I missed that thread, so it is the transparent area that's the problem.

I think it may just be that he has no fill assigned. It should still work if he just uses a transparent fill, with a transparent fill the color would not be an issue.

If that's not it then it's the other 2 items I mentioned.

> The other solution to an accuracy problem is to add a transparent object that accepts your clicks and is a tad larger than your real object. (If it's because of the transparency you could have checked IsHitTestVisible and also tried PreviewMouseLeftButtonDown, some one else may have been consuming your click.)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform