public void ResourcesFromOtherAssemblies_CanBe_Loaded()
        {
            var assembly = typeof(TestHostAssemblyDummy).Assembly;
            var current  = new I18N().Init(assembly);

            current.Locale = "es";
            Assert.AreEqual("ensamblado anfitrión", current.Translate("host"));

            current.Locale = "en";
            Assert.AreEqual("host assembly", current.Translate("host"));
        }
Exemple #2
0
        public void AnyFileExtension_CanBe_Loaded()
        {
            var current = new I18N()
                          .SingleFileResourcesMode("localeManifestWeird.weird4", "resourcesWeird")
                          .SetResourcesFolder("OtherSingleFileLocales")
                          .SetSingleFileLocaleReader(new JsonKvpSingleFileReader(), ".weird5")
                          .Init(GetType().Assembly);

            current.Locale = "es";
            Assert.AreEqual("bien", current.Translate("wellKey"));

            current.Locale = "en";
            Assert.AreEqual("well", current.Translate("wellKey"));
        }
        public void ResourceFolder_CanBe_Set()
        {
            var current = new I18N();

            current
            .SetResourcesFolder("OtherLocales")
            .Init(GetType().Assembly);

            current.Locale = "es";
            Assert.AreEqual("bien", current.Translate("well"));

            current.Locale = "en";
            Assert.AreEqual("well", current.Translate("well"));
        }
Exemple #4
0
        public XtermTerminalView()
        {
            InitializeComponent();
            StartMediatorTask();

            _webView = new WebView(WebViewExecutionMode.SeparateThread)
            {
                DefaultBackgroundColor = Colors.Transparent
            };
            Root.Children.Add(_webView);

            _webView.NavigationCompleted += _webView_NavigationCompleted;
            _webView.NavigationStarting  += _webView_NavigationStarting;
            _webView.NewWindowRequested  += _webView_NewWindowRequested;

            _copyMenuItem = new MenuFlyoutItem {
                Text = I18N.Translate("Command.Copy")
            };
            _copyMenuItem.Click += Copy_Click;

            _pasteMenuItem = new MenuFlyoutItem {
                Text = I18N.Translate("Command.Paste")
            };
            _pasteMenuItem.Click += Paste_Click;

            _webView.ContextFlyout = new MenuFlyout
            {
                Items = { _copyMenuItem, _pasteMenuItem }
            };

            _optionsChanged = new DebouncedAction <TerminalOptions>(Dispatcher, TimeSpan.FromMilliseconds(800), async options =>
            {
                var serialized = JsonConvert.SerializeObject(options);
                await ExecuteScriptAsync($"changeOptions('{serialized}')");
            });

            // _sizedChanged is used to debounce terminal resize events to
            // avoid spamming the terminal with them (this can result in
            // buffer corruption).
            _sizeChanged = new DebouncedAction <TerminalSize>(Dispatcher, TimeSpan.FromMilliseconds(1000), async size => {
                await ViewModel.Terminal.SetSize(size).ConfigureAwait(true);

                // Allow output to the terminal soon (hopefully, once the resize event has been processed).
                _unblockOutput.Invoke(true);
            });

            _outputBlockedBuffer = new MemoryStream();
            _outputBlocked       = new ManualResetEventSlim();

            // _unblockOutput allows output to the terminal again, 500ms after it invoked.
            _unblockOutput = new DebouncedAction <bool>(Dispatcher, TimeSpan.FromMilliseconds(500), x => {
                _outputBlocked.Reset();
            });


            _navigationCompleted = new SemaphoreSlim(0, 1);
            _connectedEvent      = new ManualResetEventSlim(false);

            _webView.Navigate(new Uri("ms-appx-web:///Client/index.html"));
        }
