示例#1
0
        static void Main()
        {
            Thread.CurrentThread.Name = Path.GetFileName(Environment.GetCommandLineArgs()[0]);

#if DEBUG
            Log.InitializeLog(); // Initialization of log system.
            Log.AutoWriteLog();  // Start the automatic write of log lines.
#endif
            AppDomain.CurrentDomain.UnhandledException += delegate(object sender, UnhandledExceptionEventArgs args)
            {
                var filePath  = ClassUtility.ConvertPath(System.AppDomain.CurrentDomain.BaseDirectory + "\\error_wallet.txt");
                var exception = (Exception)args.ExceptionObject;
                using (var writer = new StreamWriter(filePath, true))
                {
                    writer.WriteLine("Message :" + exception.Message + "<br/>" + Environment.NewLine +
                                     "StackTrace :" +
                                     exception.StackTrace +
                                     "" + Environment.NewLine + "Date :" + DateTime.Now);
                    writer.WriteLine(Environment.NewLine +
                                     "-----------------------------------------------------------------------------" +
                                     Environment.NewLine);
                }

                MessageBox.Show(
                    @"An error has been detected, send the file error_wallet.txt to the Team for fix the issue.");
                System.Diagnostics.Trace.TraceError(exception.StackTrace);

                Environment.Exit(1);
            };
#if WINDOWS
            ClassMemory.CleanMemory();
#endif

            bool firstStart = ClassWalletSetting.LoadSetting(); // Load the setting file.
            ClassTranslation.InitializationLanguage();          // Initialization of language system.
            ClassContact.InitializationContactList();           // Initialization of contact system.
#if WINDOWS
            Application.EnableVisualStyles();
#endif
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new WalletXiropht(firstStart)); // Start the main interface.
        }
示例#2
0
        private static string _walletSettingFile = "\\xiropht.ini"; // Path of the setting file.

        /// <summary>
        /// Save settings of the wallet gui into a file.
        /// </summary>
        public static void SaveSetting()
        {
            string syncModeSetting           = "SYNC-MODE-SETTING=";
            string syncModeManualHostSetting = "SYNC-MODE-MANUAL-HOST-SETTING=";

            switch (ClassWalletObject.WalletSyncMode)
            {
            case 0:
                syncModeSetting           += "0";
                syncModeManualHostSetting += "NONE";
                break;

            case 1:
                syncModeSetting           += "1";
                syncModeManualHostSetting += "NONE";
                break;

            case 2:
                syncModeSetting           += "2";
                syncModeManualHostSetting += ClassWalletObject.WalletSyncHostname;
                break;

            default:
                syncModeSetting           += "0";
                syncModeManualHostSetting += "NONE";
                break;
            }

            if (!File.Exists(ClassUtility.ConvertPath(System.AppDomain.CurrentDomain.BaseDirectory + _walletSettingFile)))
            {
                File.Create(ClassUtility.ConvertPath(System.AppDomain.CurrentDomain.BaseDirectory + _walletSettingFile)).Close();
            }

            StreamWriter writer = new StreamWriter(ClassUtility.ConvertPath(System.AppDomain.CurrentDomain.BaseDirectory + _walletSettingFile), false);

            writer.WriteLine(syncModeSetting);
            writer.WriteLine(syncModeManualHostSetting);
            writer.WriteLine("CURRENT-WALLET-LANGUAGE=" + ClassTranslation.CurrentLanguage);
            writer.Close();
        }
示例#3
0
        private static void Application_ThreadException(object sender, UnhandledExceptionEventArgs e)
        {
            var filePath  = ClassUtility.ConvertPath(AppDomain.CurrentDomain.BaseDirectory + "\\error_wallet.txt");
            var exception = (Exception)e.ExceptionObject;

            using (var writer = new StreamWriter(filePath, true))
            {
                writer.WriteLine("Message :" + exception.Message + "<br/>" + Environment.NewLine +
                                 "StackTrace :" +
                                 exception.StackTrace +
                                 "" + Environment.NewLine + "Date :" + DateTime.Now);
                writer.WriteLine(Environment.NewLine +
                                 "-----------------------------------------------------------------------------" +
                                 Environment.NewLine);
            }

            MessageBox.Show(
                @"An error has been detected, send the file error_wallet.txt to the Team for fix the issue.");
            Trace.TraceError(exception.StackTrace);

            Environment.Exit(1);
        }
示例#4
0
        /// <summary>
        /// Insert a new contact to the list and save the database file.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="walletAddress"></param>
        /// <returns></returns>
        public static bool InsertContact(string name, string walletAddress)
        {
            if (ListContactWallet.ContainsKey(name))
            {
#if DEBUG
                Log.WriteLine("Contact name: " + name + " already exist.");
#endif
                return(false);
            }
            if (ListContactWallet.ContainsValue(walletAddress))
            {
#if DEBUG
                Log.WriteLine("Contact wallet address: " + walletAddress + " already exist.");
#endif
                return(false);
            }
            ListContactWallet.Add(name, walletAddress);
            using (StreamWriter writerContact = new StreamWriter(ClassUtility.ConvertPath(System.AppDomain.CurrentDomain.BaseDirectory + ContactFileName), true))
            {
                writerContact.WriteLine(name + "|" + walletAddress);
            }
            return(true);
        }
