C
C#10mo ago
HappypsychoX

Help with program structure.

Hello I am working on a project to record data from multiple items and print them to paper worksheets. I have a working prototype done in Winforms, using a single type of worksheet, but the end result will need to use 3 types of worksheets. Each type of worksheet also has several variants (see first image) for a total of about 20 different worksheets. Also, each type and variant of worksheet requires some different data to be collected from the user. I am struggling on how to structure this correctly. Attempts I have tried so far seem to involve a lot of repetition which I would like to avoid doing 20 times. Can someone point me in the right direction on how to do this correctly? Things to know: I am using WPF/Caliburn Micro with MVVM pattern. I have written several small but working programs over the last few years but still very much a noob. I have include a few other diagrams of my planning process.
No description
No description
No description
10 Replies
exokem
exokem10mo ago
Could you create an abstraction for the fields and create a single form that takes a flexible number of fields and displays them generically?
HappypsychoX
HappypsychoX10mo ago
create an abstraction for the fields
By this do you mean a create a class that holds the value of all possible fields?
exokem
exokem10mo ago
A class that can be used to represent each field Maybe each field is a different instance of the class with different params or data or whatever overloads
HappypsychoX
HappypsychoX10mo ago
Ok, and instead of using xaml I just add the controls through code at runtime?
exokem
exokem10mo ago
Yes E.g. if a specific variant field needs different controls just add a virtual method so they can override what would be added at runtime
HappypsychoX
HappypsychoX10mo ago
A class that can be used to represent each field
class GenericField { public object Value { get; set; } GenericField(object value) { Value = value; } } something like this?
exokem
exokem10mo ago
If that's all the information you need it to have, yes
HappypsychoX
HappypsychoX10mo ago
Then at runtime if user chooses Form 1a for example, I can add the needed controls and bind each one to an instance of the generic class. Do I just add these instances to a collection? Can you bind to items in a collection? Still fairly new to wpf and have been using CalibirnMicro to help with bindings.
exokem
exokem10mo ago
You can bind to a collection, yes It's been a while since I used WPF so I'm not sure about the specifics
HappypsychoX
HappypsychoX10mo ago
Great. Thanks for the help. I think I have a good direction to focus my research.
Want results from more Discord servers?
Add your server