Exemple #5
0
        public SshInfoDialog(ISettingsService settingsService, ISshHelperService sshHelperService,
                             ITrayProcessCommunicationService trayProcessCommunicationService)
        {
            _sshHelperService = sshHelperService;
            _trayProcessCommunicationService = trayProcessCommunicationService;
            InitializeComponent();
            PrimaryButtonText   = I18N.Translate("OK");
            SecondaryButtonText = I18N.Translate("Cancel");
            var currentTheme = settingsService.GetCurrentTheme();

            RequestedTheme = ContrastHelper.GetIdealThemeForBackgroundColor(currentTheme.Colors.Background);

            TabThemes = new ObservableCollection <TabTheme>(settingsService.GetTabThemes());

            TerminalThemes = new ObservableCollection <TerminalTheme>
            {
                new TerminalTheme
                {
                    Id   = Guid.Empty,
                    Name = "Default"
                }
            };
            foreach (var theme in settingsService.GetThemes())
            {
                TerminalThemes.Add(theme);
            }
        }
Exemple #6
0
    void Start()
    {
        _nextLevelButton    = GameObject.Find("nextLevelButton").GetComponent <RectTransform>();
        _restartButton      = GameObject.Find("restartButton").GetComponent <RectTransform>();
        _backToMenuButton   = GameObject.Find("backToMenuButton").GetComponent <RectTransform>();
        _toolTipDisplay     = GameObject.Find("toolTipDisplay");
        _toolTipDisplayText = GameObject.Find("toolTipText").GetComponent <Text>();

        GameObject.Find("NextLevelButtonText").GetComponent <Text>().text  = I18N.Translate(NEXT_LEVEL);
        GameObject.Find("RestartButtonText").GetComponent <Text>().text    = I18N.Translate(RESTART_LEVEL);
        GameObject.Find("BackToMenuButtonText").GetComponent <Text>().text = I18N.Translate(BACK_TO_MENU);

        Screen.orientation = ScreenOrientation.LandscapeLeft;
        Time.timeScale     = 1; //if started from previous level

        _toReset          = GameObject.FindGameObjectsWithTag("toReset");
        _checkpointParent = GameObject.Find("Checkpoints");

        currentCheckpoint = 0;

        _currentPlayerName = PlayerStats.instance.currentPlayer.name;

        currentPlayerDisplay.text = _currentPlayerName;
        StartCoroutine(DisplayText(SceneManager.GetActiveScene().name, 3));
    }
Exemple #7
0
 private void ListView_DragEnter(object sender, DragEventArgs e)
 {
     Logger.Instance.Debug($"ListView_DragEnter.");
     e.AcceptedOperation             = DataPackageOperation.Move;
     e.DragUIOverride.IsGlyphVisible = false;
     e.DragUIOverride.Caption        = I18N.Translate("DropTabHere");
 }
Exemple #8
0
    public void PopulateLevelDropdown()
    {
        _levelDropdown.ClearOptions();

        if (PlayerStats.instance.currentPlayer != null)
        {
            //add possible levels for player to dropdown
            int levelReached = PlayerStats.instance.currentPlayer.maxLevel;
            for (int i = 1; i <= levelReached; i++)
            {
                _levelDropdown.options.Add(new Dropdown.OptionData()
                {
                    text = "Level " + i
                });
            }

            _levelDropdown.RefreshShownValue();
        }
        else
        {
            _levelDropdown.options.Add(new Dropdown.OptionData()
            {
                text = I18N.Translate(CHOOSE_PLAYER_FIRST)
            });
            _levelDropdown.RefreshShownValue();
        }

        _levelDropdown.value = 0;
    }
        private async void SshInfoDialog_OnPrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            SshConnectionInfoViewModel vm = (SshConnectionInfoViewModel)DataContext;

            if (string.IsNullOrEmpty(vm.Username) || string.IsNullOrEmpty(vm.Host))
            {
                args.Cancel = true;

                await new MessageDialog(I18N.Translate("UserAndHostMandatory"), I18N.Translate("InvalidInput")).ShowAsync();

                SetupFocus();
                return;
            }

            if (vm.SshPort == 0)
            {
                args.Cancel = true;

                await new MessageDialog(I18N.Translate("PortCannotBeZero"), I18N.Translate("InvalidInput")).ShowAsync();

                SetupFocus();
                return;
            }

            args.Cancel = false;
        }
Exemple #10
0
 public void ShowTooltip(GameObject toolTipTrigger)
 {
     Time.timeScale = 0;
     _toolTipDisplay.GetComponent <RectTransform>().localScale = new Vector3(1, 1, 1);
     Enum.TryParse(toolTipTrigger.name, false, out I18N.Identifier identifier);
     _toolTipDisplayText.text = I18N.Translate(identifier);
 }
Exemple #11
0
        public InputDialog(ISettingsService settingsService)
        {
            this.InitializeComponent();
            this.PrimaryButtonText = I18N.Translate("OK");
            this.CloseButtonText   = I18N.Translate("Cancel");
            var currentTheme = settingsService.GetCurrentTheme();

            RequestedTheme = ContrastHelper.GetIdealThemeForBackgroundColor(currentTheme.Colors.Background);
        }
Exemple #12
0
        private async Task RestoreDefaults()
        {
            var result = await _dialogService.ShowMessageDialogAsnyc(I18N.Translate("PleaseConfirm"), I18N.Translate("ConfirmRestoreKeybindings"), DialogButton.OK, DialogButton.Cancel).ConfigureAwait(true);

            if (result == DialogButton.OK)
            {
                _settingsService.ResetKeyBindings();
                Initialize(_settingsService.GetCommandKeyBindings());
            }
        }
Exemple #13
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void cmdLogger_Click(object sender, EventArgs e)
 {
     if (!(fmLog is LogForm) || fmLog.IsDisposed)
     {
         fmLog      = new LogForm();
         fmLog.Host = addins;
         I18N.Translate(fmLog);
     }
     fmLog.Show();
 }
        public ShellProfileSelectionDialog(ISettingsService settingsService)
        {
            Profiles        = settingsService.GetShellProfiles();
            SelectedProfile = Profiles.First();
            this.InitializeComponent();
            SecondaryButtonText = I18N.Translate("Cancel");
            var currentTheme = settingsService.GetCurrentTheme();

            RequestedTheme = ContrastHelper.GetIdealThemeForBackgroundColor(currentTheme.Colors.Background);
        }
Exemple #15
0
 private void TabDropArea_DragEnter(object sender, DragEventArgs e)
 {
     Logger.Instance.Debug("TabDropArea_DragEnter.");
     e.AcceptedOperation = DataPackageOperation.Move;
     if (e.DragUIOverride is DragUIOverride dragUiOverride)
     {
         dragUiOverride.IsGlyphVisible = false;
         dragUiOverride.Caption        = I18N.Translate("DropTabHere");
     }
 }
        public SshInfoDialog(ISettingsService settingsService, ISshHelperService sshHelperService,
                             ITrayProcessCommunicationService trayProcessCommunicationService)
        {
            _sshHelperService = sshHelperService;
            _trayProcessCommunicationService = trayProcessCommunicationService;
            InitializeComponent();
            PrimaryButtonText   = I18N.Translate("OK");
            SecondaryButtonText = I18N.Translate("Cancel");
            var currentTheme = settingsService.GetCurrentTheme();

            RequestedTheme = ContrastHelper.GetIdealThemeForBackgroundColor(currentTheme.Colors.Background);
        }
        // Requires UI thread
        private async Task RestoreDefaultsAsync()
        {
            // ConfigureAwait(true) because we need to execute Initialize in the calling (UI) thread.
            var result = await _dialogService.ShowMessageDialogAsync(I18N.Translate("PleaseConfirm"),
                                                                     I18N.Translate("ConfirmRestoreKeybindings"), DialogButton.OK, DialogButton.Cancel).ConfigureAwait(true);

            if (result == DialogButton.OK)
            {
                _settingsService.ResetKeyBindings();
                Initialize(_settingsService.GetCommandKeyBindings());
            }
        }
