C
C#5mo ago
Zappy NE

Advice/Help creating what I made in this reference image (.NET WPF)

No description
44 Replies
Zappy NE
Zappy NE5mo ago
It's to generate Javascript code for Minecraft. In-game, you can make an "Action Form" (what I call Pages) and you can add a title, body, and [buttons]. I want to make a GUI to generate this code easily. I want just 2 options for the buttons in this GUI; either text output, which is basically an empty action that is easily replaceable. The other action is redirecting to another page, with other buttons and everything else. I've tried it before but hopefully I can get a little advice for this one. I'd like to know the best methods for making the page a button lists, so they can be added, edited, and deleted without issues.
Zappy NE
Zappy NE5mo ago
This one's old but is partial inspiration
No description
No description
Pobiega
Pobiega5mo ago
So your goal is to generate the code shown on that image, with the GUI app shown on the left?
Zappy NE
Zappy NE5mo ago
Correct
Pobiega
Pobiega5mo ago
Sure, that doesnt't seem too hard. everything except the buttons is trivial, so I assume thats where you want help
Zappy NE
Zappy NE5mo ago
Currently I just have the reference image as I just want to know if there's specific tricks or advice for the different, more difficult tasks, before I start and make it harder on myself later.
Pobiega
Pobiega5mo ago
no this seems pretty straight forward to me having button index be editable might make it harder thou I'd rather recommend having a draggable list if you want to be able to re-order them
Zappy NE
Zappy NE5mo ago
I think that's a good idea, but the indices are important
Pobiega
Pobiega5mo ago
well yes, but they can be generated from the buttons order
Zappy NE
Zappy NE5mo ago
true.
Pobiega
Pobiega5mo ago
my first instict was to just have the form state keep track of what the "next id" should be and run with that but then you can't edit them or re-order so a better choice might be to calculate the IDs when the "save" or "generate" button is clicked
Zappy NE
Zappy NE5mo ago
I would like to eventually have it generate on certain actions like when the page and/or buttons are saved, but the refresh button can be renamed to "Generate" for the time being
Pobiega
Pobiega5mo ago
or just have any GUI action invoke the refresh thats fine too, if you want the code preview
Zappy NE
Zappy NE5mo ago
So I am trying to plan out the different objects and stuff to use for the UI I'm guessing a normal ListBox or something similar for the pages, as they're not important in any order
Pobiega
Pobiega5mo ago
WPF? Avalonia? Winforms?
Zappy NE
Zappy NE5mo ago
WPF If there's a better alternative that you prefer, I'm fine to look into it
Pobiega
Pobiega5mo ago
Avalonia is very similar but would let you also run this program on mac and linux WPF is windows only
Zappy NE
Zappy NE5mo ago
I plan to only use it myself on windows
Pobiega
Pobiega5mo ago
alright, then WPF is a solid choice
Zappy NE
Zappy NE5mo ago
I am looking for the behavior to work, hopefully to 100%. I would like for the visuals to represent or match what I had made in photoshop, but I'm not sure if I would want to edit them myself or find a framework or whatever it's called with custom shaped controls and stuff
Pobiega
Pobiega5mo ago
WPF allows a lot of styling
Zappy NE
Zappy NE5mo ago
I am expecting to just do it manually
Pobiega
Pobiega5mo ago
yeah you'll need to apply styles to the controls, but I think there is a way to do it "once" for the entire app per control, probably but still I can highly recommend SingletonSean on youtube for WPF stuff
Zappy NE
Zappy NE5mo ago
Definitely have seen some of his videos in the past I'll try and figure out what I need to do for each part of my UI and try to look for it in his, or other channels What would be a good way to save the data in the pages, and even the buttons, in the lists?
Pobiega
Pobiega5mo ago
wdym? you'd just put that in your viewmodel I'd make a custom class that represents an added button, and properties for the other fields (title, desc)
Zappy NE
Zappy NE5mo ago
I'd previously used this class
No description
Pobiega
Pobiega5mo ago
Seems fine. Your button would need to store the data for its "action" too other than that, I don't see any issues
Zappy NE
Zappy NE5mo ago
So should I try and make the challenge of having the button indices be changeable, or just generate an index based on when it was created?
Pobiega
Pobiega5mo ago
I'd generate index based on their position in the list if you want to support re-ordering, its probably not a huge issue
Zappy NE
Zappy NE5mo ago
In my old version, I wanted to make a button, or 3 or 4, and if one was deleted, it would find the LowestMissingNumber and use that index
Pobiega
Pobiega5mo ago
see, thats done for you if you just use the list index
Zappy NE
Zappy NE5mo ago
the lowestmissingnumber?
Pobiega
Pobiega5mo ago
ye
Zappy NE
Zappy NE5mo ago
Should I do 2 columns, then divide those columns with another grid? for the page list and the main section as 2 columns, then the main section can be a grid
Pobiega
Pobiega5mo ago
Either that, or you split it up further I'm not an expert on WPF, but if this was javascript, I'd make a component for the "page view" and its state, and create one of those for each "page" in your list it sounds reasoable to do the same here
Zappy NE
Zappy NE5mo ago
I'm just gonna find one of those SimpletonSean vids on viewmodels and stuff
Pobiega
Pobiega5mo ago
meaning you'd make a "control" for this part
No description
Pobiega
Pobiega5mo ago
and you'd databind the state to a viewmodel one model for each "page" in your pagelist
Zappy NE
Zappy NE5mo ago
yep coming back from not doing .net for a while really hurts but I'll try
Pobiega
Pobiega5mo ago
Ah, I see Klarth already recommend the exact same approach in #gui Using a DataTemplate seems like a solid option
Mayor McCheese
Mayor McCheese5mo ago
Singleton Sean
Pobiega
Pobiega5mo ago
I missed that typo lol.
Zappy NE
Zappy NE5mo ago
Figured it out but didn't bother changing it. Thanks
Mayor McCheese
Mayor McCheese5mo ago
More for other people who might look up Sean tbh