tips for dynamic UI creation - c#

I need to create a UI that will load from an xml file information that will determine the look of the UI. Simply put, the xml file will determine the locations of a bunch of buttons in a grid like interface. Im thinking that it could be built with a single Panel container with a variable number (depending on the info given in the xml file) of table layout panels. Each table layout panel will have a variable number of rows/columns (also dependant on the info given in the xml file).
I have the creation and mapping of controls working fine, however proper sizing of everything continues to be a challenge.
Are there other controls out there better suited for mapping out dynamic interfaces?
Any tips/tricks/pitfalls?

Use WPF (as mentioned) or use Gtk# (see website)
Also, a wellknown trick with Winforms is to make ample use of datagrids bound to Datatables (or DataSets in general). Even if your backend isn't actually a ADO.Net provider you can dynamically create DataTables (adding columns with proper datatypes). The datagrid will know how to make these columns editable/sortable etc.
$0.02

Related

Dynamic Forms Builder, CRUD Submissions, Multiple Files Upload Using ASP.NET MVC

In our current application there is a new requirement of our client.As they told that they need n numbers of forms at different stages of their business and those are changing time to time. Even a new forms can be added. Their requirement is once the product is delivered to them they will not come back to us again and again for each change and will create those form by their own.
Simply they want a user interface where they can create the form by drag and drop manner.
What they want :
In our application there will be a form building section where a non technical person can be able to create a form.
Mapping the controls with existing data of their existing database so that the form is populated with the corresponding data ( data will be inserted into the database using another user interface).
Once the data is populated they will take the print out of the filled up form and will proceed as per their business flow.
As they introduce new form time to time we can't provide any predefined template to them and they are not agree to design the form in HTML.
Is there any way of doing this in Asp.Net MVC (without using any CMS ).
there are a number of asp.net forms builders. And I been wanting to build my own for years. (you store the control, the location etc in a database, or even as xml, and then on page load, read the xml, and crank out the controls and layout into the page. We all built these for desktop, and you can do the same for the web.
The open source evolutility project has a FANTASTIC system for this, but it does NOT include the GUI part. But, it would be a good start. You would have to build the GUI part, but the rendering part, and save of the forms layout is all done for you. So, your forms builder would offer a set of controls to drop and move around in the form. When you save, you would have a corresponding "xml" markup bit that you save to the one "forms layout" file. On forms load, you read that xml file and produce the form (that's the part evolutility does for you). So, you need the part that has each control in a tool box (along with the xml for that control). you drop control into form, and add the xml to the "form layout in xml".
As I stated, evolutility has all the parts to render forms and layout and place controls on the final finished form for display - it just don't have a GUI for doing this part.
You can look at the project here:
http://evolutility.com/
there are others. But, it really depends on how complex of a form builder or content builder you wish to make.
But, a xml, or json based layout and definition of the controls placed on a page is a good start. You could store such "layout" information in a database. Heck have a classic master to child table, and thus save each control in evolutiity format, and simple append then all together, and then have evolutility render that xml into a working form for you.
I don't know of a open source project that combines both the "layout" and "define" of the controls AND ALSO has a GUI to build the forms. But, to be fair, the hard part (how to layout, and how to have each control defined in some json (or xml) is done for you.

Manipulate-able data table

I have requirements to implement a UI using c# where the user can manipulate what data they want to appear on a document. The data should enter the program via SQL (prefer not using Table Adapters as the database is then hardcoded into the program, but will use it if absolutely necessary).
The following UI will appear when the user chooses to enter a database table:
https://docs.google.com/file/d/0B6b_N7sDgjmvcUt2amxNaXpJRFU/edit?usp=sharing
https://docs.google.com/file/d/0B6b_N7sDgjmvdUhmMUJFbEdKeVk/edit?usp=sharing
https://docs.google.com/file/d/0B6b_N7sDgjmvM3BSWDEyM0ROOFE/edit?usp=sharing
The user should be able to choose what columns (from all tables,
connections should be made using PK/FK.) they want to add to the
table, and sort and move that data.
The control should then able to generate the sql used to pull that
information from the database (or even pass the database back to the
main program, but prefer SQL)
I've seen this UI in many programs and would like to think there is a library out there that will save me the trouble of making this UI from scratch.
Are there any libraries available for C# that has this kind of functionality?
Telerik's Rad Grid will give you all of the functionality in terms of context menus and column reordering. You wont be able to output the code needed to regenerate the table however. You can export data directly from the grid using the column ordering specified in a range of formats (pdf, word, excel, etc.).
The Rad Grid is also not free, it is part of a suite of controls.
You may also try DevExpress. We use this control library for editing operations. It is not free but worth its price.

C# saving and loading all form elements?

I'm trying to design my C# winform application with a very generalized function to automatically go through all of the form elements and save their states/values in a text file so that I can load it later. I want it to be very generalized so that it'll be a cinch to reuse this code in future projects, as it wouldn't be heavily tied down to the specifics.
The form elements I want to save are text boxes, combo boxes, data grid views, list boxes and that's about it. I want to save their values and everything about them.
One way that I was going about it was to go through every possible form element and then detect eachs type, and then create the corresponding c# code to re-create its value ('tboxmine.value="blue elephant"'), and then writing the code to a file, so that I could load the code from the file and execute it using the CSCcompiler. My code so far doesn't seem to be working correctly and I'm having my doubts that this compiler is actually running the code inside my application (I think it's possibly creating a new thread?), and it just seems like there's probably a far more straightforward relatively standard way of doing this.
This seems a bit like the reverse "best practice" approach. If you dont't know about databinding I suggest you look into that.
Basically you create classes to represent your data and use databinding to associate controls with your objects. The controls will automatically show the right value and allow the user to change it. If the user has changed the value, your object gets automatically updated.
To save the data, you would use some kind of serialization to store your objects in a file. When loading, you let the Serializer rebuilt your class structure and (best case) you are good to go.
This is not exactly what you asked for, but I think it is something you could use well ;-)
N.B.: Not the complete state of the control is saved. e.g. in a Textbox your text would be saved but the BackColor won't.
To get you started look into this tutorial: http://www.codeproject.com/Articles/24656/A-Detailed-Data-Binding-Tutorial

Populating Menu from a database

I need to populate an ASP.NET menu control with hierarchical structure with menu items that can be constantly changed, from a database (categories with n levels of sub categories).
There are some approaches for that and I would like to hear which one is the most efficient one.
I have those in mind:
Retrieving data from database and converting it to xml then transforming it with customized XSLT file and binding it to Menu control
Retrieving data from database and while looping through (recursive), inserting menu items and children to the menu control
SQL Site Map Provider (thanks to Made4Print)
Something else?
The ASP.NET Menu Control can use a .SiteMap file through a SiteMapDataSource.
You can implement your own SiteMapProvider, this way you can have your SiteMap heirarchy within your database and wireup the same components making things more dyanamic.
Here is an example: http://weblogs.asp.net/scottgu/archive/2006/01/11/435108.aspx
HTH
I agree with Marc. You could then package everything inside a server-control for reusability. Converting everything into XML and then using XSLT to somehow "convert" it back seems an overhead to me.
If you want to do this, I would definitely recommend option 2, since it contains one level of transformation less than option 1. If you already loop through the menu items and their hiearchies, you might as well build up the menu items and subitems directly - I don't see any big benefit from taking a detour over XML and then through XSLT into a menu structure, really.
Marc
PS: Option 3 (the SQL Sitemap provider) also sounds like a really good idea, if the site map structure and options are good enough for you (they usually should be). I would probably try that option first, and go from there.

How do I build a diagramming application in .NET?

I want to write a GUI seating application that allows users to draw and annotate simple "maps" of seating areas.
The end result would probably look something a little like Visio, but specifically for manipulating my "seating" data model rather than producing files.
In Java-land, there's the Graphical Editing Framework (GEF) -- is there anything like this in the .NET space? Should I just use System.Drawing.Drawing2D primitives and handle it all myself?
Here is product from Nevron. It is paid but doing it all yourself will take lot of time and effort.
Open Diagram and EasyDiagram.net are available at Codeplex. Be sure to download and look into their code.
There is Netron Library for diagramming. It is open source and uses GDI+.
Check out NShape. It is an open source diagramming framework written in C# and quite powerful. Its controls are WinForms controls but you can also use it for WPF.
You might consider using the DSL Toolkit from the Visual Studio SDK. It allows you to create a graphical DSL designer by first creating a domain model, and then creating the graphical notation that will allow users to create or edit instances of that model.
You may very well be able to create a graphical notation that looks like a seating area. This would allow your users to not only "diagram", but to produce a file containing a filled-in domain model of what was diagrammed.
Check out our MetaDraw component - www.MetaDraw.com
MetaDraw is designed to make applications like this easy.
MetaDraw will support a background image and an annotation layer
You can put users into a variety of editing modes - Lines, Curves, Text, Shapes, etc.
Every drawn element is distinct - just like in Visio, so you can allow users to select objects and move them around or resize them. Every object can have multiple hidden tags ( like seat numbers or database record pointers ). You can recognize which objects users select ( for instance take some action when user clicks seat 22 ) . You can dynamically modify propertie by code - such as searching for seat 22 and changing it's fill color. Of course you can also scroll, zoom, print, save to a variety of formats and more.

Categories

Resources