示例#5
0
        public static Dictionary <string, Dictionary <string, string> > LanguageDatabases = new Dictionary <string, Dictionary <string, string> >(); // Dictionnary content format -> {string:Language Name|Dictionnary:{string:text name|string:text content}}

        /// <summary>
        /// Read every language files, insert them to language database.
        /// </summary>
        public static void InitializationLanguage()
        {
            if (CurrentLanguage == null || string.IsNullOrEmpty(CurrentLanguage))
            {
                CurrentLanguage = "english"; // By Default on initialization.
            }
            if (Directory.Exists(ClassUtility.ConvertPath(System.AppDomain.CurrentDomain.BaseDirectory + LanguageFolderName)))
            {
                string[] languageFilesList = Directory.GetFiles(ClassUtility.ConvertPath(System.AppDomain.CurrentDomain.BaseDirectory + LanguageFolderName), "*.xirlang").Select(Path.GetFileName).ToArray();
                if (languageFilesList.Length == 0)
                {
#if DEBUG
                    Log.WriteLine("No language files found, please reinstall your gui wallet.");
#endif
#if WINDOWS
                    ClassFormPhase.MessageBoxInterface("No language files found, please reinstall your gui wallet.", "No language files found.", MessageBoxButtons.OK, MessageBoxIcon.Error);
#else
                    MessageBox.Show(ClassFormPhase.WalletXiropht, "No language files found, please reinstall your gui wallet.", "No language files found.", MessageBoxButtons.OK, MessageBoxIcon.Error);
#endif
                    Process.GetCurrentProcess().Kill();
                }
                else
                {
                    for (int i = 0; i < languageFilesList.Length; i++)
                    {
                        if (i < languageFilesList.Length)
                        {
                            if (languageFilesList[i] != null)
                            {
                                if (!string.IsNullOrEmpty(languageFilesList[i]))
                                {
                                    string currentLanguage = string.Empty;
#if DEBUG
                                    Log.WriteLine("Read language file: " + languageFilesList[i]);
#endif
                                    using (FileStream fs = File.Open(ClassUtility.ConvertPath(System.AppDomain.CurrentDomain.BaseDirectory + LanguageFolderName + "\\" + languageFilesList[i]), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                                        using (BufferedStream bs = new BufferedStream(fs))
                                            using (StreamReader sr = new StreamReader(bs))
                                            {
                                                string line;
                                                while ((line = sr.ReadLine()) != null)
                                                {
                                                    if (!line.Contains("#") && !string.IsNullOrEmpty(line)) // Ignore lines who contains # character.
                                                    {
                                                        if (line.Contains("LANGUAGE_NAME="))
                                                        {
                                                            currentLanguage = line.Replace("LANGUAGE_NAME=", "").ToLower();
#if DEBUG
                                                            Log.WriteLine("Language name detected: " + currentLanguage);
#endif
                                                            if (!LanguageDatabases.ContainsKey(currentLanguage))
                                                            {
                                                                LanguageDatabases.Add(currentLanguage, new Dictionary <string, string>());
                                                            }
                                                        }
                                                        else if (line.Contains("CONTRIBUTOR="))
                                                        {
                                                            if (!LanguageContributors.ContainsKey(currentLanguage))
                                                            {
                                                                LanguageContributors.Add(currentLanguage, new List <string>());
                                                            }
                                                            LanguageContributors[currentLanguage].Add(line.Replace("CONTRIBUTOR=", ""));
                                                        }
                                                        else
                                                        {
                                                            if (currentLanguage != string.Empty) // Ignore lines if the current language name of the file is not found.
                                                            {
                                                                var splitLanguageText   = line.Split(new[] { "=" }, StringSplitOptions.None);
                                                                var orderLanguageText   = splitLanguageText[0];
                                                                var contentLanguageText = splitLanguageText[1];

                                                                // Replace commands.
                                                                contentLanguageText = contentLanguageText.Replace(CoinNameOrder, ClassConnectorSetting.CoinName);
                                                                contentLanguageText = contentLanguageText.Replace(CoinMinNameOrder, ClassConnectorSetting.CoinNameMin);
                                                                contentLanguageText = contentLanguageText.Replace("\\n", Environment.NewLine);

                                                                // Insert.
                                                                LanguageDatabases[currentLanguage].Add(orderLanguageText, contentLanguageText);

#if DEBUG
                                                                Log.WriteLine("Insert order language text: " + orderLanguageText + " with content language text: " + contentLanguageText + " for language name: " + currentLanguage);
#endif
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
#if DEBUG
                Log.WriteLine("No language folder found, please reinstall your gui wallet.");
#endif
#if WINDOWS
                ClassFormPhase.MessageBoxInterface("No language folder found, please reinstall your gui wallet.", "No folder language found.", MessageBoxButtons.OK, MessageBoxIcon.Error);
#else
                MessageBox.Show(ClassFormPhase.WalletXiropht, "No language folder found, please reinstall your gui wallet.", "No folder language found.", MessageBoxButtons.OK, MessageBoxIcon.Error);
#endif
                Process.GetCurrentProcess().Kill();
            }
        }