public ExtensionListViewItem(FileExtensionsItem item, RequestFilteringPage page) : base(item.Extension) { Item = item; _page = page; SubItems.Add(new ListViewSubItem(this, item.Allowed ? "True" : "False")); }
public NewExtensionDialog(IServiceProvider serviceProvider, bool allowed) : base(serviceProvider) { InitializeComponent(); Text = string.Format("{0} File Name Extension", allowed ? "Allow" : "Deny"); 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 FileExtensionsItem(null) { Extension = txtName.Text }; DialogResult = DialogResult.OK; })); }
public NewExtensionDialog(IServiceProvider serviceProvider, FileExtensionsFeature feature, bool allowed) : base(serviceProvider) { InitializeComponent(); Text = string.Format("{0} File Name Extension", allowed ? "Allow" : "Deny"); 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 FileExtensionsItem(null) { Extension = txtName.Text }; if (feature.Items.Any(item => item.Match(Item))) { var service = (IManagementUIService)GetService(typeof(IManagementUIService)); service.ShowMessage( "The file extension specified already exists.", Text, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); return; } DialogResult = DialogResult.OK; })); }