예제 #1
0
        public void Update(PowerLauncherPluginSettings setting, IPublicAPI api)
        {
            if (setting == null || api == null)
            {
                return;
            }

            if (Metadata.Disabled && !setting.Disabled)
            {
                Metadata.Disabled = false;
                InitializePlugin(api);
                if (!IsPluginInitialized)
                {
                    var title = string.Format(CultureInfo.CurrentCulture, Resources.FailedToLoadPluginTitle, Metadata.Name);
                    api.ShowMsg(title, Resources.FailedToLoadPluginDescription, string.Empty, false);
                }
            }
            else
            {
                Metadata.Disabled = setting.Disabled;
            }

            Metadata.ActionKeyword = setting.ActionKeyword;
            Metadata.IsGlobal      = setting.IsGlobal;
            if (Plugin is ISettingProvider)
            {
                (Plugin as ISettingProvider).UpdateSettings(setting);
            }
        }
예제 #2
0
        /// <summary>
        /// Return one <see cref="bool"/> setting of the given settings list with the given name.
        /// </summary>
        /// <param name="settings">The object that contain all settings.</param>
        /// <param name="name">The name of the setting.</param>
        /// <returns>A settings value.</returns>
        private static bool GetSettingOrDefault(PowerLauncherPluginSettings settings, string name)
        {
            var option = settings?.AdditionalOptions?.FirstOrDefault(x => x.Key == name);

            // If a setting isn't available, we use the value defined in the method GetAdditionalOptions() as fallback.
            // We can use First() instead of FirstOrDefault() because the values must exist. Otherwise, we made a mistake when defining the settings.
            return(option?.Value ?? GetAdditionalOptions().First(x => x.Key == name).Value);
        }
예제 #3
0
        /// <summary>
        /// Return one <see cref="bool"/> setting of the given settings list with the given name.
        /// </summary>
        /// <param name="settings">The object that contain all settings.</param>
        /// <param name="name">The name of the setting.</param>
        /// <returns>A settings value.</returns>
        private static bool GetSettingOrDefault(PowerLauncherPluginSettings settings, string name)
        {
            var option = settings.AdditionalOptions.FirstOrDefault(x => x.Key == name);

            // As a fall-back if a setting isn't available, we use the value defined in the method GetAdditionalOptions()
            var settingsValue = option?.Value
                                ?? GetAdditionalOptions().FirstOrDefault(x => x.Key == name)?.Value
                                ?? default;

            return(settingsValue);
        }
예제 #4
0
        /// <summary>
        /// Update this settings.
        /// </summary>
        /// <param name="settings">The settings for all power launcher plugin.</param>
        internal void UpdateSettings(PowerLauncherPluginSettings settings)
        {
            if (settings is null || settings.AdditionalOptions is null)
            {
                return;
            }

            ShowTimeZoneNames         = GetSettingOrDefault(settings, "ShowTimeZoneNames");
            ShowTimeNames             = GetSettingOrDefault(settings, "ShowTimeNames");
            ShowMilitaryTimeZoneNames = GetSettingOrDefault(settings, "ShowMilitaryTimeZoneNames");
        }
        /// <summary>
        /// Update this settings.
        /// </summary>
        /// <param name="settings">The settings for all power launcher plugins.</param>
        internal void UpdateSettings(PowerLauncherPluginSettings settings)
        {
            if ((settings is null || settings.AdditionalOptions is null) & _initialized)
            {
                return;
            }

            OnlyDateTimeNowGlobal          = GetSettingOrDefault(settings, nameof(OnlyDateTimeNowGlobal));
            TimeWithSeconds                = GetSettingOrDefault(settings, nameof(TimeWithSeconds));
            DateWithWeekday                = GetSettingOrDefault(settings, nameof(DateWithWeekday));
            HideNumberMessageOnGlobalQuery = GetSettingOrDefault(settings, nameof(HideNumberMessageOnGlobalQuery));
        }
예제 #6
0
        public void UpdateSettings(PowerLauncherPluginSettings settings)
        {
            var driveDetection = false;

            if (settings.AdditionalOptions != null)
            {
                var option = settings.AdditionalOptions.FirstOrDefault(x => x.Key == DisableDriveDetectionWarning);

                driveDetection = option == null ? false : option.Value;
            }

            _driveDetection.IsDriveDetectionWarningCheckBoxSelected = driveDetection;
        }
예제 #7
0
        public void UpdateSettings(PowerLauncherPluginSettings settings)
        {
            var confirmSystemCommands = false;

            if (settings != null && settings.AdditionalOptions != null)
            {
                var option = settings.AdditionalOptions.FirstOrDefault(x => x.Key == ConfirmSystemCommands);

                confirmSystemCommands = option == null ? false : option.Value;
            }

            _confirmSystemCommands = confirmSystemCommands;
        }
