Beispiel #1
0
        public NewUrlDialog(IServiceProvider serviceProvider, bool allowed)
            : base(serviceProvider)
        {
            InitializeComponent();
            Text         = allowed ? "Allow URL" : "Deny Sequence";
            lblName.Text = allowed ? "URL:" : "URL sequence";

            var container = new CompositeDisposable();

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

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

            container.Add(
                Observable.FromEventPattern <EventArgs>(btnOK, "Click")
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(evt =>
            {
                Item = new UrlsItem(null, allowed)
                {
                    Url = txtName.Text
                };
                DialogResult = DialogResult.OK;
            }));
        }
Beispiel #2
0
 public UrlListViewItem(UrlsItem item, RequestFilteringPage page)
     : base(item.Url)
 {
     Item  = item;
     _page = page;
     SubItems.Add(new ListViewSubItem(this, item.Allowed ? "always allow" : "Deny"));
 }