Example #1
0
        private void CBoxLang_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            //IReadOnlyList<string> userLanguages = ApplicationLanguages.ManifestLanguages;
            //IReadOnlyList<string> runtimeLanguages = ResourceContext.GetForCurrentView().Languages;

            //ApplicationLanguages.PrimaryLanguageOverride = culture.Name;
            //Windows.ApplicationModel.Resources.Core.ResourceContext.GetForCurrentView().Reset();
            //Windows.ApplicationModel.Resources.Core.ResourceContext.GetForViewIndependentUse().Reset();

            ComboBoxItem temp1 = CBoxLang.SelectedItem as ComboBoxItem;

            switch (temp1.Name)
            {
            case "GR":
                ApplicationLanguages.PrimaryLanguageOverride = "el-GR";
                ResourceContext.SetGlobalQualifierValue("Language", "el-GR");
                break;

            default:
                ApplicationLanguages.PrimaryLanguageOverride = "en-US";
                ResourceContext.SetGlobalQualifierValue("Language", "en-US");
                break;
            }
            AppSettings.LangConfig = temp1.Name;

            //Reload frame
            var _Frame = Window.Current.Content as Frame;

            _Frame.Navigate(_Frame.Content.GetType());
            _Frame.GoBack();
            //_Frame.Navigate(this.GetType());
        }
        public void TestLocalization(string culture, string key, string expectedValue)
        {
            ResourceContext.SetGlobalQualifierValue("Language", culture);

            var provider       = new UwpUserInteractionProvider();
            var resourceLoader = provider.GetResourceLoader();

            Assert.AreEqual(expectedValue, resourceLoader.GetString(key));
        }
Example #3
0
        public MainPage()
        {
            this.InitializeComponent();

            IUIThread uiThread = new UwpUIThread();
            IUserInteractionProvider userInteractionProvider = new UwpUserInteractionProvider();

            Task.Run(async() =>
            {
                await Task.Delay(1000);
                await uiThread.RunAsync(async() =>
                {
                    await userInteractionProvider.GetUserInputAsync("Test", "English button labels", UserInputOption.YesNoCancel, UserInputResult.Cancel);
                    ResourceContext.SetGlobalQualifierValue("Language", "de-AT");
                    await userInteractionProvider.GetUserInputAsync("Test", "German button labels", UserInputOption.YesNoCancel, UserInputResult.Cancel);
                });
            });
        }
Example #4
0
        private async void DXFLOptionCombo_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBox combo = sender as ComboBox;

            // Setting the DXFeatureLevel qualifier value on all default contexts. This is needed
            // since the async operation to retrive appdata.dat as a StorageFile object will happen
            // on a background thread. This is the only way to set the qualifier on a default context
            // used in a background  thread.

            // In a different scenario, rather than obtaining a StorageFile object, another approach
            // that could be used would be to use the ResourceMap.GetValue method to get the resolved
            // resource candidate, and from that get the absolute file path. In that approach, the
            // GetValue method takes a ResourceContext parameter, and so it would be possible to set
            // the DXFeatureLevel qualifier value on a specific context rather than setting it in all
            // contexts within the app.

            ResourceContext.SetGlobalQualifierValue("dxfeaturelevel", combo.SelectedValue.ToString());

            // setting up the resource URI -- an ms-appx URI will be used to access the resource using
            // a StorageFile method

            // In a different scenario, rather than obtaining a StorageFile object, the
            // ResourceMap.GetValue method could be used to get the resolved candidate, from which an
            // absolute file path could be obtained. However, resource references used by the APIs in
            // Windows.ApplicationModel.Resources and Windows.ApplicationModel.Resources.Core use
            // ms-resource URIs, not ms-appx URIs. Within a resource map, files are always organized
            // under a "Files" top-level subtree. The ms-resource URI string for the file being accessed
            // here would be "ms-resource:///Files/appdata/appdata.dat".

            // The URI string "ms-appx:///..." is rooted at the app package root.
            Uri uri = new Uri("ms-appx:///appdata/appdata.dat");

            // The resource candidate will be resolved during the call to GetFileFromApplicationUriAsync
            // using the default context from a background thread.

            // File IO uses asynchronous techniques. For more info, see
            // http://msdn.microsoft.com/en-us/library/windows/apps/hh464924.aspx

            StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(uri);

            string content = await FileIO.ReadTextAsync(file);

            ResultText.Text = content;
        }
        public ClearViewModel()
        {
            this.clearModel     = new ClearModel();
            this.resourceLoader = ResourceLoader.GetForCurrentView("Resources");
            this.languagesList  = new List <string>()
            {
                "English", "Русский"
            };
            ResourceContext.SetGlobalQualifierValue("Language", "en-US");
            this.ScannOrCleanText = ScannText;

            DisplayDeleteDialog();

            #region Event Subscription

            this.CacheButton                     = new DelegateCommand(CacheButton_Click);
            this.LargeFilesButton                = new DelegateCommand(LargeFilesButton_Click);
            this.DuplicateButton                 = new DelegateCommand(DuplicateButton_Click);
            this.AutoClearingButton              = new DelegateCommand(AutoClearingButton_Click);
            this.DeselectAllButton               = new DelegateCommand(DeselectAllButton_Click);
            this.SelectAllButton                 = new DelegateCommand(SelectAllButton_Click);
            this.ScannAndCleanButton             = new DelegateCommand(ScannAndCleanButton_Click);
            this.SettingButton                   = new DelegateCommand(SettingButton_Click);
            this.MoreButton                      = new DelegateCommand(MoreButton_Click);
            this.ThemeDarkRadioButton            = new DelegateCommand(ThemeDarkRadioButton_Click);
            this.ThemeLightRadioButton           = new DelegateCommand(ThemeLightRadioButton_Click);
            this.LargeFileOpenFolder             = new DelegateCommand(LargeFileOpenFolder_Click);
            this.LargeFileDeleteFolderButton     = new DelegateCommand(LargeFileDeleteFolderButton_Click);
            this.LargeFileScannFolder            = new DelegateCommand(LargeFileScannFolder_Click);
            this.CleanLargeButton                = new DelegateCommand(CleanLargeButton_Click);
            this.DuplicateFileOpenFolderButton   = new DelegateCommand(DuplicateFileOpenFolderButton_Click);
            this.DuplicateFileDeleteFolderButton = new DelegateCommand(DuplicateFileDeleteFolderButton_click);
            this.DuplicateScannFolderButton      = new DelegateCommand(DuplicateScannFolderButton_Click);
            this.CleanDuplicateFileButton        = new DelegateCommand(CleanDuplicateFileButton_Click);

            #endregion
        }