private void ActionSave() { bool result; // надо скопировать данные из EditorDataModel.Items в новый ResourcesDictionary // need to copy data from EditorDataModel.Items to new ResourcesDictionary ResourceDictionary newResourceDictionary = new ResourceDictionary(); foreach (LanguageFile file in filesForProceed) { string value; newResourceDictionary.Clear(); foreach (ItemModel itemModel in EditorDataModel.Items) { switch (file.language) { case LanguageTypes.Languages.lLV: { value = itemModel.Value1; break; } case LanguageTypes.Languages.lRU: { value = itemModel.Value2; break; } case LanguageTypes.Languages.lEN: { value = itemModel.Value3; break; } default: { value = itemModel.Value4; break; } } newResourceDictionary.Add(itemModel.KeyName, value); } result = ResourceDictionaryFunctions.SaveResourceDictionaryToFile(file.file, newResourceDictionary); if (!result) { MessageBox.Show( String.Format("Cannot save resources dictionary '{0}'!", file.language) ); return; } } }
private void ActionLoad() { // Read data foreach (LanguageFile file in filesForProceed) { ResourcesDictionary[(int)file.language] = ResourceDictionaryFunctions.LoadResourceDictionaryFromFile(file.file); } bool result; // Verify data (quick way 1) result = ResourceDictionaryFunctions.VerifySizeOfResourcesDictionary(ResourcesDictionary); if (!result) { MessageBox.Show("Size of resources doesnot match!"); return; } // Verify data (way 2) result = ResourceDictionaryFunctions.VerifyKeysInResourcesDictionary(ResourcesDictionary); if (!result) { MessageBox.Show("Keys in resources does not match!"); return; } // Build list of Keys and values EditorDataModel.Items.Clear(); foreach (DictionaryEntry key in ResourcesDictionary[(int)LanguageTypes.Languages.lLV]) { ItemModel myData = new ItemModel { KeyName = key.Key.ToString(), Value1 = key.Value.ToString(), Value2 = ResourcesDictionary[(int)LanguageTypes.Languages.lRU][key.Key].ToString(), Value3 = ResourcesDictionary[(int)LanguageTypes.Languages.lEN][key.Key].ToString(), Value4 = ResourcesDictionary[(int)LanguageTypes.Languages.lDE][key.Key].ToString() }; EditorDataModel.Items.Add(myData); } //ResourceDictionaryKeys = ResourceDictionaryFunctions.GetListOfAllKeysAsObservableCollection(ResourcesDictionary[(int)LanguageTypes.Languages.lLV]); }