Control in WPF (Modeless) for binding the properties of an entity, is it possible?

Control in WPF (Modeless) for binding the properties of an entity, is it possible?

kelcyo
Contributor Contributor
945 Views
7 Replies
Message 1 of 8

Control in WPF (Modeless) for binding the properties of an entity, is it possible?

kelcyo
Contributor
Contributor

How can I use a control in WPF (Modeless) to control the properties of an entity in the drawing? As an example, a slider to control the length of a line...
Does anyone have a sample or suggestion?

0 Likes
Accepted solutions (1)
946 Views
7 Replies
Replies (7)
Message 2 of 8

norman.yuan
Mentor
Mentor
Accepted solution

@kelcyo , the reason people hesitate to respond to your question is the topic is rather complicated. While the question you asked in the tile is really simple to answer: yes, it is possible/doable. But it needs quite some work to just make a very simple sample project to show, if one wants to it right: using MVVM pattern to take advantage of WPF binding, and showing modeless UI in AutoCAD properly; organizing data per document because of the UI being modeless...

 

Anyway, I was able to squeeze a bit of time creating a quick sample project to show how it can be done. Because of, as I said, WPF binding and modeless UI, the project has too much code that would not be suitable to post here. So, I now just post a video clip here to show how it works. I will post whole project in my blog later, when I can find a bit of time, stay tuned.

 

 

 

Norman Yuan

Drive CAD With Code

EESignature

Message 3 of 8

kelcyo
Contributor
Contributor
Exactly what I mean. Waiting to see your code...thanks for the effort to help, I appreciate it...
0 Likes
Message 4 of 8

norman.yuan
Mentor
Mentor
0 Likes
Message 5 of 8

norman.yuan
Mentor
Mentor

Well, after 2 days, I updated the project and made it another post in my blog. Read it here:

 

https://drive-cad-with-code.blogspot.com/2022/09/update-entities-via-data-binding-of_25.html 

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 6 of 8

Gepaha
Collaborator
Collaborator

Norman, thank you very much for the example.

I've taken a look around and seen that it's been using Database.FingerprintGuid.

In my view Database.FingerprintGuid is not a unique identifier. Create a Database and save it under different names, they will have the same FingerprintGuid. With saveas you will get multiple drawings with the same guid.

0 Likes
Message 7 of 8

norman.yuan
Mentor
Mentor

@Gepaha , thank you to point it out. I was meant to use a unique key to segregate data among opened drawings in a session. So, yes, if the FingerprintGuid could be the same from different drawings because of them being copied from the same original drawing, then the code would not work correctly. This was my oversight because of wanting to make code more concise. I should have use Document, or Document.UnmanagedObject, as I mentioned in the article, as the dictionary key. 

 

A different topic: it is interesting that Database.FigureprintGuid could remain the same if a copy of the drawing is created and named differently. Just imagine: all drawings from an office could have the same FingerripntGuid, if the drawings are from the same template file? Or, all drawings exist in the would could have the same Data base.FingerprintGuid, if they all created based on "acad.dwt". So, what the purpose to have this FingerprintGuid? Interesting, eh?

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 8 of 8

norman.yuan
Mentor
Mentor

Thanks for @Gepaha pointing out a bug in my code (by using Database.FinerprintGuid as dictionary's key), I updated the code in my article and the source code for downloading.

 

https://drive-cad-with-code.blogspot.com/2022/09/update-entities-via-data-binding-of_25.html 

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes