I am beginning preliminary design for a general purpose application to be used in my organization. The program needs to be both generic and specialized at the same time. It will contain widgets that are common to all workflows and unique widgets (or input constraints) for individual workflows. To avoid having 97 different one-offs we're planning on building a set of schemas for each workflow. At run-time the user will select their schema from the server and the GUI will throw up the right widgets for their workflow.
This is a C# application that will run in .Net and possibly Mono. That means we are looking into GTK#, in addition to XAML and MonoMac.
We've considered writing XSLT's for our target GUI toolkit. For example:
A Glade XSLT to convert our XSD's to libglade XML.
A XAML XSLT to convert our XSD's to XAML.
A generic XML format for other toolkits that do not support a declarative syntax for GUI's.
A library of classes to read the XSD's directly and generate the GUI.
So, my question is, does this already exist? Is there some workflow toolkit out there for GTK# and libglade or WPF and XAML.
Look at System.Windows.DataTemplate which can be used automaticly by WPF (see property DataType). I think you can extract all UI blocks, which will be used to generate UI and then implement ViewModels and appropriate DataTemplates. And result UI will be composite view model of this blocks.
I did the same thing using XML. What I'm doing is writing down the property set of each controls into a XML file and then reading from it later and regenerating the window.
Some problems I met while doing so
But I was able to complete it. Anyway I guess WPF is better. But if you want an idea I guess I just gave you. (Might not be the best idea though)
Good Luck
Related
We currently have a basic implementation of configurable UI, but we feel like it's not the best way. We are developing another application that needs to be configurable from external file and we were wondering if there is a better way to do it.
We currently have xml file with elements with the name and availability which is directly translated to visibility. When the element is available="false" we hide the element with visibility="collapsed". Elements are enclosed in a Setup element with name. There is separate configuration file with setup name that we want to load.
<Setup name="All">
<Element name="toolBarDrawingTools" available="true"/>
...
</setup>
<Setup name="Operator">
<Element name="toolBarDrawingTools" available="false"/>
...
</setup>
It works reasonably well, but we feel like it's not a great approach just to hide elements. A better approach might be to create and add only elements that we need. Layout should not be much of a problem because most element would be ToolBars, MenuItems or UserControls that would be added to StackPanels. So there is no complicated element positioning. What we also found is define xml files with XAML code and at run-time convert it to visual elements. We do not need that much complexity. We have a set of UserControls that we want to dynamically add.
We do not have a clear vision what we want. In the end, we could use our current approach and it would work. What we need is to define what elements will be in final window from external source without the need to recompile whole application.
So what I am asking is what options do we have, are there any "standardized" ways or frameworks. Do you know any articles or books on this topic? Or should we stick with the simplest approach and just hide what we don't want?
Thank you
As I can understand you are after a modular application development. So I can suggest you to look at the next topics; Modular Application Development Using Prism in internet. For example, by this approach you can use the PRISM discovery mechanism(which uses the app.config file to define modules) in oreder to build whole user interface. Here are a couple of possible links:
Building an Extensible Application with MEF, WPF, and MVVM.
Modular Application Development Using Prism Library 5.0 for WPF.
A MEF explanation topic.
Let me know in case you will need more explanations.
Best regards.
Trying to understand how to use WF rule engine outside of a WWF application. I've only read a blog post on the topic. But I have certain doubts on the feasibility.
My application requirements are as follows:
Web-based UI for writing the rules, and storing them in db.
A windows service will download the rule. A rule execution engine will gather data it requires and execute the rule, and give a result as output.
The rule is simply a set of instructions which must act on a row of a table. The schema of the table is dynamic; however there is some metadata which tells the rule execution engine how to gather the necessary inputs from that row.
I know that rules are usually input using a rules editor; this is a windows form application. This usually generates a *.rules file. The WF rules engine, as per my knowledge, evaluates this file and does the execution of the rule.
The *.rules file is an xml representation of the rule.
Is there any api in the dotnet framework which generates this xml representation? And, can we build a web-based front end for inputting the rules?
Was wondering if there was an api kind of thingy and I came across the following:
http://code.msdn.microsoft.com/windowsdesktop/Creating-Rules-Using-the-23c5d561
It is an api like interface. However it consumes objects from the System.CodeDom namespace (usually various kinds of CodeExpression objects).
To go about using it you have to correctly represent the code expression objects in your front-end via some mechanism (by using xml or json). In the server, i.e. when you post the rule to the server, you have to create the necessary code expression correctly (via parsing) and feed those things to the api.
You need two types of code expression objects - one for evaluation of the rule condition, and the other for the stuff to execute when the rule passes or fails. (I only need stuff to execute when rule passes).
The sample provided there gives you an idea of how to use the api. The rest is something you'd have to build on.
A program source code is commonly represented in memory using an AST. All you'd have to design for is making your own implementation.
If you want to use Windows Workflow Foundation (WF), you must have WF XAML generated - not .rules or XML representation of that (whatever that is). Here is an example of a Workflow XAML file. There are basically three ways to generate this (starting with the least complex method)
By using the designer in Visual Studio
By generating a DynamicActivity-instance runtime and serializing it
By implementing your own generator
To answer your question: Yes - it's option #2. If your rules are very simple (if-then-else) and you don't anticipate them to increase in complexity in the future, option #3 may be a viable alternative as well.
I am working on an ASP.NET project that is relatively simple except for one requirement which requires custom questionnaires be attached to specific types of tasks. These questionnaires need to be customized regularly and no development, within the app itself, should be needed add questionnaires. The questionnaires currently do not require an editing tool and can be done by uploading a template, changing something in a DB, whatever. They can be stored in any format and the resulting output needs to be captured to be edited or viewed later.
The types of questions in the questionnaire could be:
Selections (select one from a list)
Input (text, integers, dates, etc)
Yes/No
The ability to display questions based on answers from other questions. For example if they answer yes to question X, display question Y else display question Z. Need to be able to apply data validation such as required fields, ranges, etc on questions (could all be probably capture by basic regex).
The simplest break down would be:
Create a new event.
Based on the type of event display a specific questionnaire.
Questionnaires can change over time but they can be considered as new version each time and data will always be related to a specific version and not need to be migrated to updated versions.
The questionnaire output (data elements and a final calculated value) must be captured.
XML output (or any other format) of data elements entered.
The optimal (unicorn) scenario would be to have a basic template in XML or something that a user can learn to create easily and it would be stored and versioned in a DB. When a user makes a new event, the app would fetch the appropriate template which would display the questionnaire to the user. The user would fill it out and the output would be posted as some type of output (again XML would be nice but not required). That output would be attached to the event. Done.
Are there any .NET compatible tools/libraries that I could leverage to accomplish this? InfoPath seems like a tool that might be of use but I have almost zero experience with it so I am not sure about its constraints / implementation and if it is just overkill. The solution needs to be contained within the ASP.NET application. An external editor tool for creating templates would be ok but the templates must be viewable and editable on the web with no constraints to the user.
Can anyone provide examples of this being done or hints on how you might have tackled this?
Since the application is relatively easy to create other than this one feature, I would rather not spend 80% of my time trying to implement the custom questionnaire functionality and spend more time on the problem the application is trying to solve.
Tech available: ASP.NET, Silverlight, SQL Server
I would suggest having a look at a dot net nuke implementation, I am sure there should be a lot of viable options (if not all free).
DotNetNuke
Have a look at the Forge to see free plugins
Consider evaluating SurveyMaster at CodePlex. It's licensed under Microsoft Public License (Ms-PL), and you can modify its source for your needs.
Is there an easy way (or perhaps a third-party implementation) to programmatically create a MessageBox with various types of controls on it? Ideally, with some sort of scripting language (ie. XML).
I would prefer not to code this myself from scratch.
There are two ways to do this. One is called WinForms, the other WPF. The latter even uses an XML language (called XAML). Since you didn’t specify what kinds of controls you need, this is the best answer I can offer to your question because it covers the widest available range of controls.
Could you not create a form and customise it as a compromise?
I had a similar question.
Custom MessageBoxes are much simpler to create than what I thought.
How to create a custom MessageBox
Is there a pattern where in WPF, I can build a simple UI form from an XML like definition file pulled from a database?
It would allow the user to enter data into this form, and submit it back. The data would be sent back in an XML structure that would closely/exactly mimic the UI definition.
The definition should include the data-type, and if it was a required value or not. I would then like to map these data-types and required values to Data Validation Rules, so the form could not be submitted unless it passes the check.
It should also handle the ability to have lists of repeating data.
I am in the planning stages of this project and have fairly good flexibility in the design at this point, though I am pretty sure I need to stick to the desktop, not web since I may be doing some Office Inter-op stuff as well.
What technology stack would you recommend? I think XMAL and WPF may be close to the answer.
I have also looked at XUL, but it doesn't seem ready or useful for C#. (Found this article from MSDN in 2002)
Thank you,
Keith
Model View Presenter seems to suit WPF quite well, if you've not heard of it before check out the Supervisor Controller pattern, which is a subset of MVP (the author has renamed it to Supervisor Controller and Passive View as two different flavours of MVP). It is a design principal that will help you promote the separation of concerns and works much better than MVC when you don't have a framework to physically enforce it.
You could always try to create a view engine for ASP.NET MVC that works with WPF though, that would be nice.
Well if you wanted to roll something yourself, you can load and render dynamic XAML pretty easily. Rather than have users create XAML directly you could have a subset of it "mapped" to an XML format of your choosing that you XSL into valid XAML:
XmlReader tXml = XmlReader.Create(myXamlString);
UIElement MyElement = (UIElement)XamlReader.Load(tXml);
What about Caliburn?
You might want to consider taking a look at the CSLA.NET framework. You can read about it here along with info on a well written book that's available:
http://www.lhotka.net/Default.aspx
-Eric