Storing a DockPanel in a settings file - c#

I am attempting to store a DevExpress DockPanel in a settings file. Everything appears to work in the save function, but when I go to load it upon starting the application, The Settings.Default.WebLayoutPanel variable is null: here is the save:
Settings.Default.VisibilitySwitchesPanel = _visibilitySwitchesPanel;
and here is the load
if (Settings.Default.WebLayoutPanel != null)
{
_webLayoutPanel = Settings.Default.WebLayoutPanel;
}
Any Ideas as to why it is null?

You should not save the Control instances directly into the application settings. It's a wrong way. You should save the specific settings of these controls using custom serializable wrapper and then restore these settings. Here is a useful links:
Windows Forms - Creating and Persisting Custom User Settings in C#
Using Application Settings and User Settings
As for DevExpress DockPanels, when you want to save/restore the docking layout you should use the embedded save/restore functionality: Saving and Restoring the Layout of Dock Panels

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.

Best practices with saving settings data

I've got a main class which on user event shows the settings window. There are some textboxes, radiobuttons etc. After pressing the Save button, I want to store the data to some file.
I think that the saving process should be inside the main class and settings window only takes care of displaying the current config data, validate the new data and then send them back to the main class. Is this right?
How can I "send" the current config data from main class (which knows where the config file is etc.) to the window and then "send" the new data from window to main class to be stored?
Thanks
In WPF you can use Properties.Settings (Best solution for storing any application settings). See this.
Or you can create your own settings file, as an example, you may create xml file, and store your data into it.
See:
XmlSerializer
DataContractSerializer

What is the better way to save state of checkboxes/textboxes? Saving these in ".settings" file is better?

I want to save state of lot of CheckBoxes (checked/unchecked) and some TextBoxes on a WPF screen in .settings file (As I do not want to use database/filing).
Whether I have to save all these checkboxes and textboxes in setings file or there is a better way to do it?
If this is to remember the state of controls in an application, I would definitely use user settings to store this. Creating a separate setting for each control can be time consuming initially, but it makes life a little easier later. However, if you don't want to do this, you can simply create a custom settings class with a public property for each control and then simply use an instance of that class as your one savable setting.

Save with the controls of the form

I have a windows application developed in c sharp with setup file generated. For that file I need to save the form with the controls and text with in controls. This application don't have any database. Can you suggest an extension method and also how to save the form?
There is no way to save controls. What you can do is create a serializable class to keep Form's data. You can serialize those settings and save. When you load the application next time you can deserialize and load those values to the form controls. This is one of the ways of doing it if you don't use a database to store data.

Simplify configuration dialog building .NET

I am working in C#. I find myself creating dialogs for editing my application settings all the time. For every Control on the dialog I am reading the configuration file and set it accordingly. After pressing OK, I am reading all the controls and store the values in the configuration files or something similar again.
This seems to be very time consuming, simple and repetitive. Does anybody have an idea how to simplify this process? Code generation? Helper classes?
You can bind WinForms controls directly to application settings, which should make your life a lot easier for creating dialogs to manage them.
Just select a control and look for the (Application Settings) option under the Data group in the properties pane. I put up a screenshot here to illustrate.
Do these application settings dialogs need to be pretty or are they simply there for personal configuration? If it's the latter, read all the settings into a class and assign that class to a property editor.
Not recommended for a good-looking, final UI though.
Best bet would be to use the "Settings" that are included in the default template for a winforms rather than "configuration" it is easier and the settings can be bound to just about any property for a control or read independently. Once discovered they are well documented, easy to customise and easy to use.
If you need to use configuration then I'd look at using a custom configuration section and bind that to a property grid or control set for editing. The configuration makes it easy to read and write changes to the configuration.

Categories

Resources