Example #1
0
        public static bool Load(string psFilePath, out Translation ptTranslation)
        {
            if (!File.Exists(psFilePath))
              {
            ptTranslation = null;
            return false;
              }

              FileStream lfsStream = new FileStream(psFilePath, FileMode.Open, FileAccess.Read);
              StreamReader lsrReader = new StreamReader(lfsStream, Encoding.Unicode);
              XmlSerializer lxsSerializer;

              try
              {
            lxsSerializer = new XmlSerializer(typeof(Translation));
            ptTranslation = (Translation)lxsSerializer.Deserialize(lsrReader);
            lsrReader.Close();
            lsrReader.Dispose();
            lfsStream.Dispose();

            return true;
              }
              catch (Exception e)
              {
            ptTranslation = null;
            return false;
              }
        }
Example #2
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
              Application.SetCompatibleTextRenderingDefault(false);

              Configuration.Load(out mcConfiguration);

              if (string.IsNullOrEmpty(mcConfiguration.LanguageFile) || !File.Exists(mcConfiguration.LanguageFile) || !Translation.Load(mcConfiguration.LanguageFile, out mtTranslation))
              {
            Language lfLanguage = new Language();
            if (lfLanguage.ShowDialog() != DialogResult.OK)
              return;
            mcConfiguration.LanguageFile = lfLanguage.TranslationPath;
            mtTranslation = lfLanguage.Translation;
              }

              if (args.Length == 1 && File.Exists(args[0]))
            Application.Run(new Filemode(args[0]));

              while (mbRunning)
            switch (mcConfiguration.LastMode)
            {
              case Programmode.Text:
            Application.Run(new Textmode());
            break;
              case Programmode.File:
            Application.Run(new Filemode());
            break;
            }
              Configuration.Save(mcConfiguration);
              if (mtTranslation.Changed)
            Translation.Save(mtTranslation, mcConfiguration.LanguageFile);
        }
Example #3
0
        public static bool Save(Translation ptTranslation, string psFilePath)
        {
            FileStream lfsStream = new FileStream(psFilePath, FileMode.Create, FileAccess.Write);
              StreamWriter lswWriter = new StreamWriter(lfsStream, Encoding.Unicode);
              XmlSerializer lxsSerializer;

              try
              {

            lxsSerializer = new XmlSerializer(typeof(Translation));
            lxsSerializer.Serialize(lswWriter, ptTranslation);
            lswWriter.Close();
            lswWriter.Dispose();
            lfsStream.Dispose();

            return true;
              }
              catch
              {
            if (lfsStream != null && lfsStream.CanWrite)
            {
              lfsStream.Close();
              lfsStream.Dispose();
            }
            return false;
              }
        }