Exemple #18
0
 public IEnumerable <TabTheme> GetDefaultTabThemes()
 {
     return(new[]
     {
         new TabTheme
         {
             Id = 0,
             Name = I18N.Translate("TabTheme.None"),
             BackgroundOpacity = double.NaN,
             BackgroundPointerOverOpacity = double.NaN,
             BackgroundPressedOpacity = double.NaN,
             BackgroundSelectedOpacity = double.NaN,
             BackgroundSelectedPointerOverOpacity = double.NaN,
             BackgroundSelectedPressedOpacity = double.NaN
         },
         new TabTheme
         {
             Id = 1,
             Name = I18N.Translate("TabTheme.Red"),
             Color = "#E81123"
         },
         new TabTheme
         {
             Id = 2,
             Name = I18N.Translate("TabTheme.Green"),
             Color = "#10893E"
         },
         new TabTheme
         {
             Id = 3,
             Name = I18N.Translate("TabTheme.Blue"),
             Color = "#0078D7"
         },
         new TabTheme
         {
             Id = 4,
             Name = I18N.Translate("TabTheme.Purple"),
             Color = "#881798"
         },
         new TabTheme
         {
             Id = 5,
             Name = I18N.Translate("TabTheme.Orange"),
             Color = "#FF8C00"
         },
         new TabTheme
         {
             Id = 6,
             Name = I18N.Translate("TabTheme.Teal"),
             Color = "#00B7C3"
         }
     });
 }
Exemple #19
0
        private async void SshInfoDialog_OnPrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            var result = ((ISshConnectionInfo)DataContext).Validate();

            if (result != SshConnectionInfoValidationResult.Valid)
            {
                args.Cancel = true;

                await new MessageDialog(result.GetErrorString(Environment.NewLine), I18N.Translate("InvalidInput")).ShowAsync();

                SetupFocus();
            }
        }
Exemple #20
0
 private void ShowCurrentPlayerLevel()
 {
     if (currentPlayerView != null)
     {
         //show current player and selected level
         if (currentplayer == "")
         {
             currentPlayerView.text = I18N.Translate(CHOOSE_PLAYER_FIRST);
         }
         else
         {
             currentPlayerView.text = $"{I18N.Translate(PLAYER)}: {currentplayer}\nLevel: {selectedLevel}";
         }
     }
 }
Exemple #21
0
        public static IEnumerable <string> GetErrors(SshConnectionInfoValidationResult result)
        {
            if (result == SshConnectionInfoValidationResult.Valid)
            {
                yield break;
            }

            foreach (var value in Enum.GetValues(typeof(SshConnectionInfoValidationResult))
                     .Cast <SshConnectionInfoValidationResult>().Where(r => r != SshConnectionInfoValidationResult.Valid))
            {
                if ((value & result) == value)
                {
                    yield return(I18N.Translate($"{nameof(SshConnectionInfoValidationResult)}.{value}"));
                }
            }
        }
Exemple #22
0
        public void Translate(string expected, string json, string key, string fallback, string[] args)
        {
            var options = new JsonLocalizationOptions
            {
                ResourceFolders = new[] { "test" },
                DefaultLocale   = "en-CA"
            };

            DefaultDictionaryBuilder.ReadAllText       = path => json;
            DefaultDictionaryBuilder.DirectoryGetFiles = (path, searchPattern, searchOption) => new[] { "en-ca.json" };

            I18N.BuildDictionary(new DefaultDictionaryBuilder(), options);

            var sut = new I18N(new OptionsWrapper <JsonLocalizationOptions>(options), new DefaultKeyProvider());

            Assert.Equal(expected, sut.Translate(key, fallback, args));
        }
        public CustomCommandDialog(ISettingsService settingsService, IApplicationView applicationView,
                                   ITrayProcessCommunicationService trayProcessCommunicationService, ApplicationDataContainers containers)
        {
            _settingsService = settingsService;
            _applicationView = applicationView;
            _trayProcessCommunicationService = trayProcessCommunicationService;
            _historyContainer = containers.HistoryContainer;

            InitializeComponent();

            PrimaryButtonText   = I18N.Translate("OK");
            SecondaryButtonText = I18N.Translate("Cancel");

            var currentTheme = settingsService.GetCurrentTheme();

            RequestedTheme = ContrastHelper.GetIdealThemeForBackgroundColor(currentTheme.Colors.Background);
        }
        private async void OnPrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            var deferral = args.GetDeferral();

            var error = await ViewModel.AcceptChangesAsync();

            if (!string.IsNullOrEmpty(error))
            {
                args.Cancel = true;

                await new MessageDialog(error, I18N.Translate("InvalidInput")).ShowAsync();

                SetupFocus();
            }

            deferral.Complete();
        }
