OpenKNX / Kaenx-Creator

Create your own KnxProd Files with UI.
MIT License
70 stars 20 forks source link

Add Option to copy existing parameters #5

Closed uschmelmer closed 2 years ago

uschmelmer commented 2 years ago

I added the option to clone existing parameters. Please review carefully, my first time on this project.

Cheers, Udo

uschmelmer commented 2 years ago

I also added comObject cloning. Quick test (incl check with ETS) worked. On cloning i add a empty Text to the ComObjRef, same as in the add-function: cref.Text.Add(new Models.Translation(lang, "")); cref.FunctionText.Add(new Models.Translation(lang, "")) is this fine or do we need to copy something here?

thewhobox commented 2 years ago

Thank you.

If it is an auto comonjref i just add empty translations. So everything looks fine. I testet id and found a bug, but thats on me an i already found a fix for it.

thewhobox commented 2 years ago

I changed it to

comobj.Text = new ObservableCollection<Translation>(Text.ToList());
comobj.FunctionText = new ObservableCollection<Translation>(FunctionText.ToList());

Works also fine and less code :)

uschmelmer commented 2 years ago

I changed it to

comobj.Text = new ObservableCollection<Translation>(Text.ToList());
comobj.FunctionText = new ObservableCollection<Translation>(FunctionText.ToList());

Works also fine and less code :)

It seems that this doesnt work, i copies just the reference but doesn't any deep copy. If you now change the Text in die Cloned element, it also changes the Text of the partent.

thewhobox commented 2 years ago

Yes you are right. I thought i testet it...