示例#1
0
        private bool Validate()
        {
            try
            {
                var message = string.Empty;

                if (string.IsNullOrWhiteSpace(Name))
                {
                    message = Translations.GetTranslation()["FirstNameValid"].ToString();
                }
                else if (!ContactList.Any(x => x.IsSelected == true))
                {
                    message = Translations.GetTranslation()["NoMemmbersSelected"].ToString();
                }

                if (message != string.Empty)
                {
                    Application.Current.Dispatcher.Invoke(new Action((() => { CustomMessageBox.Show(Translations.GetTranslation()["Error"].ToString(), message); })));
                    return(false);
                }
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
示例#2
0
        public void TestSpokenShipManufacturer()
        {
            var    fromName = Translations.GetTranslation("Lakon Spaceways");
            string expected = "<phoneme alphabet=\"ipa\" ph=\"leɪkɒn\">Lakon</phoneme> " + "<phoneme alphabet=\"ipa\" ph=\"speɪsweɪz\">Spaceways</phoneme>";

            Assert.AreEqual(expected, fromName);
        }
示例#3
0
        private bool Validate()
        {
            var message = string.Empty;

            if (string.IsNullOrWhiteSpace(_oldPass))
            {
                message = Translations.GetTranslation()["OldPassValid"].ToString();
            }
            else if (AESEncryptor.decryptPassword(GlobalBase.CurrentUser.Password) != _oldPass)
            {
                message = Translations.GetTranslation()["ResPassCurPassNotMatch"].ToString();
            }
            else if (_newPass.Length < 8 || string.IsNullOrWhiteSpace(_newPass) || _newPass == string.Empty || !Regex.IsMatch(_newPass, @"^[a-zA-Z0-9]{8,}$"))
            {
                message = Translations.GetTranslation()["PassValidation"].ToString();
            }

            if (message != string.Empty)
            {
                Application.Current.Dispatcher.Invoke(new Action((() => { CustomMessageBox.Show(Translations.GetTranslation()["Error"].ToString(), message); })));
                return(false);
            }

            return(true);
        }
示例#4
0
        public void TestSagAStar()
        {
            string SagI       = "Sagittarius A*";
            string translated = Translations.GetTranslation(SagI);

            SpeechService.Instance.Say(ShipDefinitions.FromEliteID(128049309), translated);
        }
示例#5
0
        //executes for commands
        private void ExecuteOnAddFile()
        {
            try
            {
                var openFileDialog = new OpenFileDialog();
                openFileDialog.Multiselect = true;
                openFileDialog.ShowDialog();
                string[] tempFileNames = openFileDialog.FileNames;

                foreach (string fileName in tempFileNames)
                {
                    FileInfo fileInfo = new FileInfo(fileName);
                    if (fileInfo.Length > GlobalBase.fileSizeConstraint)
                    {
                        CustomMessageBox.Show(Translations.GetTranslation()["FileSizeExcesedShort"].ToString(), Translations.GetTranslation()["FileSizeExcesed"].ToString(), MessageBoxType.Warning);
                        return;
                    }
                }

                FilesPath  = tempFileNames;
                FileAmount = FilesPath.Count();
            }
            catch (Exception)
            {
            }
        }
示例#6
0
        private bool ValidateOnLogin()
        {
            try
            {
                var message = string.Empty;

                if (string.IsNullOrWhiteSpace(LoginText))
                {
                    message = Translations.GetTranslation()["EmptyLogin"].ToString();
                }
                else if (Password.Length < 8 || string.IsNullOrWhiteSpace(Password) || Password == string.Empty || !Regex.IsMatch(Password, @"^[a-zA-Z0-9]{8,}$"))
                {
                    message = Translations.GetTranslation()["PassValidation"].ToString();
                }
                else if (UserServiceClient.GetUser(LoginText, AESEncryptor.encryptPassword(Password)) == null)
                {
                    message = Translations.GetTranslation()["LogPassValid"].ToString();
                }

                if (message != string.Empty)
                {
                    Application.Current.Dispatcher.Invoke(new Action((() => { CustomMessageBox.Show(Translations.GetTranslation()["Error"].ToString(), message); })));
                    return(false);
                }

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
示例#7
0
        protected void AddRecruitingButton(GuiList buildingActions, string unitToRecruit)
        {
            StringBuilder labelNextToButtonText = new StringBuilder();

            labelNextToButtonText.Append(Translations.GetTranslation(unitToRecruit)).Append(" (");      // Soldier (
            labelNextToButtonText.Append(SoldierRegistry.GetSoldierCost(unitToRecruit)).Append("G): "); // Soldier ('cost'G)
            buildingActions.addElement(ElementBuildButton.CreateBuildButton(buildingActions.Bounds.Location, labelNextToButtonText.ToString(), () => TrySpawnUnit(unitToRecruit), "Recruit"));
        }
示例#8
0
        public void TestSpokenShipModel()
        {
            var    fromEDName = Translations.GetTranslation("CobraMkIII");
            var    fromName   = Translations.GetTranslation("Cobra Mk. III");
            string expected   = "<phoneme alphabet=\"ipa\" ph=\"ˈkəʊbrə\">cobra</phoneme> " + "<phoneme alphabet=\"ipa\" ph=\"mɑːk\">Mark</phoneme> " + "<phoneme alphabet=\"ipa\" ph=\"θriː\">3</phoneme>";

            Assert.AreEqual(expected, fromEDName);
            Assert.AreEqual(expected, fromName);
        }
示例#9
0
        private void ChangeLanguage(Translations trans, Action <string> changeValue)
        {
            if (!string.IsNullOrWhiteSpace(_translatableKey))
            {
                var value = trans.GetTranslation(_translatableKey);

                changeValue(value);
            }
        }
示例#10
0
        public void TestTranslateStarSystemsStability()
        {
            string[] starSystems = Resources.starsystems.Split(new[] { '\r', '\n' });

            foreach (string starSystem in starSystems)
            {
                Translations.GetTranslation(starSystem);
            }
        }
示例#11
0
 public void TestTranslateStarSystems()
 {
     Assert.AreEqual("L H S 1 2 3 4 5", Translations.GetTranslation("LHS 12345"));
     Assert.AreEqual("H R 1 2 3 4 5", Translations.GetTranslation("HR 12345"));
     Assert.AreEqual("C X O U J 0 6 1 7 0 5 point 3 plus 2 2 2 1 2 7", Translations.GetTranslation("CXOU J061705.3+222127"));
     Assert.AreEqual("S D S S J 1 4 1 6 plus 1 3 4 8", Translations.GetTranslation("SDSS J1416+1348"));
     Assert.AreEqual("U G C S J 1 2 2 0 3 1 point 5 6 plus 2 4 3 6 1 4 point 8", Translations.GetTranslation("UGCS J122031.56+243614.8"));
     Assert.AreEqual("X T E J 1 7 4 8 minus 2 8 8", Translations.GetTranslation("XTE J1748-288"));
     Assert.AreEqual("", Translations.GetTranslation(""));
 }
示例#12
0
        private void ExecuteOnApplyChanges()
        {
            try
            {
                if (Validate())
                {
                    IsSavingProgress = true;
                    string res;
                    Task.Run((() =>
                    {
                        GlobalBase.CurrentUser.FirstName = UserName;
                        GlobalBase.CurrentUser.LastName = UserLastName;
                        GlobalBase.CurrentUser.Phone = UserPhone;
                        GlobalBase.CurrentUser.Email = UserEmail;
                        GlobalBase.CurrentUser.Bio = UserBio;
                        res = UserServiceClient.AddOrUpdateUser(GlobalBase.CurrentUser);

                        if (_newAvatar != null)
                        {
                            var chatFile = GlobalBase.FileServiceClient.getChatFileById(GlobalBase.CurrentUser.ImageId);
                            if (chatFile == null)
                            {
                                GlobalBase.CurrentUser.ImageId = GlobalBase.FileServiceClient.UploadFile(new FileService.ChatFile()
                                {
                                    Source = CompressionHelper.CompressImage(_newAvatar)
                                });
                                UserServiceClient.AddOrUpdateUser(GlobalBase.CurrentUser);
                            }
                            else
                            {
                                GlobalBase.FileServiceClient.UpdateFileSource(chatFile.Id, CompressionHelper.CompressImage(_newAvatar));
                            }
                        }

                        SetAvatarForUI();

                        if (res == string.Empty)
                        {
                            Application.Current.Dispatcher.Invoke(new Action((() =>
                            {
                                CustomMessageBox.Show(Translations.GetTranslation()["ChangesSaved"].ToString());
                            })));
                        }
                    })).ContinueWith((task =>
                    {
                        IsSavingProgress = false;
                        IsNewChanges = false;
                    }));
                }
            }
            catch (Exception)
            {
            }
        }
示例#13
0
        private void OnSend()
        {
            try
            {
                IsSending = true;

                var ts = new CancellationTokenSource();
                CancellationToken ct = ts.Token;
                Task.Factory.StartNew(() =>
                {
                    if (!string.IsNullOrWhiteSpace(Email))
                    {
                        User user = UserServiceClient.GetAllUsers().First(x => x.Email == Email);

                        if (user != null)
                        {
                            SendPassWithMail(user);
                            return;
                        }
                    }

                    if (!string.IsNullOrWhiteSpace(Login))
                    {
                        User user = UserServiceClient.GetUserByLogin(Login);

                        if (user != null)
                        {
                            SendPassWithMail(user);
                            return;
                        }
                    }

                    Application.Current.Dispatcher.Invoke(new Action((() =>
                    {
                        CustomMessageBox.Show(Translations.GetTranslation()["Error"].ToString(), Application.Current.Resources.MergedDictionaries[4]["CantFindUser"].ToString());
                        ts.Cancel();
                    })));
                }, ct).ContinueWith((task =>
                {
                    if (!ct.IsCancellationRequested)
                    {
                        Application.Current.Dispatcher.Invoke(new Action((() =>
                        {
                            CustomMessageBox.Show(Translations.GetTranslation()["RestorePass"].ToString(), Application.Current.Resources.MergedDictionaries[4]["EmailSend"].ToString());
                        })));
                    }
                    IsSending = false;
                }));
            }
            finally
            {
            }
        }
        private void AddBuilderButton(EconomyGrid grid, GuiList listBuilderActions, string buildingName, Type buildingType)
        {
            // Create the label for the element
            StringBuilder label = new StringBuilder();

            label.Append(Translations.GetTranslation(buildingName)).Append(" (");
            label.Append(BuildingRegistry.GetCost(buildingName)).Append("G): ");

            // Create the element using the label, and add a BuildBuilding clickhandler
            listBuilderActions.addElement(ElementBuildButton.CreateBuildButton(listBuilderActions.Bounds.Location, label.ToString(), BuildBuilding(grid, buildingName, buildingType)));

            // Also add this buildingID-Type pair to the BuildingRegistry
            BuildingRegistry.buildingTypeById[buildingName] = buildingType;
        }
示例#15
0
        public void TestTemplateFunctional()
        {
            var document = new SimpleDocument(@"You are entering the {P(system)} system.");
            var store    = new BuiltinStore();

            store["P"] = new NativeFunction((values) =>
            {
                return(Translations.GetTranslation(values[0].AsString));
            }, 1);
            store["system"] = "Alrai";
            var result = document.Render(store);

            Assert.AreEqual("You are entering the <phoneme alphabet=\"ipa\" ph=\"ˈalraɪ\">Alrai</phoneme> system.", result);
        }
        private void UpdateArmyInformation(Army a)
        {
            listArmySoldiers.clear();
            foreach (string soldierType in a.UnitsAndCounts.Keys)
            {
                // Create the label to add to the list
                StringBuilder sb = new StringBuilder();
                sb.Append(Translations.GetTranslation(soldierType));
                sb.Append(": ");
                sb.Append(a.SelectedUnits[soldierType] + "/");
                sb.Append(a.UnitsAndCounts[soldierType]);

                // Add this label to the list
                listArmySoldiers.addElement(ElementArmySelection.CreateBuildButton(Point.Zero, sb.ToString(), AddSelected(soldierType, a), LowerSelected(soldierType, a)));
            }
        }
        /// <summary>
        /// Prints a Unit's information on the screen, or makes the information labels disappear if there is no Unit.
        /// </summary>
        /// <param name="u">The Unit of which the information should be printed.</param>
        public void PrintSoldierInfo(Soldier u)
        {
            // No Unit? Make the unit info disappear :o
            if (u == null)
            {
                labelUnitHp.Visible = labelUnitAtt.Visible = labelUnitHit.Visible = labelUnitName.Visible = false;
                return;
            }

            // There is a Unit? Show its stats.
            labelUnitHp.Visible = labelUnitAtt.Visible = labelUnitHit.Visible = labelUnitName.Visible = true;
            labelUnitName.setLabelText("Type: " + Translations.GetTranslation(u.Name));
            labelUnitHp.setLabelText("Unit HP/Max: " + u.Stats.hp + '/' + u.Stats.maxHp);
            labelUnitAtt.setLabelText("Unit Att/Def: " + u.Stats.att + '/' + u.Stats.def);
            labelUnitHit.setLabelText("Unit Hit/Dodge: " + u.Stats.hit + '/' + u.Stats.dodge);
        }
示例#18
0
        /// <summary>
        /// This method prints the default check with respect to your assembly name, MessageLanguage and individual user settings
        /// </summary>
        public void Notify()
        {
            if (notified)
            {
                return;
            }

            notified = true;

            // ex. "You are using the latest version of [NAME]"
            Comms.Print(
                Translations.GetTranslation(
                    ("updater_" + (Success ? GitVersion == LocalVersion ? "updated" : "available" : "error")).Replace(
                        "[NAME]",
                        aName),
                    MessageLanguage));
        }
示例#19
0
        private void OnApply()
        {
            _oldPass = _restorePasswordSupplier.GetCurrentPassword();
            _newPass = _restorePasswordSupplier.GetNewPassword();

            if (Validate())
            {
                IsResetingNotProgress = false;
                IsResetingProgress    = true;

                var result = string.Empty;

                Task.Run(() =>
                {
                    try
                    {
                        GlobalBase.CurrentUser.Password = AESEncryptor.encryptPassword(_newPass);

                        UserServiceClient.AddOrUpdateUser(GlobalBase.CurrentUser);
                    }
                    catch (Exception ex)
                    {
                        result = ex.Message;
                    }
                }).ContinueWith(task =>
                {
                    if (result == string.Empty)
                    {
                        Application.Current.Dispatcher.Invoke(new Action((() =>
                        {
                            CustomMessageBox.Show(Translations.GetTranslation()["ChangesSaved"].ToString());
                            OnBack();
                            return;
                        })));
                    }
                    else
                    {
                        Application.Current.Dispatcher.Invoke(new Action((() =>
                        {
                            CustomMessageBox.Show(Translations.GetTranslation()["Error"].ToString(), result);
                        })));
                    }
                });
            }
        }
示例#20
0
        private void InitLogin(string userLogin)
        {
            try
            {
                var user = new User();
                Task.Run(() =>
                {
                    user = UserServiceClient.GetUserByLogin(userLogin);
                }).ContinueWith(task =>
                {
                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        try
                        {
                            if (user?.Status == "online")
                            {
                                CustomMessageBox.Show(
                                    Translations.GetTranslation()["Error"].ToString(),
                                    Translations.GetTranslation()["UserAlreadyOnline"].ToString(),
                                    MessageBoxType.Error);

                                IsLoginProgress = false;
                                return;
                            }
                            else if (user == null)
                            {
                                IsLoginProgress = false;
                                return;
                            }

                            var wnd = new MessageMainWnd(user);
                            wnd.Show();
                            view.CloseWindow();
                            IsLoginProgress = false;
                        }
                        catch (Exception)
                        {
                        }
                    });
                });
            }
            catch (Exception)
            {
            }
        }
示例#21
0
 private async void ExecuteOnLogin()
 {
     try
     {
         IsLoginProgress = true;
         await Task.Factory.StartNew(() =>
         {
             try
             {
                 if (ValidateOnLogin())
                 {
                     var user = UserServiceClient.GetUser(LoginText, AESEncryptor.encryptPassword(Password));
                     if (user != null)
                     {
                         if (user.Status == "online")
                         {
                             Application.Current.Dispatcher.Invoke(() =>
                             {
                                 CustomMessageBox.Show(
                                     Translations.GetTranslation()["Error"].ToString(),
                                     Translations.GetTranslation()["UserAlreadyOnline"].ToString(),
                                     MessageBoxType.Error);
                             });
                             return;
                         }
                         _serializeUser.SerializeUser(user);
                         Application.Current.Dispatcher.Invoke(() =>
                         {
                             var wnd = new MessageMainWnd(user);
                             wnd.Show();
                             view.CloseWindow();
                             IsLoginProgress = false;
                         });
                     }
                 }
             }
             catch (Exception)
             {
             }
         }).ContinueWith(task => { IsLoginProgress = false; });
     }
     catch (Exception)
     {
     }
 }
示例#22
0
        private bool ValidateOnRegister()
        {
            try
            {
                var message = string.Empty;
                if (string.IsNullOrWhiteSpace(Name))
                {
                    message = Translations.GetTranslation()["FirstNameValid"].ToString();
                }
                else if (string.IsNullOrWhiteSpace(Surname))
                {
                    message = Translations.GetTranslation()["LastNameValid"].ToString();
                }
                else if (string.IsNullOrWhiteSpace(UserLogin))
                {
                    message = Translations.GetTranslation()["EmptyLogin"].ToString();
                }
                else if (RPassword.Length < 8 || string.IsNullOrWhiteSpace(RPassword) || RPassword == string.Empty || !Regex.IsMatch(RPassword, @"^[a-zA-Z0-9]{8,}$"))
                {
                    message = Translations.GetTranslation()["PassValidation"].ToString();
                }
                else if (RPassword != Rep_RPassword)
                {
                    message = Translations.GetTranslation()["PassMatchValidation"].ToString();
                }
                else if (string.IsNullOrWhiteSpace(Email) || Email == string.Empty || !Regex.IsMatch(Email, @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z", RegexOptions.IgnoreCase))
                {
                    message = Translations.GetTranslation()["EmailValidation"].ToString();
                }

                if (message != string.Empty)
                {
                    Application.Current.Dispatcher.Invoke(new Action((() => { CustomMessageBox.Show(Translations.GetTranslation()["Error"].ToString(), message); })));
                    return(false);
                }

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
示例#23
0
        private void ExecuteOnLeaveGroup()
        {
            try
            {
                if (CustomMessageBox.Show(Translations.GetTranslation()["LeaveGroupAsk"].ToString(), MessageBoxType.ConfirmationWithYesNo) == MessageBoxResult.Yes)
                {
                    UserServiceClient.RemoveUserToChatGroupContactAsync(_group.Id, GlobalBase.CurrentUser.Id).ContinueWith(task =>
                    {
                        Application.Current.Dispatcher.Invoke(new Action(() =>
                        {
                            _view.CloseWindow();
                        }));

                        GlobalBase.UpdateContactList();
                    });
                }
            }
            catch (Exception)
            {
            }
        }
示例#24
0
        private void SendPassWithMail(User user)
        {
            try
            {
                var from = new MailAddress("*****@*****.**"); // make custom mail adress
                var to   = new MailAddress(user.Email);

                var newPas = AESEncryptor.encryptPassword(RandomNumberGenerator.RandomPassword());
                user.Password = newPas;

                UserServiceClient.AddOrUpdateUser(user);

                var message = new MailMessage(from, to);
                message.Subject = "Password restore";
                message.Body    = "Your pass - " + AESEncryptor.decryptPassword(newPas);

                var smtp = new SmtpClient("smtp.gmail.com", 587);
                smtp.Credentials = new NetworkCredential("*****@*****.**", "messageApp1");
                smtp.EnableSsl   = true;
                smtp.SendMailAsync(message);

                Application.Current.Dispatcher.Invoke(new Action((() =>
                {
                    try
                    {
                        CustomMessageBox.Show(Translations.GetTranslation()["RestorePass"].ToString(), Application.Current.Resources.MergedDictionaries[4]["EmailSend"].ToString());
                        IsSending = false;
                    }
                    finally
                    {
                    }
                })));
            }
            finally
            {
            }
        }
示例#25
0
 public void TestSsml()
 {
     SpeechService.Instance.Say(ShipDefinitions.FromEliteID(128049363), "You are travelling to the " + Translations.GetTranslation("Hotas") + " system.");
 }
示例#26
0
        private void ExecuteOnApplyChanges()
        {
            try
            {
                if (Validate())
                {
                    IsSavingProgress = true;
                    var res = string.Empty;

                    Task.Run(() =>
                    {
                        _group.Name = GroupName;

                        var chatFile = GlobalBase.FileServiceClient.getChatFileById(_group.ImageId);

                        if (_newAvatar != null)
                        {
                            if (chatFile == null)
                            {
                                _group.ImageId = GlobalBase.FileServiceClient.UploadFile(new FileService.ChatFile()
                                {
                                    Source = CompressionHelper.CompressImage(_newAvatar)
                                });
                            }
                            else
                            {
                                GlobalBase.FileServiceClient.UpdateFileSource(chatFile.Id, CompressionHelper.CompressImage(_newAvatar));
                            }
                        }

                        if (_membersToAdd?.Count != 0)
                        {
                            foreach (var uiInfo in _membersToAdd)
                            {
                                UserServiceClient.AddUserToChatGroupContact(_group.Id, (uiInfo as UserUiInfo).UserId);
                            }
                        }

                        res = UserServiceClient.AddOrUpdateChatGroup(_group);

                        SetAvatarForUI();

                        if (res == string.Empty)
                        {
                            Application.Current.Dispatcher.Invoke(new Action((() =>
                            {
                                CustomMessageBox.Show(Translations.GetTranslation()["ChangesSaved"].ToString());
                            })));
                        }
                    }).ContinueWith(task =>
                    {
                        IsSavingProgress = false;
                        IsNewChanges     = false;

                        GlobalBase.UpdateContactList();
                    });
                }
            }
            catch (Exception)
            {
            }
        }
示例#27
0
 public void TestTranslateBody6()
 {
     Assert.AreEqual(@"Boewnst T Q dash K d 9 dash 7 4 0 <say-as interpret-as=""characters"">A</say-as> <say-as interpret-as=""characters"">A</say-as> Belt", Translations.GetTranslation("Boewnst TQ-K d9-740 A A Belt"));
     Assert.AreEqual(@"Boewnst <phoneme alphabet=""ipa"" ph=""ˈtænɡo"">tango</phoneme> <phoneme alphabet=""ipa"" ph=""keˈbek"">quebec</phoneme> dash <phoneme alphabet=""ipa"" ph=""ˈkiːlo"">kilo</phoneme> <phoneme alphabet=""ipa"" ph=""ˈdɛltə"">delta</phoneme> <phoneme alphabet=""ipa"" ph=""ˈnaɪnər"">niner</phoneme> dash <phoneme alphabet=""ipa"" ph=""ˈsɛvɛn"">seven</phoneme> <phoneme alphabet=""ipa"" ph=""ˈfoʊ.ər"">fawer</phoneme> <phoneme alphabet=""ipa"" ph=""ˈzɪərəʊ"">zero</phoneme> <phoneme alphabet=""ipa"" ph=""ˈælfə"">alpha</phoneme> <phoneme alphabet=""ipa"" ph=""ˈælfə"">alpha</phoneme> Belt", Translations.GetTranslation("Boewnst TQ-K d9-740 A A Belt", true));
 }
示例#28
0
 public void TestTranslationVesper()
 {
     Assert.AreEqual(Translations.GetTranslation("VESPER-M4"), "Vesper M 4");
 }
示例#29
0
 public void TestSectorTranslations()
 {
     Assert.AreEqual("Swoiwns N Y dash B a 95 dash 0", Translations.GetTranslation("Swoiwns NY-B a95-0"));
     Assert.AreEqual("P P M 5 2 8 7", Translations.GetTranslation("PPM 5287"));
 }
示例#30
0
 public void TestSsml4()
 {
     Logging.Verbose = true;
     SpeechService.Instance.Say(ShipDefinitions.FromEliteID(128049309), @"<break time=""100ms""/>We're on our way to " + Translations.GetTranslation("i Bootis") + ".");
 }