I seek a little bit of advice...
I have an WPF C# program with an XML resource file in which I have text for some buttons, like a language file (let's call it language.xml), and 2 xml more, for example english.xml and spanish.xml.
I have the XmlDataProvider pointing to language.xml
At startup I seek in a database which language has the user in his/her configuration, and I overwrite language.xml with the content in english.xml or spanish.xml
Sometimes the program loads right, but most of the time it loads the wrong data, although you look in the language.xml and the data is right.
(When I say wrong data I mean loading the program and entering with one user with a language set, closing, and entering with another one with other language...).
It's a little bit confusing, but I hope someone have tried something like this...
Thank you in advance. :)
May be problem is in synchronization.
As example, your program begin request to database, and starts UI. XmlDataProvider is created with old xml source, then (on service response) language.xml is rewritten with new value.
More details or code parts will help to understand your situation.
Ok, got it. I had to reload the XmlDataProvider in the Loaded method.
In addition, seeing that I had to reload the XmlDataProvider itself, I set it to point directly to the correct .xml file. :)
Thank you for your answers!
You need to debug and see exactly where things get initialized ?
It would be quite simpler to have just set the language and point to the correct xml file rather than your language.xml file.You already have two language files so why do do need additional operations ....
Try to simplify and then see if you still get the proplem.
Related
C#
TL;DR: I want the user to be able to input text, which is then written to an external file, which then can be called later based on position in the file. What's the easiest way and form to read and write a list of strings to?
Very amateur question, but I can't seem to find an easy anwer on the internet. If I'm missing something obvious, please redirect me. I am writing a very simple program in which the user can input a string which is then written (added) to an external file, from which later a string can be called based on the position in the file. I found things like JSON, Resource file, SQL DB... Problem is that due to my lack of programming experience I have no idea what's the best option to look into.
Example of what I want to achieve:
User inputs strings 'Dog', 'Cat', and 'Horse' into the textbox. Each of these strings are added to the external file. Lateron, the user calls the 2nd number on the list, to which the program returns 'Cat'.
Thanks!
If you already know the kind of data that will be saved I recommend using XML Serialization. This lets you save and read your file very easily. The linked example is from Microsoft and shows a dataset being serialized. If you want to save a generic list instead of a fixed object you might find this link helpful.
Alternatively, you could save data to your application configuration file (search online for "C# application configuration for PROJECT_TYPE" where the project type is winforms/mvc/class library etc..)
To make things a tad simpler in my C# application, I decided to save all user style changes using the Properties.Settings properties, which works as expected.
But I liked the style change aspect of my app so much, and it is so important to the usage, that I have now decided to have savable and loadable style files(MyStyle.xxx) for the user to save and reload. But as I have never used these user settings before, I am unsure of how to duplicate and save this object. Can it be done simply, or can I maybe write these objects to serialized XML? What is the common approach?
P.S. I tried researching this topic but because it is so closely related to just saving user settings, all I could find was questions about saving user settings.
This is sort of sketchy but it has worked for me in the past and seems to be a pretty decent solution..
Firstly, create a list of settings you want and some default values.
Then create some JSON-esque format for your data and save in the setting as a string. From there you can jsut copy paste this template and make say 3 more string in your settings file for a total of 4 strings with the same JSON stuff in it.
It's a bit of a fuss parsing that info in and out but if you do set it up in JSON format then it shouldn't be too hard.
I am working on cloud storage system in ASP.Net MVC5. In which I made a file manager that handles cut,copy,download multiple files,edit and preview of files, but I want to edit documents like word files in real time (collaborative editing)..is there any api that can help me accordingly.
Thank you in advance.
you should use Signal R for real time applications...it may be possible with the help of application user interface but its better to write your own code according to your choice...
[http://signalr.net/][1]
dev_express and syncfusion may be your solution..try these..
This is turning into a huge comment, so I'll just explain my point of view in an answer. I'll remove it, if I see an actual answer appears.
I am suggesting you start writing your own code for collaborative editing and the reason is quite simple. You need at least slightly different processing for almost each file type, which suggests there will never be a single API to support collaborative editing for all file types, unless somebody makes it their goal to maintain it and keep up with every one created.
Start it simple, text (or hex) editing. Define how changes are made and implemented on other clients and then work your way to add as many file types (and methods that go with them) as you need.
You could use source code of 1 of these open source collaborative text editors (you'll have to find download / Github links on their websites) to get a general idea how to do it, but you will still have to put in some work and won't go far without creating your own code.
Collaborative editing requires user 1's (who just started editing) client to send either one of these:
Data pointing to changes made in file
Full file, and user 2's client (or central "server") should be able to calculate the changes made from there and implement them.
One of the problems is to overwrite only that portion of the file changes were made to (and avoid overwriting the other user 2's work).
And the biggest problem (the reason you can't have "1 for all" method/API) is each file type has its own structure meaning that different file types will have different data representing changes in file. If you try to write raw data it might work, but you'd still need to calculate and lock away specific portions of file, that contain general information, rather than data of your file.
https://xamlmarkupextensions.codeplex.com/
I'm having a problem using the xamlmarkupextensions library. This library provides the opportunity to Bind values from a resource file (resx) to different controls. Now this works perfectly, but I don't want to use the resource file... I would like to use my own database.
So I made a new database and tried some stuff and got it working. The only problem is that the value is not visible in design time... Does anybody here knows how this could work? Thanks in advance!
If I want to add a string as a setting or an image as a resource – I do it through Visual Studio.
But how do I add something complicated such as a large array or a Form which has to first be computed at runtime (or in case of the Form – populated with controls)?
I thought I could run it and persist it in settings (Properties.Settings.Default.Setting1 =...), and then publish. But that doesn't work (See: How to persist from build programmatically? ).
So how is it done?
Have you read up on serialization? I know that's kind of a generic answer, but I hope it helps.
As for a large array, you need to come up with an approach or mechanism for storing the data.
If it's a simple array that won't change very often, you can store it in the app.config.
If it's a datasource (ie: the data changes often) you could use an XML file and ideally a database.
I'm not really sure what you mean by persisting a Form. A Form should contain all controls compiled within it's own executable or dll. If you are asking how to populate the form, you would do this in the Main() method of the main form.