コード例 #1
0
        public static string GetSetting(string key, string currentValue)
        {
            var form = new FormCustomServer
            {
                txtValue = { Text = currentValue },
                Text     = $"Custom Value for Configuration Key: {key}"
            };

            return(form.ShowDialog() == DialogResult.OK
        ? form.Result
        : null);
        }
コード例 #2
0
        /// <summary>
        /// Create a custom value for a service
        /// </summary>
        private void OnCreateCustom(object sender, EventArgs e)
        {
            if (!(sender is MenuItem menuItem))
            {
                return;
            }
            if (!(menuItem.Tag is string key))
            {
                return;
            }

            developmentSettings.SelectedSettings.TryGetValue(key, out var currentValue);

            var server = FormCustomServer.GetSetting(key, currentValue);

            if (string.IsNullOrEmpty(server))
            {
                return;
            }
            developmentSettings.SelectedSettings[key] = server;

            SaveSettings();
            ReloadSettings();
        }