Allow users to create own workflow scenarios - c#

I have such task:
allow users to create smth like template forms(from predefined controls like in any CMS for web) and some workflows to be used in that forms. For example user can create form of generating some report, and after submitting it-another form must be shown, but all that should happen dynamically without hiring developer to extend the existing code. Is it possible to give some predefined scenarios to the users and allow them to choose some actions, combining that scenarios? I know that we can write such thing, but there may be many errors while implementing that and i hope there is some ready solution..
Is there a sort of CMS for Winforms/WPF?..Can you suggest the best way to finish such task?

Use WPF. You could let them enter the XAML in form of a text file or a text box and then execute it on runtime using XamlReader.

Related

How to create Work flow with custom controls

I would like to create a work flow with some custom controls and control lines. For the same i want to create my own editor to edit / Create work flow.
Can some one suggest where i can start / provide some references to start.
Thanks.
The question is too broad to give it a good and simple answer without writing a book. My advice is to split your project into sub tasks:
Create a control that e.g. looks like a box that shows some editable information (e.g. name)
Create a canvas area and place the control on it
Add Drag&Drop to the control so the user can drag it across the
canvas area
Add a second control and draw a line between them.
Create an UI to add an arbitrary number of controls to the canvas (e.g. via Drag&Drop)
Add commands to the control that represent the action (could use
ICommand)
Create a workflow manager that interprets and executes the commands
in the defined order
Extend the editor e.g. to enable the user to reconnect the lines or
to add rules and priorities to the control or even to choose a set of commands from a pool and assign them to the control
Make everything look nice
Now that you have separate tasks, you can focus on each and research them individually. Step by step. Your questions therefore become more precise and easier to answer (for yourself and others).
Why re-invent the wheel?
You could re host the windows workflow designer.
https://learn.microsoft.com/en-us/dotnet/framework/windows-workflow-foundation/samples/designer-rehosting
I've seen other articles talk about this in more detail but I couldn't immediately find them and you could of course just search yourself.
There is a huge amount of functionality in that thing which would take you forever to replicate.

Popup child window with ok and cancel buttons

I've created a simple dialog here with a list of people. All I want to do is a few simple things which are rather trivial in winforms. However I'm struggling to grasp how to do this in wpf with an mvvm approach. Could someone help me out please.
When the user hits the Add New Person button, I want a dialog to appear where a user can type in their Name and either hit OK or Cancel. If the user hits OK, it appends the person to the list. (keep in mind i'll add more edting fields for the users to input, for example last name...)
When the users has a single item in the list selected, i want them to give them the ability to click an 'edit' button showing a dialog similar to the one in the previous step, pre populated with the selected items data, so a user can edit the properties. Then depending on if they hit OK or Cancel the changes are committed.
Dropbox solution: https://www.dropbox.com/s/8sjpabfod08yil5/AddDeleteItems_basic.zip?dl=
To create and display dialogs using MVVM, you'll want to implement a dialog service pattern to handle such requests. This service would be called from within your view model.
There is a really informative Code Project article about this very topic (Showing Dialogs When Using The MVVM Pattern. My advice would be to read that article and then look through the source files accompanying the article. This should provide you with a very good starting point to achieve your use cases (custom dialogs) and can also be used for displaying standard dialogs too (e.g. open file, save file, browse folder etc).
The service pattern isn't the only way to implement this, in the following article I show how to do it using the same data-driven mechanism used for regular windows:
http://www.codeproject.com/Articles/820324/Implementing-Dialog-Boxes-in-MVVM
I suggest this tutorial for you to get started. However, for the dialog Xceed library has some cool custom controls that may help you.

Creating Custom Layouts to Present Data

I'm trying to find a package, or a solution that allows me to create custom layouts to present data. Similar to how one can create custom templates and layouts in Microsoft Word.
I've tried a RichTextBox but they are very limited. I want to create numerous custom layout types to present the data within my software and have the user select one they wish to use, with the option of printing.
Is there anything that will allow me to do this?
This is for a WinForms application.
The layouts will be designed by myself, and added into the software. The layouts will be used to present the data. Mainly for aesthetics. The application allows the user to enter their information for a CV and they can select a layout for their CV.
Hmmm. I would suggest WPF if you were not committed to a WinForms application.
Instead you can use HTML and swap out the CSS (cascading style sheet) on the fly. You will need to use a WebBrowser control to host the html (http://msdn.microsoft.com/en-us/library/system.windows.forms.webbrowser(v=vs.110).aspx).
Otherwise you could creat several controls that could bind to the same data object and swap the controls out. I like the HTML option better myself.

Creating "subforms" in WPF?

I'm pretty new to WPF and C#. I am looking to create multiple windows with in one primary window, like creating forms and subforms in Microsoft Access. I would like to work with One main .xaml and have two seprate .xaml's that the user will open with a button selection. I do not want to have multiple windows pop up (if possible). Instead I would like the main .xaml to display the selected .xaml with-in itself.
Create a User Control and switch the visualization, more examples: http://windowsclient.net/learn/video.aspx?v=76360
You can user user controlls for this. This is a good walkthrough http://www.codeproject.com/KB/WPF/UserControl.aspx
As the other individuals have said, you'll want to create a User Control. It's fairly good practice to create User Controls where possible if you'll be re-using the code.

Developing wizard UI - WPF

All in WPF:
Developing a wizard application, user has to answer a number of simple questions before brought to the main app. The main app is then prefilled with the information obtained from the wizard.
I started with a Window which I then planned to add usercontrols to. The main window would have the user control in the first row, then Next and Previous buttons to control moving between the controls in the second row. This way I could easily control the logic to switch between screens like:
WizardControl1.IsVisible = false;
WizardControl2.IsVisible = true;
But for some reason, user controls do not have setter for IsVisible. Hurray.
So then I thought I would just use seperate windows for each section of the wizard. The problem with this approach is that now when stepping between, the window opens in random positions, and by steppign through the wizard with next, the next window pops up randomly which is really distracting and frustrating.
So how can I develop a wizard properly? I don't get why this is so hard...not exactly rocket science... replacing text and controls and storing input after pressing next/previous!
Thanks
Check this link:
http://www.codeproject.com/KB/WPF/InternationalizedWizard.aspx
This is the article about building wizard in WPF by Josh Smith, it's seems to be nice pattern.
I found it's helpful for me, hope you'll too.
There is also an open source Avalon Wizard control on codeplex.
I'd probably aproach this using data binding and template selectors. Have the wizard form bind to a "WizardData" class, which exposes a list of "WizardPage" base classes.
The WizardData class can expose properties defining the correct info on the forms, and display a control for the main page that uses a template selector to determine the proper control to display based on the actual type of the particular wizard page.
It sounds like more work than it is, really. It also gives you the benefit of good separation between code and UI (all "work" is done by the WizardData and WizardPage classes), and the ability to test logic independent of the UI.
It's also a very WPF/MVVM way of approaching the problem.
I recognize this does not directly address your question, but I thought I'd mention it as a possible alternative. I've used Actipro's Wizard control with pretty good results, and when I have needed support, they have been very responsive. I am not affiliated with them in any way; I just like not having to write the plumbing to manage a wizard.
The property is called "Visibility".
I find that I do better when I dynamically add and removing controls rather than hide them.
I was looking for a Wizard solution too. I have the need to stick with stock WPF components so I implemented the wizard using a standard form and a tab control.
I only hide the tabs at runtime so there available in the IDE. At runtime just use Back, Next, Finish... to navigate thru the tab items
works good

Categories