예제 #1
0
 public ResponseHeadersListViewItem(ResponseHeadersItem item, ResponseHeadersPage page)
     : base(item.Name)
 {
     Item  = item;
     _page = page;
     SubItems.Add(new ListViewSubItem(this, item.Value));
     SubItems.Add(new ListViewSubItem(this, item.Flag));
 }
예제 #2
0
        public NewHeaderDialog(IServiceProvider serviceProvider, ResponseHeadersItem selectedItem, ResponseHeadersFeature feature)
            : base(serviceProvider)
        {
            Item = selectedItem;
            InitializeComponent();
            Text = selectedItem == null ? "Add Custom HTTP Response Header" : "Edit Custom HTTP Response Header";
            if (selectedItem != null)
            {
                txtName.Text  = Item.Name;
                txtValue.Text = Item.Value;
            }

            var container = new CompositeDisposable();

            FormClosed += (sender, args) => container.Dispose();

            container.Add(
                Observable.FromEventPattern <EventArgs>(btnOK, "Click")
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(evt =>
            {
                if (feature.Items.Any(item => item != Item && txtName.Text == item.Name))
                {
                    ShowMessage(
                        "A header with this name already exists.",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error,
                        MessageBoxDefaultButton.Button1);
                    return;
                }

                if (Item == null)
                {
                    Item = new ResponseHeadersItem(null);
                }

                Item.Name  = txtName.Text;
                Item.Value = txtValue.Text;

                DialogResult = DialogResult.OK;
            }));

            container.Add(
                Observable.FromEventPattern <CancelEventArgs>(this, "HelpButtonClicked")
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(EnvironmentVariableTarget =>
            {
                feature.ShowHelp();
            }));
        }