Changing application colours/theme by user preference - c#

I am working on on a winforms C# application and want to give the user an option to change the colour of the form background and text throughout the application.
The application contains panels, labels, textboxes etc.
One way I thought of was to store the user preference as the colours RGB value and have the form set it when the form loads for all the various controls. But this way seems a bit laboured.
Is there an easier or more effective way of achieving this?

In my opinion, the easier way to do this is to use settings file in winform which will keep user data in a file and recalls it at anytime. You can follow this link to implement this demo
You only have to create one class that handles the theme. You can automate it.

Related

Save the state of a dynamic windows form application C#

I have built a form where the user can add controls, buttons and more dynamically.
is it possible somehow to save the dynamic controls and load them automatically the next time the user starts the program?
if it is not possible I would like to know if there is a common method or good practice for saving this data to some kind of a config file?
Thanks
One way would be to loop through all the controls on the form and save them to Isolated Storage...
https://msdn.microsoft.com/en-us/library/3ak841sy.aspx
https://msdn.microsoft.com/en-us/library/xf96a1wz(v=vs.110).aspx
But it really depends on your use case, do you want to do this automatically and transparent from the user, or do you want to present the user an option to save to a file somewhere?
While it is not specifically for dynamic controls, to give you more ideas see link below on another stackoverflow question :
Best practice to save application settings in a Windows Forms Application

Contextual Text Editor in WPF

We are currently looking to create a text-editor in WPF (.NET 4.0) which will allow writers within our team to create movie scripts. In short, the functionality should ressemble that of FinalDraft or Adobe Story (i.e.: contextual positioning of text depending on the cursor's position and user intentions)
We are currently looking at two different solutions design-wise:
One WPF control which will act as the container, and multiple small text-editing controls which will represent rows within the script. This will allow us to position the controls using their margin, while also making binding easy. The challenge here would be the handling of multi-line selections. I was thinking of using a Listbox as the container, and each listbox item would be a custom control containing a textbox. This would require the instantiation of controls depending on the user's action. Everything would be skinned to give the impression that the user is working on a blank page.
One big textbox capable of displaying custom XML data. The challenge here would be to determine where exactly the cursor is located (i.e.: is the cursor on top of an actor's name, etc.) and positioning the text appropriately (i.e.: actor names are centered and in caps, etc.)
I recently tried implementing the first solution, but having to re-implement the whole selection behavior that is built-in in basic text boxes is non-trivial and requires a lot of work. As for the second solution, binding to my business objects will be much harder than simply instantiating multiple controls with different bindings.
Do you have any other solution in mind ?
I needed a text editor for a application once. We had a big xml file for settings and the user should be able edit those.
Turns out , if your file is large enough (+ 10000 lines) the rich text box is getting pritty slow.
As for building a gui mask : only if your user wirtes some short options like text. But is i understand you want your useres to write creativ text. This "mask" gui - "lot of small places" will make them feel like they are in the 80ties.
I suggest: Dont write the Programm , only write a Plugin to an exitings editor. Some are free like:
http://www.codeproject.com/Articles/42490/Using-AvalonEdit-WPF-Text-Editor
or an add in for word - people love Word and know Word
http://www.codeproject.com/Articles/8837/Writing-a-Word-Add-in-Part-I
And for binding data and the like: Once the text is written, the user just need to press the save button and you can parse the input for information. I would not do it on the fly as it can get pretty slow. Also you say that the information is linked so only if all the data is written you can make use of it.

Creating a color def file or choosing a theme for Windows Mobile 6.5 Application

I developing an application in C# on Windows mobile 6.5 and .NET 3.5 CF. I'm using multiple forms and would like to have a common color scheme that is easily changed by just changing a color definition file or some simple option in VS 2008.
I've looked around and it doesn't seem to be any clear solution. I've tried digging down to where the colors are defined to see it I could add my own that would be a global variable, or even in the designer files, but there is not mention of color, the only way I can change the color is in the properties window.
A simple way to do this is to use Form inheritance. Create a template form (named "TemplateForm.frm" or whatever), color/style is as you wish, then add one (invisible) instance of each type of control (a Button, a Checkbox, a Label etc.) that you're using on all of your other forms.
Then edit your existing forms so that they inherit from TemplateForm (instead of inheriting from Form). Add a method to TemplateForm's Load event that iterates through all the controls on the form (this needs to be recursive, of course) and styles each one (font, colors etc.) to match the corresponding (invisible template) control of that type on the parent form.
An other approach, probably not better, is to modify the system colors in the registry in [HKEY_LOCAL_MACHINE\System\GWE] "SysColor". I've used it, but I'm not a fan as it is sometime hard to get a good set of colors that work, and it changes it everywhere in the system. #MusiGenesis appoach affords you finer control.
see Customizing System Colors

Save/Load User Settings on multiple UserControls within a Window

This post is related to c# - approach for saving user settings in a WPF application?
I have found multiple examples for saving/loading one window configuration but I am not sure if it will also save the configurations for all usercontrols open inside that window or just the actual main windows configuration...
First is it possible to save/load multiple usercontrol configurations inside a window using the application/user settings?
Am I forced to just read/write xml to store the the multiple usercontrols configuration?
Thanks in advance and let me know if you need any other information!
EDIT
I have an application with a ribbonbar on top that allows the user to open one or more user controls from the ribbonbar. Hypothetically if i wanted to save all the open usercontrols window position, height, width, etc... would it still be possible to use the application settings to accomplish this?
EDIT2
I have an application and within that application there are many usercontrols a user can access. If a user opens 2 usercontrols and uses those controls often, I want to be able to save those usercontrols to the workspace so there always there when the program is open or closed. The way I am approaching it now is with serialized xml from the database. I was researching this topic and came across the application settings approach and wanted to know if this was a viable approach for my situation. Thanks again Marc for taking the time to help me figure this problem out.
What I've used is user-specific ApplicationSettings and binding those to properties I want to 'save'. Here's a good example of what I've done http://www.jaylee.org/post/2007/02/WPF-DataBinding-and-Application-Settings.aspx
I little more detail might be helpful here, I'm not sure I follow. Are you saying you have multiple instances of a given user control on a single window and you want to persist the properties for each of them?
A lot of this depends on how you created and populated those controls. If they were created dynamically from data for example, the best solution is to serialize that data to disk and re-create the controls when the application restarts.
Alternatively you could bake in the serialization of the settings into the user control itself such that it writes out it's settings to a file name based on it's instance name (control1.xml, control2.xml, etc) and then have it repopulate when the instance comes back to life.
Knowing how these controls are added and the properties are set in first place would be helpful.

How to create UI similar to file replace dialog in window 7 using C# Windows Forms?

I need to create a dialog that allows user to choose between several rather complex actions. I really like the usability of the windows 7 file replace dialog and I think it would suit my needs very well. Here's a screenshot for reference:
Is it possible to use the controls that were used for windows dialog? If not, how would you recommend creating UI similar to this dialog?
Seems like this could easily be done with a window containing a few labels for the text and three custom controls - with some images for the arrows and file icons - each of which changes their background image when the user mouses over them - and fires an event the window picks up on when they are clicked. Fairly standard WinForms stuff.
Is there a particular part of the process you need some extra help with? Like, for example, the mouse over?

Categories

Resources