Exemple #25
0
    void Start()
    {
        _playerInputField = GameObject.Find("InputPlayerField").GetComponent <InputField>();
        _levelDropdown    = GameObject.Find("LevelsDropdown").GetComponent <Dropdown>();
        _playerDropdown   = GameObject.Find("PlayersDropdown").GetComponent <Dropdown>();

        _mainPanel         = GameObject.Find("MainPanel").GetComponent <RectTransform>();
        _playerSelectPanel = GameObject.Find("PlayerSelectPanel").GetComponent <RectTransform>();
        _newPlayerPanel    = GameObject.Find("NewPlayerPanel").GetComponent <RectTransform>();
        _levelSelectPanel  = GameObject.Find("LevelSelectPanel").GetComponent <RectTransform>();
        _highScoresPanel   = GameObject.Find("HighscorePanel").GetComponent <RectTransform>();
        _donatePanel       = GameObject.Find("DonatePanel").GetComponent <RectTransform>();

        _highScorePlayersText = GameObject.Find("HighScorePlayersText").GetComponent <Text>();
        _highScoreScoresText  = GameObject.Find("HighScoreScoresText").GetComponent <Text>();


        _panels = new[]
        {
            _mainPanel, _levelSelectPanel, _newPlayerPanel, _playerSelectPanel, _highScoresPanel, _donatePanel
        };

        GameObject.Find("StartGameButtonText").GetComponent <Text>().text         = I18N.Translate(START_GAME);
        GameObject.Find("SelectPlayerButtonText").GetComponent <Text>().text      = I18N.Translate(SELECT_PLAYER);
        GameObject.Find("SelectLevelButtonText").GetComponent <Text>().text       = I18N.Translate(SELECT_LEVEL);
        GameObject.Find("NewPlayerButtonText").GetComponent <Text>().text         = I18N.Translate(NEW_PLAYER);
        GameObject.Find("DeletePlayerButtonText").GetComponent <Text>().text      = I18N.Translate(DELETE_PLAYER);
        GameObject.Find("InputPlayerBackButtonText").GetComponent <Text>().text   = I18N.Translate(BACK);
        GameObject.Find("InputPlayerFieldPlaceHolder").GetComponent <Text>().text = I18N.Translate(ENTER_NAME);
        GameObject.Find("HighScoresBackButtonText").GetComponent <Text>().text    = I18N.Translate(BACK);
        GameObject.Find("DonateButtonText").GetComponent <Text>().text            = I18N.Translate(DONATE);
        GameObject.Find("DonatePleaseText").GetComponent <Text>().text            = I18N.Translate(DONATE_PLEASE);
        GameObject.Find("DonateBackButtonText").GetComponent <Text>().text        = I18N.Translate(BACK);


        var quitButton = GameObject.Find("QuitButtonText");

        if (quitButton != null)
        {
            quitButton.GetComponent <Text>().text = I18N.Translate(QUIT_GAME);
        }

        ShowPanel(_mainPanel);
    }
Exemple #26
0
        private async void SaveLink_OnClick(object sender, RoutedEventArgs e)
        {
            SshConnectViewModel vm = (SshConnectViewModel)DataContext;

            var link = await vm.GetUrlAsync();

            if (!link.Item1)
            {
                await new MessageDialog(link.Item2, I18N.Translate("InvalidInput")).ShowAsync();

                return;
            }

            var content = ProfileProviderViewModelBase.GetShortcutFileContent(link.Item2);

            FileSavePicker savePicker = new FileSavePicker {
                SuggestedStartLocation = PickerLocationId.Desktop
            };

            if (!vm.CommandInput)
            {
                savePicker.SuggestedFileName = string.IsNullOrEmpty(vm.Username) ? $"{vm.Host}.url" : $"{vm.Username}@{vm.Host}.url";
            }

            savePicker.FileTypeChoices.Add("Shortcut", new List <string> {
                ".url"
            });

            StorageFile file = await savePicker.PickSaveFileAsync();

            if (file == null)
            {
                return;
            }

            try
            {
                await _trayProcessCommunicationService.SaveTextFileAsync(file.Path, content);
            }
            catch (Exception ex)
            {
                await new MessageDialog(ex.Message, I18N.Translate("Error")).ShowAsync();
            }
        }
