public NewModuleDialog(IServiceProvider serviceProvider, ModulesItem existing, ModulesFeature feature) : base(serviceProvider) { InitializeComponent(); Text = existing == null ? "Add Managed Module" : "Edit Managed Module"; txtName.ReadOnly = existing != null; Item = existing ?? new ModulesItem(null); if (existing != null) { txtPath.Text = Item.Type; txtName.Text = Item.Name; cbManagedHandler.Checked = Item.ForManagedOnly; } var container = new CompositeDisposable(); FormClosed += (sender, args) => container.Dispose(); container.Add( Observable.FromEventPattern <EventArgs>(btnOK, "Click") .ObserveOn(System.Threading.SynchronizationContext.Current) .Subscribe(evt => { Item.Type = txtPath.Text; Item.Name = txtName.Text; Item.ForManagedOnly = cbManagedHandler.Checked; if (!txtName.ReadOnly && feature.Items.Any(item => item.Match(Item))) { ShowMessage( "A module with this name already exists.", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); return; } DialogResult = DialogResult.OK; })); container.Add( Observable.FromEventPattern <EventArgs>(txtName, "TextChanged") .Merge(Observable.FromEventPattern <EventArgs>(txtPath, "TextChanged")) .Sample(TimeSpan.FromSeconds(1)) .ObserveOn(System.Threading.SynchronizationContext.Current) .Subscribe(evt => { btnOK.Enabled = !string.IsNullOrWhiteSpace(txtName.Text) && !string.IsNullOrWhiteSpace(txtPath.Text); })); container.Add( Observable.FromEventPattern <CancelEventArgs>(this, "HelpButtonClicked") .ObserveOn(System.Threading.SynchronizationContext.Current) .Subscribe(EnvironmentVariableTarget => { feature.ShowHelp(); })); }
public ModulesListViewItem(ModulesItem item, ModulesPage page) : base(item.Name) { this.Item = item; _page = page; this.SubItems.Add(new ListViewSubItem(this, item.IsManaged ? item.Type : item.GlobalModule.Image)); this.SubItems.Add(new ListViewSubItem(this, item.IsManaged ? "Managed" : "Native")); this.SubItems.Add(new ListViewSubItem(this, item.Flag)); }
public ModulesListViewItem(ModulesItem item, ModulesPage page) : base(item.Name) { Item = item; _page = page; SubItems.Add(new ListViewSubItem(this, item.ModuleName)); SubItems.Add(new ListViewSubItem(this, item.IsManaged ? "Managed" : "Native")); SubItems.Add(new ListViewSubItem(this, item.Flag)); }