Exemplo n.º 1
0
 public VerbListViewItem(VerbsItem item, RequestFilteringPage page)
     : base(item.Verb)
 {
     Item  = item;
     _page = page;
     SubItems.Add(new ListViewSubItem(this, item.Allowed ? "True" : "False"));
 }
        public NewVerbDialog(IServiceProvider serviceProvider, bool allowed)
            : base(serviceProvider)
        {
            InitializeComponent();
            Text = allowed ? "Allow Verb" : "Deny Verb";

            var container = new CompositeDisposable();

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

            container.Add(
                Observable.FromEventPattern <EventArgs>(txtName, "TextChanged")
                .Sample(TimeSpan.FromSeconds(1))
                .Subscribe(evt =>
            {
                btnOK.Enabled = !string.IsNullOrWhiteSpace(txtName.Text);
            }));

            container.Add(
                Observable.FromEventPattern <EventArgs>(btnOK, "Click")
                .Subscribe(evt =>
            {
                Item = new VerbsItem(null)
                {
                    Verb = txtName.Text, Allowed = allowed
                };
                DialogResult = DialogResult.OK;
            }));
        }