I am building an application where a user can dynamically add buttons at runtime.
However, I am not sure how I should be storing information without having to access a database. I have tried to store it in Properties.Settings.Default, but it does not support Button. Thus, I am using an XML file to store data. Is there any way to save button information (and all the other Controls) when the program terminates, and retrieve when restarted? (instead of using XML)
Edit0: just to make this question easier to understand, here is an example of what I am trying to achieve.
The application allows the user to add a new button and locate them by dragging. Right now, user is able to add new button and relocate it as needed. However, I am unable to save the state so that user can use the same 'layout' when the program restarts. I know that it is possible to save all state in a separate XML file, but this way seems very inefficient.
Related
I would like to save a few values from text boxes that should be loaded into the text boxes every time I restart my program.
However, since my customers all use different values and should not re-enter them with every restart, I thought I could save these values somehow.
But I have no idea how to do that.
my program is also tied to a database if there is a clean way, I would choose that too. my customers all have an account to log in to. but it can also be a simple .txt or XML file, but how does that work?
I working with visual Studio C# WinForms.
Windows Forms comes with Settings, which allow you to save variable values and load them back up the next time your program is run. The Designer allows you to create settings and set the data types for them. See the Microsoft documentation in the link above for more information.
I want to have a save preference option in my WinForms application. The user chooses yes/no and has an option to save preference, upon which the yes/no will be remembered and a form for such a choice will not be popped upon further re running the application.
I read about going to setting and changing but how to do it for different users, since all of them would choose for diff options and I need to maintain that.
Simply using a boolean variable will not help since it will be single user specific. Any suggestions?
(1) At event close main form, you call method/action save result. See How to save data when closing event happen in WinForms?
You can save it to XML file (or text file, SQL lite, SQL Server, etc), popular way is XML file(s).
Read XML file to get saved result before processing business logic in your WinForms application at Load form event or another event type at early stage of application start-up period.
(2) You also save result at previous period in config file https://stackoverflow.com/a/453230/3728901
Properties.Settings.Default["SomeProperty"] = "Some Value";
Properties.Settings.Default.Save(); // Saves settings in application configuration file
So since i didn't want a database , I am creating a file at the client side and saving the preference there.
At run time , I will read from the file and upon that , will decide whether to send form or not .
you can use a Model and store use selected config into it then you should serilaize it and save on database for specific user when reRun the application you can get config and deserialize it to Model and use it
I am using Visual studio 2010 to create CodedUI Scripts.The application under Test is a web based Loan origination application .
I am automating a part where user enter's zip code and clicks on search.
when I enter zip code manually and click on search the response is received instantly.
But when the same is done with code,Zip code is successfully sent and search button is clicked but application dose not respond.
Mouse.Click(ContactInformation.ContactInformationForm.PropertyAddress.ImageZipLookup);
Just wanted to understand if this is a playback issue and is there a alternative for using mouse.click()
Most likely, the definition for the submit button is incorrect in your recording. Open the .uitest file, find the control in question in the tree, and open the SearchProperties in the properties of the control. Verify that against the source on the page, and then try again. It's possible that the recording identified a parent HtmlDiv object or something that's receiving the input rather than the button itself (or link, if that's the case).
Personally, while I'm looking at the SearchProperties, I'd remove any properties that are unnecessary. If there's an ID or unique class for the object in question, I'd stick with that alone rather than identifying six or seven other traits that may not be correct on each run (.css styles, inner text, etc. can change depending on your app).
Just be sure you edit the SearchProperties in the UI rather than the text editor, as the .designer.cs file is recreated each time you run the Test Builder, so you would lose any changes you make directly to that file.
I'm currently facing a following issue,
I use xml file to store information and once my application is started it pulls data from xml file and based on that dynamically constructs views. The problem is that users can update data in xml file within the application and save it. However as views are already loaded with all data, user now doesn't see new data until application is restarted (closed and started again).
I'm looking for a way to refresh data inside certain elements after xml file is updated, or make it so it constantly checks data in xml file every time.
I'm thinking some sort of method that does this on a "save" button click when users update xml.
It looks like you are going to want something like the FileSystemWatcher.Changed Event. You can hook up to the event when the application loads, and know when the file changes. This will allow you to catch changes made both internally (by your program) and externally (by a text editor or something like that).
When a file change is detected, simply load the new file and refresh the views with the new data. This part can be a little complicated depending on how the data is loaded into the views. This could also require detection of changes in the views when external changes have also been made. Probably best to prompt the user before reloading. This all depends on your use case and the expected use by the user.
Sauce: http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.changed.aspx
I am working on a Version Control/File Sync System for Windows. It would be great to have a checkbox at the bottom of the classical save file dialog with the option to check/uncheck for my file versioning.
Is it possible to listen for opened save file dialogs by any program (word etc.) and replace/override that dialog with a customized one (with an additional checkbox)?
If the checkbox is checked, another window should pop-up where the user could enter some additional metadata. After that the data is stored in a local database.
I already worked with the approach by dmihailescu (link provided) but it's very complex and I do not know how to modify that example to listen for opened save file dialogs by other programs.
http://www.codeproject.com/Articles/19566/Extend-OpenFileDialog-and-SaveFileDialog-the-easy?msg=4779306#xx4779306xx
Another approach is to use the FileSystemWatcher but that's very expensive to watch the whole system and it's not very comfortable because the user has to be asked for any created file if he/she wants to version control it.
I hope someone could help me to solve that problem or has some additional tips / approaches.
Thank you.
Edit: Use-case
A user has to write a documentation and creates a new word-doc. When he/she clicks the Save as menu entry of word, my customized save file dialog should pop-up with a checkbox at the bottom, if this file should be versioned or not. If the checkbox is "active" a new window should appear where the user could enter additional metadata. After that the data should be stored in local database.
In my case, only the metadata (like the path etc.) should be stored in the database. Let's suppose a user stores the same file in two different directotries (one file is "older" and one file is the current one). If the user opens an older version of this file, my system should recognize that a "newer" one is already stored in another place and synchronize those files.
That should just be a very easy example.
You have two pieces of functionality: save and version-control. Both of the tasks are actually rather complicated. Therefore you shouldn't mix them. You better off using standard Windows API to save file and do not change that. Think about how you'd support several different Windows releases and how painful that would be.
I assume you have your own UI, and do not integrate with, say, Windows Explorer (like Tortoise Svn or Dropbox). In this case you can do version-control magic first and then just save the end file using standard API.
If you do integrate with Windows Explorer, I suggest you to have a look at Tortoise svn source code.