Ejemplo n.º 1
0
        private async void OnActivated(object sender, ActivationEventArgs activationEventArgs)
        {
            WireUpConfig();

            var features = await _packageService.GetFeatures();

            foreach (var feature in features)
            {
                Features.Add(feature);
            }

            _changedFeature = new Subject <ChocolateyFeature>();
            _changedFeature
            .Select(f => Observable.FromAsync(() => UpdateFeature(f)))
            .Concat()
            .Subscribe();

            var settings = await _packageService.GetSettings();

            foreach (var setting in settings)
            {
                Settings.Add(setting);
            }

            _changedSetting = new Subject <ChocolateySetting>();
            _changedSetting
            .Select(s => Observable.FromAsync(() => UpdateSetting(s)))
            .Concat()
            .Subscribe();

            var sources = await _packageService.GetSources();

            foreach (var source in sources)
            {
                Sources.Add(source);
            }
        }
Ejemplo n.º 2
0
        private async void OnActivated(object sender, ActivationEventArgs activationEventArgs)
        {
            _config = _configService.GetEffectiveConfiguration();

            var chocolateyFeatures = await _chocolateyService.GetFeatures();

            foreach (var chocolateyFeature in chocolateyFeatures)
            {
                ChocolateyFeatures.Add(chocolateyFeature);
            }

            _changedChocolateyFeature = new Subject <ChocolateyFeature>();
            _changedChocolateyFeature
            .Select(f => Observable.FromAsync(() => UpdateChocolateyFeature(f)))
            .Concat()
            .Subscribe();

            var chocolateySettings = await _chocolateyService.GetSettings();

            foreach (var chocolateySetting in chocolateySettings)
            {
                ChocolateySettings.Add(chocolateySetting);
            }

            _changedChocolateySetting = new Subject <ChocolateySetting>();
            _changedChocolateySetting
            .Select(s => Observable.FromAsync(() => UpdateChocolateySetting(s)))
            .Concat()
            .Subscribe();

            var chocolateyGuiFeatures = _configService.GetFeatures(global: false);

            foreach (var chocolateyGuiFeature in chocolateyGuiFeatures)
            {
                ChocolateyGuiFeatures.Add(chocolateyGuiFeature);
            }

            _changedChocolateyGuiFeature = new Subject <ChocolateyGuiFeature>();
            _changedChocolateyGuiFeature
            .Select(s => Observable.FromAsync(() => UpdateChocolateyGuiFeature(s)))
            .Concat()
            .Subscribe();

            var chocolateyGuiSettings = _configService.GetSettings(global: false);

            foreach (var chocolateyGuiSetting in chocolateyGuiSettings)
            {
                ChocolateyGuiSettings.Add(chocolateyGuiSetting);
            }

            _changedChocolateyGuiSetting = new Subject <ChocolateyGuiSetting>();
            _changedChocolateyGuiSetting
            .Select(s => Observable.FromAsync(() => UpdateChocolateyGuiSetting(s)))
            .Concat()
            .Subscribe();

            var sources = await _chocolateyService.GetSources();

            foreach (var source in sources)
            {
                Sources.Add(source);
            }
        }