Exemple #27
0
        private async void SaveLink_OnClick(object sender, RoutedEventArgs e)
        {
            SshProfileViewModel vm = (SshProfileViewModel)DataContext;

            var validationResult = await vm.ValidateAsync();

            if (validationResult != SshConnectionInfoValidationResult.Valid &&
                // We may ignore empty username for links
                validationResult != SshConnectionInfoValidationResult.UsernameEmpty)
            {
                await new MessageDialog(validationResult.GetErrorString(Environment.NewLine),
                                        I18N.Translate("InvalidInput")).ShowAsync();
                return;
            }

            string content = string.Format(ShortcutFileFormat, await _sshHelperService.ConvertToUriAsync(vm));

            string fileName = string.IsNullOrEmpty(vm.Username) ? $"{vm.Host}.url" : $"{vm.Username}@{vm.Host}.url";

            FileSavePicker savePicker = new FileSavePicker {
                SuggestedFileName = fileName, SuggestedStartLocation = PickerLocationId.Desktop
            };

            savePicker.FileTypeChoices.Add("Shortcut", new List <string> {
                ".url"
            });

            StorageFile file = await savePicker.PickSaveFileAsync();

            if (file == null)
            {
                return;
            }

            try
            {
                await _trayProcessCommunicationService.SaveTextFileAsync(file.Path, content);
            }
            catch (Exception ex)
            {
                await new MessageDialog(ex.Message, I18N.Translate("Error")).ShowAsync();
            }
        }
Exemple #28
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (e.Parameter is KeyBindingsPageViewModel viewModel)
            {
                ViewModel = viewModel;

                // Add the commands corresponding to all of the application's static commands
                foreach (var value in Enum.GetValues(typeof(Command)))
                {
                    Command command = (Command)value;
                    AddCommandMenu.Items.Add(new MenuFlyoutItem
                    {
                        Text             = I18N.Translate($"{nameof(Command)}.{command}"),
                        Command          = ViewModel.AddCommand,
                        CommandParameter = command.ToString()
                    });
                }
            }
        }
Exemple #29
0
    public void PlayerDied()
    {
        ChangeLives(-1);

        if (PlayerStats.instance.currentPlayerLives > 0)
        {
            PlayAudio(deathSound, gameSoundsSource);
            Time.timeScale = 0.2f;
            StartCoroutine(DisplayText(I18N.Translate(OUCH), 1));
            StartCoroutine(RestartFromLastCheckpoint());
        }
        else
        {
            musicSource.enabled = false;
            PlayAudio(gameOverSound, gameSoundsSource);
            Time.timeScale          = 0f;
            bigAnnounceDisplay.text = I18N.Translate(GAME_OVER);
            Show(_restartButton);
        }
    }
        public SshInfoDialog(ISettingsService settingsService, IApplicationView applicationView,
                             IFileSystemService fileSystemService, ITrayProcessCommunicationService trayProcessCommunicationService)
        {
            _settingsService   = settingsService;
            _applicationView   = applicationView;
            _fileSystemService = fileSystemService;
            _trayProcessCommunicationService = trayProcessCommunicationService;

            InitializeComponent();

            BrowseIdentityFileCommand = new AsyncCommand(BrowseIdentityFile);
            SaveLinkCommand           = new AsyncCommand(SaveLink);

            PrimaryButtonText   = I18N.Translate("OK");
            SecondaryButtonText = I18N.Translate("Cancel");

            var currentTheme = settingsService.GetCurrentTheme();

            RequestedTheme = ContrastHelper.GetIdealThemeForBackgroundColor(currentTheme.Colors.Background);
        }