예제 #8
0
파일: Main.cs 프로젝트: jsoref/PowerToys
        public void UpdateSettings(PowerLauncherPluginSettings settings)
        {
            var openNewTab         = false;
            var showHiddenProfiles = false;

            if (settings != null && settings.AdditionalOptions != null)
            {
                openNewTab         = settings.AdditionalOptions.FirstOrDefault(x => x.Key == OpenNewTab)?.Value ?? false;
                showHiddenProfiles = settings.AdditionalOptions.FirstOrDefault(x => x.Key == ShowHiddenProfiles)?.Value ?? false;
            }

            _openNewTab         = openNewTab;
            _showHiddenProfiles = showHiddenProfiles;
        }
예제 #9
0
        /// <summary>
        /// Update this settings.
        /// </summary>
        /// <param name="settings">The settings for all power launcher plugins.</param>
        internal void UpdateSettings(PowerLauncherPluginSettings settings)
        {
            if ((settings is null || settings.AdditionalOptions is null) & _initialized)
            {
                return;
            }

            ResultsFromVisibleDesktopOnly = GetSettingOrDefault(settings, nameof(ResultsFromVisibleDesktopOnly));
            SubtitleShowPid                    = GetSettingOrDefault(settings, nameof(SubtitleShowPid));
            SubtitleShowDesktopName            = GetSettingOrDefault(settings, nameof(SubtitleShowDesktopName));
            ConfirmKillProcess                 = GetSettingOrDefault(settings, nameof(ConfirmKillProcess));
            KillProcessTree                    = GetSettingOrDefault(settings, nameof(KillProcessTree));
            OpenAfterKillAndClose              = GetSettingOrDefault(settings, nameof(OpenAfterKillAndClose));
            HideKillProcessOnElevatedProcesses = GetSettingOrDefault(settings, nameof(HideKillProcessOnElevatedProcesses));
            HideExplorerSettingInfo            = GetSettingOrDefault(settings, nameof(HideExplorerSettingInfo));
        }
예제 #10
0
        public PowerLauncherPluginViewModel(PowerLauncherPluginSettings settings, Func <bool> isDark)
        {
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings), "PowerLauncherPluginSettings object is null");
            }

            this.settings = settings;
            this.isDark   = isDark;
            foreach (var item in AdditionalOptions)
            {
                item.PropertyChanged += (object sender, PropertyChangedEventArgs e) =>
                {
                    NotifyPropertyChanged(nameof(AdditionalOptions));
                };
            }
        }
예제 #11
0
        public void UpdateSettings(PowerLauncherPluginSettings settings)
        {
            var confirmSystemCommands  = false;
            var localizeSystemCommands = true;

            if (settings != null && settings.AdditionalOptions != null)
            {
                var optionConfirm = settings.AdditionalOptions.FirstOrDefault(x => x.Key == ConfirmSystemCommands);
                confirmSystemCommands = optionConfirm?.Value ?? false;

                var optionLocalize = settings.AdditionalOptions.FirstOrDefault(x => x.Key == LocalizeSystemCommands);
                localizeSystemCommands = optionLocalize?.Value ?? true;
            }

            _confirmSystemCommands  = confirmSystemCommands;
            _localizeSystemCommands = localizeSystemCommands;
        }
예제 #12
0
        public void UpdateSettings(PowerLauncherPluginSettings settings)
        {
            var confirmSystemCommands    = false;
            var localizeSystemCommands   = true;
            var reduceNetworkResultScore = true;

            if (settings != null && settings.AdditionalOptions != null)
            {
                var optionConfirm = settings.AdditionalOptions.FirstOrDefault(x => x.Key == "ConfirmSystemCommands");
                confirmSystemCommands = optionConfirm?.Value ?? confirmSystemCommands;

                var optionLocalize = settings.AdditionalOptions.FirstOrDefault(x => x.Key == "LocalizeSystemCommands");
                localizeSystemCommands = optionLocalize?.Value ?? localizeSystemCommands;

                var optionNetworkScore = settings.AdditionalOptions.FirstOrDefault(x => x.Key == "ReduceNetworkResultScore");
                reduceNetworkResultScore = optionNetworkScore?.Value ?? reduceNetworkResultScore;
            }

            _confirmSystemCommands    = confirmSystemCommands;
            _localizeSystemCommands   = localizeSystemCommands;
            _reduceNetworkResultScore = reduceNetworkResultScore;
        }
예제 #13
0
 public void UpdateSettings(PowerLauncherPluginSettings settings)
 {
     TimeDateSettings.Instance.UpdateSettings(settings);
 }
예제 #14
0
 public void UpdateSettings(PowerLauncherPluginSettings settings)
 {
     _notGlobalIfUri = settings?.AdditionalOptions?.FirstOrDefault(x => x.Key == NotGlobalIfUri)?.Value ?? false;
 }
예제 #15
0
 /// <summary>
 /// Update the plugin settings
 /// </summary>
 /// <param name="settings">The settings for all power launcher plugin.</param>
 public void UpdateSettings(PowerLauncherPluginSettings settings)
 {
     _timeZoneSettings.UpdateSettings(settings);
 }
예제 #16
0
 public void UpdateSettings(PowerLauncherPluginSettings settings)
 {
     WindowWalkerSettings.Instance.UpdateSettings(settings);
 }