Ejemplo n.º 1
0
 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);
     }
 }
Ejemplo n.º 2
0
        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;
            }
        }
Ejemplo n.º 3
0
 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);
     }
 }
Ejemplo n.º 4
0
		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);
			}
		}
Ejemplo n.º 5
0
		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;
			}
		}