Beispiel #1
0
        private void setHeaders_Click(object sender, EventArgs e)
        {
            NameValueCollection initialValues = new NameValueCollection();

            if (headers == null || headers.Count == 0)
            {
                initialValues.Add("Authorization", "Bearer token");
            }
            else
            {
                initialValues.Add(headers);
            }
            NameValueDialog headerForm =
                new NameValueDialog("Request Headers", initialValues);

            headerForm.ShowDialog();
            headers = headerForm.NameValues;
        }
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (context != null
                && context.Instance != null
                && provider != null)
            {

                IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

                if (edSvc != null)
                {
                    NameValueObject nvc = value as NameValueObject;
                    if (nvc != null)
                    {
                         NameValueDialog nameValueEditor = new NameValueDialog(nvc,type,nvt);

                        do
                        {
                            DialogResult dlgRes = edSvc.ShowDialog(nameValueEditor);
                            if (dlgRes == DialogResult.OK)
                            {
                                return nameValueEditor.NameValueCollection;
                            }
                            if (MessageBox.Show("Closing this window will remove all the changes made.",
                                                "Close Window?",
                                                MessageBoxButtons.OKCancel) == DialogResult.Cancel)
                            {
                                exit = false;
                            }
                            else
                            {
                                exit = true;
                            }
                        } while (!exit) ;
                    }
                }
            }

            return value;
        }