public ReservedUrlListViewItem(ReservedUrlsItem item, HttpApiPage page)
     : base(item.UrlPrefix)
 {
     Item  = item;
     _page = page;
     SubItems.Add(new ListViewSubItem(this, item.SecurityDescriptor));
 }
        public NewReservedUrlDialog(IServiceProvider serviceProvider, ReservedUrlsFeature feature)
            : base(serviceProvider)
        {
            InitializeComponent();
            var container = new CompositeDisposable();

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

            container.Add(
                Observable.FromEventPattern <EventArgs>(txtAddress, "TextChanged")
                .Sample(TimeSpan.FromSeconds(0.5))
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(evt =>
            {
                btnOK.Enabled = txtAddress.Text.Length > 0;
            }));

            container.Add(
                Observable.FromEventPattern <EventArgs>(btnOK, "Click")
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(evt =>
            {
                Item = new ReservedUrlsItem(txtAddress.Text, "D:(A;;GX;;;WD)", feature);
                if (feature.Items.Any(item => item.Match(Item)))
                {
                    ShowMessage(
                        "A URL reservation already exists.",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error,
                        MessageBoxDefaultButton.Button1);
                    return;
                }

                DialogResult = DialogResult.OK;
            }));

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