private void SaveChanges(bool showWarning) { try { Resources ds = grdResources.DataSource as Resources; if (ds != null && ds.HasChanges()) { DialogResult res = DialogResult.Yes; if (showWarning) { res = MessageBox.Show("Save changes?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question); } if (res == DialogResult.Yes) { ds.AcceptChanges(); string fileName = GetLocaleFile(); ds.WriteXml(fileName); } } } catch (Exception ex) { ShowError(ex); } }
private void ImportLanguagePack() { try { string path = Path.Combine(this.DataDirectory, importedLocale); string sourceFile = Path.Combine(this.DataDirectory, @"en-US\Resources.xml"); string destFile = Path.Combine(path, "Resources.xml"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } if (!File.Exists(destFile)) { File.Copy(sourceFile, destFile); } ClearTmpDir(); SetStatusBarText("Extracting language pack..."); ZipUtils.Unzip("Tmp", importedFileName); Resources ds = new Resources(); ds.ReadXml(destFile); int count = ImportFiles(importedLocale, ds, this.TmpDirectory, this.TmpDirectory); ds.AcceptChanges(); ds.WriteXml(destFile); DeleteTmpDir(); LoadLocales(); SetCurrentLocale(importedLocale); FinishProgress(); string message = string.Format("{0} record(s) imported successfully.", count); MessageBox.Show(this, message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { if (IsThreadAbortException(ex)) { return; } throw; } }
private static void LoadResources(string source) { try { string destination = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Data\en-US"); if (!Directory.Exists(destination)) { Directory.CreateDirectory(destination); } dsResources = new Resources(); LoadFiles(source, source); dsResources.AcceptChanges(); string fileName = Path.Combine(destination, "Resources.xml"); dsResources.WriteXml(fileName); } catch (Exception ex) { ShowError(ex); } }
private void BindResourcesGrid() { try { if (string.IsNullOrEmpty(cbSupportedLocales.Text)) { grdResources.DataMember = null; grdResources.DataSource = null; return; } string localeName = null; DataRowView row = cbSupportedLocales.SelectedValue as DataRowView; if (row != null) { localeName = (string)row["Name"]; } else { localeName = cbSupportedLocales.SelectedValue as string; } if (!string.IsNullOrEmpty(localeName)) { dsResources = new Resources(); string fileName = Path.Combine(this.DataDirectory, localeName + "\\resources.xml"); dsResources.ReadXml(fileName); dsResources.AcceptChanges(); grdResources.DataSource = dsResources; grdResources.DataMember = this.dsResources.Tables[0].TableName; } } catch (Exception ex) { ShowError(ex); } }
private void ImportLanguagePack() { try { string path = Path.Combine(this.DataDirectory, importedLocale); string sourceFile = Path.Combine(this.DataDirectory, @"en-US\Resources.xml"); string destFile = Path.Combine(path, "Resources.xml"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } if (!File.Exists(destFile)) { File.Copy(sourceFile, destFile); } ClearTmpDir(); SetStatusBarText("Extracting language pack..."); ZipUtils.Unzip("Tmp", importedFileName); Resources ds = new Resources(); ds.ReadXml(destFile); int count = ImportFiles(importedLocale, ds, this.TmpDirectory, this.TmpDirectory); ds.AcceptChanges(); ds.WriteXml(destFile); DeleteTmpDir(); LoadLocales(); SetCurrentLocale(importedLocale); FinishProgress(); string message = string.Format("{0} record(s) imported successfully.", count); MessageBox.Show(this, message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { if (IsThreadAbortException(ex)) return; throw; } }