Ejemplo n.º 3
0
        private async void OnActivated(object sender, ActivationEventArgs activationEventArgs)
        {
            _config = _configService.GetEffectiveConfiguration();

            var chocolateyFeatures = await _chocolateyService.GetFeatures();

            foreach (var chocolateyFeature in chocolateyFeatures)
            {
#if !DEBUG // We hide this during DEBUG as it is a dark feature
                var descriptionKey = "Chocolatey_" + chocolateyFeature.Name + "Description";

                var newDescription = _translationSource[descriptionKey];

                if (string.IsNullOrEmpty(newDescription))
                {
                    descriptionKey = chocolateyFeature.Description;
                    newDescription = _translationSource[descriptionKey];
                }

                if (!string.IsNullOrEmpty(newDescription))
                {
                    chocolateyFeature.Description       = newDescription;
                    _translationSource.PropertyChanged += (s, e) =>
                    {
                        chocolateyFeature.Description = _translationSource[descriptionKey];
                    };
                }
#endif
                ChocolateyFeatures.Add(chocolateyFeature);
            }

            _changedChocolateyFeature = new Subject <ChocolateyFeature>();
            _changedChocolateyFeature
            .Select(f => Observable.FromAsync(() => UpdateChocolateyFeature(f)))
            .Concat()
            .Subscribe();

            var chocolateySettings = await _chocolateyService.GetSettings();

            foreach (var chocolateySetting in chocolateySettings)
            {
#if !DEBUG // We hide this during DEBUG as it is a dark feature
                var descriptionKey = "Chocolatey_" + chocolateySetting.Key + "Description";

                var newDescription = _translationSource[descriptionKey];

                if (string.IsNullOrEmpty(newDescription))
                {
                    descriptionKey = chocolateySetting.Description;
                    newDescription = _translationSource[descriptionKey];
                }

                if (!string.IsNullOrEmpty(newDescription))
                {
                    chocolateySetting.Description       = newDescription;
                    _translationSource.PropertyChanged += (s, e) =>
                    {
                        chocolateySetting.Description = _translationSource[descriptionKey];
                    };
                }
#endif
                ChocolateySettings.Add(chocolateySetting);
            }

            _changedChocolateySetting = new Subject <ChocolateySetting>();
            _changedChocolateySetting
            .Select(s => Observable.FromAsync(() => UpdateChocolateySetting(s)))
            .Concat()
            .Subscribe();

            var chocolateyGuiFeatures = _configService.GetFeatures(global: false, useResourceKeys: true);
            foreach (var chocolateyGuiFeature in chocolateyGuiFeatures)
            {
                chocolateyGuiFeature.DisplayTitle = _translationSource["ChocolateyGUI_" + chocolateyGuiFeature.Title + "Title"];
#if DEBUG
                var descriptionKey = string.Empty;
#else
                var descriptionKey = "ChocolateyGUI_" + chocolateyGuiFeature.Title + "Description";
#endif

                var newDescription = _translationSource[descriptionKey];

                if (string.IsNullOrEmpty(newDescription))
                {
                    descriptionKey = chocolateyGuiFeature.Description;
                    newDescription = _translationSource[descriptionKey];
                }

                if (!string.IsNullOrEmpty(newDescription))
                {
                    chocolateyGuiFeature.Description    = newDescription;
                    _translationSource.PropertyChanged += (s, e) =>
                    {
                        chocolateyGuiFeature.DisplayTitle = _translationSource["ChocolateyGUI_" + chocolateyGuiFeature.Title + "Title"];
                        chocolateyGuiFeature.Description  = _translationSource[descriptionKey];
                    };
                }

                ChocolateyGuiFeatures.Add(chocolateyGuiFeature);
            }

            _changedChocolateyGuiFeature = new Subject <ChocolateyGuiFeature>();
            _changedChocolateyGuiFeature
            .Select(s => Observable.FromAsync(() => UpdateChocolateyGuiFeature(s)))
            .Concat()
            .Subscribe();

            var chocolateyGuiSettings = _configService.GetSettings(global: false, useResourceKeys: true);
            foreach (var chocolateyGuiSetting in chocolateyGuiSettings.Where(c => !string.Equals(c.Key, nameof(UseLanguage), StringComparison.OrdinalIgnoreCase)))
            {
                chocolateyGuiSetting.DisplayName = _translationSource["ChocolateyGUI_" + chocolateyGuiSetting.Key + "Title"];
#if DEBUG
                var descriptionKey = string.Empty;
#else
                var descriptionKey = "ChocolateyGUI_" + chocolateyGuiSetting.Key + "Description";
#endif

                var newDescription = _translationSource[descriptionKey];

                if (string.IsNullOrEmpty(newDescription))
                {
                    descriptionKey = chocolateyGuiSetting.Description;
                    newDescription = _translationSource[descriptionKey];
                }

                if (!string.IsNullOrEmpty(newDescription))
                {
                    chocolateyGuiSetting.Description    = newDescription;
                    _translationSource.PropertyChanged += (s, e) =>
                    {
                        chocolateyGuiSetting.DisplayName =
                            _translationSource["ChocolateyGUI_" + chocolateyGuiSetting.Key + "Title"];
                        chocolateyGuiSetting.Description = _translationSource[descriptionKey];
                    };
                }

                ChocolateyGuiSettings.Add(chocolateyGuiSetting);
            }

            _changedChocolateyGuiSetting = new Subject <ChocolateyGuiSetting>();
            _changedChocolateyGuiSetting
            .Select(s => Observable.FromAsync(() => UpdateChocolateyGuiSetting(s)))
            .Concat()
            .Subscribe();

            var sources = await _chocolateyService.GetSources();

            foreach (var source in sources)
            {
                Sources.Add(source);
            }

            AllLanguages.Clear();

            foreach (var language in Internationalization.GetAllSupportedCultures().OrderBy(c => c.NativeName))
            {
                AllLanguages.Add(language);
            }

            var selectedLanguage = _config.UseLanguage;

            // We set it to the configuration itself, instead of the property
            // as we do not want to save the configuration file when it is not needed.
            _config.UseLanguage = Internationalization.GetSupportedCultureInfo(selectedLanguage).Name;
            NotifyOfPropertyChange(nameof(UseLanguage));
        }